@@ -49,6 +49,12 @@ impl FunctionKind {
4949 }
5050}
5151
52+ #[ derive( Debug , Clone , Copy ) ]
53+ pub enum Linkage {
54+ External ,
55+ Internal
56+ }
57+
5258/// A function declaration, with a signature, arguments, and argument names.
5359///
5460/// The argument names vector must be the same length as the ones in the
@@ -69,6 +75,9 @@ pub struct Function {
6975
7076 /// The kind of function this is.
7177 kind : FunctionKind ,
78+
79+ // The linkage of the function.
80+ linkage : Linkage ,
7281}
7382
7483impl Function {
@@ -79,13 +88,15 @@ impl Function {
7988 sig : TypeId ,
8089 comment : Option < String > ,
8190 kind : FunctionKind ,
91+ linkage : Linkage
8292 ) -> Self {
8393 Function {
8494 name : name,
8595 mangled_name : mangled_name,
8696 signature : sig,
8797 comment : comment,
8898 kind : kind,
99+ linkage : linkage
89100 }
90101 }
91102
@@ -108,6 +119,12 @@ impl Function {
108119 pub fn kind ( & self ) -> FunctionKind {
109120 self . kind
110121 }
122+
123+ /// Get this function's linkage.
124+ pub fn linkage ( & self ) -> Linkage {
125+ self . linkage
126+ }
127+
111128}
112129
113130impl DotAttributes for Function {
@@ -477,11 +494,11 @@ impl ClangSubItemParser for Function {
477494 }
478495
479496 let linkage = cursor. linkage ( ) ;
480- if linkage != CXLinkage_External &&
481- linkage != CXLinkage_UniqueExternal
482- {
483- return Err ( ParseError :: Continue ) ;
484- }
497+ let linkage = match linkage {
498+ CXLinkage_External | CXLinkage_UniqueExternal => Linkage :: External ,
499+ CXLinkage_Internal => Linkage :: Internal ,
500+ _ => return Err ( ParseError :: Continue )
501+ } ;
485502
486503 // Grab the signature using Item::from_ty.
487504 let sig =
@@ -511,7 +528,7 @@ impl ClangSubItemParser for Function {
511528
512529 let comment = cursor. raw_comment ( ) ;
513530
514- let function = Self :: new ( name, mangled_name, sig, comment, kind) ;
531+ let function = Self :: new ( name, mangled_name, sig, comment, kind, linkage ) ;
515532 Ok ( ParseResult :: New ( function, Some ( cursor) ) )
516533 }
517534}
0 commit comments