summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindgen-tests/tests/expectations/tests/blocklist-methods.rs35
-rw-r--r--bindgen-tests/tests/headers/blocklist-methods.hpp8
-rw-r--r--bindgen/lib.rs8
3 files changed, 51 insertions, 0 deletions
diff --git a/bindgen-tests/tests/expectations/tests/blocklist-methods.rs b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs
new file mode 100644
index 00000000..5b625f0a
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/blocklist-methods.rs
@@ -0,0 +1,35 @@
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct Foo {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
+}
+extern "C" {
+ #[link_name = "\u{1}_ZN3Foo3fooEv"]
+ pub fn Foo_foo(this: *mut Foo) -> ::std::os::raw::c_int;
+}
+impl Foo {
+ #[inline]
+ pub unsafe fn foo(&mut self) -> ::std::os::raw::c_int {
+ unsafe { Foo_foo(self) }
+ }
+}
diff --git a/bindgen-tests/tests/headers/blocklist-methods.hpp b/bindgen-tests/tests/headers/blocklist-methods.hpp
new file mode 100644
index 00000000..4be21b94
--- /dev/null
+++ b/bindgen-tests/tests/headers/blocklist-methods.hpp
@@ -0,0 +1,8 @@
+// bindgen-flags: --blocklist-function="Foo_ba.*"
+
+class Foo {
+ public:
+ int foo();
+ int bar();
+ int baz();
+};
diff --git a/bindgen/lib.rs b/bindgen/lib.rs
index 3696c499..03de8430 100644
--- a/bindgen/lib.rs
+++ b/bindgen/lib.rs
@@ -850,6 +850,10 @@ impl Builder {
/// Hide the given function from the generated bindings. Regular expressions
/// are supported.
///
+ /// Methods can be blocklisted by prefixing the name of the type implementing
+ /// them followed by an underscore. So if `Foo` has a method `bar`, it can
+ /// be blocklisted as `Foo_bar`.
+ ///
/// To blocklist functions prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs
@@ -929,6 +933,10 @@ impl Builder {
/// transitively refers to) appears in the generated bindings. Regular
/// expressions are supported.
///
+ /// Methods can be allowlisted by prefixing the name of the type
+ /// implementing them followed by an underscore. So if `Foo` has a method
+ /// `bar`, it can be allowlisted as `Foo_bar`.
+ ///
/// To allowlist functions prefixed with "mylib" use `"mylib_.*"`.
/// For more complicated expressions check
/// [regex](https://docs.rs/regex/*/regex/) docs