Skip to content

Commit

Permalink
Also de-duplicate functions with wrapped static functions feature (ru…
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau authored Feb 16, 2023
1 parent 52a8cde commit 62d91c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions bindgen-tests/tests/headers/wrap-static-fns.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
static inline int foo() {
return 11;
}
static int bar();
static int bar() {
return 1;
}
Expand Down
16 changes: 8 additions & 8 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4029,14 +4029,10 @@ impl CodeGenerator for Function {

let is_internal = matches!(self.linkage(), Linkage::Internal);

if is_internal {
if ctx.options().wrap_static_fns {
result.items_to_serialize.push(item.id());
} else {
// We can't do anything with Internal functions if we are not wrapping them so just
// avoid generating anything for them.
return None;
}
if is_internal && !ctx.options().wrap_static_fns {
// We can't do anything with Internal functions if we are not wrapping them so just
// avoid generating anything for them.
return None;
}

// Pure virtual methods have no actual symbol, so we can't generate
Expand Down Expand Up @@ -4139,6 +4135,10 @@ impl CodeGenerator for Function {
abi => abi,
};

if is_internal && ctx.options().wrap_static_fns {
result.items_to_serialize.push(item.id());
}

// Handle overloaded functions by giving each overload its own unique
// suffix.
let times_seen = result.overload_number(&canonical_name);
Expand Down

0 comments on commit 62d91c5

Please sign in to comment.