Skip to content

Commit 3ab1350

Browse files
committed
Fix CI attempt 1
1 parent 12cda08 commit 3ab1350

13 files changed

+91
-83
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,7 @@ impl CodeGenerator for ObjCInterface {
37523752
}
37533753
};
37543754

3755-
let struct_name = ctx.rust_ident(self.struct_name());
3755+
let struct_name = ctx.rust_ident(self.name());
37563756
if !(self.is_category() || self.is_protocol()) {
37573757
let class_name = ctx.rust_ident(self.name());
37583758
let struct_block = quote! {

src/ir/objc.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct ObjCInterface {
3131
/// The list of template names almost always, ObjectType or KeyType
3232
pub template_names: Vec<String>,
3333

34+
/// The list of protocols that this interface conforms to.
3435
pub conforms_to: Vec<ItemId>,
3536

3637
/// List of the methods defined in this interfae
@@ -77,7 +78,7 @@ impl ObjCInterface {
7778

7879
/// Formats the name for rust
7980
/// Can be like NSObject, but with categories might be like NSObject_NSCoderMethods
80-
/// and protocols are like protocol_NSObject
81+
/// and protocols are like PNSObject
8182
pub fn rust_name(&self) -> String {
8283
if let Some(ref cat) = self.category {
8384
format!("{}_{}", self.name(), cat)
@@ -90,10 +91,6 @@ impl ObjCInterface {
9091
}
9192
}
9293

93-
pub fn struct_name(&self) -> String {
94-
format!("{}", self.name().to_owned())
95-
}
96-
9794
/// Is this a template interface?
9895
pub fn is_template(&self) -> bool {
9996
!self.template_names.is_empty()
@@ -143,7 +140,7 @@ impl ObjCInterface {
143140
}
144141
CXCursor_ObjCProtocolRef => {
145142
// Gather protocols this interface conforms to
146-
let needle = format!("protocol_{}", c.spelling());
143+
let needle = format!("P{}", c.spelling());
147144
let items_map = ctx.items();
148145
debug!("Interface {} conforms to {}, find the item", interface.name, needle);
149146

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl<ObjectType: 'static> interface_Foo<ObjectType> for struct_Foo {}
30-
pub trait interface_Foo<ObjectType>: Sized + std::ops::Deref {
30+
impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
31+
pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
3132
unsafe fn get(self) -> u64
3233
where
3334
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -36,24 +37,25 @@ pub trait interface_Foo<ObjectType>: Sized + std::ops::Deref {
3637
}
3738
}
3839
#[repr(transparent)]
39-
pub struct struct_FooMultiGeneric(pub id);
40-
impl std::ops::Deref for struct_FooMultiGeneric {
40+
#[derive(Clone, Copy)]
41+
pub struct FooMultiGeneric(pub id);
42+
impl std::ops::Deref for FooMultiGeneric {
4143
type Target = objc::runtime::Object;
4244
fn deref(&self) -> &Self::Target {
4345
unsafe { &*self.0 }
4446
}
4547
}
46-
unsafe impl objc::Message for struct_FooMultiGeneric {}
47-
impl struct_FooMultiGeneric {
48+
unsafe impl objc::Message for FooMultiGeneric {}
49+
impl FooMultiGeneric {
4850
pub fn alloc() -> Self {
4951
Self(unsafe { msg_send!(objc::class!(FooMultiGeneric), alloc) })
5052
}
5153
}
5254
impl<KeyType: 'static, ObjectType: 'static>
53-
interface_FooMultiGeneric<KeyType, ObjectType> for struct_FooMultiGeneric
55+
IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
5456
{
5557
}
56-
pub trait interface_FooMultiGeneric<KeyType, ObjectType>:
58+
pub trait IFooMultiGeneric<KeyType, ObjectType>:
5759
Sized + std::ops::Deref
5860
{
5961
unsafe fn objectForKey_(self, key: u64) -> u64

tests/expectations/tests/objc_category.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,30 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {
3132
unsafe fn method(self)
3233
where
3334
<Self as std::ops::Deref>::Target: objc::Message + Sized,
3435
{
3536
msg_send!(self, method)
3637
}
3738
}
38-
impl Foo_BarCategory for struct_Foo {}
39+
impl Foo_BarCategory for Foo {}
3940
pub trait Foo_BarCategory: Sized + std::ops::Deref {
4041
unsafe fn categoryMethod(self)
4142
where

tests/expectations/tests/objc_class.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,25 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
extern "C" {
16-
pub static mut fooVar: *mut id;
16+
pub static mut fooVar: *mut objc::runtime::Object;
1717
}
1818
#[repr(transparent)]
19-
pub struct struct_Foo(pub id);
20-
impl std::ops::Deref for struct_Foo {
19+
#[derive(Clone, Copy)]
20+
pub struct Foo(pub id);
21+
impl std::ops::Deref for Foo {
2122
type Target = objc::runtime::Object;
2223
fn deref(&self) -> &Self::Target {
2324
unsafe { &*self.0 }
2425
}
2526
}
26-
unsafe impl objc::Message for struct_Foo {}
27-
impl struct_Foo {
27+
unsafe impl objc::Message for Foo {}
28+
impl Foo {
2829
pub fn alloc() -> Self {
2930
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
3031
}
3132
}
32-
impl interface_Foo for struct_Foo {}
33-
pub trait interface_Foo: Sized + std::ops::Deref {
33+
impl IFoo for Foo {}
34+
pub trait IFoo: Sized + std::ops::Deref {
3435
unsafe fn method(self)
3536
where
3637
<Self as std::ops::Deref>::Target: objc::Message + Sized,

tests/expectations/tests/objc_class_method.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {
3132
unsafe fn method()
3233
where
3334
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -52,7 +53,7 @@ pub trait interface_Foo: Sized + std::ops::Deref {
5253
{
5354
msg_send!(class!(Foo), methodReturningInt)
5455
}
55-
unsafe fn methodReturningFoo() -> *mut id
56+
unsafe fn methodReturningFoo() -> *mut objc::runtime::Object
5657
where
5758
<Self as std::ops::Deref>::Target: objc::Message + Sized,
5859
{

tests/expectations/tests/objc_interface.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {}
31-
pub trait protocol_bar: Sized + std::ops::Deref {}
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {}
32+
pub trait Pbar: Sized + std::ops::Deref {}

tests/expectations/tests/objc_interface_type.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {}
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {}
3132
#[repr(C)]
3233
#[derive(Debug, Copy, Clone)]
3334
pub struct FooStruct {
34-
pub foo: *mut id,
35+
pub foo: *mut objc::runtime::Object,
3536
}
3637
#[test]
3738
fn bindgen_test_layout_FooStruct() {
@@ -67,5 +68,5 @@ extern "C" {
6768
pub fn fooFunc(foo: id);
6869
}
6970
extern "C" {
70-
pub static mut kFoo: *const id;
71+
pub static mut kFoo: *const objc::runtime::Object;
7172
}

tests/expectations/tests/objc_method.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {
3132
unsafe fn method(self)
3233
where
3334
<Self as std::ops::Deref>::Target: objc::Message + Sized,
@@ -52,7 +53,7 @@ pub trait interface_Foo: Sized + std::ops::Deref {
5253
{
5354
msg_send!(self, methodReturningInt)
5455
}
55-
unsafe fn methodReturningFoo(self) -> *mut id
56+
unsafe fn methodReturningFoo(self) -> *mut objc::runtime::Object
5657
where
5758
<Self as std::ops::Deref>::Target: objc::Message + Sized,
5859
{

tests/expectations/tests/objc_method_clash.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {
3132
unsafe fn foo(self)
3233
where
3334
<Self as std::ops::Deref>::Target: objc::Message + Sized,

tests/expectations/tests/objc_property_fnptr.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ extern crate objc;
1313
#[allow(non_camel_case_types)]
1414
pub type id = *mut objc::runtime::Object;
1515
#[repr(transparent)]
16-
pub struct struct_Foo(pub id);
17-
impl std::ops::Deref for struct_Foo {
16+
#[derive(Clone, Copy)]
17+
pub struct Foo(pub id);
18+
impl std::ops::Deref for Foo {
1819
type Target = objc::runtime::Object;
1920
fn deref(&self) -> &Self::Target {
2021
unsafe { &*self.0 }
2122
}
2223
}
23-
unsafe impl objc::Message for struct_Foo {}
24-
impl struct_Foo {
24+
unsafe impl objc::Message for Foo {}
25+
impl Foo {
2526
pub fn alloc() -> Self {
2627
Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
2728
}
2829
}
29-
impl interface_Foo for struct_Foo {}
30-
pub trait interface_Foo: Sized + std::ops::Deref {
30+
impl IFoo for Foo {}
31+
pub trait IFoo: Sized + std::ops::Deref {
3132
unsafe fn func(
3233
self,
3334
) -> ::std::option::Option<

0 commit comments

Comments
 (0)