summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/mod.rs5
-rw-r--r--tests/expectations/tests/libclang-3.9/objc_template.rs12
-rw-r--r--tests/expectations/tests/libclang-4/objc_template.rs12
-rw-r--r--tests/expectations/tests/libclang-5/objc_inheritance.rs2
-rw-r--r--tests/expectations/tests/libclang-5/objc_template.rs12
5 files changed, 23 insertions, 20 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index d07e27a7..1a9416c9 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -3992,7 +3992,10 @@ impl CodeGenerator for ObjCInterface {
};
result.push(from_block);
- let error_msg = format!("This {} cannot be downcasted to {}", parent_struct_name, child_struct_name);
+ let error_msg = format!(
+ "This {} cannot be downcasted to {}",
+ parent_struct_name, child_struct_name
+ );
let try_into_block = quote! {
impl std::convert::TryFrom<#parent_struct> for #class_name {
type Error = &'static str;
diff --git a/tests/expectations/tests/libclang-3.9/objc_template.rs b/tests/expectations/tests/libclang-3.9/objc_template.rs
index 9c5a5b75..4ccf72b7 100644
--- a/tests/expectations/tests/libclang-3.9/objc_template.rs
+++ b/tests/expectations/tests/libclang-3.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) -> id
+ unsafe fn get(&self) -> id
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: id) -> id
+ unsafe fn objectForKey_(&self, key: id) -> id
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/libclang-4/objc_template.rs b/tests/expectations/tests/libclang-4/objc_template.rs
index eab2e36a..36b7d22b 100644
--- a/tests/expectations/tests/libclang-4/objc_template.rs
+++ b/tests/expectations/tests/libclang-4/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) -> *mut ObjectType
+ unsafe fn get(&self) -> *mut ObjectType
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: *mut KeyType) -> *mut ObjectType
+ unsafe fn objectForKey_(&self, key: *mut KeyType) -> *mut ObjectType
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/libclang-5/objc_inheritance.rs b/tests/expectations/tests/libclang-5/objc_inheritance.rs
index 42c961e7..5f07dbaa 100644
--- a/tests/expectations/tests/libclang-5/objc_inheritance.rs
+++ b/tests/expectations/tests/libclang-5/objc_inheritance.rs
@@ -49,7 +49,7 @@ impl From<Bar> for Foo {
}
}
impl std::convert::TryFrom<Foo> for Bar {
- type Error = String;
+ type Error = &'static str;
fn try_from(parent: Foo) -> Result<Bar, Self::Error> {
let is_kind_of: bool =
unsafe { msg_send!(parent, isKindOfClass: class!(Bar)) };
diff --git a/tests/expectations/tests/libclang-5/objc_template.rs b/tests/expectations/tests/libclang-5/objc_template.rs
index eab2e36a..36b7d22b 100644
--- a/tests/expectations/tests/libclang-5/objc_template.rs
+++ b/tests/expectations/tests/libclang-5/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) -> *mut ObjectType
+ unsafe fn get(&self) -> *mut ObjectType
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: *mut KeyType) -> *mut ObjectType
+ unsafe fn objectForKey_(&self, key: *mut KeyType) -> *mut ObjectType
where
<Self as std::ops::Deref>::Target: objc::Message + Sized,
{
- msg_send!(self, objectForKey: key)
+ msg_send!(*self, objectForKey: key)
}
}