1 #![allow( 2 dead_code, 3 non_snake_case, 4 non_camel_case_types, 5 non_upper_case_globals 6 )] 7 #![cfg(target_os = "macos")] 8 9 use objc::{self, class, msg_send, sel, sel_impl}; 10 #[allow(non_camel_case_types)] 11 pub type id = *mut objc::runtime::Object; 12 pub trait PSomeProtocol: Sized + std::ops::Deref { protocolMethod(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized,13 unsafe fn protocolMethod(&self) 14 where 15 <Self as std::ops::Deref>::Target: objc::Message + Sized, 16 { 17 msg_send!(*self, protocolMethod) 18 } protocolClassMethod() where <Self as std::ops::Deref>::Target: objc::Message + Sized,19 unsafe fn protocolClassMethod() 20 where 21 <Self as std::ops::Deref>::Target: objc::Message + Sized, 22 { 23 msg_send!(class!(SomeProtocol), protocolClassMethod) 24 } 25 } 26 #[repr(transparent)] 27 #[derive(Debug, Copy, Clone)] 28 pub struct AllowlistMe(pub id); 29 impl std::ops::Deref for AllowlistMe { 30 type Target = objc::runtime::Object; deref(&self) -> &Self::Target31 fn deref(&self) -> &Self::Target { 32 unsafe { &*self.0 } 33 } 34 } 35 unsafe impl objc::Message for AllowlistMe {} 36 impl AllowlistMe { alloc() -> Self37 pub fn alloc() -> Self { 38 Self(unsafe { msg_send!(class!(AllowlistMe), alloc) }) 39 } 40 } 41 impl PSomeProtocol for AllowlistMe {} 42 impl IAllowlistMe for AllowlistMe {} 43 pub trait IAllowlistMe: Sized + std::ops::Deref { method(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized,44 unsafe fn method(&self) 45 where 46 <Self as std::ops::Deref>::Target: objc::Message + Sized, 47 { 48 msg_send!(*self, method) 49 } classMethod() where <Self as std::ops::Deref>::Target: objc::Message + Sized,50 unsafe fn classMethod() 51 where 52 <Self as std::ops::Deref>::Target: objc::Message + Sized, 53 { 54 msg_send!(class!(AllowlistMe), classMethod) 55 } 56 } 57 impl AllowlistMe_InterestingCategory for AllowlistMe {} 58 pub trait AllowlistMe_InterestingCategory: Sized + std::ops::Deref {} 59