Skip to content

Commit c48a0f3

Browse files
committed
Allow generating hidden visibility functions
1 parent d5fc49c commit c48a0f3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

bindgen/ir/function.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,11 @@ impl ClangSubItemParser for Function {
730730

731731
debug!("Function::parse({cursor:?}, {:?})", cursor.cur_type());
732732
let visibility = cursor.visibility();
733-
if visibility != CXVisibility_Default {
733+
let allow_hidden = context.options().generate_hidden_functions &&
734+
(visibility == CXVisibility_Hidden ||
735+
visibility == CXVisibility_Protected);
736+
737+
if visibility != CXVisibility_Default && !allow_hidden {
734738
return Err(ParseError::Continue);
735739
}
736740
if cursor.access_specifier() == CX_CXXPrivate &&

bindgen/options/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,4 +2329,16 @@ options! {
23292329
},
23302330
as_args: "--generate-private-functions",
23312331
},
2332+
/// Whether to allow generating functions that are marked with hidden or protected visibility.
2333+
generate_hidden_functions: bool {
2334+
methods: {
2335+
/// Set whether to generate functions that are not externally visible according to clang.
2336+
pub fn generate_hidden_functions(mut self, doit: bool) -> Self {
2337+
self.options.generate_hidden_functions = doit;
2338+
self
2339+
}
2340+
2341+
},
2342+
as_args: "--generate-hidden-functions",
2343+
},
23322344
}

0 commit comments

Comments
 (0)