From 7c745c26b550eb93da1629e224033c4aa1aad7fe Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 11 Sep 2023 02:05:00 +0200 Subject: [PATCH 1/3] Fix NSObjectProtocol ProtocolType implementation --- crates/icrate/examples/browser.rs | 4 +- crates/icrate/examples/delegate.rs | 4 +- crates/icrate/examples/metal.rs | 16 +++---- crates/objc2/CHANGELOG.md | 3 ++ crates/objc2/src/__macro_helpers/mod.rs | 50 +++++++++++++++------ crates/objc2/src/declare/mod.rs | 46 +++++++++++++++++-- crates/objc2/src/macros/declare_class.rs | 5 +-- crates/objc2/src/runtime/nsobject.rs | 8 +++- crates/objc2/src/runtime/protocol_object.rs | 13 +++--- 9 files changed, 110 insertions(+), 39 deletions(-) diff --git a/crates/icrate/examples/browser.rs b/crates/icrate/examples/browser.rs index 9db062c3e..1bc466863 100644 --- a/crates/icrate/examples/browser.rs +++ b/crates/icrate/examples/browser.rs @@ -73,6 +73,8 @@ declare_class!( } } + unsafe impl NSObjectProtocol for Delegate {} + unsafe impl NSApplicationDelegate for Delegate { #[method(applicationDidFinishLaunching:)] #[allow(non_snake_case)] @@ -293,8 +295,6 @@ impl Delegate { } } -unsafe impl NSObjectProtocol for Delegate {} - fn main() { let mtm = MainThreadMarker::new().unwrap(); let app = NSApplication::sharedApplication(mtm); diff --git a/crates/icrate/examples/delegate.rs b/crates/icrate/examples/delegate.rs index 248b7e487..5d4e44457 100644 --- a/crates/icrate/examples/delegate.rs +++ b/crates/icrate/examples/delegate.rs @@ -50,6 +50,8 @@ declare_class!( } } + unsafe impl NSObjectProtocol for AppDelegate {} + unsafe impl NSApplicationDelegate for AppDelegate { #[method(applicationDidFinishLaunching:)] fn did_finish_launching(&self, notification: &NSNotification) { @@ -65,8 +67,6 @@ declare_class!( } ); -unsafe impl NSObjectProtocol for AppDelegate {} - impl AppDelegate { pub fn new(ivar: u8, another_ivar: bool, mtm: MainThreadMarker) -> Id { unsafe { msg_send_id![mtm.alloc(), initWith: ivar, another: another_ivar] } diff --git a/crates/icrate/examples/metal.rs b/crates/icrate/examples/metal.rs index 2c13d0176..7b31d439e 100644 --- a/crates/icrate/examples/metal.rs +++ b/crates/icrate/examples/metal.rs @@ -31,21 +31,21 @@ use objc2::{ #[rustfmt::skip] const SHADERS: &str = r#" #include - + struct SceneProperties { float time; - }; - + }; + struct VertexInput { metal::packed_float3 position; metal::packed_float3 color; }; - + struct VertexOutput { metal::float4 position [[position]]; metal::float4 color; }; - + vertex VertexOutput vertex_main( device const SceneProperties& properties [[buffer(0)]], device const VertexInput* vertices [[buffer(1)]], @@ -64,7 +64,7 @@ const SHADERS: &str = r#" out.color = metal::float4(in.color, 1); return out; } - + fragment metal::float4 fragment_main(VertexOutput in [[stage_in]]) { return in.color; } @@ -155,6 +155,8 @@ declare_class!( } } + unsafe impl NSObjectProtocol for Delegate {} + // define the delegate methods for the `NSApplicationDelegate` protocol unsafe impl NSApplicationDelegate for Delegate { #[method(applicationDidFinishLaunching:)] @@ -356,8 +358,6 @@ declare_class!( } ); -unsafe impl NSObjectProtocol for Delegate {} - impl Delegate { pub fn new(mtm: MainThreadMarker) -> Id { unsafe { msg_send_id![mtm.alloc(), init] } diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index c458ad14e..bf31a9715 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -43,6 +43,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ]; ``` +### Fixed +* Fixed the name of the protocol that `NSObjectProtocol` references. + ## 0.4.1 - 2023-07-31 diff --git a/crates/objc2/src/__macro_helpers/mod.rs b/crates/objc2/src/__macro_helpers/mod.rs index 0ffdf610e..6ce8507fe 100644 --- a/crates/objc2/src/__macro_helpers/mod.rs +++ b/crates/objc2/src/__macro_helpers/mod.rs @@ -580,32 +580,56 @@ impl ClassProtocolMethodsBuilder<'_, '_> { } } - #[inline] + #[cfg(all(debug_assertions, feature = "verify"))] pub fn __finish(self) { - #[cfg(all(debug_assertions, feature = "verify"))] + let superclass = self.builder.superclass(); + if let Some(protocol) = self.protocol { for desc in &self.required_instance_methods { - if !self.registered_instance_methods.contains(&desc.sel) { - panic!( - "must implement required protocol method -[{protocol} {}]", - desc.sel - ) + if self.registered_instance_methods.contains(&desc.sel) { + continue; + } + + // TODO: Don't do this when `NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION` + if superclass + .and_then(|superclass| superclass.instance_method(desc.sel)) + .is_some() + { + continue; } + + panic!( + "must implement required protocol method -[{protocol} {}]", + desc.sel + ) } } - #[cfg(all(debug_assertions, feature = "verify"))] if let Some(protocol) = self.protocol { for desc in &self.required_class_methods { - if !self.registered_class_methods.contains(&desc.sel) { - panic!( - "must implement required protocol method +[{protocol} {}]", - desc.sel - ) + if self.registered_class_methods.contains(&desc.sel) { + continue; + } + + // TODO: Don't do this when `NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION` + if superclass + .and_then(|superclass| superclass.class_method(desc.sel)) + .is_some() + { + continue; } + + panic!( + "must implement required protocol method +[{protocol} {}]", + desc.sel + ); } } } + + #[inline] + #[cfg(not(all(debug_assertions, feature = "verify")))] + pub fn __finish(self) {} } #[cfg(test)] diff --git a/crates/objc2/src/declare/mod.rs b/crates/objc2/src/declare/mod.rs index 6f1cde4c5..52a7f3777 100644 --- a/crates/objc2/src/declare/mod.rs +++ b/crates/objc2/src/declare/mod.rs @@ -356,7 +356,7 @@ impl ClassBuilder { } #[allow(unused)] - fn superclass(&self) -> Option<&AnyClass> { + pub(crate) fn superclass(&self) -> Option<&AnyClass> { // SAFETY: Though the class is not finalized, `class_getSuperclass` is // still safe to call. unsafe { AnyClass::superclass_raw(self.cls.as_ptr()) } @@ -612,7 +612,9 @@ impl ClassBuilder { pub fn add_protocol(&mut self, proto: &AnyProtocol) { let success = unsafe { ffi::class_addProtocol(self.as_mut_ptr(), proto.as_ptr()) }; let success = Bool::from_raw(success).as_bool(); - assert!(success, "failed to add protocol {proto}"); + if cfg!(not(feature = "gnustep-1-7")) { + assert!(success, "failed to add protocol {proto}"); + } } // fn add_property(&self, name: &str, attributes: &[ffi::objc_property_attribute_t]); @@ -770,7 +772,7 @@ mod tests { use crate::mutability::Immutable; use crate::rc::Id; use crate::runtime::{NSObject, NSObjectProtocol}; - use crate::{declare_class, extern_methods, msg_send, test_utils, ClassType}; + use crate::{declare_class, extern_methods, msg_send, test_utils, ClassType, ProtocolType}; #[test] fn test_alignment() { @@ -900,7 +902,43 @@ mod tests { } #[test] - #[should_panic = "failed to add protocol NSObject"] + fn inheriting_does_not_implement_protocols() { + let builder = ClassBuilder::new( + "TestClassBuilderInheritingDoesNotImplementProtocols", + NSObject::class(), + ) + .unwrap(); + + let cls = builder.register(); + let conforms = cls.conforms_to(::protocol().unwrap()); + if cfg!(feature = "gnustep-1-7") { + // FIXME: GNUStep works differently here! + assert!(conforms); + } else { + assert!(!conforms); + } + } + + #[test] + fn inherit_nsobject_add_protocol() { + let mut builder = ClassBuilder::new( + "TestClassBuilderInheritNSObjectAddProtocol", + NSObject::class(), + ) + .unwrap(); + + let protocol = ::protocol().unwrap(); + + builder.add_protocol(protocol); + let cls = builder.register(); + assert!(cls.conforms_to(protocol)); + } + + #[test] + #[cfg_attr( + not(feature = "gnustep-1-7"), + should_panic = "failed to add protocol NSObject" + )] fn duplicate_protocol() { let cls = test_utils::custom_class(); let mut builder = ClassBuilder::new("TestClassBuilderDuplicateProtocol", cls).unwrap(); diff --git a/crates/objc2/src/macros/declare_class.rs b/crates/objc2/src/macros/declare_class.rs index 126dd94e6..1b99c3592 100644 --- a/crates/objc2/src/macros/declare_class.rs +++ b/crates/objc2/src/macros/declare_class.rs @@ -259,6 +259,8 @@ /// # } /// } /// +/// unsafe impl NSObjectProtocol for MyCustomObject {} +/// /// # #[cfg(available_in_icrate)] /// unsafe impl NSCopying for MyCustomObject { /// #[method_id(copyWithZone:)] @@ -274,9 +276,6 @@ /// } /// ); /// -/// // TODO: Allow moving this inside `declare_class!` -/// unsafe impl NSObjectProtocol for MyCustomObject {} -/// /// impl MyCustomObject { /// pub fn new(foo: u8) -> Id { /// unsafe { msg_send_id![Self::alloc(), initWithFoo: foo] } diff --git a/crates/objc2/src/runtime/nsobject.rs b/crates/objc2/src/runtime/nsobject.rs index 4b2570818..73b9c97e9 100644 --- a/crates/objc2/src/runtime/nsobject.rs +++ b/crates/objc2/src/runtime/nsobject.rs @@ -165,7 +165,7 @@ crate::__inner_extern_protocol!( () (NSObjectProtocol) (dyn NSObjectProtocol) - ("NSCopying") + ("NSObject") ); unsafe impl NSObjectProtocol for NSObject {} @@ -372,4 +372,10 @@ mod tests { assert_eq!(ptr1, ptr2); } + + #[test] + fn conforms_to_nsobjectprotocol() { + let protocol = ::protocol().unwrap(); + assert!(NSObject::class().conforms_to(protocol)); + } } diff --git a/crates/objc2/src/runtime/protocol_object.rs b/crates/objc2/src/runtime/protocol_object.rs index cdcaeeab7..15e891a57 100644 --- a/crates/objc2/src/runtime/protocol_object.rs +++ b/crates/objc2/src/runtime/protocol_object.rs @@ -253,8 +253,15 @@ mod tests { type Mutability = Mutable; const NAME: &'static str = "ProtocolTestsDummyClass"; } + + unsafe impl NSObjectProtocol for DummyClass {} ); + unsafe impl Foo for DummyClass {} + unsafe impl Bar for DummyClass {} + unsafe impl FooBar for DummyClass {} + // unsafe impl FooFooBar for DummyClass {} + extern_methods!( unsafe impl DummyClass { #[method_id(new)] @@ -262,12 +269,6 @@ mod tests { } ); - unsafe impl NSObjectProtocol for DummyClass {} - unsafe impl Foo for DummyClass {} - unsafe impl Bar for DummyClass {} - unsafe impl FooBar for DummyClass {} - // unsafe impl FooFooBar for DummyClass {} - #[test] fn impl_traits() { assert_impl_all!(NSObject: NSObjectProtocol); From b4326d08ecbceb83a78a419ffbc8b20c03c6d67f Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 11 Sep 2023 01:11:09 +0200 Subject: [PATCH 2/3] Remove ProtocolType implementation for NSObject It is more like an odd edge-case that `NSObject` implements `ProtocolType` and can be used as `ProtocolObject`, users should instead use `NSObjectProtocol` which works like any other protocol. --- crates/objc2/CHANGELOG.md | 4 ++++ crates/objc2/src/protocol_type.rs | 8 +++---- crates/objc2/src/runtime/nsobject.rs | 24 ++------------------- crates/objc2/src/runtime/nsproxy.rs | 4 ++-- crates/objc2/src/runtime/protocol_object.rs | 18 ++++++++-------- crates/tests/src/test_object.rs | 4 ++-- 6 files changed, 23 insertions(+), 39 deletions(-) diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index bf31a9715..2ed8ef40e 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -46,6 +46,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed * Fixed the name of the protocol that `NSObjectProtocol` references. +### Removed +* **BREAKING**: Removed `ProtocolType` implementation for `NSObject`. + Use the more precise `NSObjectProtocol` trait instead! + ## 0.4.1 - 2023-07-31 diff --git a/crates/objc2/src/protocol_type.rs b/crates/objc2/src/protocol_type.rs index 11c8c8b42..8b5580e0b 100644 --- a/crates/objc2/src/protocol_type.rs +++ b/crates/objc2/src/protocol_type.rs @@ -23,10 +23,10 @@ use crate::runtime::AnyProtocol; /// /// ``` /// use objc2::ProtocolType; -/// use objc2::runtime::NSObject; -/// // Get a protocol object representing `NSObject` -/// let protocol = NSObject::protocol().expect("NSObject to have a protocol"); -/// assert_eq!(NSObject::NAME, protocol.name()); +/// use objc2::runtime::NSObjectProtocol; +/// // Get a protocol object representing the `NSObject` protocol +/// let protocol = ::protocol().expect("NSObject to have a protocol"); +/// assert_eq!(::NAME, protocol.name()); /// ``` /// /// Use the [`extern_protocol!`] macro to implement this trait for a type. diff --git a/crates/objc2/src/runtime/nsobject.rs b/crates/objc2/src/runtime/nsobject.rs index 73b9c97e9..f188fb09d 100644 --- a/crates/objc2/src/runtime/nsobject.rs +++ b/crates/objc2/src/runtime/nsobject.rs @@ -3,7 +3,7 @@ use core::hash; use crate::mutability::Root; use crate::rc::{DefaultId, Id}; -use crate::runtime::{AnyClass, AnyObject, AnyProtocol, ImplementedBy, ProtocolObject}; +use crate::runtime::{AnyClass, AnyObject, ProtocolObject}; use crate::{extern_methods, msg_send, msg_send_id, Message}; use crate::{ClassType, ProtocolType}; @@ -170,26 +170,6 @@ crate::__inner_extern_protocol!( unsafe impl NSObjectProtocol for NSObject {} -unsafe impl ProtocolType for NSObject { - const NAME: &'static str = "NSObject"; - - fn protocol() -> Option<&'static AnyProtocol> { - Some( - AnyProtocol::get(::NAME) - .expect("could not find NSObject protocol"), - ) - } - - const __INNER: () = (); -} - -unsafe impl ImplementedBy for NSObject -where - T: ?Sized + Message + NSObjectProtocol, -{ - const __INNER: () = (); -} - extern_methods!( unsafe impl NSObject { /// Create a new empty `NSObject`. @@ -234,7 +214,7 @@ impl fmt::Debug for NSObject { #[doc(alias = "description")] #[doc(alias = "debugDescription")] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let obj: &ProtocolObject = ProtocolObject::from_ref(self); + let obj: &ProtocolObject = ProtocolObject::from_ref(self); obj.fmt(f) } } diff --git a/crates/objc2/src/runtime/nsproxy.rs b/crates/objc2/src/runtime/nsproxy.rs index e4ff409c4..cfd87851d 100644 --- a/crates/objc2/src/runtime/nsproxy.rs +++ b/crates/objc2/src/runtime/nsproxy.rs @@ -2,7 +2,7 @@ use core::fmt; use core::hash; use crate::mutability::Root; -use crate::runtime::{AnyClass, AnyObject, NSObject, NSObjectProtocol, ProtocolObject}; +use crate::runtime::{AnyClass, AnyObject, NSObjectProtocol, ProtocolObject}; use crate::ClassType; crate::__emit_struct! { @@ -97,7 +97,7 @@ impl fmt::Debug for NSProxy { #[doc(alias = "description")] #[doc(alias = "debugDescription")] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let obj: &ProtocolObject = ProtocolObject::from_ref(self); + let obj: &ProtocolObject = ProtocolObject::from_ref(self); obj.fmt(f) } } diff --git a/crates/objc2/src/runtime/protocol_object.rs b/crates/objc2/src/runtime/protocol_object.rs index 15e891a57..ae8c8d085 100644 --- a/crates/objc2/src/runtime/protocol_object.rs +++ b/crates/objc2/src/runtime/protocol_object.rs @@ -272,7 +272,7 @@ mod tests { #[test] fn impl_traits() { assert_impl_all!(NSObject: NSObjectProtocol); - assert_impl_all!(ProtocolObject: NSObjectProtocol); + assert_impl_all!(ProtocolObject: NSObjectProtocol); assert_not_impl_any!(ProtocolObject: NSObjectProtocol); assert_impl_all!(ProtocolObject: NSObjectProtocol); assert_impl_all!(ProtocolObject: NSObjectProtocol); @@ -280,7 +280,7 @@ mod tests { assert_impl_all!(DummyClass: NSObjectProtocol); assert_not_impl_any!(NSObject: Foo); - assert_not_impl_any!(ProtocolObject: Foo); + assert_not_impl_any!(ProtocolObject: Foo); assert_impl_all!(ProtocolObject: Foo); assert_not_impl_any!(ProtocolObject: Foo); assert_impl_all!(ProtocolObject: Foo); @@ -288,7 +288,7 @@ mod tests { assert_impl_all!(DummyClass: Foo); assert_not_impl_any!(NSObject: Bar); - assert_not_impl_any!(ProtocolObject: Bar); + assert_not_impl_any!(ProtocolObject: Bar); assert_not_impl_any!(ProtocolObject: Bar); assert_impl_all!(ProtocolObject: Bar); assert_impl_all!(ProtocolObject: Bar); @@ -296,7 +296,7 @@ mod tests { assert_impl_all!(DummyClass: Bar); assert_not_impl_any!(NSObject: FooBar); - assert_not_impl_any!(ProtocolObject: FooBar); + assert_not_impl_any!(ProtocolObject: FooBar); assert_not_impl_any!(ProtocolObject: FooBar); assert_not_impl_any!(ProtocolObject: FooBar); assert_impl_all!(ProtocolObject: FooBar); @@ -304,7 +304,7 @@ mod tests { assert_impl_all!(DummyClass: FooBar); assert_not_impl_any!(NSObject: FooFooBar); - assert_not_impl_any!(ProtocolObject: FooFooBar); + assert_not_impl_any!(ProtocolObject: FooFooBar); assert_not_impl_any!(ProtocolObject: FooFooBar); assert_not_impl_any!(ProtocolObject: FooFooBar); assert_not_impl_any!(ProtocolObject: FooFooBar); @@ -326,10 +326,10 @@ mod tests { let foo: &ProtocolObject = ProtocolObject::from_ref(&*obj); let _foo: &ProtocolObject = ProtocolObject::from_ref(foo); - let _nsobject: &ProtocolObject = ProtocolObject::from_ref(foobar); - let _nsobject: &ProtocolObject = ProtocolObject::from_ref(bar); - let nsobject: &ProtocolObject = ProtocolObject::from_ref(&*obj); - let _nsobject: &ProtocolObject = ProtocolObject::from_ref(nsobject); + let _nsobject: &ProtocolObject = ProtocolObject::from_ref(foobar); + let _nsobject: &ProtocolObject = ProtocolObject::from_ref(bar); + let nsobject: &ProtocolObject = ProtocolObject::from_ref(&*obj); + let _nsobject: &ProtocolObject = ProtocolObject::from_ref(nsobject); let _foobar: &mut ProtocolObject = ProtocolObject::from_mut(&mut *obj); let _foobar: Id> = ProtocolObject::from_id(obj); diff --git a/crates/tests/src/test_object.rs b/crates/tests/src/test_object.rs index 9466ff4a8..abb5fde52 100644 --- a/crates/tests/src/test_object.rs +++ b/crates/tests/src/test_object.rs @@ -326,6 +326,6 @@ fn test_protocol() { #[cfg(feature = "Foundation_all")] assert_eq!(MyTestObject::h().as_i32(), 8); - // Check that transforming to `NSObject` works - let _obj: &ProtocolObject = ProtocolObject::from_ref(&*proto); + // Check that transforming to `NSObjectProtocol` works + let _obj: &ProtocolObject = ProtocolObject::from_ref(&*proto); } From 1ad018a295d793eb96db632715bcf3f2c6186280 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 11 Sep 2023 00:42:27 +0200 Subject: [PATCH 3/3] Fix renamed protocols --- crates/header-translator/src/stmt.rs | 22 +++++++++++++++---- crates/icrate/CHANGELOG.md | 2 ++ crates/icrate/src/fixes/Foundation/copying.rs | 8 ++----- crates/icrate/src/generated | 2 +- crates/icrate/tests/renamed_protocols.rs | 9 ++++++++ 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 crates/icrate/tests/renamed_protocols.rs diff --git a/crates/header-translator/src/stmt.rs b/crates/header-translator/src/stmt.rs index ff06650d3..a1ac445e7 100644 --- a/crates/header-translator/src/stmt.rs +++ b/crates/header-translator/src/stmt.rs @@ -369,6 +369,7 @@ pub enum Stmt { /// extern_protocol! ProtocolDecl { id: ItemIdentifier, + actual_name: Option, availability: Availability, protocols: BTreeSet, methods: Vec, @@ -797,9 +798,14 @@ impl Stmt { .collect() } EntityKind::ObjCProtocolDecl => { - let id = ItemIdentifier::new(entity, context) - .map_name(|name| context.replace_protocol_name(name)); - let data = context.protocol_data.get(&id.name); + let actual_id = ItemIdentifier::new(entity, context); + let data = context.protocol_data.get(&actual_id.name); + let actual_name = data + .map(|data| data.renamed.is_some()) + .unwrap_or_default() + .then(|| actual_id.name.clone()); + + let id = actual_id.map_name(|name| context.replace_protocol_name(name)); if data.map(|data| data.skipped).unwrap_or_default() { return vec![]; @@ -830,6 +836,7 @@ impl Stmt { vec![Self::ProtocolDecl { id, + actual_name, availability, protocols, methods, @@ -1616,6 +1623,7 @@ impl fmt::Display for Stmt { } Self::ProtocolDecl { id, + actual_name, availability, protocols, methods, @@ -1683,7 +1691,13 @@ impl fmt::Display for Stmt { } writeln!(f, " }}")?; writeln!(f)?; - writeln!(f, " unsafe impl ProtocolType for dyn {} {{}}", id.name)?; + writeln!(f, " unsafe impl ProtocolType for dyn {} {{", id.name)?; + if let Some(actual_name) = actual_name { + writeln!(f)?; + writeln!(f, " const NAME: &'static str = {actual_name:?};")?; + write!(f, " ")?; + } + writeln!(f, "}}")?; writeln!(f, ");")?; } Self::StructDecl { diff --git a/crates/icrate/CHANGELOG.md b/crates/icrate/CHANGELOG.md index 01a0f4da0..162306d76 100644 --- a/crates/icrate/CHANGELOG.md +++ b/crates/icrate/CHANGELOG.md @@ -65,6 +65,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). to use in such hashing collections. * **BREAKING**: Added `HasStableHash` requirement on `NSDictionary` and `NSSet` creation methods, fixing a long-standing soundess issue. +* Fixed the protocol names of `NSAccessibilityElementProtocol`, + `NSTextAttachmentCellProtocol` and `NSFileProviderItemProtocol`. ## icrate 0.0.4 - 2023-07-31 diff --git a/crates/icrate/src/fixes/Foundation/copying.rs b/crates/icrate/src/fixes/Foundation/copying.rs index 5117ae079..b0d7c8ef4 100644 --- a/crates/icrate/src/fixes/Foundation/copying.rs +++ b/crates/icrate/src/fixes/Foundation/copying.rs @@ -41,9 +41,7 @@ extern_protocol!( Self: CounterpartOrSelf; } - unsafe impl ProtocolType for dyn NSCopying { - const NAME: &'static str = "NSCopying"; - } + unsafe impl ProtocolType for dyn NSCopying {} ); // FIXME: Remove this hack which makes NSMutableDictionary tests work @@ -86,7 +84,5 @@ extern_protocol!( Self: CounterpartOrSelf; } - unsafe impl ProtocolType for dyn NSMutableCopying { - const NAME: &'static str = "NSMutableCopying"; - } + unsafe impl ProtocolType for dyn NSMutableCopying {} ); diff --git a/crates/icrate/src/generated b/crates/icrate/src/generated index 316a9c6f9..845c371d2 160000 --- a/crates/icrate/src/generated +++ b/crates/icrate/src/generated @@ -1 +1 @@ -Subproject commit 316a9c6f9640f34f859c0d9bf0da8973f03a3a00 +Subproject commit 845c371d2154a052e9adb70f952266ce81e2a13f diff --git a/crates/icrate/tests/renamed_protocols.rs b/crates/icrate/tests/renamed_protocols.rs new file mode 100644 index 000000000..57277240c --- /dev/null +++ b/crates/icrate/tests/renamed_protocols.rs @@ -0,0 +1,9 @@ +#![cfg(feature = "AppKit")] +use icrate::AppKit::NSAccessibilityElementProtocol; +use objc2::ProtocolType; + +#[test] +fn accessibility_element_protocol() { + let actual: &str = ::NAME; + assert_eq!(actual, "NSAccessibilityElement"); +}