Skip to content

Commit

Permalink
Remove old internal Foundation re-export
Browse files Browse the repository at this point in the history
This was used back when the crates were called `icrate`, but now that
they are split, it no longer makes sense.
  • Loading branch information
madsmtm committed Sep 12, 2024
1 parent ec058b3 commit dfb7562
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! `utf16_lit`, `windows`, `const_utf16`, `wide-literals`, ...
use core::ffi::c_void;

use crate::Foundation::NSString;
use crate::NSString;
use objc2::runtime::AnyClass;

// This is defined in CoreFoundation, but we don't emit a link attribute
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/attributed_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::panic::{RefUnwindSafe, UnwindSafe};
use objc2::rc::Retained;
use objc2::AllocAnyThread;

use crate::Foundation::*;
use crate::*;

// Same reasoning as `NSString`.
impl UnwindSafe for NSAttributedString {}
Expand Down
6 changes: 3 additions & 3 deletions framework-crates/objc2-foundation/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use core::fmt;
use core::panic::{RefUnwindSafe, UnwindSafe};

use crate::Foundation::NSBundle;
use crate::NSBundle;

impl UnwindSafe for NSBundle {}
impl RefUnwindSafe for NSBundle {}

impl NSBundle {
#[cfg(feature = "NSString")]
#[cfg(feature = "NSDictionary")]
pub fn name(&self) -> Option<objc2::rc::Retained<crate::Foundation::NSString>> {
use crate::{ns_string, Foundation::NSString};
pub fn name(&self) -> Option<objc2::rc::Retained<crate::NSString>> {
use crate::{ns_string, NSString};
use objc2::rc::Retained;

let info = self.infoDictionary()?;
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use objc2::rc::Retained;
use objc2::rc::RetainedFromIterator;
use objc2::{extern_methods, AllocAnyThread};

use crate::Foundation::{NSData, NSMutableData};
use crate::{NSData, NSMutableData};

impl UnwindSafe for NSData {}
impl RefUnwindSafe for NSData {}
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use core::fmt;
use core::panic::{RefUnwindSafe, UnwindSafe};

use crate::Foundation::NSError;
use crate::NSError;

impl UnwindSafe for NSError {}
impl RefUnwindSafe for NSError {}
Expand Down
8 changes: 4 additions & 4 deletions framework-crates/objc2-foundation/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use objc2::rc::Retained;
use objc2::runtime::{NSObject, NSObjectProtocol};
use objc2::{extern_methods, sel};

use crate::Foundation::NSException;
use crate::NSException;

// SAFETY: Exception objects are immutable data containers, and documented as
// thread safe.
Expand All @@ -33,9 +33,9 @@ impl NSException {
#[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
#[cfg(feature = "NSDictionary")]
pub fn new(
name: &crate::Foundation::NSExceptionName,
reason: Option<&crate::Foundation::NSString>,
user_info: Option<&crate::Foundation::NSDictionary>,
name: &crate::NSExceptionName,
reason: Option<&crate::NSString>,
user_info: Option<&crate::NSDictionary>,
) -> Option<Retained<Self>> {
use objc2::AllocAnyThread;

Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ mod tests {
))]
#[cfg(feature = "NSGeometry")]
fn test_partial_eq() {
use crate::Foundation::{NSEqualPoints, NSEqualRects, NSEqualSizes};
use crate::{NSEqualPoints, NSEqualRects, NSEqualSizes};

// We assume that comparisons handle e.g. `x` and `y` in the same way,
// therefore we set the coordinates / dimensions to the same.
Expand Down
7 changes: 3 additions & 4 deletions framework-crates/objc2-foundation/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use objc2::runtime::ProtocolObject;
use objc2::ClassType;
use objc2::Message;

use crate::Foundation::{NSFastEnumeration, NSFastEnumerationState};
use crate::{NSFastEnumeration, NSFastEnumerationState};

/// Swift and Objective-C both have a stack buffer size of 16, so we do that
/// as well.
Expand Down Expand Up @@ -654,11 +654,10 @@ macro_rules! __impl_into_iter {
#[cfg(feature = "NSValue")]
mod tests {
use alloc::vec::Vec;

use super::*;
use core::mem::size_of;

use crate::Foundation::{NSArray, NSNumber};
use super::*;
use crate::{NSArray, NSNumber};

#[test]
#[cfg_attr(
Expand Down
6 changes: 0 additions & 6 deletions framework-crates/objc2-foundation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,3 @@ pub(crate) type FourCharCode = u32;
pub type OSType = FourCharCode;
#[allow(unused)]
pub(crate) type UTF32Char = u32; // Or maybe Rust's char?

// Temporary
#[allow(non_snake_case, unused, unreachable_pub)]
mod Foundation {
pub use crate::*;
}
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/macros/ns_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
///
/// Equivalent to the [boxed C-strings] `@"string"` syntax in Objective-C.
///
/// [`NSString`]: crate::Foundation::NSString
/// [`NSString`]: crate::NSString
/// [boxed C-strings]: https://clang.llvm.org/docs/ObjectiveCLiterals.html#boxed-c-strings
///
///
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/ns_consumed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern "C" {
#[cfg(feature = "NSMapTable")]
pub fn NSFreeMapTable(table: *mut crate::Foundation::NSMapTable);
pub fn NSFreeMapTable(table: *mut crate::NSMapTable);
}

// TODO: Add `-[NSKeyedUnarchiverDelegate unarchiver:didDecodeObject:]`
6 changes: 3 additions & 3 deletions framework-crates/objc2-foundation/src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use core::panic::{RefUnwindSafe, UnwindSafe};
use objc2::encode::Encoding;
use objc2::rc::Retained;

use crate::Foundation::NSNumber;
use crate::NSNumber;

impl UnwindSafe for NSNumber {}
impl RefUnwindSafe for NSNumber {}
Expand Down Expand Up @@ -61,7 +61,7 @@ impl NSNumber {

#[inline]
#[cfg(feature = "NSGeometry")]
pub fn new_cgfloat(val: crate::Foundation::CGFloat) -> Retained<Self> {
pub fn new_cgfloat(val: crate::CGFloat) -> Retained<Self> {
#[cfg(target_pointer_width = "64")]
{
Self::new_f64(val)
Expand Down Expand Up @@ -105,7 +105,7 @@ impl NSNumber {

#[inline]
#[cfg(feature = "NSGeometry")]
pub fn as_cgfloat(&self) -> crate::Foundation::CGFloat {
pub fn as_cgfloat(&self) -> crate::CGFloat {
#[cfg(target_pointer_width = "64")]
{
self.as_f64()
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/process_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use core::fmt;
use core::panic::{RefUnwindSafe, UnwindSafe};

use crate::Foundation::NSProcessInfo;
use crate::NSProcessInfo;

// SAFETY: The documentation explicitly states:
// > NSProcessInfo is thread-safe in macOS 10.7 and later.
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::ops::Range;

use objc2::encode::{Encode, Encoding, RefEncode};

use crate::Foundation::NSUInteger;
use crate::NSUInteger;

/// TODO.
///
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl NSString {
///
/// Prefer using the [`ns_string!`] macro when possible.
///
/// [`ns_string!`]: crate::Foundation::ns_string
/// [`ns_string!`]: crate::ns_string
#[doc(alias = "initWithBytes")]
#[doc(alias = "initWithBytes:length:encoding:")]
#[allow(clippy::should_implement_trait)] // Not really sure of a better name
Expand Down
16 changes: 8 additions & 8 deletions framework-crates/objc2-foundation/src/tests/attributed_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloc::string::ToString;
use objc2::rc::{autoreleasepool, Retained};
use objc2::runtime::AnyObject;

use crate::Foundation::{self, ns_string, NSAttributedString, NSObject, NSString};
use crate::{ns_string, NSAttributedString, NSMutableAttributedString, NSObject, NSString};

#[test]
fn test_new() {
Expand All @@ -32,7 +32,7 @@ fn test_from_nsstring() {

#[test]
fn test_copy() {
use Foundation::{NSCopying, NSMutableCopying, NSObjectProtocol};
use crate::{NSCopying, NSMutableCopying, NSObjectProtocol};

let s1 = NSAttributedString::from_nsstring(ns_string!("abc"));
let s2 = s1.copy();
Expand All @@ -43,7 +43,7 @@ fn test_copy() {

let s3 = s1.mutableCopy();
assert_ne!(Retained::as_ptr(&s1), Retained::as_ptr(&s3).cast());
assert!(s3.is_kind_of::<Foundation::NSMutableAttributedString>());
assert!(s3.is_kind_of::<NSMutableAttributedString>());
}

#[test]
Expand All @@ -62,7 +62,7 @@ fn test_debug() {
let s = unsafe {
NSAttributedString::new_with_attributes(
ns_string!("abc"),
&Foundation::NSDictionary::from_retained_objects(&[ns_string!("test")], &[obj]),
&crate::NSDictionary::from_retained_objects(&[ns_string!("test")], &[obj]),
)
};
let expected = if cfg!(feature = "gnustep-1-7") {
Expand All @@ -75,7 +75,7 @@ fn test_debug() {

#[test]
fn test_new_mutable() {
let s = Foundation::NSMutableAttributedString::new();
let s = NSMutableAttributedString::new();
assert_eq!(&s.string().to_string(), "");
}

Expand All @@ -85,14 +85,14 @@ fn test_new_mutable() {
ignore = "thread safety issues regarding initialization"
)]
fn test_copy_mutable() {
use Foundation::{NSCopying, NSMutableCopying, NSObjectProtocol};
use crate::{NSCopying, NSMutableCopying, NSObjectProtocol};

let s1 = Foundation::NSMutableAttributedString::from_nsstring(ns_string!("abc"));
let s1 = NSMutableAttributedString::from_nsstring(ns_string!("abc"));
let s2 = s1.copy();
assert_ne!(Retained::as_ptr(&s1).cast(), Retained::as_ptr(&s2));
assert!(s2.is_kind_of::<NSAttributedString>());

let s3 = s1.mutableCopy();
assert_ne!(Retained::as_ptr(&s1), Retained::as_ptr(&s3));
assert!(s3.is_kind_of::<Foundation::NSMutableAttributedString>());
assert!(s3.is_kind_of::<NSMutableAttributedString>());
}
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "NSBundle")]
use alloc::format;

use crate::Foundation::NSBundle;
use crate::NSBundle;

#[test]
#[cfg(feature = "NSString")]
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "NSData")]
use alloc::{format, vec};

use crate::Foundation::NSData;
use crate::NSData;

#[test]
fn test_bytes() {
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![cfg(feature = "NSString")]
use alloc::format;

use crate::Foundation::{ns_string, NSCocoaErrorDomain, NSError};
use crate::{ns_string, NSCocoaErrorDomain, NSError};

#[test]
fn basic() {
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(feature = "NSLock")]
use crate::Foundation::{NSLock, NSLocking};
use crate::{NSLock, NSLocking};

#[test]
fn lock_unlock() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(feature = "NSData")]

use crate::Foundation::{NSData, NSMutableData};
use crate::{NSData, NSMutableData};

#[test]
fn test_bytes_mut() {
Expand Down
6 changes: 3 additions & 3 deletions framework-crates/objc2-foundation/src/tests/mutable_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use core::any::TypeId;
use core::fmt::Write;
use objc2::runtime::NSObject;

use crate::Foundation::{NSMutableString, NSString};
use crate::{CopyingHelper, MutableCopyingHelper};
use crate::{NSMutableString, NSString};

#[test]
fn display_debug() {
Expand Down Expand Up @@ -50,7 +50,7 @@ fn test_with_capacity() {
#[test]
#[cfg(feature = "NSObject")]
fn test_copy() {
use crate::Foundation::{NSCopying, NSMutableCopying, NSObjectProtocol};
use crate::{NSCopying, NSMutableCopying, NSObjectProtocol};
use objc2::rc::Retained;

let s1 = NSMutableString::from_str("abc");
Expand Down Expand Up @@ -87,7 +87,7 @@ fn counterpart() {
#[test]
#[cfg(all(feature = "NSObject", feature = "NSZone"))]
fn test_copy_with_zone() {
use crate::Foundation::{NSCopying, NSMutableCopying, NSObjectProtocol};
use crate::{NSCopying, NSMutableCopying, NSObjectProtocol};
use objc2::rc::Retained;

let s1 = NSString::from_str("abc");
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/number.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "NSValue")]
use alloc::format;

use crate::Foundation::NSNumber;
use crate::NSNumber;

#[test]
fn basic() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![cfg(feature = "NSProcessInfo")]
use alloc::format;

use crate::Foundation::NSProcessInfo;
use crate::NSProcessInfo;

#[test]
fn debug() {
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(feature = "NSProxy")]
use crate::Foundation::NSProxy;
use crate::NSProxy;
use objc2::ClassType;

#[test]
Expand Down
6 changes: 3 additions & 3 deletions framework-crates/objc2-foundation/src/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::string::ToString;

use objc2::rc::autoreleasepool;

use crate::Foundation::{ns_string, NSString};
use crate::{ns_string, NSString};

#[test]
fn test_equality() {
Expand Down Expand Up @@ -79,7 +79,7 @@ fn test_interior_nul() {
#[test]
#[cfg(feature = "NSObject")]
fn test_copy() {
use crate::Foundation::{NSCopying, NSMutableCopying, NSMutableString, NSObjectProtocol};
use crate::{NSCopying, NSMutableCopying, NSMutableString, NSObjectProtocol};
use objc2::rc::Retained;

let s1 = NSString::from_str("abc");
Expand All @@ -96,7 +96,7 @@ fn test_copy() {
#[test]
#[cfg(feature = "NSObject")]
fn test_copy_nsstring_is_same() {
use crate::Foundation::NSCopying;
use crate::NSCopying;

let string1 = NSString::from_str("Hello, world!");
let string2 = string1.copy();
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-foundation/src/tests/uuid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "NSUUID")]
use alloc::format;

use crate::Foundation::NSUUID;
use crate::NSUUID;
use objc2::rc::Retained;

#[test]
Expand Down
Loading

0 comments on commit dfb7562

Please sign in to comment.