summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/item.rs2
-rw-r--r--src/lib.rs23
-rw-r--r--src/options.rs12
-rw-r--r--tests/expectations/tests/blacklist-identifier.rs8
-rw-r--r--tests/expectations/tests/blacklist-item.rs30
-rw-r--r--tests/headers/blacklist-identifier.h5
-rw-r--r--tests/headers/blacklist-item.hpp21
7 files changed, 70 insertions, 31 deletions
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 396886e1..5f0ccc0b 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -637,7 +637,7 @@ impl Item {
let path = self.canonical_path(ctx);
let name = path[1..].join("::");
- ctx.options().blacklisted_identifiers.matches(&name) ||
+ ctx.options().blacklisted_items.matches(&name) ||
match self.kind {
ItemKind::Type(..) => {
ctx.options().blacklisted_types.matches(&name) ||
diff --git a/src/lib.rs b/src/lib.rs
index 7149d2f6..039bd39a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -312,11 +312,11 @@ impl Builder {
.count();
self.options
- .blacklisted_identifiers
+ .blacklisted_items
.get_items()
.iter()
.map(|item| {
- output_vector.push("--blacklist-identifier".into());
+ output_vector.push("--blacklist-item".into());
output_vector.push(
item.trim_left_matches("^")
.trim_right_matches("$")
@@ -768,10 +768,11 @@ impl Builder {
self
}
- /// Hide the given identifier from the generated bindings. Regular expressions
- /// are supported.
- pub fn blacklist_identifier<T: AsRef<str>>(mut self, arg: T) -> Builder {
- self.options.blacklisted_identifiers.insert(arg);
+ /// Hide the given item from the generated bindings, regardless of
+ /// whether it's a type, function, module, etc. Regular
+ /// expressions are supported.
+ pub fn blacklist_item<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blacklisted_items.insert(arg);
self
}
@@ -1334,9 +1335,9 @@ struct BindgenOptions {
/// in the generated code.
blacklisted_functions: RegexSet,
- /// The set of identifiers (regardless of Item type) that have
- /// been blacklisted and should not appear in the generated code.
- blacklisted_identifiers: RegexSet,
+ /// The set of items, regardless of item-type, that have been
+ /// blacklisted and should not appear in the generated code.
+ blacklisted_items: RegexSet,
/// The set of types that should be treated as opaque structures in the
/// generated code.
@@ -1556,7 +1557,7 @@ impl BindgenOptions {
self.whitelisted_functions.build();
self.blacklisted_types.build();
self.blacklisted_functions.build();
- self.blacklisted_identifiers.build();
+ self.blacklisted_items.build();
self.opaque_types.build();
self.bitfield_enums.build();
self.constified_enums.build();
@@ -1590,7 +1591,7 @@ impl Default for BindgenOptions {
rust_features: rust_target.into(),
blacklisted_types: Default::default(),
blacklisted_functions: Default::default(),
- blacklisted_identifiers: Default::default(),
+ blacklisted_items: Default::default(),
opaque_types: Default::default(),
rustfmt_path: Default::default(),
whitelisted_types: Default::default(),
diff --git a/src/options.rs b/src/options.rs
index 7e5a5e67..3594be4e 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -78,10 +78,10 @@ where
.takes_value(true)
.multiple(true)
.number_of_values(1),
- Arg::with_name("blacklist-identifier")
- .long("blacklist-identifier")
- .help("Mark <identifier> as hidden.")
- .value_name("identifier")
+ Arg::with_name("blacklist-item")
+ .long("blacklist-item")
+ .help("Mark <item> as hidden.")
+ .value_name("item")
.takes_value(true)
.multiple(true)
.number_of_values(1),
@@ -377,9 +377,9 @@ where
}
}
- if let Some(hidden_identifiers) = matches.values_of("blacklist-identifier") {
+ if let Some(hidden_identifiers) = matches.values_of("blacklist-item") {
for id in hidden_identifiers {
- builder = builder.blacklist_identifier(id);
+ builder = builder.blacklist_item(id);
}
}
diff --git a/tests/expectations/tests/blacklist-identifier.rs b/tests/expectations/tests/blacklist-identifier.rs
deleted file mode 100644
index d6776794..00000000
--- a/tests/expectations/tests/blacklist-identifier.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-/* automatically generated by rust-bindgen */
-
-#![allow(
- dead_code,
- non_snake_case,
- non_camel_case_types,
- non_upper_case_globals
-)]
diff --git a/tests/expectations/tests/blacklist-item.rs b/tests/expectations/tests/blacklist-item.rs
new file mode 100644
index 00000000..33a63d86
--- /dev/null
+++ b/tests/expectations/tests/blacklist-item.rs
@@ -0,0 +1,30 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+pub mod root {
+ #[allow(unused_imports)]
+ use self::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN9someClass16somePublicMethodEi"]
+ pub fn someClass_somePublicMethod(this: *mut root::someClass, foo: ::std::os::raw::c_int);
+ }
+ pub mod foo {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ }
+ pub mod bar {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN3bar18NamespacedFunctionEv"]
+ pub fn NamespacedFunction();
+ }
+ }
+}
diff --git a/tests/headers/blacklist-identifier.h b/tests/headers/blacklist-identifier.h
deleted file mode 100644
index f48d50ad..00000000
--- a/tests/headers/blacklist-identifier.h
+++ /dev/null
@@ -1,5 +0,0 @@
-// bindgen-flags: --blacklist-identifier "someFunction" --blacklist-identifier "SOME_DEFUN" --blacklist-identifier "someVar"
-
-void someFunction();
-extern int someVar;
-#define SOME_DEFUN 123
diff --git a/tests/headers/blacklist-item.hpp b/tests/headers/blacklist-item.hpp
new file mode 100644
index 00000000..90f4d694
--- /dev/null
+++ b/tests/headers/blacklist-item.hpp
@@ -0,0 +1,21 @@
+// bindgen-flags: --blacklist-item "SomeFunction" --blacklist-item "SOME_DEFUN" --blacklist-item "someVar" --blacklist-item "ExternFunction" --blacklist-item "foo::NamespacedFunction" --blacklist-item "someClass" --enable-cxx-namespaces
+
+void SomeFunction();
+extern int someVar;
+#define SOME_DEFUN 123
+
+class someClass {
+ void somePrivateMethod();
+public:
+ void somePublicMethod(int foo);
+};
+
+extern "C" void ExternFunction();
+
+namespace foo {
+ void NamespacedFunction();
+}
+
+namespace bar {
+ void NamespacedFunction();
+}