diff options
author | Cameron Mulhern <csmulhern@gmail.com> | 2021-12-27 10:49:50 -0500 |
---|---|---|
committer | Darren Kulp <darren@kulp.ch> | 2022-10-02 19:40:24 -0400 |
commit | 8b69ba05aa685d3bf02f7f21bc5cab63262e1de5 (patch) | |
tree | 24e34119d6892e180eb69a4e5f8ddf8ae8ef0dea /tests | |
parent | e68b8c0e2b2ceeb42c35e74bd9344a1a99ec2e0c (diff) |
Enables blocklisting of Objective-C methods
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/objc_blocklist.rs | 42 | ||||
-rw-r--r-- | tests/headers/objc_blocklist.h | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/expectations/tests/objc_blocklist.rs b/tests/expectations/tests/objc_blocklist.rs new file mode 100644 index 00000000..7d5d19b0 --- /dev/null +++ b/tests/expectations/tests/objc_blocklist.rs @@ -0,0 +1,42 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] +#![cfg(target_os = "macos")] + +#[macro_use] +extern crate objc; +#[allow(non_camel_case_types)] +pub type id = *mut objc::runtime::Object; +#[repr(transparent)] +#[derive(Debug, Copy, Clone)] +pub struct SomeClass(pub id); +impl std::ops::Deref for SomeClass { + type Target = objc::runtime::Object; + fn deref(&self) -> &Self::Target { + unsafe { &*self.0 } + } +} +unsafe impl objc::Message for SomeClass {} +impl SomeClass { + pub fn alloc() -> Self { + Self(unsafe { msg_send!(class!(SomeClass), alloc) }) + } +} +impl ISomeClass for SomeClass {} +pub trait ISomeClass: Sized + std::ops::Deref { + unsafe fn ambiguouslyBlockedMethod(&self) + where + <Self as std::ops::Deref>::Target: objc::Message + Sized, + { + msg_send!(*self, ambiguouslyBlockedMethod) + } + unsafe fn instanceMethod(&self) + where + <Self as std::ops::Deref>::Target: objc::Message + Sized, + { + msg_send!(*self, instanceMethod) + } +} diff --git a/tests/headers/objc_blocklist.h b/tests/headers/objc_blocklist.h new file mode 100644 index 00000000..605f2993 --- /dev/null +++ b/tests/headers/objc_blocklist.h @@ -0,0 +1,9 @@ +// bindgen-flags: --objc-extern-crate --blocklist-item ISomeClass::class_ambiguouslyBlockedMethod --blocklist-item ISomeClass::blockedInstanceMethod -- -x objective-c +// bindgen-osx-only + +@interface SomeClass ++ (void)ambiguouslyBlockedMethod; +- (void)ambiguouslyBlockedMethod; +- (void)instanceMethod; +- (void)blockedInstanceMethod; +@end |