Skip to content

Commit 0826a96

Browse files
committed
Use objc2
1 parent f4c24f2 commit 0826a96

File tree

19 files changed

+47
-48
lines changed

19 files changed

+47
-48
lines changed

cocoa-foundation/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ license = "MIT / Apache-2.0"
1212
default-target = "x86_64-apple-darwin"
1313

1414
[dependencies]
15-
block = "0.1"
15+
block = { version = "=0.2.0-alpha.4", package = "block2" }
1616
bitflags = "1.0"
1717
libc = "0.2"
1818
core-foundation = { path = "../core-foundation", version = "0.9" }
1919
core-graphics-types = { path = "../core-graphics-types", version = "0.1" }
2020
foreign-types = "0.3"
21-
# Current `master` of objc
22-
objc = { version = "=0.3.0-alpha.0", package = "objc2" }
23-
objc-encode = "1.1.0"
21+
objc2 = { version = "=0.3.0-beta.0" }
22+
objc-encode = { version = "=2.0.0-pre.0", package = "objc2-encode" }

cocoa-foundation/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
use objc::runtime;
10+
use objc2::runtime;
1111

12-
pub use objc::runtime::{BOOL, NO, YES};
12+
pub use objc2::runtime::{BOOL, NO, YES};
1313

1414
pub type Class = *mut runtime::Class;
1515
#[allow(non_camel_case_types)]

cocoa-foundation/src/foundation.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::os::raw::c_void;
1414
use base::{id, BOOL, NO, SEL, nil};
1515
use block::Block;
1616
use libc;
17-
use objc_encode::{Encode, Encoding};
17+
use objc_encode::{Encode, Encoding, RefEncode};
1818

1919

2020
#[cfg(target_pointer_width = "32")]
@@ -692,9 +692,8 @@ unsafe impl Encode for NSFastEnumerationState {
692692
);
693693
}
694694

695-
unsafe impl Encode for &'_ NSFastEnumerationState {
696-
const ENCODING: Encoding<'static> =
697-
Encoding::Pointer(&NSFastEnumerationState::ENCODING);
695+
unsafe impl RefEncode for NSFastEnumerationState {
696+
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING);
698697
}
699698

700699
const NS_FAST_ENUM_BUF_SIZE: usize = 16;

cocoa-foundation/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern crate foreign_types;
1818
extern crate libc;
1919
pub extern crate objc_encode;
2020
#[macro_use]
21-
extern crate objc;
21+
extern crate objc2;
2222

2323
pub use objc_encode as __objc_encode;
2424

cocoa-foundation/tests/foundation.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[macro_use]
2-
extern crate objc;
2+
extern crate objc2;
33
extern crate block;
44
extern crate cocoa_foundation;
55

@@ -160,16 +160,18 @@ mod foundation {
160160
}
161161

162162
// First test cocoa sorting...
163-
let mut comparator = ConcreteBlock::new(|s0: id, s1: id| {
163+
let comparator = ConcreteBlock::new(|s0: id, s1: id| {
164164
match compare_function(&s0, &s1) {
165165
Ordering::Less => NSComparisonResult::NSOrderedAscending,
166166
Ordering::Equal => NSComparisonResult::NSOrderedSame,
167167
Ordering::Greater => NSComparisonResult::NSOrderedDescending,
168168
}
169169
});
170+
let comparator_ptr: *const _ = &*comparator;
171+
let comparator_ptr = comparator_ptr as *mut _;
170172

171173
let associated_iter = keys.iter().zip(objects.iter());
172-
for (k_id, (k, v)) in dict.keysSortedByValueUsingComparator_(&mut *comparator)
174+
for (k_id, (k, v)) in dict.keysSortedByValueUsingComparator_(comparator_ptr)
173175
.iter()
174176
.zip(associated_iter) {
175177
assert!(k_id.isEqualToString(k));

cocoa/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ license = "MIT / Apache-2.0"
1212
default-target = "x86_64-apple-darwin"
1313

1414
[dependencies]
15-
block = "0.1"
15+
block = { version = "=0.2.0-alpha.4", package = "block2" }
1616
bitflags = "1.0"
1717
libc = "0.2"
1818
cocoa-foundation = { path = "../cocoa-foundation", version = "0.1" }
1919
core-foundation = { path = "../core-foundation", version = "0.9" }
2020
core-graphics = { path = "../core-graphics", version = "0.22" }
2121
foreign-types = "0.3"
22-
# Current `master` of objc
23-
objc = { version = "=0.3.0-alpha.0", package = "objc2" }
24-
objc-encode = "1.1.0"
22+
objc2 = { version = "=0.3.0-beta.0" }
23+
objc-encode = { version = "=2.0.0-pre.0", package = "objc2-encode" }

cocoa/examples/fullscreen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate cocoa;
22
extern crate core_graphics;
33

44
#[macro_use]
5-
extern crate objc;
5+
extern crate objc2;
66

77
use cocoa::base::{selector, nil, NO, id};
88
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
@@ -14,8 +14,8 @@ use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular,
1414

1515
use core_graphics::display::CGDisplay;
1616

17-
use objc::runtime::{Object, Sel};
18-
use objc::declare::ClassDecl;
17+
use objc2::runtime::{Object, Sel};
18+
use objc2::declare::ClassDecl;
1919

2020
fn main() {
2121
unsafe {

cocoa/src/appkit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ pub trait NSButton: Sized {
32143214
}
32153215
unsafe fn initWithFrame_(self, frameRect: NSRect) -> id;
32163216
unsafe fn setTarget_(self, target: id /* Instance */);
3217-
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance *) */);
3217+
unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance *) */);
32183218
}
32193219

32203220
impl NSButton for id {
@@ -3234,7 +3234,7 @@ impl NSButton for id {
32343234
msg_send![self, setTarget:target]
32353235
}
32363236

3237-
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance method *) */) {
3237+
unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance method *) */) {
32383238
msg_send![self, setAction:selector]
32393239
}
32403240
}

cocoa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern crate foreign_types;
2323
extern crate libc;
2424
extern crate objc_encode;
2525
#[macro_use]
26-
extern crate objc;
26+
extern crate objc2;
2727

2828
#[cfg(target_os = "macos")]
2929
pub mod appkit;

cocoa/src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
/// # Example with NSWindowDelegate
1414
/// ``` no_run
1515
/// #[macro_use] extern crate cocoa;
16-
/// #[macro_use] extern crate objc;
16+
/// #[macro_use] extern crate objc2;
1717
///
1818
/// use cocoa::appkit::NSWindow;
1919
/// use cocoa::base::{id, nil};
2020
///
21-
/// use objc::runtime::{Object, Sel};
21+
/// use objc2::runtime::{Object, Sel};
2222
///
2323
/// # fn main() {
2424
/// unsafe {
@@ -57,7 +57,7 @@ macro_rules! delegate {
5757
$( ($($sel:ident :)+) => $func:expr),*
5858
}
5959
) => ({
60-
let mut decl = objc::declare::ClassDecl::new($name, class!(NSObject)).unwrap();
60+
let mut decl = objc2::declare::ClassDecl::new($name, class!(NSObject)).unwrap();
6161

6262
$(
6363
decl.add_ivar::<$var_type>(stringify!($var));

0 commit comments

Comments
 (0)