summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-13 02:42:44 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-13 02:44:59 +0200
commitc30320f73522edec44ce0ecd6b82597bda5deb86 (patch)
tree3a7c447c25e86d65ad5ebfb09e66cd6c528536e5
parentfca27e2d13ecafd6b4f658b89567a7244e64a897 (diff)
item: Consider replaced items hidden.
-rw-r--r--src/ir/context.rs12
-rw-r--r--src/ir/item.rs2
-rw-r--r--tests/expectations/replaces_double.rs15
-rw-r--r--tests/headers/replaces_double.hpp20
4 files changed, 46 insertions, 3 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 4842eb94..78c1cde2 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -647,10 +647,18 @@ impl<'ctx> BindgenContext<'ctx> {
self.replacements.insert(name.into(), potential_ty);
}
- pub fn hidden_by_name(&self, name: &str) -> bool {
+ pub fn hidden_by_name(&self, name: &str, id: ItemId) -> bool {
debug_assert!(self.in_codegen_phase(),
"You're not supposed to call this yet");
- self.options.hidden_types.contains(name)
+ self.options.hidden_types.contains(name) ||
+ self.is_replaced_type(name, id)
+ }
+
+ pub fn is_replaced_type(&self, name: &str, id: ItemId) -> bool {
+ match self.replacements.get(name) {
+ Some(replaced_by) if *replaced_by != id => true,
+ _ => false,
+ }
}
pub fn opaque_by_name(&self, name: &str) -> bool {
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 80085c8b..56ddf639 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -247,7 +247,7 @@ impl Item {
debug_assert!(ctx.in_codegen_phase(),
"You're not supposed to call this yet");
self.annotations.hide() ||
- ctx.hidden_by_name(&self.real_canonical_name(ctx, false))
+ ctx.hidden_by_name(&self.real_canonical_name(ctx, false), self.id)
}
pub fn is_opaque(&self, ctx: &BindgenContext) -> bool {
diff --git a/tests/expectations/replaces_double.rs b/tests/expectations/replaces_double.rs
new file mode 100644
index 00000000..50dafd42
--- /dev/null
+++ b/tests/expectations/replaces_double.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub ptr: Rooted_MaybeWrapped<T>,
+}
+/**
+ * <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+ */
+pub type Rooted_MaybeWrapped<T> = T;
diff --git a/tests/headers/replaces_double.hpp b/tests/headers/replaces_double.hpp
new file mode 100644
index 00000000..1a78b0d9
--- /dev/null
+++ b/tests/headers/replaces_double.hpp
@@ -0,0 +1,20 @@
+// bindgen-flags: --blacklist-type Wrapper -- --std=c++11
+
+template<typename T>
+struct Wrapper {
+ struct Wrapped {
+ T t;
+ };
+ using Type = Wrapped;
+};
+
+template<typename T>
+class Rooted {
+ using MaybeWrapped = typename Wrapper<T>::Type;
+ MaybeWrapped ptr;
+
+ /**
+ * <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+ */
+ using MaybeWrapped_simple = T;
+};