Skip to content

Commit f56d1ca

Browse files
committed
Fix objc2 imports in objc2::foundation
1 parent ac9fdbf commit f56d1ca

29 files changed

+104
-139
lines changed

objc2/src/foundation/array.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ use core::marker::PhantomData;
44
use core::ops::{Index, IndexMut, Range};
55
use core::panic::{RefUnwindSafe, UnwindSafe};
66

7-
use objc2::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId};
8-
use objc2::runtime::{Class, Object};
9-
use objc2::Message;
10-
use objc2::{msg_send, msg_send_id};
11-
127
use super::{
138
NSCopying, NSEnumerator, NSFastEnumeration, NSFastEnumerator, NSMutableArray, NSMutableCopying,
149
NSObject, NSRange,
1510
};
16-
use crate::__inner_extern_class;
11+
use crate::rc::{DefaultId, Id, Owned, Ownership, Shared, SliceId};
12+
use crate::runtime::{Class, Object};
13+
use crate::Message;
14+
use crate::{__inner_extern_class, msg_send, msg_send_id};
1715

1816
__inner_extern_class! {
1917
/// TODO
@@ -244,10 +242,9 @@ mod tests {
244242
use alloc::format;
245243
use alloc::vec::Vec;
246244

247-
use objc2::rc::autoreleasepool;
248-
249245
use super::*;
250246
use crate::foundation::{NSString, NSValue};
247+
use crate::rc::autoreleasepool;
251248

252249
fn sample_array(len: usize) -> Id<NSArray<NSObject, Owned>, Owned> {
253250
let mut vec = Vec::with_capacity(len);

objc2/src/foundation/attributed_string.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use core::fmt;
22
use core::panic::{RefUnwindSafe, UnwindSafe};
33

4-
use objc2::rc::{DefaultId, Id, Shared};
5-
use objc2::runtime::Object;
6-
use objc2::{msg_send, msg_send_id};
7-
84
use super::{
95
NSCopying, NSDictionary, NSMutableAttributedString, NSMutableCopying, NSObject, NSString,
106
};
11-
use crate::extern_class;
7+
use crate::rc::{DefaultId, Id, Shared};
8+
use crate::runtime::Object;
9+
use crate::{extern_class, msg_send, msg_send_id};
1210

1311
extern_class! {
1412
/// A string that has associated attributes for portions of its text.
@@ -145,9 +143,9 @@ impl fmt::Debug for NSAttributedString {
145143
mod tests {
146144
use alloc::string::ToString;
147145
use alloc::{format, vec};
148-
use objc2::rc::{autoreleasepool, Owned};
149146

150147
use super::*;
148+
use crate::rc::{autoreleasepool, Owned};
151149

152150
#[test]
153151
fn test_new() {

objc2/src/foundation/comparison_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::cmp::Ordering;
22

3-
use objc2::{Encode, Encoding, RefEncode};
3+
use crate::{Encode, Encoding, RefEncode};
44

55
/// Constants that indicate sort order.
66
///

objc2/src/foundation/copying.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use objc2::rc::{Id, Owned, Ownership};
2-
use objc2::{msg_send_id, Message};
1+
use crate::rc::{Id, Owned, Ownership};
2+
use crate::{msg_send_id, Message};
33

44
pub unsafe trait NSCopying: Message {
55
/// Indicates whether the type is mutable or immutable.

objc2/src/foundation/data.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use core::ops::Index;
66
use core::panic::{RefUnwindSafe, UnwindSafe};
77
use core::slice::{self, SliceIndex};
88

9-
use objc2::rc::{DefaultId, Id, Shared};
10-
use objc2::runtime::{Class, Object};
11-
use objc2::{msg_send, msg_send_id};
12-
139
use super::{NSCopying, NSMutableCopying, NSMutableData, NSObject};
14-
use crate::extern_class;
10+
use crate::rc::{DefaultId, Id, Shared};
11+
use crate::runtime::{Class, Object};
12+
use crate::{extern_class, msg_send, msg_send_id};
1513

1614
extern_class! {
1715
/// A static byte buffer in memory.
@@ -70,7 +68,7 @@ impl NSData {
7068
//
7169
// NSMutableData does not have this problem.
7270
#[cfg(feature = "gnustep-1-7")]
73-
let cls = objc2::class!(NSDataWithDeallocatorBlock);
71+
let cls = crate::class!(NSDataWithDeallocatorBlock);
7472
#[cfg(not(feature = "gnustep-1-7"))]
7573
let cls = Self::class();
7674

objc2/src/foundation/dictionary.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use core::ops::Index;
66
use core::panic::{RefUnwindSafe, UnwindSafe};
77
use core::ptr;
88

9-
use objc2::rc::{DefaultId, Id, Owned, Shared, SliceId};
10-
use objc2::{msg_send, msg_send_id, Message};
11-
129
use super::{NSArray, NSCopying, NSEnumerator, NSFastEnumeration, NSObject};
13-
use crate::__inner_extern_class;
10+
use crate::rc::{DefaultId, Id, Owned, Shared, SliceId};
11+
use crate::{__inner_extern_class, msg_send, msg_send_id, Message};
1412

1513
__inner_extern_class! {
1614
#[derive(PartialEq, Eq, Hash)]
@@ -173,10 +171,10 @@ impl<K: fmt::Debug + Message, V: fmt::Debug + Message> fmt::Debug for NSDictiona
173171
mod tests {
174172
use alloc::format;
175173
use alloc::vec;
176-
use objc2::rc::{autoreleasepool, Id, Shared};
177174

178-
use super::NSDictionary;
179-
use crate::foundation::{NSObject, NSString};
175+
use super::*;
176+
use crate::foundation::NSString;
177+
use crate::rc::autoreleasepool;
180178

181179
fn sample_dict(key: &str) -> Id<NSDictionary<NSString, NSObject>, Shared> {
182180
let string = NSString::from_str(key);

objc2/src/foundation/enumerator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use core::ptr;
44
use core::slice;
55
use std::os::raw::c_ulong;
66

7-
use objc2::rc::{Id, Owned};
8-
use objc2::runtime::Object;
9-
use objc2::{msg_send, Encode, Encoding, Message, RefEncode};
7+
use crate::rc::{Id, Owned};
8+
use crate::runtime::Object;
9+
use crate::{msg_send, Encode, Encoding, Message, RefEncode};
1010

1111
// TODO: https://doc.rust-lang.org/stable/reference/trait-bounds.html#lifetime-bounds
1212
pub struct NSEnumerator<'a, T: Message> {

objc2/src/foundation/exception.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ use core::fmt;
22
use core::hint::unreachable_unchecked;
33
use core::panic::{RefUnwindSafe, UnwindSafe};
44

5-
use objc2::exception::Exception;
6-
use objc2::rc::{Id, Shared};
7-
use objc2::runtime::Object;
8-
use objc2::{msg_send, msg_send_id, sel};
9-
105
use super::{NSCopying, NSDictionary, NSObject, NSString};
11-
use crate::extern_class;
6+
use crate::exception::Exception;
7+
use crate::rc::{Id, Shared};
8+
use crate::runtime::Object;
9+
use crate::{extern_class, msg_send, msg_send_id, sel};
1210

1311
extern_class! {
1412
/// A special condition that interrupts the normal flow of program

objc2/src/foundation/geometry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use objc2::{Encode, Encoding, RefEncode};
1+
use crate::{Encode, Encoding, RefEncode};
22

33
#[cfg(target_pointer_width = "64")]
44
type InnerFloat = f64;
@@ -313,7 +313,7 @@ mod tests {
313313
#[test]
314314
#[cfg(any(all(feature = "apple", target_os = "macos"), feature = "gnustep-1-7"))] // or macabi
315315
fn test_partial_eq() {
316-
use objc2::runtime::Bool;
316+
use crate::runtime::Bool;
317317

318318
// Note: No need to use "C-unwind"
319319
extern "C" {

objc2/src/foundation/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub use self::zone::NSZone;
5252
// Available under Foundation, so makes sense here as well:
5353
// https://developer.apple.com/documentation/foundation/numbers_data_and_basic_values?language=objc
5454
#[doc(no_inline)]
55-
pub use objc2::ffi::{NSInteger, NSUInteger};
55+
pub use crate::ffi::{NSInteger, NSUInteger};
5656

5757
#[cfg(feature = "apple")]
5858
#[link(name = "Foundation", kind = "framework")]
@@ -89,9 +89,9 @@ mod zone;
8989
#[cfg(test)]
9090
mod tests {
9191
use core::panic::{RefUnwindSafe, UnwindSafe};
92-
use objc2::rc::{Id, Owned, Shared};
9392

9493
use super::*;
94+
use crate::rc::{Id, Owned, Shared};
9595

9696
// We expect most Foundation types to be UnwindSafe and RefUnwindSafe,
9797
// since they follow Rust's usual mutability rules (&T = immutable).

0 commit comments

Comments
 (0)