@@ -49,6 +49,12 @@ impl FunctionKind {
49
49
}
50
50
}
51
51
52
+ #[ derive( Debug , Clone , Copy ) ]
53
+ pub enum Linkage {
54
+ External ,
55
+ Internal
56
+ }
57
+
52
58
/// A function declaration, with a signature, arguments, and argument names.
53
59
///
54
60
/// The argument names vector must be the same length as the ones in the
@@ -69,6 +75,9 @@ pub struct Function {
69
75
70
76
/// The kind of function this is.
71
77
kind : FunctionKind ,
78
+
79
+ // The linkage of the function.
80
+ linkage : Linkage ,
72
81
}
73
82
74
83
impl Function {
@@ -79,13 +88,15 @@ impl Function {
79
88
sig : TypeId ,
80
89
comment : Option < String > ,
81
90
kind : FunctionKind ,
91
+ linkage : Linkage
82
92
) -> Self {
83
93
Function {
84
94
name : name,
85
95
mangled_name : mangled_name,
86
96
signature : sig,
87
97
comment : comment,
88
98
kind : kind,
99
+ linkage : linkage
89
100
}
90
101
}
91
102
@@ -108,6 +119,12 @@ impl Function {
108
119
pub fn kind ( & self ) -> FunctionKind {
109
120
self . kind
110
121
}
122
+
123
+ /// Get this function's linkage.
124
+ pub fn linkage ( & self ) -> Linkage {
125
+ self . linkage
126
+ }
127
+
111
128
}
112
129
113
130
impl DotAttributes for Function {
@@ -477,11 +494,11 @@ impl ClangSubItemParser for Function {
477
494
}
478
495
479
496
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
+ } ;
485
502
486
503
// Grab the signature using Item::from_ty.
487
504
let sig =
@@ -511,7 +528,7 @@ impl ClangSubItemParser for Function {
511
528
512
529
let comment = cursor. raw_comment ( ) ;
513
530
514
- let function = Self :: new ( name, mangled_name, sig, comment, kind) ;
531
+ let function = Self :: new ( name, mangled_name, sig, comment, kind, linkage ) ;
515
532
Ok ( ParseResult :: New ( function, Some ( cursor) ) )
516
533
}
517
534
}
0 commit comments