Skip to content

Commit b105a98

Browse files
committed
Fix everything but copy issue
1 parent 43c568c commit b105a98

36 files changed

+68
-86
lines changed

src/codegen/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4129,7 +4129,7 @@ impl CodeGenerator for ObjCInterface {
41294129
.collect();
41304130

41314131
quote! {
4132-
pub trait #trait_name <#(#template_names),*> : #trait_constraints {
4132+
pub trait #trait_name <#(#template_names:'static),*> : #trait_constraints {
41334133
#( #impl_items )*
41344134
}
41354135
}
@@ -4159,7 +4159,7 @@ impl CodeGenerator for ObjCInterface {
41594159
impl #class_name {
41604160
pub fn alloc() -> Self {
41614161
Self(unsafe {
4162-
msg_send!(objc::class!(#class_name), alloc)
4162+
msg_send!(class!(#class_name), alloc)
41634163
})
41644164
}
41654165
}
@@ -4245,7 +4245,7 @@ impl CodeGenerator for ObjCInterface {
42454245
impl std::convert::TryFrom<#parent_struct> for #class_name {
42464246
type Error = &'static str;
42474247
fn try_from(parent: #parent_struct) -> Result<#class_name, Self::Error> {
4248-
let is_kind_of : bool = unsafe { msg_send!(parent, isKindOfClass:class!(#class_name))};
4248+
let is_kind_of : bool = unsafe { objc::msg_send!(parent, isKindOfClass:class!(#class_name))};
42494249
if is_kind_of {
42504250
Ok(#class_name(parent.0))
42514251
} else {
@@ -4381,7 +4381,7 @@ pub mod utils {
43814381
}
43824382
} else {
43834383
quote! {
4384-
use objc;
4384+
use objc::{self, msg_send, sel, sel_impl, class};
43854385
}
43864386
};
43874387

tests/expectations/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ authors = [
77
"Emilio Cobos Álvarez <[email protected]>",
88
"The Servo project developers",
99
]
10+
edition = "2018"
1011

1112
[dependencies]
1213
objc = "0.2"

tests/expectations/tests/libclang-4/objc_inheritance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]

tests/expectations/tests/libclang-4/objc_template.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -26,7 +25,7 @@ impl Foo {
2625
}
2726
}
2827
impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
29-
pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
28+
pub trait IFoo<ObjectType: 'static>: Sized + std::ops::Deref {
3029
unsafe fn get(&self) -> *mut ObjectType
3130
where
3231
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -53,7 +52,7 @@ impl<KeyType: 'static, ObjectType: 'static>
5352
IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
5453
{
5554
}
56-
pub trait IFooMultiGeneric<KeyType, ObjectType>:
55+
pub trait IFooMultiGeneric<KeyType: 'static, ObjectType: 'static>:
5756
Sized + std::ops::Deref
5857
{
5958
unsafe fn objectForKey_(&self, key: *mut KeyType) -> *mut ObjectType

tests/expectations/tests/libclang-5/objc_inheritance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]

tests/expectations/tests/libclang-5/objc_template.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -26,7 +25,7 @@ impl Foo {
2625
}
2726
}
2827
impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
29-
pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
28+
pub trait IFoo<ObjectType: 'static>: Sized + std::ops::Deref {
3029
unsafe fn get(&self) -> *mut ObjectType
3130
where
3231
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -53,7 +52,7 @@ impl<KeyType: 'static, ObjectType: 'static>
5352
IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
5453
{
5554
}
56-
pub trait IFooMultiGeneric<KeyType, ObjectType>:
55+
pub trait IFooMultiGeneric<KeyType: 'static, ObjectType: 'static>:
5756
Sized + std::ops::Deref
5857
{
5958
unsafe fn objectForKey_(&self, key: *mut KeyType) -> *mut ObjectType

tests/expectations/tests/libclang-9/objc_inheritance.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}
@@ -39,7 +38,7 @@ impl std::ops::Deref for Bar {
3938
unsafe impl objc::Message for Bar {}
4039
impl Bar {
4140
pub fn alloc() -> Self {
42-
Self(unsafe { msg_send!(objc::class!(Bar), alloc) })
41+
Self(unsafe { msg_send!(class!(Bar), alloc) })
4342
}
4443
}
4544
impl IFoo for Bar {}
@@ -52,7 +51,7 @@ impl std::convert::TryFrom<Foo> for Bar {
5251
type Error = &'static str;
5352
fn try_from(parent: Foo) -> Result<Bar, Self::Error> {
5453
let is_kind_of: bool =
55-
unsafe { msg_send!(parent, isKindOfClass: class!(Bar)) };
54+
unsafe { objc::msg_send!(parent, isKindOfClass: class!(Bar)) };
5655
if is_kind_of {
5756
Ok(Bar(parent.0))
5857
} else {
@@ -74,7 +73,7 @@ impl std::ops::Deref for Baz {
7473
unsafe impl objc::Message for Baz {}
7574
impl Baz {
7675
pub fn alloc() -> Self {
77-
Self(unsafe { msg_send!(objc::class!(Baz), alloc) })
76+
Self(unsafe { msg_send!(class!(Baz), alloc) })
7877
}
7978
}
8079
impl IBar for Baz {}
@@ -87,7 +86,7 @@ impl std::convert::TryFrom<Bar> for Baz {
8786
type Error = &'static str;
8887
fn try_from(parent: Bar) -> Result<Baz, Self::Error> {
8988
let is_kind_of: bool =
90-
unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
89+
unsafe { objc::msg_send!(parent, isKindOfClass: class!(Baz)) };
9190
if is_kind_of {
9291
Ok(Baz(parent.0))
9392
} else {
@@ -105,7 +104,7 @@ impl std::convert::TryFrom<Foo> for Baz {
105104
type Error = &'static str;
106105
fn try_from(parent: Foo) -> Result<Baz, Self::Error> {
107106
let is_kind_of: bool =
108-
unsafe { msg_send!(parent, isKindOfClass: class!(Baz)) };
107+
unsafe { objc::msg_send!(parent, isKindOfClass: class!(Baz)) };
109108
if is_kind_of {
110109
Ok(Baz(parent.0))
111110
} else {

tests/expectations/tests/libclang-9/objc_template.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,11 +21,11 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
29-
pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
28+
pub trait IFoo<ObjectType: 'static>: Sized + std::ops::Deref {
3029
unsafe fn get(&self) -> u64
3130
where
3231
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -46,14 +45,14 @@ impl std::ops::Deref for FooMultiGeneric {
4645
unsafe impl objc::Message for FooMultiGeneric {}
4746
impl FooMultiGeneric {
4847
pub fn alloc() -> Self {
49-
Self(unsafe { msg_send!(objc::class!(FooMultiGeneric), alloc) })
48+
Self(unsafe { msg_send!(class!(FooMultiGeneric), alloc) })
5049
}
5150
}
5251
impl<KeyType: 'static, ObjectType: 'static>
5352
IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
5453
{
5554
}
56-
pub trait IFooMultiGeneric<KeyType, ObjectType>:
55+
pub trait IFooMultiGeneric<KeyType: 'static, ObjectType: 'static>:
5756
Sized + std::ops::Deref
5857
{
5958
unsafe fn objectForKey_(&self, key: u64) -> u64

tests/expectations/tests/objc_allowlist.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
pub trait PSomeProtocol: Sized + std::ops::Deref {
@@ -36,7 +35,7 @@ impl std::ops::Deref for AllowlistMe {
3635
unsafe impl objc::Message for AllowlistMe {}
3736
impl AllowlistMe {
3837
pub fn alloc() -> Self {
39-
Self(unsafe { msg_send!(objc::class!(AllowlistMe), alloc) })
38+
Self(unsafe { msg_send!(class!(AllowlistMe), alloc) })
4039
}
4140
}
4241
impl PSomeProtocol for AllowlistMe {}

tests/expectations/tests/objc_category.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

tests/expectations/tests/objc_class.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
extern "C" {
@@ -25,7 +24,7 @@ impl std::ops::Deref for Foo {
2524
unsafe impl objc::Message for Foo {}
2625
impl Foo {
2726
pub fn alloc() -> Self {
28-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
27+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2928
}
3029
}
3130
impl IFoo for Foo {}

tests/expectations/tests/objc_class_method.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

tests/expectations/tests/objc_interface.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

tests/expectations/tests/objc_interface_type.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

tests/expectations/tests/objc_method.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

tests/expectations/tests/objc_method_clash.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
)]
77
#![cfg(target_os = "macos")]
88

9-
#[macro_use]
10-
extern crate objc;
9+
use objc::{self, class, msg_send, sel, sel_impl};
1110
#[allow(non_camel_case_types)]
1211
pub type id = *mut objc::runtime::Object;
1312
#[repr(transparent)]
@@ -22,7 +21,7 @@ impl std::ops::Deref for Foo {
2221
unsafe impl objc::Message for Foo {}
2322
impl Foo {
2423
pub fn alloc() -> Self {
25-
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
24+
Self(unsafe { msg_send!(class!(Foo), alloc) })
2625
}
2726
}
2827
impl IFoo for Foo {}

0 commit comments

Comments
 (0)