Skip to content

Commit 1514177

Browse files
committed
Remove vtable method class prefix with --disable-name-namespacing
Fix for #2438
1 parent 59a43e1 commit 1514177

File tree

6 files changed

+97
-2
lines changed

6 files changed

+97
-2
lines changed

bindgen-tests/tests/expectations/tests/disable-namespacing.rs

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/vtable_no_namespacing.rs

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/headers/disable-namespacing.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ namespace bar {
55

66
typedef int Baz;
77

8+
// anonymous structs should still be "namespaced"
9+
struct Foo {
10+
struct {
11+
int a;
12+
} anon;
13+
};
14+
815
}
916
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// bindgen-flags: --disable-name-namespacing
2+
3+
struct Test_Interface {
4+
virtual void Virtual_Method() = 0;
5+
};

bindgen/codegen/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,6 @@ impl CodeGenerator for Vtable<'_> {
12251225
let signature_item = ctx.resolve_item(function.signature());
12261226
let TypeKind::Function(ref signature) = signature_item.expect_type().kind() else { panic!("Function signature type mismatch") };
12271227

1228-
// FIXME: Is there a canonical name without the class prepended?
12291228
let function_name = function_item.canonical_name(ctx);
12301229

12311230
// FIXME: Need to account for overloading with times_seen (separately from regular function path).

bindgen/ir/item.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,9 @@ impl Item {
876876
true
877877
});
878878

879-
let ids: Vec<_> = if ctx.options().disable_nested_struct_naming {
879+
let ids: Vec<_> = if ctx.options().disable_nested_struct_naming ||
880+
ctx.options().disable_name_namespacing
881+
{
880882
let mut ids = Vec::new();
881883

882884
// If target is anonymous we need find its first named ancestor.

0 commit comments

Comments
 (0)