Skip to content

Commit 62330d0

Browse files
committed
Denote private functions.
1 parent 41d01fc commit 62330d0

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/codegen/helpers.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ pub mod attributes {
9494
}
9595
}
9696

97+
pub fn is_private() -> TokenStream {
98+
quote! {
99+
#[bindgen_private]
100+
}
101+
}
102+
97103
pub fn unused_template_param_in_arg_or_return() -> TokenStream {
98104
quote! {
99105
#[bindgen_unused_template_param_in_arg_or_return]

src/codegen/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,10 @@ impl CodeGenerator for Function {
40384038
attributes.push(attributes::is_pure_virtual());
40394039
}
40404040

4041+
if self.is_private() {
4042+
attributes.push(attributes::is_private());
4043+
}
4044+
40414045
let abi = match signature.abi() {
40424046
Abi::ThisCall if !ctx.options().rust_features().thiscall_abi => {
40434047
warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target");

src/ir/function.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pub struct Function {
9797

9898
/// C++ special member kind, if any.
9999
special_member: Option<SpecialMemberKind>,
100+
101+
/// C++ visibility
102+
is_private: bool,
100103
}
101104

102105
impl Function {
@@ -109,6 +112,7 @@ impl Function {
109112
kind: FunctionKind,
110113
linkage: Linkage,
111114
special_member: Option<SpecialMemberKind>,
115+
is_private: bool,
112116
) -> Self {
113117
Function {
114118
name,
@@ -118,6 +122,7 @@ impl Function {
118122
kind,
119123
linkage,
120124
special_member,
125+
is_private,
121126
}
122127
}
123128

@@ -150,6 +155,11 @@ impl Function {
150155
pub fn special_member(&self) -> Option<SpecialMemberKind> {
151156
self.special_member
152157
}
158+
159+
/// Whether it is private
160+
pub fn is_private(&self) -> bool {
161+
self.is_private
162+
}
153163
}
154164

155165
impl DotAttributes for Function {
@@ -603,9 +613,7 @@ impl ClangSubItemParser for Function {
603613
return Err(ParseError::Continue);
604614
}
605615

606-
if cursor.access_specifier() == CX_CXXPrivate {
607-
return Err(ParseError::Continue);
608-
}
616+
let is_private = cursor.access_specifier() == CX_CXXPrivate;
609617

610618
if cursor.is_inlined_function() {
611619
if !context.options().generate_inline_functions {
@@ -666,6 +674,7 @@ impl ClangSubItemParser for Function {
666674
kind,
667675
linkage,
668676
special_member,
677+
is_private,
669678
);
670679
Ok(ParseResult::New(function, Some(cursor)))
671680
}

0 commit comments

Comments
 (0)