diff options
-rw-r--r-- | libbindgen/src/ir/item.rs | 8 | ||||
-rw-r--r-- | libbindgen/tests/expectations/tests/canonical_path_without_namespacing.rs | 23 | ||||
-rw-r--r-- | libbindgen/tests/headers/canonical_path_without_namespacing.hpp | 7 |
3 files changed, 36 insertions, 2 deletions
diff --git a/libbindgen/src/ir/item.rs b/libbindgen/src/ir/item.rs index a754801c..6601216e 100644 --- a/libbindgen/src/ir/item.rs +++ b/libbindgen/src/ir/item.rs @@ -1235,10 +1235,14 @@ impl ItemCanonicalPath for Item { fn namespace_aware_canonical_path(&self, ctx: &BindgenContext) -> Vec<String> { + let path = self.canonical_path(ctx); if ctx.options().enable_cxx_namespaces { - return self.canonical_path(ctx); + return path; } - return vec![self.canonical_path(ctx)[1..].join("_")]; + if ctx.options().disable_name_namespacing { + return vec![path.last().unwrap().clone()]; + } + return vec![path[1..].join("_")]; } fn canonical_path(&self, ctx: &BindgenContext) -> Vec<String> { diff --git a/libbindgen/tests/expectations/tests/canonical_path_without_namespacing.rs b/libbindgen/tests/expectations/tests/canonical_path_without_namespacing.rs new file mode 100644 index 00000000..0b1f561c --- /dev/null +++ b/libbindgen/tests/expectations/tests/canonical_path_without_namespacing.rs @@ -0,0 +1,23 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct Bar { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::<Bar>() , 1usize); + assert_eq!(::std::mem::align_of::<Bar>() , 1usize); +} +impl Clone for Bar { + fn clone(&self) -> Self { *self } +} +extern "C" { + #[link_name = "_Z3bazPN3foo3BarE"] + pub fn baz(arg1: *mut Bar); +} diff --git a/libbindgen/tests/headers/canonical_path_without_namespacing.hpp b/libbindgen/tests/headers/canonical_path_without_namespacing.hpp new file mode 100644 index 00000000..92e85842 --- /dev/null +++ b/libbindgen/tests/headers/canonical_path_without_namespacing.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --disable-name-namespacing + +namespace foo { + struct Bar {}; +} + +void baz(foo::Bar*); |