diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-24 09:58:58 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-24 09:58:58 +0100 |
commit | c6a9b3b9fa4abfc4801d83162a6405ec32571d18 (patch) | |
tree | 8e518b62bce34f09b7294fe4c19da6c30856aca0 | |
parent | 615130d8f74ff005ffc44e96b9ddd2bcaa4c4e76 (diff) |
codegen: Fix typedef re-export in namespaces when bindings aren't at the root.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | bindgen-integration/build.rs | 2 | ||||
-rw-r--r-- | bindgen-integration/cpp/Test.h | 6 | ||||
-rw-r--r-- | src/codegen/mod.rs | 10 | ||||
-rw-r--r-- | tests/expectations/tests/issue-410.rs | 2 | ||||
-rw-r--r-- | tests/expectations/tests/reparented_replacement.rs | 2 |
6 files changed, 15 insertions, 8 deletions
@@ -1,4 +1,5 @@ # Cargo target/ *~ +./bindgen-integration/Cargo.lock #*# diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index 2c18c94a..9b157c5a 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -13,6 +13,8 @@ fn main() { let bindings = Builder::default() .no_unstable_rust() + .enable_cxx_namespaces() + .raw_line("pub use self::root::*;") .header("cpp/Test.h") .clang_arg("-x") .clang_arg("c++") diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h index ebd58649..f1e38c40 100644 --- a/bindgen-integration/cpp/Test.h +++ b/bindgen-integration/cpp/Test.h @@ -9,4 +9,10 @@ public: Test(double foo); }; +namespace testing { + typedef Test TypeAlias; + +} // namespace testing + +typedef testing::TypeAlias TypeAlias; diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 7451dd11..0385b56d 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -539,12 +539,10 @@ impl CodeGenerator for Type { }; let typedef = if let Some(mut p) = simple_enum_path { - if p.segments.len() == 1 { - p.segments.insert(0, ast::PathSegment { - identifier: ctx.ext_cx().ident_of("self"), - parameters: None, - }); - } + p.segments.insert(0, ast::PathSegment { + identifier: ctx.ext_cx().ident_of("self"), + parameters: None, + }); typedef.use_().build(p).as_(rust_name) } else { let mut generics = typedef.type_(rust_name).generics(); diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index a5d94960..570e88ba 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -10,7 +10,7 @@ pub mod root { pub mod JS { #[allow(unused_imports)] use self::super::super::root; - pub use root::_bindgen_ty_1 as JSWhyMagic; + pub use self::root::_bindgen_ty_1 as JSWhyMagic; #[repr(C)] #[derive(Debug, Copy)] pub struct Value { diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index e8ccc931..a50a446d 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -25,5 +25,5 @@ pub mod root { fn clone(&self) -> Self { *self } } } - pub use root::foo::Bar as ReferencesBar; + pub use self::root::foo::Bar as ReferencesBar; } |