• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #[repr(transparent)]
13 #[derive(Debug, Copy, Clone)]
14 pub struct Foo(pub id);
15 impl std::ops::Deref for Foo {
16     type Target = objc::runtime::Object;
deref(&self) -> &Self::Target17     fn deref(&self) -> &Self::Target {
18         unsafe { &*self.0 }
19     }
20 }
21 unsafe impl objc::Message for Foo {}
22 impl Foo {
alloc() -> Self23     pub fn alloc() -> Self {
24         Self(unsafe { msg_send!(class!(Foo), alloc) })
25     }
26 }
27 impl IFoo for Foo {}
28 pub trait IFoo: Sized + std::ops::Deref {
func( &self, ) -> ::std::option::Option< unsafe extern "C" fn( arg1: ::std::os::raw::c_char, arg2: ::std::os::raw::c_short, arg3: f32, ) -> ::std::os::raw::c_int, > where <Self as std::ops::Deref>::Target: objc::Message + Sized,29     unsafe fn func(
30         &self,
31     ) -> ::std::option::Option<
32         unsafe extern "C" fn(
33             arg1: ::std::os::raw::c_char,
34             arg2: ::std::os::raw::c_short,
35             arg3: f32,
36         ) -> ::std::os::raw::c_int,
37     >
38     where
39         <Self as std::ops::Deref>::Target: objc::Message + Sized,
40     {
41         msg_send!(*self, func)
42     }
setFunc_( &self, func: ::std::option::Option< unsafe extern "C" fn( arg1: ::std::os::raw::c_char, arg2: ::std::os::raw::c_short, arg3: f32, ) -> ::std::os::raw::c_int, >, ) where <Self as std::ops::Deref>::Target: objc::Message + Sized,43     unsafe fn setFunc_(
44         &self,
45         func: ::std::option::Option<
46             unsafe extern "C" fn(
47                 arg1: ::std::os::raw::c_char,
48                 arg2: ::std::os::raw::c_short,
49                 arg3: f32,
50             ) -> ::std::os::raw::c_int,
51         >,
52     ) where
53         <Self as std::ops::Deref>::Target: objc::Message + Sized,
54     {
55         msg_send!(*self, setFunc: func)
56     }
57 }
58