summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2016-12-07 17:04:56 -1000
committerEmilio Cobos Álvarez <emilio@crisal.io>2016-12-07 17:05:23 -1000
commit27fb5df28b063e59fd4d4f9e1ad858f681e9e6d0 (patch)
tree13d6df9987bf613b79fac7e65884d56de24adf20
parentc3685effcee7c49a747b2e149432f4113bc22713 (diff)
ir: Fix namespace_aware_canonical_name with disable_name_namespacing.
-rw-r--r--libbindgen/src/ir/item.rs8
-rw-r--r--libbindgen/tests/expectations/tests/canonical_path_without_namespacing.rs23
-rw-r--r--libbindgen/tests/headers/canonical_path_without_namespacing.hpp7
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*);