• 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 {
method(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized,29     unsafe fn method(&self)
30     where
31         <Self as std::ops::Deref>::Target: objc::Message + Sized,
32     {
33         msg_send!(*self, method)
34     }
methodWithInt_(&self, foo: ::std::os::raw::c_int) where <Self as std::ops::Deref>::Target: objc::Message + Sized,35     unsafe fn methodWithInt_(&self, foo: ::std::os::raw::c_int)
36     where
37         <Self as std::ops::Deref>::Target: objc::Message + Sized,
38     {
39         msg_send!(*self, methodWithInt: foo)
40     }
methodWithFoo_(&self, foo: Foo) where <Self as std::ops::Deref>::Target: objc::Message + Sized,41     unsafe fn methodWithFoo_(&self, foo: Foo)
42     where
43         <Self as std::ops::Deref>::Target: objc::Message + Sized,
44     {
45         msg_send!(*self, methodWithFoo: foo)
46     }
methodReturningInt(&self) -> ::std::os::raw::c_int where <Self as std::ops::Deref>::Target: objc::Message + Sized,47     unsafe fn methodReturningInt(&self) -> ::std::os::raw::c_int
48     where
49         <Self as std::ops::Deref>::Target: objc::Message + Sized,
50     {
51         msg_send!(*self, methodReturningInt)
52     }
methodReturningFoo(&self) -> Foo where <Self as std::ops::Deref>::Target: objc::Message + Sized,53     unsafe fn methodReturningFoo(&self) -> Foo
54     where
55         <Self as std::ops::Deref>::Target: objc::Message + Sized,
56     {
57         msg_send!(*self, methodReturningFoo)
58     }
methodWithArg1_andArg2_andArg3_( &self, intvalue: ::std::os::raw::c_int, ptr: *mut ::std::os::raw::c_char, floatvalue: f32, ) where <Self as std::ops::Deref>::Target: objc::Message + Sized,59     unsafe fn methodWithArg1_andArg2_andArg3_(
60         &self,
61         intvalue: ::std::os::raw::c_int,
62         ptr: *mut ::std::os::raw::c_char,
63         floatvalue: f32,
64     ) where
65         <Self as std::ops::Deref>::Target: objc::Message + Sized,
66     {
67         msg_send ! (* self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue)
68     }
methodWithAndWithoutKeywords_arg2Name__arg4Name_( &self, arg1: ::std::os::raw::c_int, arg2: f32, arg3: f32, arg4: ::std::os::raw::c_int, ) -> instancetype where <Self as std::ops::Deref>::Target: objc::Message + Sized,69     unsafe fn methodWithAndWithoutKeywords_arg2Name__arg4Name_(
70         &self,
71         arg1: ::std::os::raw::c_int,
72         arg2: f32,
73         arg3: f32,
74         arg4: ::std::os::raw::c_int,
75     ) -> instancetype
76     where
77         <Self as std::ops::Deref>::Target: objc::Message + Sized,
78     {
79         msg_send ! (* self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4)
80     }
81 }
82 pub type instancetype = id;
83