Skip to content

Commit 4726ff5

Browse files
committed
Use objc2
1 parent 38bd899 commit 4726ff5

File tree

20 files changed

+53
-54
lines changed

20 files changed

+53
-54
lines changed

cocoa-foundation/Cargo.toml

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

1414
[dependencies]
15-
block = "0.1"
15+
block = { version = "=0.2.0-alpha.5", 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" }
20-
# Current `master` of objc
21-
objc = { version = "=0.3.0-alpha.0", package = "objc2" }
22-
objc-encode = "1.1.0"
20+
objc2 = { version = "=0.3.0-beta.1" }
21+
objc-encode = { version = "=2.0.0-pre.1", 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use base::{id, nil, BOOL, NO, SEL};
1313
use block::Block;
1414
use libc;
15-
use objc_encode::{Encode, Encoding};
15+
use objc_encode::{Encode, Encoding, RefEncode};
1616
use std::os::raw::c_void;
1717
use std::ptr;
1818

@@ -720,8 +720,8 @@ unsafe impl Encode for NSFastEnumerationState {
720720
);
721721
}
722722

723-
unsafe impl Encode for &'_ NSFastEnumerationState {
724-
const ENCODING: Encoding<'static> = Encoding::Pointer(&NSFastEnumerationState::ENCODING);
723+
unsafe impl RefEncode for NSFastEnumerationState {
724+
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING);
725725
}
726726

727727
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
@@ -17,7 +17,7 @@ extern crate core_graphics_types;
1717
extern crate libc;
1818
pub extern crate objc_encode;
1919
#[macro_use]
20-
extern crate objc;
20+
extern crate objc2;
2121

2222
pub use objc_encode as __objc_encode;
2323

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

@@ -164,16 +164,18 @@ mod foundation {
164164
}
165165

166166
// First test cocoa sorting...
167-
let mut comparator =
167+
let comparator =
168168
ConcreteBlock::new(|s0: id, s1: id| match compare_function(&s0, &s1) {
169169
Ordering::Less => NSComparisonResult::NSOrderedAscending,
170170
Ordering::Equal => NSComparisonResult::NSOrderedSame,
171171
Ordering::Greater => NSComparisonResult::NSOrderedDescending,
172172
});
173+
let comparator_ptr: *const _ = &*comparator;
174+
let comparator_ptr = comparator_ptr as *mut _;
173175

174176
let associated_iter = keys.iter().zip(objects.iter());
175177
for (k_id, (k, v)) in dict
176-
.keysSortedByValueUsingComparator_(&mut *comparator)
178+
.keysSortedByValueUsingComparator_(comparator_ptr)
177179
.iter()
178180
.zip(associated_iter)
179181
{

cocoa/Cargo.toml

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

1414
[dependencies]
15-
block = "0.1"
15+
block = { version = "=0.2.0-alpha.5", 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.23" }
2121
foreign-types = "0.5"
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.1" }
23+
objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" }

cocoa/examples/fullscreen.rs

Lines changed: 6 additions & 7 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::appkit::{
88
NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps,
@@ -17,8 +17,8 @@ use cocoa::foundation::{
1717

1818
use core_graphics::display::CGDisplay;
1919

20-
use objc::declare::ClassDecl;
21-
use objc::runtime::{Object, Sel};
20+
use objc2::declare::ClassDecl;
21+
use objc2::runtime::{Object, Sel};
2222

2323
fn main() {
2424
unsafe {
@@ -75,16 +75,15 @@ fn main() {
7575

7676
decl.add_method(
7777
sel!(window:willUseFullScreenPresentationOptions:),
78-
will_use_fillscreen_presentation_options
79-
as extern "C" fn(&Object, Sel, id, NSUInteger) -> NSUInteger,
78+
will_use_fillscreen_presentation_options as extern "C" fn(_, _, _, _) -> _,
8079
);
8180
decl.add_method(
8281
sel!(windowWillEnterFullScreen:),
83-
window_entering_fullscreen as extern "C" fn(&Object, Sel, id),
82+
window_entering_fullscreen as extern "C" fn(_, _, _),
8483
);
8584
decl.add_method(
8685
sel!(windowDidEnterFullScreen:),
87-
window_entering_fullscreen as extern "C" fn(&Object, Sel, id),
86+
window_entering_fullscreen as extern "C" fn(_, _, _),
8887
);
8988

9089
let delegate_class = decl.register();

cocoa/examples/nsvisualeffectview_blur.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate cocoa;
2-
extern crate objc;
2+
extern crate objc2;
33

44
use cocoa::base::{nil, selector, NO};
5-
use objc::*;
5+
use objc2::*;
66

77
use cocoa::appkit::{
88
NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSBackingStoreType, NSColor,

cocoa/src/appkit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ pub trait NSButton: Sized {
35363536
}
35373537
unsafe fn initWithFrame_(self, frameRect: NSRect) -> id;
35383538
unsafe fn setTarget_(self, target: id /* Instance */);
3539-
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance *) */);
3539+
unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance *) */);
35403540
}
35413541

35423542
impl NSButton for id {
@@ -3556,7 +3556,7 @@ impl NSButton for id {
35563556
msg_send![self, setTarget: target]
35573557
}
35583558

3559-
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance method *) */) {
3559+
unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance method *) */) {
35603560
msg_send![self, setAction: selector]
35613561
}
35623562
}

cocoa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern crate foreign_types;
2222
extern crate libc;
2323
extern crate objc_encode;
2424
#[macro_use]
25-
extern crate objc;
25+
extern crate objc2;
2626

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

0 commit comments

Comments
 (0)