diff options
author | Sebastian Imlay <sebastian.imlay@gmail.com> | 2020-08-24 14:21:03 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-09-16 12:26:24 +0200 |
commit | 840b738ecfeefbd31d8676c60e2eca7ad6d0f424 (patch) | |
tree | 49d3c4c3494433c550d3297093362c22249e9278 /tests | |
parent | f4d10c360453e91973cd08189af6185bb7c964c9 (diff) |
Initial stuff for changing ownership and adding inheritance
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/libclang-9/objc_inheritance.rs | 21 | ||||
-rw-r--r-- | tests/expectations/tests/libclang-9/objc_template.rs | 12 | ||||
-rw-r--r-- | tests/expectations/tests/objc_category.rs | 10 | ||||
-rw-r--r-- | tests/expectations/tests/objc_class.rs | 6 | ||||
-rw-r--r-- | tests/expectations/tests/objc_class_method.rs | 2 | ||||
-rw-r--r-- | tests/expectations/tests/objc_interface.rs | 2 | ||||
-rw-r--r-- | tests/expectations/tests/objc_interface_type.rs | 2 | ||||
-rw-r--r-- | tests/expectations/tests/objc_method.rs | 30 | ||||
-rw-r--r-- | tests/expectations/tests/objc_method_clash.rs | 6 | ||||
-rw-r--r-- | tests/expectations/tests/objc_pointer_return_types.rs | 8 | ||||
-rw-r--r-- | tests/expectations/tests/objc_property_fnptr.rs | 10 | ||||
-rw-r--r-- | tests/expectations/tests/objc_protocol.rs | 2 |
12 files changed, 63 insertions, 48 deletions
diff --git a/tests/expectations/tests/libclang-9/objc_inheritance.rs b/tests/expectations/tests/libclang-9/objc_inheritance.rs index cd2b085d..ef16325e 100644 --- a/tests/expectations/tests/libclang-9/objc_inheritance.rs +++ b/tests/expectations/tests/libclang-9/objc_inheritance.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -28,7 +28,7 @@ impl Foo { impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref {} #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Bar(pub id); impl std::ops::Deref for Bar { type Target = objc::runtime::Object; @@ -43,10 +43,15 @@ impl Bar { } } impl IFoo for Bar {} +impl From<Bar> for Foo { + fn from(child: Bar) -> Foo { + Foo(child.0) + } +} impl IBar for Bar {} pub trait IBar: Sized + std::ops::Deref {} #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Baz(pub id); impl std::ops::Deref for Baz { type Target = objc::runtime::Object; @@ -61,6 +66,16 @@ impl Baz { } } impl IBar for Baz {} +impl From<Baz> for Bar { + fn from(child: Baz) -> Bar { + Bar(child.0) + } +} impl IFoo for Baz {} +impl From<Baz> for Foo { + fn from(child: Baz) -> Foo { + Foo(child.0) + } +} impl IBaz for Baz {} pub trait IBaz: Sized + std::ops::Deref {} diff --git a/tests/expectations/tests/libclang-9/objc_template.rs b/tests/expectations/tests/libclang-9/objc_template.rs index 09cc739c..88cf209b 100644 --- a/tests/expectations/tests/libclang-9/objc_template.rs +++ b/tests/expectations/tests/libclang-9/objc_template.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -27,15 +27,15 @@ impl Foo { } impl<ObjectType: 'static> IFoo<ObjectType> for Foo {} pub trait IFoo<ObjectType>: Sized + std::ops::Deref { - unsafe fn get(self) -> u64 + unsafe fn get(&self) -> u64 where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, get) + msg_send!(*self, get) } } #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct FooMultiGeneric(pub id); impl std::ops::Deref for FooMultiGeneric { type Target = objc::runtime::Object; @@ -56,10 +56,10 @@ impl<KeyType: 'static, ObjectType: 'static> pub trait IFooMultiGeneric<KeyType, ObjectType>: Sized + std::ops::Deref { - unsafe fn objectForKey_(self, key: u64) -> u64 + unsafe fn objectForKey_(&self, key: u64) -> u64 where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, objectForKey: key) + msg_send!(*self, objectForKey: key) } } diff --git a/tests/expectations/tests/objc_category.rs b/tests/expectations/tests/objc_category.rs index 2c39be96..e0328c70 100644 --- a/tests/expectations/tests/objc_category.rs +++ b/tests/expectations/tests/objc_category.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -27,19 +27,19 @@ impl Foo { } impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { - unsafe fn method(self) + unsafe fn method(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, method) + msg_send!(*self, method) } } impl Foo_BarCategory for Foo {} pub trait Foo_BarCategory: Sized + std::ops::Deref { - unsafe fn categoryMethod(self) + unsafe fn categoryMethod(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, categoryMethod) + msg_send!(*self, categoryMethod) } } diff --git a/tests/expectations/tests/objc_class.rs b/tests/expectations/tests/objc_class.rs index a1de91fb..5a8a71d1 100644 --- a/tests/expectations/tests/objc_class.rs +++ b/tests/expectations/tests/objc_class.rs @@ -14,7 +14,7 @@ extern "C" { pub static mut fooVar: Foo; } #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -30,10 +30,10 @@ impl Foo { } impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { - unsafe fn method(self) + unsafe fn method(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, method) + msg_send!(*self, method) } } diff --git a/tests/expectations/tests/objc_class_method.rs b/tests/expectations/tests/objc_class_method.rs index d28a233d..d1f39b0c 100644 --- a/tests/expectations/tests/objc_class_method.rs +++ b/tests/expectations/tests/objc_class_method.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; diff --git a/tests/expectations/tests/objc_interface.rs b/tests/expectations/tests/objc_interface.rs index 7cabf762..c5ba2758 100644 --- a/tests/expectations/tests/objc_interface.rs +++ b/tests/expectations/tests/objc_interface.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; diff --git a/tests/expectations/tests/objc_interface_type.rs b/tests/expectations/tests/objc_interface_type.rs index e8a15963..2585df6e 100644 --- a/tests/expectations/tests/objc_interface_type.rs +++ b/tests/expectations/tests/objc_interface_type.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; diff --git a/tests/expectations/tests/objc_method.rs b/tests/expectations/tests/objc_method.rs index e24768d2..7c4fbd43 100644 --- a/tests/expectations/tests/objc_method.rs +++ b/tests/expectations/tests/objc_method.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -27,48 +27,48 @@ impl Foo { } impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { - unsafe fn method(self) + unsafe fn method(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, method) + msg_send!(*self, method) } - unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int) + unsafe fn methodWithInt_(&self, foo: ::std::os::raw::c_int) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, methodWithInt: foo) + msg_send!(*self, methodWithInt: foo) } - unsafe fn methodWithFoo_(self, foo: Foo) + unsafe fn methodWithFoo_(&self, foo: Foo) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, methodWithFoo: foo) + msg_send!(*self, methodWithFoo: foo) } - unsafe fn methodReturningInt(self) -> ::std::os::raw::c_int + unsafe fn methodReturningInt(&self) -> ::std::os::raw::c_int where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, methodReturningInt) + msg_send!(*self, methodReturningInt) } - unsafe fn methodReturningFoo(self) -> Foo + unsafe fn methodReturningFoo(&self) -> Foo where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, methodReturningFoo) + msg_send!(*self, methodReturningFoo) } unsafe fn methodWithArg1_andArg2_andArg3_( - self, + &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, { - msg_send ! ( self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue ) + msg_send ! ( * self , methodWithArg1 : intvalue andArg2 : ptr andArg3 : floatvalue ) } unsafe fn methodWithAndWithoutKeywords_arg2Name__arg4Name_( - self, + &self, arg1: ::std::os::raw::c_int, arg2: f32, arg3: f32, @@ -77,7 +77,7 @@ pub trait IFoo: Sized + std::ops::Deref { where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send ! ( self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4 ) + msg_send ! ( * self , methodWithAndWithoutKeywords : arg1 arg2Name : arg2 arg3 : arg3 arg4Name : arg4 ) } } pub type instancetype = id; diff --git a/tests/expectations/tests/objc_method_clash.rs b/tests/expectations/tests/objc_method_clash.rs index ba741f8d..8370f33f 100644 --- a/tests/expectations/tests/objc_method_clash.rs +++ b/tests/expectations/tests/objc_method_clash.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -27,11 +27,11 @@ impl Foo { } impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { - unsafe fn foo(self) + unsafe fn foo(&self) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, foo) + msg_send!(*self, foo) } unsafe fn class_foo() where diff --git a/tests/expectations/tests/objc_pointer_return_types.rs b/tests/expectations/tests/objc_pointer_return_types.rs index 0f222c8b..c9b6b52a 100644 --- a/tests/expectations/tests/objc_pointer_return_types.rs +++ b/tests/expectations/tests/objc_pointer_return_types.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Bar(pub id); impl std::ops::Deref for Bar { type Target = objc::runtime::Object; @@ -28,7 +28,7 @@ impl Bar { impl IBar for Bar {} pub trait IBar: Sized + std::ops::Deref {} #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -44,11 +44,11 @@ impl Foo { } impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { - unsafe fn methodUsingBar_(self, my_bar: Bar) + unsafe fn methodUsingBar_(&self, my_bar: Bar) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, methodUsingBar: my_bar) + msg_send!(*self, methodUsingBar: my_bar) } unsafe fn methodReturningBar() -> Bar where diff --git a/tests/expectations/tests/objc_property_fnptr.rs b/tests/expectations/tests/objc_property_fnptr.rs index b9bcf306..85f18e9c 100644 --- a/tests/expectations/tests/objc_property_fnptr.rs +++ b/tests/expectations/tests/objc_property_fnptr.rs @@ -11,7 +11,7 @@ extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; @@ -28,7 +28,7 @@ impl Foo { impl IFoo for Foo {} pub trait IFoo: Sized + std::ops::Deref { unsafe fn func( - self, + &self, ) -> ::std::option::Option< unsafe extern "C" fn( arg1: ::std::os::raw::c_char, @@ -39,10 +39,10 @@ pub trait IFoo: Sized + std::ops::Deref { where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, func) + msg_send!(*self, func) } unsafe fn setFunc_( - self, + &self, func: ::std::option::Option< unsafe extern "C" fn( arg1: ::std::os::raw::c_char, @@ -53,6 +53,6 @@ pub trait IFoo: Sized + std::ops::Deref { ) where <Self as std::ops::Deref>::Target: objc::Message + Sized, { - msg_send!(self, setFunc: func) + msg_send!(*self, setFunc: func) } } diff --git a/tests/expectations/tests/objc_protocol.rs b/tests/expectations/tests/objc_protocol.rs index 5a659b2c..e68ddcc1 100644 --- a/tests/expectations/tests/objc_protocol.rs +++ b/tests/expectations/tests/objc_protocol.rs @@ -12,7 +12,7 @@ extern crate objc; pub type id = *mut objc::runtime::Object; pub trait PFoo: Sized + std::ops::Deref {} #[repr(transparent)] -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct Foo(pub id); impl std::ops::Deref for Foo { type Target = objc::runtime::Object; |