@@ -49,6 +49,15 @@ impl FunctionKind {
49
49
}
50
50
}
51
51
52
+ /// The style of linkage
53
+ #[ derive( Debug , Clone , Copy ) ]
54
+ pub enum Linkage {
55
+ /// Externally visible and can be linked against
56
+ External ,
57
+ /// Not exposed externally. 'static inline' functions will have this kind of linkage
58
+ Internal
59
+ }
60
+
52
61
/// A function declaration, with a signature, arguments, and argument names.
53
62
///
54
63
/// The argument names vector must be the same length as the ones in the
@@ -69,6 +78,9 @@ pub struct Function {
69
78
70
79
/// The kind of function this is.
71
80
kind : FunctionKind ,
81
+
82
+ /// The linkage of the function.
83
+ linkage : Linkage ,
72
84
}
73
85
74
86
impl Function {
@@ -79,13 +91,15 @@ impl Function {
79
91
sig : TypeId ,
80
92
comment : Option < String > ,
81
93
kind : FunctionKind ,
94
+ linkage : Linkage
82
95
) -> Self {
83
96
Function {
84
97
name : name,
85
98
mangled_name : mangled_name,
86
99
signature : sig,
87
100
comment : comment,
88
101
kind : kind,
102
+ linkage : linkage
89
103
}
90
104
}
91
105
@@ -108,6 +122,12 @@ impl Function {
108
122
pub fn kind ( & self ) -> FunctionKind {
109
123
self . kind
110
124
}
125
+
126
+ /// Get this function's linkage.
127
+ pub fn linkage ( & self ) -> Linkage {
128
+ self . linkage
129
+ }
130
+
111
131
}
112
132
113
133
impl DotAttributes for Function {
@@ -477,11 +497,11 @@ impl ClangSubItemParser for Function {
477
497
}
478
498
479
499
let linkage = cursor. linkage ( ) ;
480
- if linkage != CXLinkage_External &&
481
- linkage != CXLinkage_UniqueExternal
482
- {
483
- return Err ( ParseError :: Continue ) ;
484
- }
500
+ let linkage = match linkage {
501
+ CXLinkage_External | CXLinkage_UniqueExternal => Linkage :: External ,
502
+ CXLinkage_Internal => Linkage :: Internal ,
503
+ _ => return Err ( ParseError :: Continue )
504
+ } ;
485
505
486
506
// Grab the signature using Item::from_ty.
487
507
let sig =
@@ -511,7 +531,7 @@ impl ClangSubItemParser for Function {
511
531
512
532
let comment = cursor. raw_comment ( ) ;
513
533
514
- let function = Self :: new ( name, mangled_name, sig, comment, kind) ;
534
+ let function = Self :: new ( name, mangled_name, sig, comment, kind, linkage ) ;
515
535
Ok ( ParseResult :: New ( function, Some ( cursor) ) )
516
536
}
517
537
}
0 commit comments