From 47cd390d69c4e968bd303b0d79fbbbcbf5c6228c Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 8 Dec 2022 14:21:35 +0100 Subject: [PATCH] Move objc2::foundation to icrate::Foundation With the plan to have most of it autogenerated --- .github/workflows/ci.yml | 6 +- README.md | 2 +- .../CHANGELOG.md} | 17 ++- crates/icrate/Cargo.toml | 5 +- crates/icrate/examples/basic_usage.rs | 3 +- crates/icrate/examples/delegate.rs | 3 +- crates/icrate/examples/nspasteboard.rs | 2 +- crates/icrate/examples/speech_synthesis.rs | 3 +- .../src/Foundation/additions}/__ns_string.rs | 36 ++--- .../src/Foundation/additions}/array.rs | 22 +-- .../additions}/attributed_string.rs | 8 +- .../src/Foundation/additions}/bundle.rs | 4 +- .../additions}/comparison_result.rs | 2 +- .../src/Foundation/additions}/copying.rs | 6 +- .../src/Foundation/additions}/data.rs | 8 +- .../src/Foundation/additions}/dictionary.rs | 8 +- .../src/Foundation/additions}/enumerator.rs | 8 +- .../src/Foundation/additions}/error.rs | 6 +- .../src/Foundation/additions}/exception.rs | 8 +- .../src/Foundation/additions}/geometry.rs | 22 +-- .../src/Foundation/additions}/lock.rs | 4 +- .../src/Foundation/additions}/mod.rs | 16 +-- .../Foundation/additions}/mutable_array.rs | 24 ++-- .../additions}/mutable_attributed_string.rs | 4 +- .../src/Foundation/additions}/mutable_data.rs | 6 +- .../additions}/mutable_dictionary.rs | 40 +++--- .../src/Foundation/additions}/mutable_set.rs | 34 ++--- .../Foundation/additions}/mutable_string.rs | 4 +- .../src/Foundation/additions}/number.rs | 10 +- .../src/Foundation/additions}/process_info.rs | 4 +- .../src/Foundation/additions}/range.rs | 8 +- .../src/Foundation/additions}/set.rs | 52 +++---- .../src/Foundation/additions}/string.rs | 12 +- .../src/Foundation/additions}/thread.rs | 10 +- .../src/Foundation/additions}/uuid.rs | 4 +- .../src/Foundation/additions}/value.rs | 21 +-- crates/icrate/src/Foundation/mod.rs | 5 +- crates/icrate/src/lib.rs | 3 + crates/objc2/CHANGELOG.md | 5 +- crates/objc2/Cargo.toml | 8 +- crates/objc2/src/__macro_helpers.rs | 86 ++++++------ crates/objc2/src/declare/ivar.rs | 2 +- crates/objc2/src/declare/ivar_drop.rs | 26 ++-- crates/objc2/src/lib.rs | 7 +- crates/objc2/src/macros/extern_class.rs | 5 + crates/objc2/src/rc/id.rs | 28 ++-- crates/objc2/src/rc/mod.rs | 8 +- crates/objc2/src/rc/test_object.rs | 132 +++++++++--------- crates/objc2/src/rc/weak_id.rs | 10 +- crates/objc2/src/runtime/nsobject.rs | 8 +- crates/objc2/tests/id_retain_autoreleased.rs | 43 ++---- crates/objc2/tests/no_prelude.rs | 4 + crates/objc2/tests/use_macros.rs | 16 ++- .../test_ns_string/expected/gnustep-x86.s | 6 +- .../test_ns_string/expected/gnustep-x86_64.s | 6 +- .../crates/test_ns_string/lib.rs | 6 +- crates/test-ui/ui/invalid_ns_string_input.rs | 2 +- crates/test-ui/ui/invalid_ns_string_output.rs | 2 +- .../ui/msg_send_id_invalid_return.stderr | 33 ++--- .../ui/msg_send_super_not_classtype.stderr | 22 +-- crates/test-ui/ui/ns_string_not_const.rs | 2 +- .../test-ui/ui/ns_string_output_not_const.rs | 2 +- fuzz/Cargo.toml | 2 +- 63 files changed, 448 insertions(+), 463 deletions(-) rename crates/{objc2/CHANGELOG_FOUNDATION.md => icrate/CHANGELOG.md} (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/__ns_string.rs (94%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/array.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/attributed_string.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/bundle.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/comparison_result.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/copying.rs (92%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/data.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/dictionary.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/enumerator.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/error.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/exception.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/geometry.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/lock.rs (92%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mod.rs (95%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_array.rs (94%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_attributed_string.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_data.rs (98%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_dictionary.rs (91%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_set.rs (92%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/mutable_string.rs (98%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/number.rs (98%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/process_info.rs (95%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/range.rs (96%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/set.rs (93%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/string.rs (98%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/thread.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/uuid.rs (97%) rename crates/{objc2/src/foundation => icrate/src/Foundation/additions}/value.rs (95%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cb9a3605..219977807 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,8 +159,8 @@ jobs: ARGS: --no-default-features --features=std,${{ matrix.runtime || 'apple' }} ${{ matrix.args }} # Use --no-fail-fast, except with dinghy TESTARGS: ${{ matrix.dinghy && ' ' || '--no-fail-fast' }} ${{ matrix.test-args }} - SOME_FEATURES: ${{ matrix.features || 'malloc,block,exception,foundation' }} - FEATURES: ${{ matrix.features || 'malloc,block,exception,foundation,catch-all,verify,uuid' }} + SOME_FEATURES: ${{ matrix.features || 'malloc,block,exception,Foundation' }} + FEATURES: ${{ matrix.features || 'malloc,block,exception,Foundation,catch-all,verify,uuid' }} UNSTABLE_FEATURES: ${{ matrix.unstable-features || 'unstable-autoreleasesafe,unstable-c-unwind' }} CMD: cargo @@ -428,7 +428,7 @@ jobs: - name: Test static class and selectors if: ${{ !matrix.dinghy && (matrix.runtime || 'apple') == 'apple' }} - run: cargo test ${{ env.ARGS }} ${{ env.TESTARGS }} --features foundation,unstable-static-sel,unstable-static-class + run: cargo test ${{ env.ARGS }} ${{ env.TESTARGS }} --features Foundation,unstable-static-sel,unstable-static-class - name: Run assembly tests if: ${{ !contains(matrix.runtime, 'compiler-rt') }} diff --git a/README.md b/README.md index a90350bc9..6fad0767e 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ fork [here][origin-issue-101]: - [`objc_id`](https://github.com/SSheldon/rust-objc-id) - Moved to `objc2::rc`. - [`objc-foundation`](https://github.com/SSheldon/rust-objc-foundation) - - Moved to `objc2::foundation`. + - Moved to `icrate::Foundation`. - [`block`](https://github.com/SSheldon/rust-block) - Renamed to `block2`. diff --git a/crates/objc2/CHANGELOG_FOUNDATION.md b/crates/icrate/CHANGELOG.md similarity index 96% rename from crates/objc2/CHANGELOG_FOUNDATION.md rename to crates/icrate/CHANGELOG.md index 10854be32..bed2b15dc 100644 --- a/crates/objc2/CHANGELOG_FOUNDATION.md +++ b/crates/icrate/CHANGELOG.md @@ -1,22 +1,27 @@ # Changelog -Changes to the `objc2::foundation` module will be documented in this file. -This previously existed as a separate crate `objc2_foundation`, hence the -separation. +Changes to `icrate` will be documented in this file. + +This previously existed as a separate crate `objc2_foundation`, later it was +integrated into `objc2::foundation`, and later again split out - hence the +confusing versioning. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## Unreleased - YYYY-MM-DD +## icrate Unreleased - YYYY-MM-DD ### Added * Added `NSString::write_to_file`. * Added `NSLock` class and `NSLocking` protocol. +### Changed +* **BREAKING**: Moved from `objc2::foundation` into `icrate::Foundation`. + ### Fixed * Fixed `NSZone` not being `#[repr(C)]`. -## objc2 0.3.0-beta.3 - 2022-09-01 +## objc2::foundation 0.3.0-beta.3 - 2022-09-01 ### Added * Added `NSSet`. @@ -36,7 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). binding to requires a non-negative size. -## objc2 0.3.0-beta.2 - 2022-08-28 +## objc2::foundation 0.3.0-beta.2 - 2022-08-28 ### Added * Added `NSNumber`. diff --git a/crates/icrate/Cargo.toml b/crates/icrate/Cargo.toml index 14b3212eb..0d34a82dd 100644 --- a/crates/icrate/Cargo.toml +++ b/crates/icrate/Cargo.toml @@ -22,6 +22,9 @@ license = "MIT" objc2 = { path = "../objc2", version = "=0.3.0-beta.3", default-features = false, optional = true } block2 = { path = "../block2", version = "=0.2.0-alpha.6", default-features = false, optional = true } +# Provide methods to convert between `uuid::Uuid` and `icrate::Foundation::NSUUID` +uuid = { version = "1.1.2", optional = true, default-features = false } + [package.metadata.docs.rs] default-target = "x86_64-apple-darwin" all-features = true @@ -88,4 +91,4 @@ unstable-docsrs = [] AppKit = ["Foundation", "CoreData"] AuthenticationServices = ["Foundation"] CoreData = ["Foundation"] -Foundation = ["objective-c", "blocks", "objc2/foundation"] +Foundation = ["objective-c", "blocks"] diff --git a/crates/icrate/examples/basic_usage.rs b/crates/icrate/examples/basic_usage.rs index 3b0f18289..5029b5a5f 100644 --- a/crates/icrate/examples/basic_usage.rs +++ b/crates/icrate/examples/basic_usage.rs @@ -1,5 +1,6 @@ +use icrate::ns_string; use icrate::objc2::rc::autoreleasepool; -use icrate::Foundation::{ns_string, NSArray, NSDictionary, NSObject}; +use icrate::Foundation::{NSArray, NSDictionary, NSObject}; fn main() { // Create and compare NSObjects diff --git a/crates/icrate/examples/delegate.rs b/crates/icrate/examples/delegate.rs index d3adecde9..dbde88af6 100644 --- a/crates/icrate/examples/delegate.rs +++ b/crates/icrate/examples/delegate.rs @@ -1,9 +1,10 @@ #![cfg_attr(not(target_os = "macos"), allow(unused))] +use icrate::ns_string; use icrate::objc2::declare::{Ivar, IvarDrop}; use icrate::objc2::rc::{Id, Shared}; use icrate::objc2::runtime::Object; use icrate::objc2::{declare_class, extern_class, msg_send, msg_send_id, ClassType}; -use icrate::Foundation::{ns_string, NSCopying, NSObject, NSString}; +use icrate::Foundation::{NSCopying, NSObject, NSString}; #[cfg(target_os = "macos")] #[link(name = "AppKit", kind = "framework")] diff --git a/crates/icrate/examples/nspasteboard.rs b/crates/icrate/examples/nspasteboard.rs index 3f1b93da3..47f4c27f1 100644 --- a/crates/icrate/examples/nspasteboard.rs +++ b/crates/icrate/examples/nspasteboard.rs @@ -63,7 +63,7 @@ impl NSPasteboard { /// pub fn text_impl_2(&self) -> Id { // The NSPasteboard API is a bit weird, it requires you to pass - // classes as objects, which `objc2::foundation::NSArray` was not + // classes as objects, which `icrate::Foundation::NSArray` was not // really made for - so we convert the class to an `Object` type // instead. Also, we wrap it in `ManuallyDrop` because I'm not sure // how classes handle `release` calls? diff --git a/crates/icrate/examples/speech_synthesis.rs b/crates/icrate/examples/speech_synthesis.rs index ea09df37d..faf8bfb38 100644 --- a/crates/icrate/examples/speech_synthesis.rs +++ b/crates/icrate/examples/speech_synthesis.rs @@ -12,9 +12,10 @@ use std::thread; use std::time::Duration; +use icrate::ns_string; use icrate::objc2::rc::{Id, Owned}; use icrate::objc2::{extern_class, msg_send, msg_send_id, ClassType}; -use icrate::Foundation::{ns_string, NSObject, NSString}; +use icrate::Foundation::{NSObject, NSString}; #[cfg(target_os = "macos")] mod appkit { diff --git a/crates/objc2/src/foundation/__ns_string.rs b/crates/icrate/src/Foundation/additions/__ns_string.rs similarity index 94% rename from crates/objc2/src/foundation/__ns_string.rs rename to crates/icrate/src/Foundation/additions/__ns_string.rs index 9827d484a..2a1d2699c 100644 --- a/crates/objc2/src/foundation/__ns_string.rs +++ b/crates/icrate/src/Foundation/additions/__ns_string.rs @@ -17,9 +17,9 @@ use core::mem::ManuallyDrop; use core::ptr; use core::sync::atomic::{AtomicPtr, Ordering}; -use crate::foundation::NSString; -use crate::rc::Id; -use crate::runtime::Class; +use crate::Foundation::NSString; +use objc2::rc::Id; +use objc2::runtime::Class; // This is defined in CoreFoundation, but we don't emit a link attribute // here because it is already linked via Foundation. @@ -239,7 +239,7 @@ impl CachedNSString { } } -/// Creates an [`NSString`][`crate::foundation::NSString`] from a static string. +/// Creates an [`NSString`][`crate::Foundation::NSString`] from a static string. /// /// Note: This works by placing statics in special sections, which may not /// work completely reliably yet, see [#258]; until then, you should be @@ -254,8 +254,8 @@ impl CachedNSString { /// the argument, and produces a `&'static NSString`: /// /// ``` -/// use objc2::ns_string; -/// use objc2::foundation::NSString; +/// use icrate::ns_string; +/// use icrate::Foundation::NSString; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// let hello: &'static NSString = ns_string!("hello"); @@ -274,7 +274,7 @@ impl CachedNSString { /// string to the most efficient encoding, you don't have to do anything! /// /// ``` -/// # use objc2::ns_string; +/// # use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// let hello_ru = ns_string!("Привет"); @@ -292,7 +292,7 @@ impl CachedNSString { /// expect: /// /// ``` -/// # use objc2::ns_string; +/// # use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// let example = ns_string!("example\0"); @@ -312,8 +312,8 @@ impl CachedNSString { /// Because of that, this should be preferred over [`NSString::from_str`] /// where possible. /// -/// [`NSString::from_str`]: crate::foundation::NSString::from_str -#[cfg(feature = "foundation")] // For auto_doc_cfg +/// [`NSString::from_str`]: crate::Foundation::NSString::from_str +#[cfg(feature = "Foundation")] // For auto_doc_cfg #[macro_export] macro_rules! ns_string { ($s:expr) => {{ @@ -362,7 +362,7 @@ macro_rules! __ns_string_inner { // The full UTF-16 contents along with the written length. const UTF16_FULL: (&[u16; $inp.len()], usize) = { let mut out = [0u16; $inp.len()]; - let mut iter = $crate::foundation::__ns_string::EncodeUtf16Iter::new($inp); + let mut iter = $crate::Foundation::__ns_string::EncodeUtf16Iter::new($inp); let mut written = 0; while let Some((state, chars)) = iter.next() { @@ -403,17 +403,17 @@ macro_rules! __ns_string_inner { // The section is the same as what clang sets, see: // https://github.com/llvm/llvm-project/blob/release/13.x/clang/lib/CodeGen/CodeGenModule.cpp#L5243 #[link_section = "__DATA,__cfstring"] - static CFSTRING: $crate::foundation::__ns_string::CFConstString = unsafe { - if $crate::foundation::__ns_string::is_ascii_no_nul($inp) { + static CFSTRING: $crate::Foundation::__ns_string::CFConstString = unsafe { + if $crate::Foundation::__ns_string::is_ascii_no_nul($inp) { // This is technically an optimization (UTF-16 strings are // always valid), but it's a fairly important one! - $crate::foundation::__ns_string::CFConstString::new_ascii( - &$crate::foundation::__ns_string::__CFConstantStringClassReference, + $crate::Foundation::__ns_string::CFConstString::new_ascii( + &$crate::Foundation::__ns_string::__CFConstantStringClassReference, &ASCII, ) } else { - $crate::foundation::__ns_string::CFConstString::new_utf16( - &$crate::foundation::__ns_string::__CFConstantStringClassReference, + $crate::Foundation::__ns_string::CFConstString::new_utf16( + &$crate::Foundation::__ns_string::__CFConstantStringClassReference, &UTF16, ) } @@ -426,7 +426,7 @@ macro_rules! __ns_string_inner { #[macro_export] macro_rules! __ns_string_inner { ($inp:ident) => {{ - use $crate::foundation::__ns_string::CachedNSString; + use $crate::Foundation::__ns_string::CachedNSString; static CACHED_NSSTRING: CachedNSString = CachedNSString::new(); CACHED_NSSTRING.get($inp) }}; diff --git a/crates/objc2/src/foundation/array.rs b/crates/icrate/src/Foundation/additions/array.rs similarity index 96% rename from crates/objc2/src/foundation/array.rs rename to crates/icrate/src/Foundation/additions/array.rs index b00f1071b..eed927f11 100644 --- a/crates/objc2/src/foundation/array.rs +++ b/crates/icrate/src/Foundation/additions/array.rs @@ -8,9 +8,9 @@ use super::{ NSCopying, NSEnumerator, NSFastEnumeration, NSFastEnumerator, NSMutableArray, NSMutableCopying, NSObject, NSRange, }; -use crate::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; -use crate::runtime::Object; -use crate::{ClassType, Message, __inner_extern_class, extern_methods, msg_send, msg_send_id}; +use objc2::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; +use objc2::runtime::Object; +use objc2::{ClassType, Message, __inner_extern_class, extern_methods, msg_send, msg_send_id}; __inner_extern_class!( /// An immutable ordered collection of objects. @@ -306,8 +306,8 @@ mod tests { use alloc::vec::Vec; use super::*; - use crate::foundation::{NSNumber, NSString}; - use crate::rc::{RcTestObject, ThreadTestData}; + use crate::Foundation::{NSNumber, NSString}; + use objc2::rc::{__RcTestObject, __ThreadTestData}; fn sample_array(len: usize) -> Id, Owned> { let mut vec = Vec::with_capacity(len); @@ -377,8 +377,8 @@ mod tests { #[test] fn test_retains_stored() { - let obj = Id::into_shared(RcTestObject::new()); - let mut expected = ThreadTestData::current(); + let obj = Id::into_shared(__RcTestObject::new()); + let mut expected = __ThreadTestData::current(); let input = [obj.clone(), obj.clone()]; expected.retain += 2; @@ -417,9 +417,9 @@ mod tests { #[test] fn test_nscopying_uses_retain() { - let obj = Id::into_shared(RcTestObject::new()); + let obj = Id::into_shared(__RcTestObject::new()); let array = NSArray::from_slice(&[obj]); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let _copy = array.copy(); expected.assert_current(); @@ -435,9 +435,9 @@ mod tests { ignore = "this works differently on different framework versions" )] fn test_iter_no_retain() { - let obj = Id::into_shared(RcTestObject::new()); + let obj = Id::into_shared(__RcTestObject::new()); let array = NSArray::from_slice(&[obj]); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let iter = array.iter(); expected.retain += 0; diff --git a/crates/objc2/src/foundation/attributed_string.rs b/crates/icrate/src/Foundation/additions/attributed_string.rs similarity index 97% rename from crates/objc2/src/foundation/attributed_string.rs rename to crates/icrate/src/Foundation/additions/attributed_string.rs index 15f4928d3..f7bcebb01 100644 --- a/crates/objc2/src/foundation/attributed_string.rs +++ b/crates/icrate/src/Foundation/additions/attributed_string.rs @@ -4,9 +4,9 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{ NSCopying, NSDictionary, NSMutableAttributedString, NSMutableCopying, NSObject, NSString, }; -use crate::rc::{Allocated, DefaultId, Id, Shared}; -use crate::runtime::Object; -use crate::{extern_class, extern_methods, ClassType}; +use objc2::rc::{Allocated, DefaultId, Id, Shared}; +use objc2::runtime::Object; +use objc2::{extern_class, extern_methods, ClassType}; extern_class!( /// A string that has associated attributes for portions of its text. @@ -150,7 +150,7 @@ mod tests { use alloc::{format, vec}; use super::*; - use crate::rc::{autoreleasepool, Owned}; + use objc2::rc::{autoreleasepool, Owned}; #[test] fn test_new() { diff --git a/crates/objc2/src/foundation/bundle.rs b/crates/icrate/src/Foundation/additions/bundle.rs similarity index 96% rename from crates/objc2/src/foundation/bundle.rs rename to crates/icrate/src/Foundation/additions/bundle.rs index 0d3495099..6ced266b7 100644 --- a/crates/objc2/src/foundation/bundle.rs +++ b/crates/icrate/src/Foundation/additions/bundle.rs @@ -2,8 +2,8 @@ use core::fmt; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSCopying, NSDictionary, NSObject, NSString}; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, ClassType}; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, ClassType}; extern_class!( /// A representation of the code and resources stored in a bundle diff --git a/crates/objc2/src/foundation/comparison_result.rs b/crates/icrate/src/Foundation/additions/comparison_result.rs similarity index 96% rename from crates/objc2/src/foundation/comparison_result.rs rename to crates/icrate/src/Foundation/additions/comparison_result.rs index bfd6d0665..d5be1b055 100644 --- a/crates/objc2/src/foundation/comparison_result.rs +++ b/crates/icrate/src/Foundation/additions/comparison_result.rs @@ -1,6 +1,6 @@ use core::cmp::Ordering; -use crate::{Encode, Encoding, RefEncode}; +use objc2::encode::{Encode, Encoding, RefEncode}; /// Constants that indicate sort order. /// diff --git a/crates/objc2/src/foundation/copying.rs b/crates/icrate/src/Foundation/additions/copying.rs similarity index 92% rename from crates/objc2/src/foundation/copying.rs rename to crates/icrate/src/Foundation/additions/copying.rs index cc6c36578..bed083ddb 100644 --- a/crates/objc2/src/foundation/copying.rs +++ b/crates/icrate/src/Foundation/additions/copying.rs @@ -1,5 +1,5 @@ -use crate::rc::{Id, Owned, Ownership}; -use crate::{msg_send_id, Message}; +use objc2::rc::{Id, Owned, Ownership}; +use objc2::{msg_send_id, Message}; pub unsafe trait NSCopying: Message { /// Indicates whether the type is mutable or immutable. @@ -21,7 +21,7 @@ pub unsafe trait NSCopying: Message { /// `copy` message (and others) does not create a new instance, but /// instead just retains the instance). /// - /// [`NSString`]: crate::foundation::NSString + /// [`NSString`]: crate::Foundation::NSString type Ownership: Ownership; /// The output type. diff --git a/crates/objc2/src/foundation/data.rs b/crates/icrate/src/Foundation/additions/data.rs similarity index 96% rename from crates/objc2/src/foundation/data.rs rename to crates/icrate/src/Foundation/additions/data.rs index 6c75bdbed..ec8ebcf5a 100644 --- a/crates/objc2/src/foundation/data.rs +++ b/crates/icrate/src/Foundation/additions/data.rs @@ -7,9 +7,9 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use core::slice::{self, SliceIndex}; use super::{NSCopying, NSMutableCopying, NSMutableData, NSObject}; -use crate::rc::{DefaultId, Id, Shared}; -use crate::runtime::{Class, Object}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::rc::{DefaultId, Id, Shared}; +use objc2::runtime::{Class, Object}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// A static byte buffer in memory. @@ -53,7 +53,7 @@ extern_methods!( // // NSMutableData does not have this problem. #[cfg(feature = "gnustep-1-7")] - let cls = crate::class!(NSDataWithDeallocatorBlock); + let cls = objc2::class!(NSDataWithDeallocatorBlock); #[cfg(not(feature = "gnustep-1-7"))] let cls = Self::class(); diff --git a/crates/objc2/src/foundation/dictionary.rs b/crates/icrate/src/Foundation/additions/dictionary.rs similarity index 97% rename from crates/objc2/src/foundation/dictionary.rs rename to crates/icrate/src/Foundation/additions/dictionary.rs index efd56f5ad..61675981d 100644 --- a/crates/objc2/src/foundation/dictionary.rs +++ b/crates/icrate/src/Foundation/additions/dictionary.rs @@ -7,8 +7,8 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use core::ptr; use super::{NSArray, NSCopying, NSEnumerator, NSFastEnumeration, NSObject}; -use crate::rc::{DefaultId, Id, Owned, Shared, SliceId}; -use crate::{ClassType, __inner_extern_class, extern_methods, msg_send, msg_send_id, Message}; +use objc2::rc::{DefaultId, Id, Owned, Shared, SliceId}; +use objc2::{ClassType, __inner_extern_class, extern_methods, msg_send, msg_send_id, Message}; __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] @@ -162,8 +162,8 @@ mod tests { use alloc::vec; use super::*; - use crate::foundation::NSString; - use crate::rc::autoreleasepool; + use crate::Foundation::NSString; + use objc2::rc::autoreleasepool; fn sample_dict(key: &str) -> Id, Shared> { let string = NSString::from_str(key); diff --git a/crates/objc2/src/foundation/enumerator.rs b/crates/icrate/src/Foundation/additions/enumerator.rs similarity index 96% rename from crates/objc2/src/foundation/enumerator.rs rename to crates/icrate/src/Foundation/additions/enumerator.rs index 1d3629ec4..998e6a1ae 100644 --- a/crates/objc2/src/foundation/enumerator.rs +++ b/crates/icrate/src/Foundation/additions/enumerator.rs @@ -4,9 +4,9 @@ use core::ptr; use core::slice; use std::os::raw::c_ulong; -use crate::rc::{Id, Owned}; -use crate::runtime::Object; -use crate::{msg_send, Encode, Encoding, Message, RefEncode}; +use objc2::rc::{Id, Owned}; +use objc2::runtime::Object; +use objc2::{msg_send, Encode, Encoding, Message, RefEncode}; // TODO: https://doc.rust-lang.org/stable/reference/trait-bounds.html#lifetime-bounds pub struct NSEnumerator<'a, T: Message> { @@ -168,7 +168,7 @@ impl<'a, C: NSFastEnumeration + ?Sized> Iterator for NSFastEnumerator<'a, C> { #[cfg(test)] mod tests { use super::NSFastEnumeration; - use crate::foundation::{NSArray, NSNumber}; + use crate::Foundation::{NSArray, NSNumber}; #[test] fn test_enumerator() { diff --git a/crates/objc2/src/foundation/error.rs b/crates/icrate/src/Foundation/additions/error.rs similarity index 97% rename from crates/objc2/src/foundation/error.rs rename to crates/icrate/src/Foundation/additions/error.rs index 05a6d9dd3..d9c5c9159 100644 --- a/crates/objc2/src/foundation/error.rs +++ b/crates/icrate/src/Foundation/additions/error.rs @@ -2,9 +2,9 @@ use core::fmt; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSCopying, NSDictionary, NSObject, NSString}; -use crate::ffi::NSInteger; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::ffi::NSInteger; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// Information about an error condition including a domain, a diff --git a/crates/objc2/src/foundation/exception.rs b/crates/icrate/src/Foundation/additions/exception.rs similarity index 97% rename from crates/objc2/src/foundation/exception.rs rename to crates/icrate/src/Foundation/additions/exception.rs index fbf52ee43..06349c0f4 100644 --- a/crates/objc2/src/foundation/exception.rs +++ b/crates/icrate/src/Foundation/additions/exception.rs @@ -3,10 +3,10 @@ use core::hint::unreachable_unchecked; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSCopying, NSDictionary, NSObject, NSString}; -use crate::exception::Exception; -use crate::rc::{Id, Shared}; -use crate::runtime::Object; -use crate::{extern_class, extern_methods, msg_send_id, sel, ClassType}; +use objc2::exception::Exception; +use objc2::rc::{Id, Shared}; +use objc2::runtime::Object; +use objc2::{extern_class, extern_methods, msg_send_id, sel, ClassType}; extern_class!( /// A special condition that interrupts the normal flow of program diff --git a/crates/objc2/src/foundation/geometry.rs b/crates/icrate/src/Foundation/additions/geometry.rs similarity index 96% rename from crates/objc2/src/foundation/geometry.rs rename to crates/icrate/src/Foundation/additions/geometry.rs index 0005a40a1..fb43d062c 100644 --- a/crates/objc2/src/foundation/geometry.rs +++ b/crates/icrate/src/Foundation/additions/geometry.rs @@ -1,4 +1,4 @@ -use crate::{Encode, Encoding, RefEncode}; +use objc2::encode::{Encode, Encoding, RefEncode}; #[cfg(target_pointer_width = "64")] type InnerFloat = f64; @@ -73,7 +73,7 @@ impl CGPoint { /// # Examples /// /// ``` - /// use objc2::foundation::CGPoint; + /// use icrate::Foundation::CGPoint; /// assert_eq!(CGPoint::new(10.0, -2.3), CGPoint { x: 10.0, y: -2.3 }); /// ``` #[inline] @@ -89,7 +89,7 @@ impl CGPoint { /// # Examples /// /// ``` - /// use objc2::foundation::CGPoint; + /// use icrate::Foundation::CGPoint; /// assert_eq!(CGPoint::ZERO, CGPoint { x: 0.0, y: 0.0 }); /// ``` #[doc(alias = "NSZeroPoint")] @@ -134,7 +134,7 @@ impl CGSize { /// # Examples /// /// ``` - /// use objc2::foundation::CGSize; + /// use icrate::Foundation::CGSize; /// let size = CGSize::new(10.0, 2.3); /// assert_eq!(size.width, 10.0); /// assert_eq!(size.height, 2.3); @@ -143,7 +143,7 @@ impl CGSize { /// Negative values are allowed (though often undesired). /// /// ``` - /// use objc2::foundation::CGSize; + /// use icrate::Foundation::CGSize; /// let size = CGSize::new(-1.0, 0.0); /// assert_eq!(size.width, -1.0); /// ``` @@ -168,7 +168,7 @@ impl CGSize { /// # Examples /// /// ``` - /// use objc2::foundation::CGSize; + /// use icrate::Foundation::CGSize; /// assert_eq!(CGSize::new(-1.0, 1.0).abs(), CGSize::new(1.0, 1.0)); /// ``` #[inline] @@ -182,7 +182,7 @@ impl CGSize { /// # Examples /// /// ``` - /// use objc2::foundation::CGSize; + /// use icrate::Foundation::CGSize; /// assert_eq!(CGSize::ZERO, CGSize { width: 0.0, height: 0.0 }); /// ``` #[doc(alias = "NSZeroSize")] @@ -229,7 +229,7 @@ impl CGRect { /// # Examples /// /// ``` - /// use objc2::foundation::{CGPoint, CGRect, CGSize}; + /// use icrate::Foundation::{CGPoint, CGRect, CGSize}; /// let origin = CGPoint::new(10.0, -2.3); /// let size = CGSize::new(5.0, 0.0); /// let rect = CGRect::new(origin, size); @@ -254,7 +254,7 @@ impl CGRect { /// # Examples /// /// ``` - /// use objc2::foundation::{CGPoint, CGRect, CGSize}; + /// use icrate::Foundation::{CGPoint, CGRect, CGSize}; /// let origin = CGPoint::new(1.0, 1.0); /// let size = CGSize::new(-5.0, -2.0); /// let rect = CGRect::new(origin, size); @@ -308,7 +308,7 @@ impl CGRect { /// # Examples /// /// ``` - /// use objc2::foundation::{CGPoint, CGRect, CGSize}; + /// use icrate::Foundation::{CGPoint, CGRect, CGSize}; /// assert!(CGRect::ZERO.is_empty()); /// let point = CGPoint::new(1.0, 2.0); /// assert!(CGRect::new(point, CGSize::ZERO).is_empty()); @@ -391,7 +391,7 @@ mod tests { #[test] #[cfg(any(all(feature = "apple", target_os = "macos"), feature = "gnustep-1-7"))] // or macabi fn test_partial_eq() { - use crate::runtime::Bool; + use objc2::runtime::Bool; // Note: No need to use "C-unwind" extern "C" { diff --git a/crates/objc2/src/foundation/lock.rs b/crates/icrate/src/Foundation/additions/lock.rs similarity index 92% rename from crates/objc2/src/foundation/lock.rs rename to crates/icrate/src/Foundation/additions/lock.rs index 6580044b4..f49a6a86c 100644 --- a/crates/objc2/src/foundation/lock.rs +++ b/crates/icrate/src/Foundation/additions/lock.rs @@ -1,6 +1,6 @@ use super::{NSObject, NSString}; -use crate::rc::{Id, Owned, Shared}; -use crate::{extern_class, extern_methods, extern_protocol, ClassType, ConformsTo, ProtocolType}; +use objc2::rc::{Id, Owned, Shared}; +use objc2::{extern_class, extern_methods, extern_protocol, ClassType, ConformsTo, ProtocolType}; // TODO: Proper Send/Sync impls here diff --git a/crates/objc2/src/foundation/mod.rs b/crates/icrate/src/Foundation/additions/mod.rs similarity index 95% rename from crates/objc2/src/foundation/mod.rs rename to crates/icrate/src/Foundation/additions/mod.rs index 381150d01..18ee67713 100644 --- a/crates/objc2/src/foundation/mod.rs +++ b/crates/icrate/src/Foundation/additions/mod.rs @@ -19,8 +19,8 @@ //! call a method on them using the [`msg_send!`] family of macros. //! //! [pull requests]: https://github.com/madsmtm/objc2/pulls -//! [`Message`]: crate::Message -//! [`msg_send!`]: crate::msg_send +//! [`Message`]: crate::objc2::Message +//! [`msg_send!`]: crate::objc2::msg_send //! //! //! # Use of `Deref` @@ -43,9 +43,9 @@ //! conversion, that is a possibility too. //! //! [`Deref`]: std::ops::Deref -//! [`ClassType`]: crate::ClassType +//! [`ClassType`]: crate::objc2::ClassType //! [anti-pattern-deref]: https://rust-unofficial.github.io/patterns/anti_patterns/deref.html -//! [`Id::into_super`]: crate::rc::Id::into_super +//! [`Id::into_super`]: objc2::rc::Id::into_super // TODO: Remove these #![allow(missing_docs)] @@ -80,18 +80,18 @@ pub use self::thread::{is_main_thread, is_multi_threaded, MainThreadMarker, NSTh #[cfg(not(macos_10_7))] // Temporary pub use self::uuid::NSUUID; pub use self::value::NSValue; -pub use crate::runtime::{NSObject, NSZone}; +pub use objc2::runtime::{NSObject, NSZone}; // Available under Foundation, so makes sense here as well: // https://developer.apple.com/documentation/foundation/numbers_data_and_basic_values?language=objc #[doc(no_inline)] -pub use crate::ffi::{NSInteger, NSUInteger}; +pub use objc2::ffi::{NSInteger, NSUInteger}; /// A value indicating that a requested item couldn’t be found or doesn’t exist. /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotfound?language=objc). #[allow(non_upper_case_globals)] -pub const NSNotFound: NSInteger = crate::ffi::NSIntegerMax; +pub const NSNotFound: NSInteger = objc2::ffi::NSIntegerMax; /// A number of seconds. /// @@ -142,7 +142,7 @@ mod tests { use core::panic::{RefUnwindSafe, UnwindSafe}; use super::*; - use crate::rc::{Id, Owned, Shared}; + use objc2::rc::{Id, Owned, Shared}; // We expect most Foundation types to be UnwindSafe and RefUnwindSafe, // since they follow Rust's usual mutability rules (&T = immutable). diff --git a/crates/objc2/src/foundation/mutable_array.rs b/crates/icrate/src/Foundation/additions/mutable_array.rs similarity index 94% rename from crates/objc2/src/foundation/mutable_array.rs rename to crates/icrate/src/Foundation/additions/mutable_array.rs index c00992b13..cc3912881 100644 --- a/crates/objc2/src/foundation/mutable_array.rs +++ b/crates/icrate/src/Foundation/additions/mutable_array.rs @@ -10,8 +10,8 @@ use super::{ NSArray, NSComparisonResult, NSCopying, NSFastEnumeration, NSFastEnumerator, NSMutableCopying, NSObject, }; -use crate::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; -use crate::{ClassType, Message, __inner_extern_class, extern_methods, msg_send}; +use objc2::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; +use objc2::{ClassType, Message, __inner_extern_class, extern_methods, msg_send}; __inner_extern_class!( /// A growable ordered collection of objects. @@ -245,15 +245,15 @@ mod tests { use alloc::vec; use super::*; - use crate::foundation::NSString; - use crate::rc::{autoreleasepool, RcTestObject, ThreadTestData}; + use crate::Foundation::NSString; + use objc2::rc::{__RcTestObject, __ThreadTestData, autoreleasepool}; #[test] fn test_adding() { let mut array = NSMutableArray::new(); - let obj1 = RcTestObject::new(); - let obj2 = RcTestObject::new(); - let mut expected = ThreadTestData::current(); + let obj1 = __RcTestObject::new(); + let obj2 = __RcTestObject::new(); + let mut expected = __ThreadTestData::current(); array.push(obj1); expected.retain += 1; @@ -272,10 +272,10 @@ mod tests { #[test] fn test_replace() { let mut array = NSMutableArray::new(); - let obj1 = RcTestObject::new(); - let obj2 = RcTestObject::new(); + let obj1 = __RcTestObject::new(); + let obj2 = __RcTestObject::new(); array.push(obj1); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let old_obj = array.replace(0, obj2); expected.retain += 2; @@ -288,9 +288,9 @@ mod tests { fn test_remove() { let mut array = NSMutableArray::new(); for _ in 0..4 { - array.push(RcTestObject::new()); + array.push(__RcTestObject::new()); } - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let _obj = array.remove(1); expected.retain += 1; diff --git a/crates/objc2/src/foundation/mutable_attributed_string.rs b/crates/icrate/src/Foundation/additions/mutable_attributed_string.rs similarity index 96% rename from crates/objc2/src/foundation/mutable_attributed_string.rs rename to crates/icrate/src/Foundation/additions/mutable_attributed_string.rs index d08d7ea78..945476a88 100644 --- a/crates/objc2/src/foundation/mutable_attributed_string.rs +++ b/crates/icrate/src/Foundation/additions/mutable_attributed_string.rs @@ -1,8 +1,8 @@ use core::fmt; use super::{NSAttributedString, NSCopying, NSMutableCopying, NSObject, NSString}; -use crate::rc::{DefaultId, Id, Owned, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::rc::{DefaultId, Id, Owned, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// A mutable string that has associated attributes. diff --git a/crates/objc2/src/foundation/mutable_data.rs b/crates/icrate/src/Foundation/additions/mutable_data.rs similarity index 98% rename from crates/objc2/src/foundation/mutable_data.rs rename to crates/icrate/src/Foundation/additions/mutable_data.rs index 6509d7600..5aed4a636 100644 --- a/crates/objc2/src/foundation/mutable_data.rs +++ b/crates/icrate/src/Foundation/additions/mutable_data.rs @@ -8,8 +8,8 @@ use std::io; use super::data::with_slice; use super::{NSCopying, NSData, NSMutableCopying, NSObject, NSRange}; -use crate::rc::{DefaultId, Id, Owned, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::rc::{DefaultId, Id, Owned, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// A dynamic byte buffer in memory. @@ -239,7 +239,7 @@ impl<'a> IntoIterator for &'a mut NSMutableData { #[cfg(test)] mod tests { use super::*; - use crate::runtime::Object; + use objc2::runtime::Object; #[test] fn test_bytes_mut() { diff --git a/crates/objc2/src/foundation/mutable_dictionary.rs b/crates/icrate/src/Foundation/additions/mutable_dictionary.rs similarity index 91% rename from crates/objc2/src/foundation/mutable_dictionary.rs rename to crates/icrate/src/Foundation/additions/mutable_dictionary.rs index 8ec36a9b5..269260296 100644 --- a/crates/objc2/src/foundation/mutable_dictionary.rs +++ b/crates/icrate/src/Foundation/additions/mutable_dictionary.rs @@ -6,8 +6,8 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use core::ptr; use super::{NSArray, NSCopying, NSDictionary, NSFastEnumeration, NSObject}; -use crate::rc::{DefaultId, Id, Owned, Shared}; -use crate::{ClassType, __inner_extern_class, extern_methods, msg_send_id, Message}; +use objc2::rc::{DefaultId, Id, Owned, Shared}; +use objc2::{ClassType, __inner_extern_class, extern_methods, msg_send_id, Message}; __inner_extern_class!( /// A mutable collection of objects associated with unique keys. @@ -46,7 +46,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -67,7 +67,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSNumber, NSObject}; + /// use icrate::Foundation::{NSMutableDictionary, NSNumber, NSObject}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// let dict = NSMutableDictionary::from_keys_and_objects( @@ -93,8 +93,8 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; - /// use objc2::ns_string; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -114,7 +114,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -148,7 +148,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -176,8 +176,8 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; - /// use objc2::ns_string; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -203,7 +203,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -222,7 +222,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableDictionary, NSObject, NSString}; + /// use icrate::Foundation::{NSMutableDictionary, NSObject, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -276,10 +276,8 @@ mod tests { use super::*; use alloc::vec; - use crate::{ - foundation::{NSNumber, NSString}, - rc::{RcTestObject, ThreadTestData}, - }; + use crate::Foundation::{NSNumber, NSString}; + use objc2::rc::{__RcTestObject, __ThreadTestData}; fn sample_dict() -> Id, Owned> { NSMutableDictionary::from_keys_and_objects( @@ -326,10 +324,10 @@ mod tests { #[test] fn test_insert_retain_release() { let mut dict = NSMutableDictionary::new(); - dict.insert(NSNumber::new_i32(1), RcTestObject::new()); - let mut expected = ThreadTestData::current(); + dict.insert(NSNumber::new_i32(1), __RcTestObject::new()); + let mut expected = __ThreadTestData::current(); - let old = dict.insert(NSNumber::new_i32(1), RcTestObject::new()); + let old = dict.insert(NSNumber::new_i32(1), __RcTestObject::new()); expected.alloc += 1; expected.init += 1; expected.retain += 2; @@ -366,9 +364,9 @@ mod tests { fn test_remove_clear_release_dealloc() { let mut dict = NSMutableDictionary::new(); for i in 0..4 { - dict.insert(NSNumber::new_i32(i), RcTestObject::new()); + dict.insert(NSNumber::new_i32(i), __RcTestObject::new()); } - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let _obj = dict.remove(&NSNumber::new_i32(1)); expected.retain += 1; diff --git a/crates/objc2/src/foundation/mutable_set.rs b/crates/icrate/src/Foundation/additions/mutable_set.rs similarity index 92% rename from crates/objc2/src/foundation/mutable_set.rs rename to crates/icrate/src/Foundation/additions/mutable_set.rs index 03f44b5a8..12b0a6de2 100644 --- a/crates/objc2/src/foundation/mutable_set.rs +++ b/crates/icrate/src/Foundation/additions/mutable_set.rs @@ -4,8 +4,8 @@ use core::marker::PhantomData; use super::set::with_objects; use super::{NSCopying, NSFastEnumeration, NSFastEnumerator, NSMutableCopying, NSObject, NSSet}; -use crate::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; -use crate::{ClassType, Message, __inner_extern_class, extern_methods}; +use objc2::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; +use objc2::{ClassType, Message, __inner_extern_class, extern_methods}; __inner_extern_class!( /// A growable unordered collection of unique objects. @@ -38,7 +38,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; + /// use icrate::Foundation::{NSMutableSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -54,7 +54,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; + /// use icrate::Foundation::{NSMutableSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -73,7 +73,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; + /// use icrate::Foundation::{NSMutableSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -91,7 +91,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSMutableString}; + /// use icrate::Foundation::{NSMutableSet, NSMutableString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -117,7 +117,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; + /// use icrate::Foundation::{NSMutableSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -148,7 +148,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; + /// use icrate::Foundation::{NSMutableSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -180,8 +180,8 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableSet, NSString}; - /// use objc2::ns_string; + /// use icrate::Foundation::{NSMutableSet, NSString}; + /// use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -258,9 +258,9 @@ mod tests { use alloc::vec; use super::*; - use crate::foundation::{NSMutableString, NSString}; use crate::ns_string; - use crate::rc::{RcTestObject, ThreadTestData}; + use crate::Foundation::{NSMutableString, NSString}; + use objc2::rc::{__RcTestObject, __ThreadTestData}; #[test] fn test_insert() { @@ -332,9 +332,9 @@ mod tests { #[test] fn test_insert_retain_release() { let mut set = NSMutableSet::new(); - let obj1 = RcTestObject::new(); - let obj2 = RcTestObject::new(); - let mut expected = ThreadTestData::current(); + let obj1 = __RcTestObject::new(); + let obj2 = __RcTestObject::new(); + let mut expected = __ThreadTestData::current(); set.insert(obj1); expected.retain += 1; @@ -354,9 +354,9 @@ mod tests { fn test_clear_release_dealloc() { let mut set = NSMutableSet::new(); for _ in 0..4 { - set.insert(RcTestObject::new()); + set.insert(__RcTestObject::new()); } - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); set.clear(); expected.release += 4; diff --git a/crates/objc2/src/foundation/mutable_string.rs b/crates/icrate/src/Foundation/additions/mutable_string.rs similarity index 98% rename from crates/objc2/src/foundation/mutable_string.rs rename to crates/icrate/src/Foundation/additions/mutable_string.rs index c0253ff03..45359b1db 100644 --- a/crates/objc2/src/foundation/mutable_string.rs +++ b/crates/icrate/src/Foundation/additions/mutable_string.rs @@ -4,8 +4,8 @@ use core::ops::AddAssign; use core::str; use super::{NSCopying, NSMutableCopying, NSObject, NSString}; -use crate::rc::{DefaultId, Id, Owned, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::rc::{DefaultId, Id, Owned, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// A dynamic plain-text Unicode string object. diff --git a/crates/objc2/src/foundation/number.rs b/crates/icrate/src/Foundation/additions/number.rs similarity index 98% rename from crates/objc2/src/foundation/number.rs rename to crates/icrate/src/Foundation/additions/number.rs index 103550ef0..caaa3ee81 100644 --- a/crates/objc2/src/foundation/number.rs +++ b/crates/icrate/src/Foundation/additions/number.rs @@ -9,8 +9,8 @@ use std::os::raw::{ use super::{ CGFloat, NSComparisonResult, NSCopying, NSInteger, NSObject, NSString, NSUInteger, NSValue, }; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, msg_send, msg_send_id, ClassType, Encoding}; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, msg_send, msg_send_id, ClassType, Encoding}; extern_class!( /// An object wrapper for primitive scalars. @@ -167,9 +167,9 @@ impl NSNumber { /// number properties. /// /// ``` - /// use objc2::Encoding; - /// use objc2::foundation::NSNumber; - /// use objc2::rc::{Id, Shared}; + /// use icrate::Foundation::NSNumber; + /// use icrate::objc2::Encoding; + /// use icrate::objc2::rc::{Id, Shared}; /// /// // Note: `bool` would convert to either `Signed` or `Unsigned`, /// // depending on platform diff --git a/crates/objc2/src/foundation/process_info.rs b/crates/icrate/src/Foundation/additions/process_info.rs similarity index 95% rename from crates/objc2/src/foundation/process_info.rs rename to crates/icrate/src/Foundation/additions/process_info.rs index a70567f60..362932722 100644 --- a/crates/objc2/src/foundation/process_info.rs +++ b/crates/icrate/src/Foundation/additions/process_info.rs @@ -2,8 +2,8 @@ use core::fmt; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSObject, NSString}; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, ClassType}; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, ClassType}; extern_class!( /// A collection of information about the current process. diff --git a/crates/objc2/src/foundation/range.rs b/crates/icrate/src/Foundation/additions/range.rs similarity index 96% rename from crates/objc2/src/foundation/range.rs rename to crates/icrate/src/Foundation/additions/range.rs index 43232a753..95f601a53 100644 --- a/crates/objc2/src/foundation/range.rs +++ b/crates/icrate/src/Foundation/additions/range.rs @@ -1,7 +1,7 @@ use core::ops::Range; use super::NSUInteger; -use crate::{Encode, Encoding, RefEncode}; +use objc2::encode::{Encode, Encoding, RefEncode}; /// TODO. /// @@ -22,7 +22,7 @@ impl NSRange { /// # Examples /// /// ``` - /// use objc2::foundation::NSRange; + /// use icrate::Foundation::NSRange; /// assert_eq!(NSRange::new(3, 2), NSRange::from(3..5)); /// ``` #[inline] @@ -37,7 +37,7 @@ impl NSRange { /// # Examples /// /// ``` - /// use objc2::foundation::NSRange; + /// use icrate::Foundation::NSRange; /// /// assert!(!NSRange::from(3..5).is_empty()); /// assert!( NSRange::from(3..3).is_empty()); @@ -52,7 +52,7 @@ impl NSRange { /// # Examples /// /// ``` - /// use objc2::foundation::NSRange; + /// use icrate::Foundation::NSRange; /// /// assert!(!NSRange::from(3..5).contains(2)); /// assert!( NSRange::from(3..5).contains(3)); diff --git a/crates/objc2/src/foundation/set.rs b/crates/icrate/src/Foundation/additions/set.rs similarity index 93% rename from crates/objc2/src/foundation/set.rs rename to crates/icrate/src/Foundation/additions/set.rs index 18a344ebc..8a7656d7e 100644 --- a/crates/objc2/src/foundation/set.rs +++ b/crates/icrate/src/Foundation/additions/set.rs @@ -7,8 +7,8 @@ use super::{ NSArray, NSCopying, NSEnumerator, NSFastEnumeration, NSFastEnumerator, NSMutableCopying, NSMutableSet, NSObject, }; -use crate::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; -use crate::{ClassType, Message, __inner_extern_class, extern_methods, msg_send, msg_send_id}; +use objc2::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId}; +use objc2::{ClassType, Message, __inner_extern_class, extern_methods, msg_send, msg_send_id}; __inner_extern_class!( /// An immutable unordered collection of unique objects. @@ -58,7 +58,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -78,7 +78,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -99,7 +99,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -116,7 +116,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -133,7 +133,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -151,7 +151,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -174,7 +174,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSMutableString, NSSet}; + /// use icrate::Foundation::{NSMutableString, NSSet}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -200,7 +200,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -223,7 +223,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSNumber, NSSet, NSString}; + /// use icrate::Foundation::{NSNumber, NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -250,8 +250,8 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; - /// use objc2::ns_string; + /// use icrate::Foundation::{NSSet, NSString}; + /// use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -269,8 +269,8 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; - /// use objc2::ns_string; + /// use icrate::Foundation::{NSSet, NSString}; + /// use icrate::ns_string; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -289,7 +289,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -309,7 +309,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -331,7 +331,7 @@ extern_methods!( /// # Examples /// /// ``` - /// use objc2::foundation::{NSSet, NSString}; + /// use icrate::Foundation::{NSSet, NSString}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// @@ -400,9 +400,9 @@ mod tests { use alloc::vec; use super::*; - use crate::foundation::{NSMutableString, NSNumber, NSString}; use crate::ns_string; - use crate::rc::{RcTestObject, ThreadTestData}; + use crate::Foundation::{NSMutableString, NSNumber, NSString}; + use objc2::rc::{__RcTestObject, __ThreadTestData}; #[test] fn test_new() { @@ -604,8 +604,8 @@ mod tests { #[test] fn test_retains_stored() { - let obj = Id::into_shared(RcTestObject::new()); - let mut expected = ThreadTestData::current(); + let obj = Id::into_shared(__RcTestObject::new()); + let mut expected = __ThreadTestData::current(); let input = [obj.clone(), obj.clone()]; expected.retain += 2; @@ -639,9 +639,9 @@ mod tests { #[test] fn test_nscopying_uses_retain() { - let obj = Id::into_shared(RcTestObject::new()); + let obj = Id::into_shared(__RcTestObject::new()); let set = NSSet::from_slice(&[obj]); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let _copy = set.copy(); expected.assert_current(); @@ -657,9 +657,9 @@ mod tests { ignore = "this works differently on different framework versions" )] fn test_iter_no_retain() { - let obj = Id::into_shared(RcTestObject::new()); + let obj = Id::into_shared(__RcTestObject::new()); let set = NSSet::from_slice(&[obj]); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let iter = set.iter(); expected.retain += 0; diff --git a/crates/objc2/src/foundation/string.rs b/crates/icrate/src/Foundation/additions/string.rs similarity index 98% rename from crates/objc2/src/foundation/string.rs rename to crates/icrate/src/Foundation/additions/string.rs index 9f868c488..ad909b59d 100644 --- a/crates/objc2/src/foundation/string.rs +++ b/crates/icrate/src/Foundation/additions/string.rs @@ -13,10 +13,10 @@ use core::str; use std::os::raw::c_char; use super::{NSComparisonResult, NSCopying, NSError, NSMutableCopying, NSMutableString, NSObject}; -use crate::rc::{autoreleasepool, AutoreleasePool, DefaultId, Id, Shared}; -use crate::runtime::__nsstring::{nsstring_len, nsstring_to_str, UTF8_ENCODING}; -use crate::runtime::{Class, Object}; -use crate::{extern_class, extern_methods, msg_send, ClassType}; +use objc2::rc::{autoreleasepool, AutoreleasePool, DefaultId, Id, Shared}; +use objc2::runtime::__nsstring::{nsstring_len, nsstring_to_str, UTF8_ENCODING}; +use objc2::runtime::{Class, Object}; +use objc2::{extern_class, extern_methods, msg_send, ClassType}; extern_class!( /// An immutable, plain-text Unicode string object. @@ -62,7 +62,7 @@ extern_methods!( /// ``` /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; - /// use objc2::ns_string; + /// use icrate::ns_string; /// let error_tag = ns_string!("Error: "); /// let error_string = ns_string!("premature end of file."); /// let error_message = error_tag.concat(error_string); @@ -89,7 +89,7 @@ extern_methods!( /// ``` /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; - /// use objc2::ns_string; + /// use icrate::ns_string; /// /// let extension = ns_string!("scratch.tiff"); /// assert_eq!(&*ns_string!("/tmp").join_path(extension), ns_string!("/tmp/scratch.tiff")); diff --git a/crates/objc2/src/foundation/thread.rs b/crates/icrate/src/Foundation/additions/thread.rs similarity index 97% rename from crates/objc2/src/foundation/thread.rs rename to crates/icrate/src/Foundation/additions/thread.rs index c934a7586..f9dd1e311 100644 --- a/crates/objc2/src/foundation/thread.rs +++ b/crates/icrate/src/Foundation/additions/thread.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSObject, NSString}; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType}; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType}; extern_class!( /// A thread of execution. @@ -106,9 +106,9 @@ fn make_multithreaded() { /// Use when designing APIs that are only safe to use on the main thread: /// /// ```no_run -/// use objc2::foundation::MainThreadMarker; -/// use objc2::runtime::Object; -/// use objc2::msg_send; +/// use icrate::Foundation::MainThreadMarker; +/// use icrate::objc2::runtime::Object; +/// use icrate::objc2::msg_send; /// # let obj = 0 as *const Object; /// /// // This action requires the main thread, so we take a marker as parameter. diff --git a/crates/objc2/src/foundation/uuid.rs b/crates/icrate/src/Foundation/additions/uuid.rs similarity index 97% rename from crates/objc2/src/foundation/uuid.rs rename to crates/icrate/src/Foundation/additions/uuid.rs index c47e6245d..9ec1eefbd 100644 --- a/crates/objc2/src/foundation/uuid.rs +++ b/crates/icrate/src/Foundation/additions/uuid.rs @@ -2,8 +2,8 @@ use core::fmt; use core::panic::{RefUnwindSafe, UnwindSafe}; use super::{NSCopying, NSObject, NSString}; -use crate::rc::{DefaultId, Id, Shared}; -use crate::{extern_class, extern_methods, msg_send_id, ClassType, Encode, Encoding, RefEncode}; +use objc2::rc::{DefaultId, Id, Shared}; +use objc2::{extern_class, extern_methods, msg_send_id, ClassType, Encode, Encoding, RefEncode}; extern_class!( /// A universally unique value. diff --git a/crates/objc2/src/foundation/value.rs b/crates/icrate/src/Foundation/additions/value.rs similarity index 95% rename from crates/objc2/src/foundation/value.rs rename to crates/icrate/src/Foundation/additions/value.rs index cde99f430..5cc8bff54 100644 --- a/crates/objc2/src/foundation/value.rs +++ b/crates/icrate/src/Foundation/additions/value.rs @@ -9,8 +9,8 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use super::{NSCopying, NSObject, NSPoint, NSRange, NSRect, NSSize}; -use crate::rc::{Id, Shared}; -use crate::{extern_class, extern_methods, msg_send, msg_send_id, ClassType, Encode}; +use objc2::rc::{Id, Shared}; +use objc2::{extern_class, extern_methods, msg_send, msg_send_id, ClassType, Encode}; extern_class!( /// A container wrapping any encodable type as an Obective-C object. @@ -58,7 +58,7 @@ extern_methods!( /// Create an `NSValue` containing an [`NSPoint`][super::NSPoint]. /// /// ``` - /// use objc2::foundation::{NSPoint, NSValue}; + /// use icrate::Foundation::{NSPoint, NSValue}; /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// let val = NSValue::new::(NSPoint::new(1.0, 1.0)); @@ -108,7 +108,7 @@ extern_methods!( /// ``` /// use std::ffi::c_void; /// use std::ptr; - /// use objc2::foundation::NSValue; + /// use icrate::Foundation::NSValue; /// /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; @@ -237,7 +237,7 @@ mod tests { use core::{ptr, slice}; use super::*; - use crate::rc::{RcTestObject, ThreadTestData}; + use objc2::rc::{__RcTestObject, __ThreadTestData}; #[test] fn basic() { @@ -247,13 +247,16 @@ mod tests { #[test] fn does_not_retain() { - let obj = RcTestObject::new(); - let expected = ThreadTestData::current(); + let obj = __RcTestObject::new(); + let expected = __ThreadTestData::current(); - let val = NSValue::new::<*const RcTestObject>(&*obj); + let val = NSValue::new::<*const __RcTestObject>(&*obj); expected.assert_current(); - assert!(ptr::eq(unsafe { val.get::<*const RcTestObject>() }, &*obj)); + assert!(ptr::eq( + unsafe { val.get::<*const __RcTestObject>() }, + &*obj + )); expected.assert_current(); let _clone = val.clone(); diff --git a/crates/icrate/src/Foundation/mod.rs b/crates/icrate/src/Foundation/mod.rs index 693764910..50273cdab 100644 --- a/crates/icrate/src/Foundation/mod.rs +++ b/crates/icrate/src/Foundation/mod.rs @@ -1,11 +1,10 @@ +mod additions; mod fixes; #[path = "../generated/Foundation/mod.rs"] mod generated; +pub use self::additions::*; #[allow(unreachable_pub)] pub use self::fixes::*; #[allow(unreachable_pub)] pub use self::generated::*; - -pub use objc2::foundation::*; -pub use objc2::ns_string; diff --git a/crates/icrate/src/lib.rs b/crates/icrate/src/lib.rs index 63dd280bc..1aaf6d74c 100644 --- a/crates/icrate/src/lib.rs +++ b/crates/icrate/src/lib.rs @@ -12,6 +12,9 @@ // Update in Cargo.toml as well. #![doc(html_root_url = "https://docs.rs/icrate/0.0.1")] +#[cfg(feature = "alloc")] +extern crate alloc; + #[cfg(feature = "std")] extern crate std; diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index c89dad6cf..530944764 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -1,7 +1,6 @@ # Changelog -Notable changes to this crate will be documented in this file. See the -`CHANGELOG_FOUNDATION.md` file for changes to the `objc2::foundation` module! +Notable changes to this crate will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -61,6 +60,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * **BREAKING**: `declare_class!` uses `ConformsTo<...>` instead of the temporary `Protocol<...>` syntax. * Require implementors of `Message` to support weak references. +* **BREAKING**: Moved `objc2::foundation` into `icrate::Foundation`. +* **BREAKING**: Moved `objc2::ns_string` into `icrate::ns_string`. ### Fixed * Fixed duplicate selector extraction in `extern_methods!`. diff --git a/crates/objc2/Cargo.toml b/crates/objc2/Cargo.toml index 58eed05ab..9f636c473 100644 --- a/crates/objc2/Cargo.toml +++ b/crates/objc2/Cargo.toml @@ -19,15 +19,12 @@ license = "MIT" # NOTE: 'unstable' features are _not_ considered part of the SemVer contract, # and may be removed in a minor release. [features] -default = ["std", "apple", "foundation"] +default = ["std", "apple"] # Currently not possible to turn off, put here for forwards compatibility. std = ["alloc", "objc2-encode/std", "objc-sys/std", "block2?/std"] alloc = ["objc2-encode/alloc", "objc-sys/alloc", "block2?/alloc"] -# Enable the `objc2::foundation` submodule. It is enabled by default. -foundation = [] - # Enables `objc2::exception::throw` and `objc2::exception::catch` exception = ["objc-sys/unstable-exception"] @@ -86,9 +83,6 @@ objc2-encode = { path = "../objc2-encode", version = "=2.0.0-pre.2", default-fea objc2-proc-macros = { path = "../objc2-proc-macros", version = "0.1.0", optional = true } block2 = { path = "../block2", version = "=0.2.0-alpha.6", default-features = false, optional = true } -# Provide methods to convert between `uuid::Uuid` and `objc2::foundation::NSUUID` -uuid = { version = "1.1.2", optional = true, default-features = false } - [dev-dependencies] iai = { version = "0.1", git = "https://github.com/madsmtm/iai", branch = "callgrind" } diff --git a/crates/objc2/src/__macro_helpers.rs b/crates/objc2/src/__macro_helpers.rs index 23ffe9825..3d915d1f8 100644 --- a/crates/objc2/src/__macro_helpers.rs +++ b/crates/objc2/src/__macro_helpers.rs @@ -641,7 +641,7 @@ mod tests { #[cfg(feature = "objc2-proc-macros")] use crate::__hash_idents; - use crate::rc::{Owned, RcTestObject, Shared, ThreadTestData}; + use crate::rc::{Owned, Shared, __RcTestObject, __ThreadTestData}; use crate::runtime::{NSObject, NSZone, Object}; use crate::{class, msg_send_id, ClassType}; @@ -653,8 +653,8 @@ mod tests { #[test] fn test_new_not_on_class() { - let mut expected = ThreadTestData::current(); - let obj = RcTestObject::new(); + let mut expected = __ThreadTestData::current(); + let obj = __RcTestObject::new(); let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstance] }; let _obj: Option> = unsafe { msg_send_id![&obj, newMethodOnInstance] }; @@ -667,9 +667,9 @@ mod tests { // newScriptingObjectOfClass only available on macOS #[cfg_attr(not(all(feature = "apple", target_os = "macos")), ignore)] fn test_new_with_args() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); - let object_class = RcTestObject::class(); + let object_class = __RcTestObject::class(); let key: Id = unsafe { msg_send_id![class!(NSString), new] }; let contents_value: *const Object = ptr::null(); let properties: Id = unsafe { msg_send_id![class!(NSDictionary), new] }; @@ -690,10 +690,10 @@ mod tests { #[test] fn test_macro_alloc() { - let mut expected = ThreadTestData::current(); - let cls = RcTestObject::class(); + let mut expected = __ThreadTestData::current(); + let cls = __RcTestObject::class(); - let obj: Allocated = unsafe { msg_send_id![cls, alloc] }; + let obj: Allocated<__RcTestObject> = unsafe { msg_send_id![cls, alloc] }; expected.alloc += 1; expected.assert_current(); @@ -705,42 +705,42 @@ mod tests { #[test] fn test_alloc_with_zone() { - let mut expected = ThreadTestData::current(); - let cls = RcTestObject::class(); + let mut expected = __ThreadTestData::current(); + let cls = __RcTestObject::class(); let zone: *const NSZone = ptr::null(); - let _obj: Allocated = unsafe { msg_send_id![cls, allocWithZone: zone] }; + let _obj: Allocated<__RcTestObject> = unsafe { msg_send_id![cls, allocWithZone: zone] }; expected.alloc += 1; expected.assert_current(); } #[test] fn test_macro_init() { - let mut expected = ThreadTestData::current(); - let cls = RcTestObject::class(); + let mut expected = __ThreadTestData::current(); + let cls = __RcTestObject::class(); - let obj: Option> = unsafe { msg_send_id![cls, alloc] }; + let obj: Option> = unsafe { msg_send_id![cls, alloc] }; expected.alloc += 1; // Don't check allocation error - let _obj: Id = unsafe { msg_send_id![obj, init] }; + let _obj: Id<__RcTestObject, Shared> = unsafe { msg_send_id![obj, init] }; expected.init += 1; expected.assert_current(); - let obj: Option> = unsafe { msg_send_id![cls, alloc] }; + let obj: Option> = unsafe { msg_send_id![cls, alloc] }; expected.alloc += 1; // Check allocation error before init let obj = obj.unwrap(); - let _obj: Id = unsafe { msg_send_id![Some(obj), init] }; + let _obj: Id<__RcTestObject, Shared> = unsafe { msg_send_id![Some(obj), init] }; expected.init += 1; expected.assert_current(); } #[test] fn test_macro() { - let mut expected = ThreadTestData::current(); - let cls = RcTestObject::class(); + let mut expected = __ThreadTestData::current(); + let cls = __RcTestObject::class(); crate::rc::autoreleasepool(|_| { - let _obj: Id = unsafe { msg_send_id![cls, new] }; + let _obj: Id<__RcTestObject, Owned> = unsafe { msg_send_id![cls, new] }; expected.alloc += 1; expected.init += 1; expected.assert_current(); @@ -749,28 +749,28 @@ mod tests { expected.alloc += 1; expected.assert_current(); - let obj: Id = unsafe { msg_send_id![obj, init] }; + let obj: Id<__RcTestObject, Owned> = unsafe { msg_send_id![obj, init] }; expected.init += 1; expected.assert_current(); - let _copy: Id = unsafe { msg_send_id![&obj, copy] }; + let _copy: Id<__RcTestObject, Shared> = unsafe { msg_send_id![&obj, copy] }; expected.copy += 1; expected.alloc += 1; expected.init += 1; expected.assert_current(); - let _mutable_copy: Id = + let _mutable_copy: Id<__RcTestObject, Shared> = unsafe { msg_send_id![&obj, mutableCopy] }; expected.mutable_copy += 1; expected.alloc += 1; expected.init += 1; expected.assert_current(); - let _self: Id = unsafe { msg_send_id![&obj, self] }; + let _self: Id<__RcTestObject, Shared> = unsafe { msg_send_id![&obj, self] }; expected.retain += 1; expected.assert_current(); - let _desc: Option> = + let _desc: Option> = unsafe { msg_send_id![&obj, description] }; expected.assert_current(); }); @@ -788,16 +788,16 @@ mod tests { } #[test] - #[should_panic = "failed creating new instance using +[RcTestObject newReturningNull]"] + #[should_panic = "failed creating new instance using +[__RcTestObject newReturningNull]"] fn test_new_with_null() { - let _obj: Id = - unsafe { msg_send_id![RcTestObject::class(), newReturningNull] }; + let _obj: Id<__RcTestObject, Owned> = + unsafe { msg_send_id![__RcTestObject::class(), newReturningNull] }; } #[test] - #[should_panic = "unexpected NULL returned from -[RcTestObject newMethodOnInstanceNull]"] + #[should_panic = "unexpected NULL returned from -[__RcTestObject newMethodOnInstanceNull]"] fn test_new_any_with_null() { - let obj = RcTestObject::new(); + let obj = __RcTestObject::new(); let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstanceNull] }; } @@ -810,40 +810,40 @@ mod tests { } #[test] - #[should_panic = "failed allocating with +[RcTestObject allocReturningNull]"] + #[should_panic = "failed allocating with +[__RcTestObject allocReturningNull]"] fn test_alloc_with_null() { - let _obj: Allocated = - unsafe { msg_send_id![RcTestObject::class(), allocReturningNull] }; + let _obj: Allocated<__RcTestObject> = + unsafe { msg_send_id![__RcTestObject::class(), allocReturningNull] }; } #[test] #[should_panic = "failed initializing object with -initReturningNull"] fn test_init_with_null() { - let obj: Option> = - unsafe { msg_send_id![RcTestObject::class(), alloc] }; - let _obj: Id = unsafe { msg_send_id![obj, initReturningNull] }; + let obj: Option> = + unsafe { msg_send_id![__RcTestObject::class(), alloc] }; + let _obj: Id<__RcTestObject, Owned> = unsafe { msg_send_id![obj, initReturningNull] }; } #[test] #[should_panic = "failed allocating object"] #[cfg(not(debug_assertions))] // Does NULL receiver checks fn test_init_with_null_receiver() { - let obj: Option> = None; - let _obj: Id = unsafe { msg_send_id![obj, init] }; + let obj: Option> = None; + let _obj: Id<__RcTestObject, Owned> = unsafe { msg_send_id![obj, init] }; } #[test] #[should_panic = "failed copying object"] fn test_copy_with_null() { - let obj = Id::into_shared(RcTestObject::new()); - let _obj: Id = unsafe { msg_send_id![&obj, copyReturningNull] }; + let obj = Id::into_shared(__RcTestObject::new()); + let _obj: Id<__RcTestObject, Shared> = unsafe { msg_send_id![&obj, copyReturningNull] }; } #[test] - #[should_panic = "unexpected NULL returned from -[RcTestObject methodReturningNull]"] + #[should_panic = "unexpected NULL returned from -[__RcTestObject methodReturningNull]"] fn test_normal_with_null() { - let obj = Id::into_shared(RcTestObject::new()); - let _obj: Id = unsafe { msg_send_id![&obj, methodReturningNull] }; + let obj = Id::into_shared(__RcTestObject::new()); + let _obj: Id<__RcTestObject, Shared> = unsafe { msg_send_id![&obj, methodReturningNull] }; } #[test] diff --git a/crates/objc2/src/declare/ivar.rs b/crates/objc2/src/declare/ivar.rs index 38de124ca..42ff49671 100644 --- a/crates/objc2/src/declare/ivar.rs +++ b/crates/objc2/src/declare/ivar.rs @@ -397,7 +397,7 @@ mod tests { static HAS_RUN_DEALLOC: AtomicBool = AtomicBool::new(false); declare_class!( - #[derive(Debug, PartialEq)] + #[derive(Debug, PartialEq, Eq)] struct CustomDrop { ivar: u8, } diff --git a/crates/objc2/src/declare/ivar_drop.rs b/crates/objc2/src/declare/ivar_drop.rs index 90ed62a70..012453cc4 100644 --- a/crates/objc2/src/declare/ivar_drop.rs +++ b/crates/objc2/src/declare/ivar_drop.rs @@ -209,7 +209,7 @@ unsafe fn box_unreachable() -> ! { mod tests { use super::*; use crate::declare::{Ivar, IvarType}; - use crate::rc::{Allocated, Owned, RcTestObject, Shared, ThreadTestData}; + use crate::rc::{Allocated, Owned, Shared, __RcTestObject, __ThreadTestData}; use crate::runtime::NSObject; use crate::runtime::Object; use crate::{declare_class, msg_send, msg_send_id, ClassType}; @@ -239,12 +239,12 @@ mod tests { } declare_class!( - #[derive(Debug, PartialEq)] + #[derive(Debug, PartialEq, Eq)] struct IvarTester { - ivar1: IvarDrop>, - ivar2: IvarDrop>>, - ivar3: IvarDrop>>, - ivar4: IvarDrop>>>, + ivar1: IvarDrop>, + ivar2: IvarDrop>>, + ivar3: IvarDrop>>, + ivar4: IvarDrop>>>, } unsafe impl ClassType for IvarTester { @@ -256,10 +256,10 @@ mod tests { fn init(&mut self) -> Option<&mut Self> { let this: Option<&mut Self> = unsafe { msg_send![super(self), init] }; this.map(|this| { - Ivar::write(&mut this.ivar1, Id::into_shared(RcTestObject::new())); - *this.ivar2 = Some(RcTestObject::new()); - Ivar::write(&mut this.ivar3, Box::new(RcTestObject::new())); - *this.ivar4 = Some(Box::new(RcTestObject::new())); + Ivar::write(&mut this.ivar1, Id::into_shared(__RcTestObject::new())); + *this.ivar2 = Some(__RcTestObject::new()); + Ivar::write(&mut this.ivar3, Box::new(__RcTestObject::new())); + *this.ivar4 = Some(Box::new(__RcTestObject::new())); this }) } @@ -276,7 +276,7 @@ mod tests { #[test] fn test_alloc_dealloc() { - let expected = ThreadTestData::current(); + let expected = __ThreadTestData::current(); let obj: Allocated = unsafe { msg_send_id![IvarTester::class(), alloc] }; expected.assert_current(); @@ -287,7 +287,7 @@ mod tests { #[test] fn test_init_drop() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let mut obj: Id = unsafe { msg_send_id![IvarTester::class(), new] }; expected.alloc += 4; @@ -326,6 +326,6 @@ mod tests { let mut obj: Id = unsafe { msg_send_id![IvarTester::alloc(), initInvalid] }; - *obj.ivar1 = RcTestObject::new().into(); + *obj.ivar1 = __RcTestObject::new().into(); } } diff --git a/crates/objc2/src/lib.rs b/crates/objc2/src/lib.rs index 264eaddbf..b8af202ad 100644 --- a/crates/objc2/src/lib.rs +++ b/crates/objc2/src/lib.rs @@ -217,8 +217,6 @@ mod cache; mod class_type; pub mod declare; pub mod exception; -#[cfg(feature = "foundation")] -pub mod foundation; mod macros; mod message; mod protocol; @@ -228,6 +226,11 @@ pub mod runtime; mod test_utils; mod verify; +#[cfg(test)] +#[cfg_attr(feature = "apple", link(name = "Foundation", kind = "framework"))] +#[cfg_attr(feature = "gnustep-1-7", link(name = "gnustep-base", kind = "dylib"))] +extern "C" {} + /// Hacky way to make GNUStep link properly to Foundation while testing. /// /// This is a temporary solution to make our CI work for now! diff --git a/crates/objc2/src/macros/extern_class.rs b/crates/objc2/src/macros/extern_class.rs index 7cf091549..7dfd8e7fa 100644 --- a/crates/objc2/src/macros/extern_class.rs +++ b/crates/objc2/src/macros/extern_class.rs @@ -66,6 +66,11 @@ /// # #[cfg(feature = "gnustep-1-7")] /// # unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; /// +/// // Link to the Foundation framework +/// #[cfg_attr(feature = "apple", link(name = "Foundation", kind = "framework"))] +/// #[cfg_attr(feature = "gnustep-1-7", link(name = "gnustep-base", kind = "dylib"))] +/// extern "C" {} +/// /// extern_class!( /// /// An example description. /// #[derive(PartialEq, Eq, Hash)] // Uses the superclass' implementation diff --git a/crates/objc2/src/rc/id.rs b/crates/objc2/src/rc/id.rs index d2a0cbe9b..a6ef7b41a 100644 --- a/crates/objc2/src/rc/id.rs +++ b/crates/objc2/src/rc/id.rs @@ -762,7 +762,7 @@ impl UnwindSafe for Id {} mod tests { use super::*; use crate::msg_send; - use crate::rc::{autoreleasepool, RcTestObject, ThreadTestData}; + use crate::rc::{__RcTestObject, __ThreadTestData, autoreleasepool}; use crate::runtime::Object; #[track_caller] @@ -773,9 +773,9 @@ mod tests { #[test] fn test_drop() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); - let obj = RcTestObject::new(); + let obj = __RcTestObject::new(); expected.alloc += 1; expected.init += 1; expected.assert_current(); @@ -788,9 +788,9 @@ mod tests { #[test] fn test_autorelease() { - let obj: Id<_, Shared> = RcTestObject::new().into(); + let obj: Id<_, Shared> = __RcTestObject::new().into(); let cloned = obj.clone(); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); autoreleasepool(|pool| { let _ref = obj.autorelease(pool); @@ -814,9 +814,9 @@ mod tests { #[test] fn test_clone() { - let obj: Id<_, Owned> = RcTestObject::new(); + let obj: Id<_, Owned> = __RcTestObject::new(); assert_retain_count(&obj, 1); - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); let obj: Id<_, Shared> = obj.into(); expected.assert_current(); @@ -841,10 +841,10 @@ mod tests { #[test] fn test_retain_autoreleased_works_as_retain() { - let obj: Id<_, Shared> = RcTestObject::new().into(); - let mut expected = ThreadTestData::current(); + let obj: Id<_, Shared> = __RcTestObject::new().into(); + let mut expected = __ThreadTestData::current(); - let ptr = Id::as_ptr(&obj) as *mut RcTestObject; + let ptr = Id::as_ptr(&obj) as *mut __RcTestObject; let _obj2: Id<_, Shared> = unsafe { Id::retain_autoreleased(ptr) }.unwrap(); expected.retain += 1; expected.assert_current(); @@ -852,15 +852,15 @@ mod tests { #[test] fn test_cast() { - let obj: Id = RcTestObject::new(); - let expected = ThreadTestData::current(); + let obj: Id<__RcTestObject, _> = __RcTestObject::new(); + let expected = __ThreadTestData::current(); // SAFETY: Any object can be cast to `Object` let obj: Id = unsafe { Id::cast(obj) }; expected.assert_current(); - // SAFETY: The object was originally `RcTestObject` - let _obj: Id = unsafe { Id::cast(obj) }; + // SAFETY: The object was originally `__RcTestObject` + let _obj: Id<__RcTestObject, _> = unsafe { Id::cast(obj) }; expected.assert_current(); } } diff --git a/crates/objc2/src/rc/mod.rs b/crates/objc2/src/rc/mod.rs index c58fc8178..49191bba3 100644 --- a/crates/objc2/src/rc/mod.rs +++ b/crates/objc2/src/rc/mod.rs @@ -61,21 +61,17 @@ mod id; mod id_forwarding_impls; mod id_traits; mod ownership; -mod weak_id; - -#[cfg(test)] mod test_object; +mod weak_id; pub use self::allocated::Allocated; pub use self::autorelease::{autoreleasepool, AutoreleasePool, AutoreleaseSafe}; pub use self::id::Id; pub use self::id_traits::{DefaultId, SliceId, SliceIdMut}; pub use self::ownership::{Owned, Ownership, Shared}; +pub use self::test_object::{__RcTestObject, __ThreadTestData}; pub use self::weak_id::WeakId; -#[cfg(test)] -pub(crate) use self::test_object::{RcTestObject, ThreadTestData}; - #[cfg(test)] mod tests { use core::marker::PhantomData; diff --git a/crates/objc2/src/rc/test_object.rs b/crates/objc2/src/rc/test_object.rs index 191e4598c..eff86295b 100644 --- a/crates/objc2/src/rc/test_object.rs +++ b/crates/objc2/src/rc/test_object.rs @@ -6,28 +6,30 @@ use super::{Id, Owned}; use crate::runtime::{NSObject, NSZone}; use crate::{declare_class, msg_send, msg_send_id, ClassType}; +// TODO: Put tests that use this in another crate #[derive(Debug, Clone, Default, PartialEq, Eq)] -pub(crate) struct ThreadTestData { - pub(crate) alloc: usize, - pub(crate) dealloc: usize, - pub(crate) init: usize, - pub(crate) retain: usize, - pub(crate) copy: usize, - pub(crate) mutable_copy: usize, - pub(crate) release: usize, - pub(crate) autorelease: usize, - pub(crate) try_retain: usize, - pub(crate) try_retain_fail: usize, +#[doc(hidden)] +pub struct __ThreadTestData { + pub alloc: usize, + pub dealloc: usize, + pub init: usize, + pub retain: usize, + pub copy: usize, + pub mutable_copy: usize, + pub release: usize, + pub autorelease: usize, + pub try_retain: usize, + pub try_retain_fail: usize, } -impl ThreadTestData { +impl __ThreadTestData { /// Get the amount of method calls performed on the current thread. - pub(crate) fn current() -> ThreadTestData { + pub fn current() -> __ThreadTestData { TEST_DATA.with(|data| data.borrow().clone()) } #[track_caller] - pub(crate) fn assert_current(&self) { + pub fn assert_current(&self) { let current = Self::current(); let mut expected = self.clone(); if cfg!(feature = "gnustep-1-7") { @@ -44,20 +46,21 @@ impl ThreadTestData { } std::thread_local! { - pub(crate) static TEST_DATA: RefCell = RefCell::new(Default::default()); + static TEST_DATA: RefCell<__ThreadTestData> = RefCell::new(Default::default()); } declare_class!( /// A helper object that counts how many times various reference-counting /// primitives are called. - #[derive(Debug, PartialEq)] - pub(crate) struct RcTestObject {} + #[derive(Debug, PartialEq, Eq)] + #[doc(hidden)] + pub struct __RcTestObject {} - unsafe impl ClassType for RcTestObject { + unsafe impl ClassType for __RcTestObject { type Super = NSObject; } - unsafe impl RcTestObject { + unsafe impl __RcTestObject { #[method(newReturningNull)] fn new_returning_null() -> *mut Self { ptr::null_mut() @@ -163,10 +166,10 @@ declare_class!( } #[method(boolAndShouldError:error:)] - fn class_error_bool(should_error: bool, err: Option<&mut *mut RcTestObject>) -> bool { + fn class_error_bool(should_error: bool, err: Option<&mut *mut __RcTestObject>) -> bool { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } false } else { @@ -178,11 +181,11 @@ declare_class!( fn instance_error_bool( &self, should_error: bool, - err: Option<&mut *mut RcTestObject>, + err: Option<&mut *mut __RcTestObject>, ) -> bool { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } false } else { @@ -193,15 +196,15 @@ declare_class!( #[method(idAndShouldError:error:)] fn class_error_id( should_error: bool, - err: Option<&mut *mut RcTestObject>, - ) -> *mut RcTestObject { + err: Option<&mut *mut __RcTestObject>, + ) -> *mut __RcTestObject { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } ptr::null_mut() } else { - RcTestObject::new().autorelease_return() + __RcTestObject::new().autorelease_return() } } @@ -209,23 +212,23 @@ declare_class!( fn instance_error_id( self: &Self, should_error: bool, - err: Option<&mut *mut RcTestObject>, - ) -> *mut RcTestObject { + err: Option<&mut *mut __RcTestObject>, + ) -> *mut __RcTestObject { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } ptr::null_mut() } else { - RcTestObject::new().autorelease_return() + __RcTestObject::new().autorelease_return() } } #[method(newAndShouldError:error:)] - fn new_error(should_error: bool, err: Option<&mut *mut RcTestObject>) -> *mut Self { + fn new_error(should_error: bool, err: Option<&mut *mut __RcTestObject>) -> *mut Self { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } ptr::null_mut() } else { @@ -234,10 +237,10 @@ declare_class!( } #[method(allocAndShouldError:error:)] - fn alloc_error(should_error: bool, err: Option<&mut *mut RcTestObject>) -> *mut Self { + fn alloc_error(should_error: bool, err: Option<&mut *mut __RcTestObject>) -> *mut Self { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } ptr::null_mut() } else { @@ -249,11 +252,11 @@ declare_class!( fn init_error( this: &mut Self, should_error: bool, - err: Option<&mut *mut RcTestObject>, + err: Option<&mut *mut __RcTestObject>, ) -> *mut Self { if should_error { if let Some(err) = err { - *err = RcTestObject::new().autorelease_inner(); + *err = __RcTestObject::new().autorelease_inner(); } let _: () = unsafe { msg_send![this, release] }; ptr::null_mut() @@ -264,28 +267,30 @@ declare_class!( } ); -unsafe impl Send for RcTestObject {} -unsafe impl Sync for RcTestObject {} +unsafe impl Send for __RcTestObject {} +unsafe impl Sync for __RcTestObject {} -impl RcTestObject { - pub(crate) fn new() -> Id { +impl __RcTestObject { + #[doc(hidden)] + pub fn new() -> Id { // Use msg_send! - msg_send_id! is tested elsewhere! unsafe { Id::new(msg_send![Self::class(), new]) }.unwrap() } } declare_class!( - #[derive(Debug, PartialEq)] - pub(crate) struct RcTestObjectSubclass {} + #[derive(Debug, PartialEq, Eq)] + struct RcTestObjectSubclass {} unsafe impl ClassType for RcTestObjectSubclass { #[inherits(NSObject)] - type Super = RcTestObject; + type Super = __RcTestObject; } ); +#[cfg_attr(not(test), allow(unused))] impl RcTestObjectSubclass { - pub(crate) fn new() -> Id { + fn new() -> Id { unsafe { msg_send_id![Self::class(), new] } } } @@ -297,13 +302,13 @@ mod tests { #[test] fn ensure_declared_name() { - assert_eq!(RcTestObject::class().name(), RcTestObject::NAME); + assert_eq!(__RcTestObject::class().name(), __RcTestObject::NAME); } macro_rules! test_error_bool { ($expected:expr, $($obj:tt)*) => { // Succeeds - let res: Result<(), Id> = unsafe { + let res: Result<(), Id<__RcTestObject, Shared>> = unsafe { msg_send![$($obj)*, boolAndShouldError: false, error: _] }; assert_eq!(res, Ok(())); @@ -312,7 +317,7 @@ mod tests { // Errors let res = autoreleasepool(|_pool| { // `Ok` type is inferred to be `()` - let res: Id = unsafe { + let res: Id<__RcTestObject, Shared> = unsafe { msg_send![$($obj)*, boolAndShouldError: true, error: _] }.expect_err("not err"); $expected.alloc += 1; @@ -334,12 +339,12 @@ mod tests { #[test] fn test_error_bool() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); - let cls = RcTestObject::class(); + let cls = __RcTestObject::class(); test_error_bool!(expected, cls); - let obj = RcTestObject::new(); + let obj = __RcTestObject::new(); expected.alloc += 1; expected.init += 1; test_error_bool!(expected, &obj); @@ -350,7 +355,7 @@ mod tests { test_error_bool!(expected, &obj); test_error_bool!(expected, super(&obj)); test_error_bool!(expected, super(&obj, RcTestObjectSubclass::class())); - test_error_bool!(expected, super(&obj, RcTestObject::class())); + test_error_bool!(expected, super(&obj, __RcTestObject::class())); } // This is imperfect, but will do for now. @@ -369,7 +374,7 @@ mod tests { ($expected:expr, $if_autorelease_not_skipped:expr, $sel:ident, $($obj:tt)*) => { // Succeeds let res = autoreleasepool(|_pool| { - let res: Result, Id> = unsafe { + let res: Result, Id<__RcTestObject, Shared>> = unsafe { msg_send_id![$($obj)*, $sel: false, error: _] }; let res = res.expect("not ok"); @@ -390,7 +395,7 @@ mod tests { // Errors let res = autoreleasepool(|_pool| { - let res: Result, Id> = unsafe { + let res: Result, Id<__RcTestObject, Shared>> = unsafe { msg_send_id![$($obj)*, $sel: true, error: _] }; $expected.alloc += 1; @@ -412,13 +417,13 @@ mod tests { #[test] fn test_error_id() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); - let cls = RcTestObject::class(); + let cls = __RcTestObject::class(); test_error_id!(expected, IF_AUTORELEASE_NOT_SKIPPED, idAndShouldError, cls); test_error_id!(expected, 0, newAndShouldError, cls); - let obj = RcTestObject::new(); + let obj = __RcTestObject::new(); expected.alloc += 1; expected.init += 1; test_error_id!(expected, IF_AUTORELEASE_NOT_SKIPPED, idAndShouldError, &obj); @@ -430,17 +435,17 @@ mod tests { expected.alloc += 1; expected.release += 1; expected.dealloc += 1; - RcTestObject::alloc() + __RcTestObject::alloc() }); } #[test] fn test_error_alloc() { - let mut expected = ThreadTestData::current(); + let mut expected = __ThreadTestData::current(); // Succeeds - let res: Result, Id> = - unsafe { msg_send_id![RcTestObject::class(), allocAndShouldError: false, error: _] }; + let res: Result, Id<__RcTestObject, Shared>> = + unsafe { msg_send_id![__RcTestObject::class(), allocAndShouldError: false, error: _] }; let res = res.expect("not ok"); expected.alloc += 1; expected.assert_current(); @@ -452,8 +457,9 @@ mod tests { // Errors let res = autoreleasepool(|_pool| { - let res: Result, Id> = - unsafe { msg_send_id![RcTestObject::class(), allocAndShouldError: true, error: _] }; + let res: Result, Id<__RcTestObject, Shared>> = unsafe { + msg_send_id![__RcTestObject::class(), allocAndShouldError: true, error: _] + }; expected.alloc += 1; expected.init += 1; expected.autorelease += 1; diff --git a/crates/objc2/src/rc/weak_id.rs b/crates/objc2/src/rc/weak_id.rs index 8c1cecffe..53b44eebb 100644 --- a/crates/objc2/src/rc/weak_id.rs +++ b/crates/objc2/src/rc/weak_id.rs @@ -150,13 +150,13 @@ impl TryFrom> for Id { #[cfg(test)] mod tests { use super::*; - use crate::rc::{RcTestObject, ThreadTestData}; + use crate::rc::{__RcTestObject, __ThreadTestData}; use crate::runtime::Object; #[test] fn test_weak() { - let obj: Id<_, Shared> = RcTestObject::new().into(); - let mut expected = ThreadTestData::current(); + let obj: Id<_, Shared> = __RcTestObject::new().into(); + let mut expected = __ThreadTestData::current(); let weak = WeakId::new(&obj); expected.assert_current(); @@ -184,8 +184,8 @@ mod tests { #[test] fn test_weak_clone() { - let obj: Id<_, Shared> = RcTestObject::new().into(); - let mut expected = ThreadTestData::current(); + let obj: Id<_, Shared> = __RcTestObject::new().into(); + let mut expected = __ThreadTestData::current(); let weak = WeakId::new(&obj); expected.assert_current(); diff --git a/crates/objc2/src/runtime/nsobject.rs b/crates/objc2/src/runtime/nsobject.rs index 898779933..b9ba38c86 100644 --- a/crates/objc2/src/runtime/nsobject.rs +++ b/crates/objc2/src/runtime/nsobject.rs @@ -178,7 +178,7 @@ mod tests { use super::*; use alloc::format; - use crate::rc::RcTestObject; + use crate::rc::__RcTestObject; #[test] fn test_deref() { @@ -247,10 +247,10 @@ mod tests { fn test_is_kind_of() { let obj = NSObject::new(); assert!(obj.is_kind_of::()); - assert!(!obj.is_kind_of::()); + assert!(!obj.is_kind_of::<__RcTestObject>()); - let obj = RcTestObject::new(); + let obj = __RcTestObject::new(); assert!(obj.is_kind_of::()); - assert!(obj.is_kind_of::()); + assert!(obj.is_kind_of::<__RcTestObject>()); } } diff --git a/crates/objc2/tests/id_retain_autoreleased.rs b/crates/objc2/tests/id_retain_autoreleased.rs index f6ad0ab56..fe0913746 100644 --- a/crates/objc2/tests/id_retain_autoreleased.rs +++ b/crates/objc2/tests/id_retain_autoreleased.rs @@ -1,8 +1,12 @@ -use std::ffi::c_void; +use core::mem::ManuallyDrop; +use objc2::msg_send; use objc2::rc::{autoreleasepool, Id, Shared}; -use objc2::runtime::Object; -use objc2::{class, msg_send}; +use objc2::runtime::NSObject; + +#[cfg_attr(feature = "apple", link(name = "Foundation", kind = "framework"))] +#[cfg_attr(feature = "gnustep-1-7", link(name = "gnustep-base", kind = "dylib"))] +extern "C" {} #[cfg(feature = "gnustep-1-7")] #[test] @@ -10,31 +14,14 @@ fn ensure_linkage() { unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; } -fn retain_count(obj: &Object) -> usize { +fn retain_count(obj: &NSObject) -> usize { unsafe { msg_send![obj, retainCount] } } -fn create_data(bytes: &[u8]) -> Id { - let bytes_ptr: *const c_void = bytes.as_ptr().cast(); +fn create_obj() -> Id { + let obj = ManuallyDrop::new(NSObject::new()); unsafe { - // let obj: *mut Object = msg_send![ - // class!(NSMutableData), - // dataWithBytes: bytes_ptr, - // length: bytes.len(), - // ]; - // - // On x86 (and perhaps others), dataWithBytes does not tail call - // `autorelease` and hence the return address points into that instead - // of our code, making the fast autorelease scheme fail. - // - // So instead, we call `autorelease` manually here. - let obj: *mut Object = msg_send![class!(NSMutableData), alloc]; - let obj: *mut Object = msg_send![ - obj, - initWithBytes: bytes_ptr, - length: bytes.len(), - ]; - let obj: *mut Object = msg_send![obj, autorelease]; + let obj: *mut NSObject = msg_send![&*obj, autorelease]; // All code between the `msg_send!` and the `retain_autoreleased` must // be able to be optimized away for this to work. Id::retain_autoreleased(obj).unwrap() @@ -46,7 +33,7 @@ fn test_retain_autoreleased() { autoreleasepool(|_| { // Run once to allow DYLD to resolve the symbol stubs. // Required for making `retain_autoreleased` work on x86_64. - let _data = create_data(b"12"); + let _data = create_obj(); // When compiled in release mode / with optimizations enabled, // subsequent usage of `retain_autoreleased` will succeed in retaining @@ -59,14 +46,14 @@ fn test_retain_autoreleased() { 1 }; - let data = create_data(b"34"); + let data = create_obj(); assert_eq!(retain_count(&data), expected); - let data = create_data(b"56"); + let data = create_obj(); assert_eq!(retain_count(&data), expected); // Here we manually clean up the autorelease, so it will always be 1. - let data = autoreleasepool(|_| create_data(b"78")); + let data = autoreleasepool(|_| create_obj()); assert_eq!(retain_count(&data), 1); }); } diff --git a/crates/objc2/tests/no_prelude.rs b/crates/objc2/tests/no_prelude.rs index 64dc2b983..3bf51bba9 100644 --- a/crates/objc2/tests/no_prelude.rs +++ b/crates/objc2/tests/no_prelude.rs @@ -11,6 +11,10 @@ extern crate objc2 as new_objc2; use new_objc2::{ClassType, ProtocolType}; +#[cfg_attr(feature = "apple", link(name = "Foundation", kind = "framework"))] +#[cfg_attr(feature = "gnustep-1-7", link(name = "gnustep-base", kind = "dylib"))] +extern "C" {} + #[cfg(feature = "gnustep-1-7")] #[test] fn ensure_linkage() { diff --git a/crates/objc2/tests/use_macros.rs b/crates/objc2/tests/use_macros.rs index e82b4d3d4..7a0b2f653 100644 --- a/crates/objc2/tests/use_macros.rs +++ b/crates/objc2/tests/use_macros.rs @@ -1,6 +1,16 @@ use objc2::runtime::{Class, NSObject, Object}; use objc2::{class, declare_class, msg_send, sel, ClassType}; +#[cfg_attr(feature = "apple", link(name = "Foundation", kind = "framework"))] +#[cfg_attr(feature = "gnustep-1-7", link(name = "gnustep-base", kind = "dylib"))] +extern "C" {} + +#[cfg(feature = "gnustep-1-7")] +#[test] +fn ensure_linkage() { + unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; +} + declare_class!( struct MyObject {} @@ -9,12 +19,6 @@ declare_class!( } ); -#[cfg(feature = "gnustep-1-7")] -#[test] -fn ensure_linkage() { - unsafe { objc2::__gnustep_hack::get_class_to_force_linkage() }; -} - #[test] fn use_class_and_msg_send() { unsafe { diff --git a/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86.s b/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86.s index 33269cb65..dd0cceae1 100644 --- a/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86.s +++ b/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86.s @@ -23,7 +23,7 @@ get_ascii: lea eax, [ebx + .Lanon.[ID].0@GOTOFF] push 3 push eax - call SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@PLT + call SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@PLT add esp, 16 mov ecx, eax xchg dword ptr [ebx + SYM(test_ns_string[CRATE_ID]::get_ascii::CACHED_NSSTRING, 0).0@GOTOFF], ecx @@ -56,7 +56,7 @@ get_utf16: lea eax, [ebx + .Lanon.[ID].1@GOTOFF] push 5 push eax - call SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@PLT + call SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@PLT add esp, 16 mov ecx, eax xchg dword ptr [ebx + SYM(test_ns_string[CRATE_ID]::get_utf16::CACHED_NSSTRING, 0).0@GOTOFF], ecx @@ -89,7 +89,7 @@ get_with_nul: lea eax, [ebx + .Lanon.[ID].2@GOTOFF] push 6 push eax - call SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@PLT + call SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@PLT add esp, 16 mov ecx, eax xchg dword ptr [ebx + SYM(test_ns_string[CRATE_ID]::get_with_nul::CACHED_NSSTRING, 0).0@GOTOFF], ecx diff --git a/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86_64.s b/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86_64.s index 6a2478d16..fdbe85019 100644 --- a/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86_64.s +++ b/crates/test-assembly/crates/test_ns_string/expected/gnustep-x86_64.s @@ -14,7 +14,7 @@ get_ascii: .LBB0_1: lea rdi, [rip + .Lanon.[ID].0] mov esi, 3 - call qword ptr [rip + SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] + call qword ptr [rip + SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] mov rcx, rax xchg qword ptr [rip + SYM(test_ns_string[CRATE_ID]::get_ascii::CACHED_NSSTRING, 0).0], rcx pop rcx @@ -36,7 +36,7 @@ get_utf16: .LBB1_1: lea rdi, [rip + .Lanon.[ID].1] mov esi, 5 - call qword ptr [rip + SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] + call qword ptr [rip + SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] mov rcx, rax xchg qword ptr [rip + SYM(test_ns_string[CRATE_ID]::get_utf16::CACHED_NSSTRING, 0).0], rcx pop rcx @@ -58,7 +58,7 @@ get_with_nul: .LBB2_1: lea rdi, [rip + .Lanon.[ID].2] mov esi, 6 - call qword ptr [rip + SYM(objc2::foundation::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] + call qword ptr [rip + SYM(icrate::Foundation::additions::string::NSString::from_str::GENERATED_ID, 0)@GOTPCREL] mov rcx, rax xchg qword ptr [rip + SYM(test_ns_string[CRATE_ID]::get_with_nul::CACHED_NSSTRING, 0).0], rcx pop rcx diff --git a/crates/test-assembly/crates/test_ns_string/lib.rs b/crates/test-assembly/crates/test_ns_string/lib.rs index 8fedc7a7b..d3357fecb 100644 --- a/crates/test-assembly/crates/test_ns_string/lib.rs +++ b/crates/test-assembly/crates/test_ns_string/lib.rs @@ -1,7 +1,7 @@ //! Test the output of the `ns_string!` macro. #![cfg(feature = "Foundation")] -use icrate::Foundation::ns_string; +use icrate::ns_string; use icrate::Foundation::NSString; // Temporary to allow testing putting string references in statics. @@ -10,14 +10,14 @@ use icrate::Foundation::NSString; #[no_mangle] static EMPTY: &NSString = { const INPUT: &[u8] = b""; - icrate::objc2::__ns_string_inner!(@inner INPUT); + icrate::__ns_string_inner!(@inner INPUT); CFSTRING.as_nsstring_const() }; #[cfg(feature = "apple")] #[no_mangle] static XYZ: &NSString = { const INPUT: &[u8] = b"xyz"; - icrate::objc2::__ns_string_inner!(@inner INPUT); + icrate::__ns_string_inner!(@inner INPUT); CFSTRING.as_nsstring_const() }; diff --git a/crates/test-ui/ui/invalid_ns_string_input.rs b/crates/test-ui/ui/invalid_ns_string_input.rs index 860dec501..b8f7503ac 100644 --- a/crates/test-ui/ui/invalid_ns_string_input.rs +++ b/crates/test-ui/ui/invalid_ns_string_input.rs @@ -1,4 +1,4 @@ -use objc2::ns_string; +use icrate::ns_string; fn main() { let _ = ns_string!(1u8); diff --git a/crates/test-ui/ui/invalid_ns_string_output.rs b/crates/test-ui/ui/invalid_ns_string_output.rs index f9de57cf2..a25d965f2 100644 --- a/crates/test-ui/ui/invalid_ns_string_output.rs +++ b/crates/test-ui/ui/invalid_ns_string_output.rs @@ -1,4 +1,4 @@ -use objc2::ns_string; +use icrate::ns_string; fn main() { let _: u8 = ns_string!("abc"); diff --git a/crates/test-ui/ui/msg_send_id_invalid_return.stderr b/crates/test-ui/ui/msg_send_id_invalid_return.stderr index 5f44124c4..28d37a1b3 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_return.stderr +++ b/crates/test-ui/ui/msg_send_id_invalid_return.stderr @@ -27,14 +27,9 @@ error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied | = help: the following other types implement trait `Message`: Exception - NSArray - NSAttributedString - NSBundle - NSData - NSDictionary - NSError - NSException - and $N others + NSObject + __RcTestObject + objc2::runtime::Object = note: required for `RetainSemantics<1>` to implement `MsgSendId<&objc2::runtime::Class, Id>` error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied @@ -48,14 +43,9 @@ error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied | = help: the following other types implement trait `Message`: Exception - NSArray - NSAttributedString - NSBundle - NSData - NSDictionary - NSError - NSException - and $N others + NSObject + __RcTestObject + objc2::runtime::Object = note: required for `RetainSemantics<1>` to implement `MsgSendId<&objc2::runtime::Class, Id>` error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied @@ -87,14 +77,9 @@ error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied | = help: the following other types implement trait `Message`: Exception - NSArray - NSAttributedString - NSBundle - NSData - NSDictionary - NSError - NSException - and $N others + NSObject + __RcTestObject + objc2::runtime::Object = note: required for `RetainSemantics<2>` to implement `MsgSendId<&objc2::runtime::Class, Allocated>` error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Allocated<_>` diff --git a/crates/test-ui/ui/msg_send_super_not_classtype.stderr b/crates/test-ui/ui/msg_send_super_not_classtype.stderr index 915cbbd22..ac543fd94 100644 --- a/crates/test-ui/ui/msg_send_super_not_classtype.stderr +++ b/crates/test-ui/ui/msg_send_super_not_classtype.stderr @@ -8,15 +8,8 @@ error[E0277]: the trait bound `objc2::runtime::Object: ClassType` is not satisfi | required by a bound introduced by this call | = help: the following other types implement trait `ClassType`: - NSArray - NSAttributedString - NSBundle - NSData - NSDictionary - NSError - NSException - NSLock - and $N others + NSObject + __RcTestObject note: required by a bound in `__send_super_message_static` --> $WORKSPACE/crates/objc2/src/message/mod.rs | @@ -33,15 +26,8 @@ error[E0277]: the trait bound `objc2::runtime::Object: ClassType` is not satisfi | required by a bound introduced by this call | = help: the following other types implement trait `ClassType`: - NSArray - NSAttributedString - NSBundle - NSData - NSDictionary - NSError - NSException - NSLock - and $N others + NSObject + __RcTestObject note: required by a bound in `__send_super_message_static` --> $WORKSPACE/crates/objc2/src/message/mod.rs | diff --git a/crates/test-ui/ui/ns_string_not_const.rs b/crates/test-ui/ui/ns_string_not_const.rs index 30ff981c2..1e7885be1 100644 --- a/crates/test-ui/ui/ns_string_not_const.rs +++ b/crates/test-ui/ui/ns_string_not_const.rs @@ -1,4 +1,4 @@ -use objc2::ns_string; +use icrate::ns_string; fn main() { let s: &str = "abc"; diff --git a/crates/test-ui/ui/ns_string_output_not_const.rs b/crates/test-ui/ui/ns_string_output_not_const.rs index 28438403a..597ee36b6 100644 --- a/crates/test-ui/ui/ns_string_output_not_const.rs +++ b/crates/test-ui/ui/ns_string_output_not_const.rs @@ -1,5 +1,5 @@ use icrate::Foundation::NSString; -use objc2::ns_string; +use icrate::ns_string; fn main() { static STRING: &NSString = ns_string!("abc"); diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index a2e61a389..a9aac22b5 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -9,7 +9,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -objc2 = { path = "../crates/objc2", features = ["foundation"], default-features = false } +objc2 = { path = "../crates/objc2", default-features = false } [features] default = ["apple", "std"]