summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/expectations/tests/libclang-3.9/objc_inheritance.rs76
-rw-r--r--tests/expectations/tests/libclang-4/objc_inheritance.rs66
-rw-r--r--tests/expectations/tests/libclang-5/objc_inheritance.rs66
3 files changed, 197 insertions, 11 deletions
diff --git a/tests/expectations/tests/libclang-3.9/objc_inheritance.rs b/tests/expectations/tests/libclang-3.9/objc_inheritance.rs
index cd2b085d..982fc14c 100644
--- a/tests/expectations/tests/libclang-3.9/objc_inheritance.rs
+++ b/tests/expectations/tests/libclang-3.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,78 @@ impl Bar {
}
}
impl IFoo for Bar {}
+
+mpl From<Bar> for Foo {
+
++ fn from(child: Bar) -> Foo {
+
++ Foo(child.0)
+
++ }
+
++}
+
+impl std::convert::TryFrom<Foo> for Bar {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Bar, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Bar)) };
+ if is_kind_of {
+ Ok(Bar(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Bar"
+ ))
+ }
+ }
+}
impl IBar for Bar {}
+impl From<Baz> for Bar {
+ fn from(child: Baz) -> Bar {
+ Bar(child.0)
+ }
+}
+
+impl std::convert::TryFrom<Bar> for Baz {
+ type Error = String;
+ fn try_from(parent: Bar) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Bar", "Baz"
+ ))
+ }
+ }
+}
+impl IFoo for Baz {}
+impl From<Baz> for Foo {
+ fn from(child: Baz) -> Foo {
+ Foo(child.0)
+ }
+}
+impl std::convert::TryFrom<Foo> for Baz {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Baz"
+ ))
+ }
+ }
+}
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;
@@ -60,7 +128,5 @@ impl Baz {
Self(unsafe { msg_send!(objc::class!(Baz), alloc) })
}
}
-impl IBar for Baz {}
-impl IFoo for Baz {}
impl IBaz for Baz {}
pub trait IBaz: Sized + std::ops::Deref {}
diff --git a/tests/expectations/tests/libclang-4/objc_inheritance.rs b/tests/expectations/tests/libclang-4/objc_inheritance.rs
index cd2b085d..a84f6f37 100644
--- a/tests/expectations/tests/libclang-4/objc_inheritance.rs
+++ b/tests/expectations/tests/libclang-4/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,30 @@ impl Bar {
}
}
impl IFoo for Bar {}
+impl From<Bar> for Foo {
+ fn from(child: Bar) -> Foo {
+ Foo(child.0)
+ }
+}
+impl std::convert::TryFrom<Foo> for Bar {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Bar, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Bar)) };
+ if is_kind_of {
+ Ok(Bar(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Bar"
+ ))
+ }
+ }
+}
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 +81,46 @@ impl Baz {
}
}
impl IBar for Baz {}
+impl From<Baz> for Bar {
+ fn from(child: Baz) -> Bar {
+ Bar(child.0)
+ }
+}
+impl std::convert::TryFrom<Bar> for Baz {
+ type Error = String;
+ fn try_from(parent: Bar) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Bar", "Baz"
+ ))
+ }
+ }
+}
impl IFoo for Baz {}
+impl From<Baz> for Foo {
+ fn from(child: Baz) -> Foo {
+ Foo(child.0)
+ }
+}
+impl std::convert::TryFrom<Foo> for Baz {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Baz"
+ ))
+ }
+ }
+}
impl IBaz for Baz {}
pub trait IBaz: Sized + std::ops::Deref {}
diff --git a/tests/expectations/tests/libclang-5/objc_inheritance.rs b/tests/expectations/tests/libclang-5/objc_inheritance.rs
index cd2b085d..a84f6f37 100644
--- a/tests/expectations/tests/libclang-5/objc_inheritance.rs
+++ b/tests/expectations/tests/libclang-5/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,30 @@ impl Bar {
}
}
impl IFoo for Bar {}
+impl From<Bar> for Foo {
+ fn from(child: Bar) -> Foo {
+ Foo(child.0)
+ }
+}
+impl std::convert::TryFrom<Foo> for Bar {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Bar, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Bar)) };
+ if is_kind_of {
+ Ok(Bar(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Bar"
+ ))
+ }
+ }
+}
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 +81,46 @@ impl Baz {
}
}
impl IBar for Baz {}
+impl From<Baz> for Bar {
+ fn from(child: Baz) -> Bar {
+ Bar(child.0)
+ }
+}
+impl std::convert::TryFrom<Bar> for Baz {
+ type Error = String;
+ fn try_from(parent: Bar) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Bar", "Baz"
+ ))
+ }
+ }
+}
impl IFoo for Baz {}
+impl From<Baz> for Foo {
+ fn from(child: Baz) -> Foo {
+ Foo(child.0)
+ }
+}
+impl std::convert::TryFrom<Foo> for Baz {
+ type Error = String;
+ fn try_from(parent: Foo) -> Result<Baz, Self::Error> {
+ let is_kind_of: bool =
+ unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
+ if is_kind_of {
+ Ok(Baz(parent.0))
+ } else {
+ Err(format!(
+ "This {} is not an cannot be downcasted to {}",
+ "Foo", "Baz"
+ ))
+ }
+ }
+}
impl IBaz for Baz {}
pub trait IBaz: Sized + std::ops::Deref {}