diff --git a/crates/objc2/src/__macro_helpers/msg_send.rs b/crates/objc2/src/__macro_helpers/msg_send.rs index ab3b7df66..b0effde27 100644 --- a/crates/objc2/src/__macro_helpers/msg_send.rs +++ b/crates/objc2/src/__macro_helpers/msg_send.rs @@ -248,7 +248,7 @@ mod tests { unsafe impl ClassType for RcTestObjectSubclass { #[inherits(NSObject)] type Super = RcTestObject; - type Mutability = mutability::Immutable; + type Mutability = mutability::InteriorMutable; const NAME: &'static str = "RcTestObjectSubclass"; } diff --git a/crates/objc2/src/rc/id.rs b/crates/objc2/src/rc/id.rs index a1a38af2e..388eeee06 100644 --- a/crates/objc2/src/rc/id.rs +++ b/crates/objc2/src/rc/id.rs @@ -96,7 +96,7 @@ use crate::{ffi, ClassType, Message}; /// # unsafe impl ClassType for NSString { /// # type Super = NSObject; /// # // This is wrong, but let's do it for the example -/// # type Mutability = objc2::mutability::Immutable; +/// # type Mutability = objc2::mutability::InteriorMutable; /// # } /// # ); /// diff --git a/crates/objc2/src/rc/test_object.rs b/crates/objc2/src/rc/test_object.rs index 752c0360e..34380e71b 100644 --- a/crates/objc2/src/rc/test_object.rs +++ b/crates/objc2/src/rc/test_object.rs @@ -2,7 +2,7 @@ use core::cell::RefCell; use core::ptr; -use crate::mutability::Immutable; +use crate::mutability::InteriorMutable; use crate::rc::{Allocated, DefaultRetained, Retained}; use crate::runtime::{NSObject, NSZone}; use crate::{declare_class, msg_send, msg_send_id, ClassType, DeclaredClass}; @@ -70,7 +70,7 @@ declare_class!( unsafe impl ClassType for RcTestObject { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "__RcTestObject"; } diff --git a/crates/objc2/src/runtime/declare.rs b/crates/objc2/src/runtime/declare.rs index 8c84b4c47..c97ba5ecf 100644 --- a/crates/objc2/src/runtime/declare.rs +++ b/crates/objc2/src/runtime/declare.rs @@ -578,7 +578,7 @@ mod tests { use super::*; use crate::encode::RefEncode; - use crate::mutability::Immutable; + use crate::mutability::InteriorMutable; use crate::rc::Retained; use crate::runtime::{NSObject, NSObjectProtocol}; use crate::{ @@ -824,7 +824,7 @@ mod tests { unsafe impl ClassType for GenericDeclareClass { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "GenericDeclareClass"; #[inline] @@ -867,7 +867,7 @@ mod tests { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestInheritedNSObjectMethodsWork"; } diff --git a/crates/objc2/tests/declare_class.rs b/crates/objc2/tests/declare_class.rs index a32bb1de1..113eed7b7 100644 --- a/crates/objc2/tests/declare_class.rs +++ b/crates/objc2/tests/declare_class.rs @@ -1,7 +1,7 @@ #![deny(deprecated, unreachable_code)] use core::ptr::{self, NonNull}; -use objc2::mutability::Immutable; +use objc2::mutability::InteriorMutable; use objc2::rc::Retained; use objc2::runtime::NSObject; use objc2::{declare_class, extern_methods, sel, ClassType, DeclaredClass}; @@ -13,7 +13,7 @@ declare_class!( unsafe impl ClassType for DeclareClassDepreactedMethod { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "DeclareClassDepreactedMethod"; } @@ -46,7 +46,7 @@ declare_class!( unsafe impl ClassType for DeclareClassCfg { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "DeclareClassCfg"; } @@ -190,7 +190,7 @@ declare_class!( unsafe impl ClassType for TestMultipleColonSelector { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestMultipleColonSelector"; } @@ -265,7 +265,7 @@ declare_class!( unsafe impl ClassType for DeclareClassAllTheBool { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "DeclareClassAllTheBool"; } @@ -330,7 +330,7 @@ declare_class!( unsafe impl ClassType for DeclareClassUnreachable { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "DeclareClassUnreachable"; } @@ -381,7 +381,7 @@ declare_class!( unsafe impl ClassType for OutParam { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "OutParam"; } @@ -471,7 +471,7 @@ fn test_pointer_receiver_allowed() { unsafe impl ClassType for PointerReceiver { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "PointerReceiver"; } diff --git a/crates/objc2/tests/no_prelude.rs b/crates/objc2/tests/no_prelude.rs index 02f786106..855a3101e 100644 --- a/crates/objc2/tests/no_prelude.rs +++ b/crates/objc2/tests/no_prelude.rs @@ -95,7 +95,7 @@ new_objc2::declare_class!( unsafe impl ClassType for CustomObject { type Super = new_objc2::runtime::NSObject; - type Mutability = new_objc2::mutability::Immutable; + type Mutability = new_objc2::mutability::InteriorMutable; const NAME: &'static str = "CustomObject"; } @@ -134,7 +134,7 @@ new_objc2::extern_class!( unsafe impl ClassType for NSObject2 { type Super = new_objc2::runtime::NSObject; - type Mutability = new_objc2::mutability::Immutable; + type Mutability = new_objc2::mutability::InteriorMutable; const NAME: &'static str = "NSObject"; } ); diff --git a/crates/objc2/tests/use_macros.rs b/crates/objc2/tests/use_macros.rs index ce2ffe197..3e9a6073f 100644 --- a/crates/objc2/tests/use_macros.rs +++ b/crates/objc2/tests/use_macros.rs @@ -1,4 +1,4 @@ -use objc2::mutability::Immutable; +use objc2::mutability::InteriorMutable; use objc2::runtime::{AnyClass, NSObject}; use objc2::{class, declare_class, msg_send, sel, ClassType, DeclaredClass}; @@ -7,7 +7,7 @@ declare_class!( unsafe impl ClassType for MyObject { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "MyObject"; } diff --git a/crates/tests/src/test_declare_class_protocol.rs b/crates/tests/src/test_declare_class_protocol.rs index 62726dbf7..e531f433e 100644 --- a/crates/tests/src/test_declare_class_protocol.rs +++ b/crates/tests/src/test_declare_class_protocol.rs @@ -1,5 +1,5 @@ #![cfg(feature = "all")] -use objc2::mutability::Immutable; +use objc2::mutability::InteriorMutable; use objc2::rc::Retained; use objc2::runtime::{NSObject, NSZone}; use objc2::{declare_class, ClassType, DeclaredClass, ProtocolType}; @@ -13,7 +13,7 @@ fn test_declare_class_duplicate() { unsafe impl ClassType for Custom1 { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassDuplicate"; } @@ -25,7 +25,7 @@ fn test_declare_class_duplicate() { unsafe impl ClassType for Custom2 { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassDuplicate"; } @@ -44,7 +44,7 @@ fn test_declare_class_protocol() { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassProtocolNotFound"; } @@ -73,7 +73,7 @@ fn test_declare_class_invalid_method() { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassInvalidMethod"; } @@ -100,7 +100,7 @@ fn test_declare_class_missing_protocol_method() { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassMissingProtocolMethod"; } @@ -122,7 +122,7 @@ fn test_declare_class_invalid_protocol_method() { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassInvalidProtocolMethod"; } @@ -151,7 +151,7 @@ fn test_declare_class_extra_protocol_method() { unsafe impl ClassType for Custom { type Super = NSObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "TestDeclareClassExtraProtocolMethod"; } diff --git a/crates/tests/src/test_foundation_retain_semantics.rs b/crates/tests/src/test_foundation_retain_semantics.rs index dc5440d90..8a38b8d87 100644 --- a/crates/tests/src/test_foundation_retain_semantics.rs +++ b/crates/tests/src/test_foundation_retain_semantics.rs @@ -2,7 +2,7 @@ use std::ptr; use std::vec::Vec; -use objc2::mutability::Immutable; +use objc2::mutability::InteriorMutable; use objc2::rc::Retained; use objc2::{declare_class, extern_methods, ClassType, DeclaredClass}; use objc2_foundation::{ @@ -356,7 +356,7 @@ declare_class!( unsafe impl ClassType for NSCopyingRcTestObject { type Super = RcTestObject; - type Mutability = Immutable; + type Mutability = InteriorMutable; const NAME: &'static str = "NSCopyingRcTestObject"; } diff --git a/framework-crates/objc2-app-kit/src/lib.rs b/framework-crates/objc2-app-kit/src/lib.rs index 892ec72b8..779a00467 100644 --- a/framework-crates/objc2-app-kit/src/lib.rs +++ b/framework-crates/objc2-app-kit/src/lib.rs @@ -79,6 +79,25 @@ pub use self::text::*; #[allow(unused)] pub(crate) type UTF32Char = u32; // Or maybe Rust's char? +// TODO: Send + Sync for NSColor. Documentation says: +// > Color objects are immutable and thread-safe +// +// But unsure if this applies for things like `-setFill`? + +// TODO: Send + Sync for NSCursor. It is immutable, stated here: +// https://developer.apple.com/documentation/appkit/nscursor/1527062-image?language=objc +// +// But unsure if `push`/`pop` methods are safe from non-main threads? + +// NOTE: NSEvent is immutable, so it _may_ be possible to make Send + Sync, +// but let's refrain from doing so, because of: +// > Safely handled only on the same thread, whether that be the main +// > thread or a secondary thread; otherwise you run the risk of having +// > events get out of sequence. +// +// +// + #[cfg(test)] mod tests { #[test] diff --git a/framework-crates/objc2-app-kit/translation-config.toml b/framework-crates/objc2-app-kit/translation-config.toml index 511cba2df..e622cda61 100644 --- a/framework-crates/objc2-app-kit/translation-config.toml +++ b/framework-crates/objc2-app-kit/translation-config.toml @@ -217,30 +217,6 @@ class.NSWindow.mutability = "MainThreadOnly" # Documented as "Thread-Unsafe" # class.NSResponder.mutability = "InteriorMutable" -# Documentation says: -# > Color objects are immutable and thread-safe -# -# TODO: Send + Sync -class.NSColor.mutability = "Immutable" - -# NSCursor is immutable, stated here: -# https://developer.apple.com/documentation/appkit/nscursor/1527062-image?language=objc -# -# TODO: Send + Sync -class.NSCursor.mutability = "Immutable" - -# Since this is immutable, it _may_ be possible to make Send+Sync, but -# let's refrain from doing so, because of: -# > Safely handled only on the same thread, whether that be the main -# > thread or a secondary thread; otherwise you run the risk of having -# > events get out of sequence. -# -# -class.NSEvent.mutability = "Immutable" - -class.NSTouch.mutability = "Immutable" -class.NSUserInterfaceCompressionOptions.mutability = "Immutable" - ### ### Safety ### diff --git a/framework-crates/objc2-cloud-kit/translation-config.toml b/framework-crates/objc2-cloud-kit/translation-config.toml index 83c267354..724b8ed3f 100644 --- a/framework-crates/objc2-cloud-kit/translation-config.toml +++ b/framework-crates/objc2-cloud-kit/translation-config.toml @@ -7,6 +7,3 @@ ios = "8.0" tvos = "9.0" watchos = "3.0" visionos = "1.0" - -class.CKRecordID.mutability = "Immutable" -class.CKRecordZoneID.mutability = "Immutable" diff --git a/framework-crates/objc2-foundation/translation-config.toml b/framework-crates/objc2-foundation/translation-config.toml index 3c686ca55..a291450dd 100644 --- a/framework-crates/objc2-foundation/translation-config.toml +++ b/framework-crates/objc2-foundation/translation-config.toml @@ -308,14 +308,6 @@ class.NSMutableURLRequest.mutability = "InteriorMutableWithSuperclass(Foundation class.NSEnumerator.mutability = "Mutable" class.NSDirectoryEnumerator.mutability = "Mutable" -class.NSValue.mutability = "Immutable" -class.NSNumber.mutability = "Immutable" -class.NSDecimalNumber.mutability = "Immutable" - -class.NSIndexPath.mutability = "Immutable" - -class.NSUUID.mutability = "Immutable" - ### ### Safety ### diff --git a/generated b/generated index c22aa5b99..e38c5a9b9 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit c22aa5b99f888c3279c41f6fc0842e6f7af17e6f +Subproject commit e38c5a9b9167ce05ea026f00bfa189162372b797