From 088bde8a01058c546a99279c5c2815e671b09fa4 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 20 Jul 2022 05:15:53 +0200 Subject: [PATCH] Use objc2 --- cocoa-foundation/Cargo.toml | 7 +++---- cocoa-foundation/src/base.rs | 4 ++-- cocoa-foundation/src/foundation.rs | 7 +++---- cocoa-foundation/src/lib.rs | 2 +- cocoa-foundation/tests/foundation.rs | 8 +++++--- cocoa/Cargo.toml | 7 +++---- cocoa/examples/fullscreen.rs | 6 +++--- cocoa/src/appkit.rs | 4 ++-- cocoa/src/lib.rs | 2 +- cocoa/src/macros.rs | 6 +++--- cocoa/src/quartzcore.rs | 6 +++--- core-foundation-sys/Cargo.toml | 2 +- core-foundation-sys/src/array.rs | 4 ++-- core-foundation-sys/src/attributed_string.rs | 4 ++-- core-foundation-sys/src/dictionary.rs | 4 ++-- core-foundation-sys/src/string.rs | 4 ++-- core-graphics-types/Cargo.toml | 2 +- core-graphics/Cargo.toml | 2 +- core-graphics/src/sys.rs | 14 +++++++------- 19 files changed, 47 insertions(+), 48 deletions(-) diff --git a/cocoa-foundation/Cargo.toml b/cocoa-foundation/Cargo.toml index bfd5f3ba3..696a555e0 100644 --- a/cocoa-foundation/Cargo.toml +++ b/cocoa-foundation/Cargo.toml @@ -12,12 +12,11 @@ license = "MIT / Apache-2.0" default-target = "x86_64-apple-darwin" [dependencies] -block = "0.1" +block = { version = "=0.2.0-alpha.5", package = "block2" } bitflags = "1.0" libc = "0.2" core-foundation = { path = "../core-foundation", version = "0.9" } core-graphics-types = { path = "../core-graphics-types", version = "0.1" } foreign-types = "0.3" -# Current `master` of objc -objc = { version = "=0.3.0-alpha.0", package = "objc2" } -objc-encode = "1.1.0" +objc2 = { version = "=0.3.0-beta.1" } +objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" } diff --git a/cocoa-foundation/src/base.rs b/cocoa-foundation/src/base.rs index 028205e89..4cebe99b1 100644 --- a/cocoa-foundation/src/base.rs +++ b/cocoa-foundation/src/base.rs @@ -7,9 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use objc::runtime; +use objc2::runtime; -pub use objc::runtime::{BOOL, NO, YES}; +pub use objc2::runtime::{BOOL, NO, YES}; pub type Class = *mut runtime::Class; #[allow(non_camel_case_types)] diff --git a/cocoa-foundation/src/foundation.rs b/cocoa-foundation/src/foundation.rs index f085e6633..c2d8f3896 100644 --- a/cocoa-foundation/src/foundation.rs +++ b/cocoa-foundation/src/foundation.rs @@ -14,7 +14,7 @@ use std::os::raw::c_void; use base::{id, BOOL, NO, SEL, nil}; use block::Block; use libc; -use objc_encode::{Encode, Encoding}; +use objc_encode::{Encode, Encoding, RefEncode}; #[cfg(target_pointer_width = "32")] @@ -692,9 +692,8 @@ unsafe impl Encode for NSFastEnumerationState { ); } -unsafe impl Encode for &'_ NSFastEnumerationState { - const ENCODING: Encoding<'static> = - Encoding::Pointer(&NSFastEnumerationState::ENCODING); +unsafe impl RefEncode for NSFastEnumerationState { + const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING); } const NS_FAST_ENUM_BUF_SIZE: usize = 16; diff --git a/cocoa-foundation/src/lib.rs b/cocoa-foundation/src/lib.rs index 4b26760eb..cee00ef9f 100644 --- a/cocoa-foundation/src/lib.rs +++ b/cocoa-foundation/src/lib.rs @@ -18,7 +18,7 @@ extern crate foreign_types; extern crate libc; pub extern crate objc_encode; #[macro_use] -extern crate objc; +extern crate objc2; pub use objc_encode as __objc_encode; diff --git a/cocoa-foundation/tests/foundation.rs b/cocoa-foundation/tests/foundation.rs index ab6401bbb..e0a0de9c9 100644 --- a/cocoa-foundation/tests/foundation.rs +++ b/cocoa-foundation/tests/foundation.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate objc; +extern crate objc2; extern crate block; extern crate cocoa_foundation; @@ -160,16 +160,18 @@ mod foundation { } // First test cocoa sorting... - let mut comparator = ConcreteBlock::new(|s0: id, s1: id| { + let comparator = ConcreteBlock::new(|s0: id, s1: id| { match compare_function(&s0, &s1) { Ordering::Less => NSComparisonResult::NSOrderedAscending, Ordering::Equal => NSComparisonResult::NSOrderedSame, Ordering::Greater => NSComparisonResult::NSOrderedDescending, } }); + let comparator_ptr: *const _ = &*comparator; + let comparator_ptr = comparator_ptr as *mut _; let associated_iter = keys.iter().zip(objects.iter()); - for (k_id, (k, v)) in dict.keysSortedByValueUsingComparator_(&mut *comparator) + for (k_id, (k, v)) in dict.keysSortedByValueUsingComparator_(comparator_ptr) .iter() .zip(associated_iter) { assert!(k_id.isEqualToString(k)); diff --git a/cocoa/Cargo.toml b/cocoa/Cargo.toml index ac690ac09..c8c295f13 100644 --- a/cocoa/Cargo.toml +++ b/cocoa/Cargo.toml @@ -12,13 +12,12 @@ license = "MIT / Apache-2.0" default-target = "x86_64-apple-darwin" [dependencies] -block = "0.1" +block = { version = "=0.2.0-alpha.5", package = "block2" } bitflags = "1.0" libc = "0.2" cocoa-foundation = { path = "../cocoa-foundation", version = "0.1" } core-foundation = { path = "../core-foundation", version = "0.9" } core-graphics = { path = "../core-graphics", version = "0.22" } foreign-types = "0.3" -# Current `master` of objc -objc = { version = "=0.3.0-alpha.0", package = "objc2" } -objc-encode = "1.1.0" +objc2 = { version = "=0.3.0-beta.1" } +objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" } diff --git a/cocoa/examples/fullscreen.rs b/cocoa/examples/fullscreen.rs index c826a29ae..b64aad02e 100644 --- a/cocoa/examples/fullscreen.rs +++ b/cocoa/examples/fullscreen.rs @@ -2,7 +2,7 @@ extern crate cocoa; extern crate core_graphics; #[macro_use] -extern crate objc; +extern crate objc2; use cocoa::base::{selector, nil, NO, id}; use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo, @@ -14,8 +14,8 @@ use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, use core_graphics::display::CGDisplay; -use objc::runtime::{Object, Sel}; -use objc::declare::ClassDecl; +use objc2::runtime::{Object, Sel}; +use objc2::declare::ClassDecl; fn main() { unsafe { diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index ea2b39c59..0a7383f7f 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -3214,7 +3214,7 @@ pub trait NSButton: Sized { } unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; unsafe fn setTarget_(self, target: id /* Instance */); - unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance *) */); + unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance *) */); } impl NSButton for id { @@ -3234,7 +3234,7 @@ impl NSButton for id { msg_send![self, setTarget:target] } - unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance method *) */) { + unsafe fn setAction_(self, selector: objc2::runtime::Sel /* (Instance method *) */) { msg_send![self, setAction:selector] } } diff --git a/cocoa/src/lib.rs b/cocoa/src/lib.rs index b7c2c2d14..93a1571c2 100644 --- a/cocoa/src/lib.rs +++ b/cocoa/src/lib.rs @@ -23,7 +23,7 @@ extern crate foreign_types; extern crate libc; extern crate objc_encode; #[macro_use] -extern crate objc; +extern crate objc2; #[cfg(target_os = "macos")] pub mod appkit; diff --git a/cocoa/src/macros.rs b/cocoa/src/macros.rs index 77c6a16d3..58a4c6d94 100644 --- a/cocoa/src/macros.rs +++ b/cocoa/src/macros.rs @@ -13,12 +13,12 @@ /// # Example with NSWindowDelegate /// ``` no_run /// #[macro_use] extern crate cocoa; -/// #[macro_use] extern crate objc; +/// #[macro_use] extern crate objc2; /// /// use cocoa::appkit::NSWindow; /// use cocoa::base::{id, nil}; /// -/// use objc::runtime::{Object, Sel}; +/// use objc2::runtime::{Object, Sel}; /// /// # fn main() { /// unsafe { @@ -57,7 +57,7 @@ macro_rules! delegate { $( ($($sel:ident :)+) => $func:expr),* } ) => ({ - let mut decl = objc::declare::ClassDecl::new($name, class!(NSObject)).unwrap(); + let mut decl = objc2::declare::ClassDecl::new($name, class!(NSObject)).unwrap(); $( decl.add_ivar::<$var_type>(stringify!($var)); diff --git a/cocoa/src/quartzcore.rs b/cocoa/src/quartzcore.rs index 24d9e3e83..d8a935c00 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -1840,9 +1840,9 @@ unsafe impl ::objc_encode::Encode for CVTimeStamp { ); } -unsafe impl ::objc_encode::Encode for &'_ CVTimeStamp { - const ENCODING: ::objc_encode::Encoding<'static> = - ::objc_encode::Encoding::Pointer(&::ENCODING); +unsafe impl ::objc_encode::RefEncode for CVTimeStamp { + const ENCODING_REF: ::objc_encode::Encoding<'static> = + ::objc_encode::Encoding::Pointer(&::ENCODING); } pub type CVTimeStampFlags = u64; diff --git a/core-foundation-sys/Cargo.toml b/core-foundation-sys/Cargo.toml index c1a509408..e3dc47b52 100644 --- a/core-foundation-sys/Cargo.toml +++ b/core-foundation-sys/Cargo.toml @@ -8,7 +8,7 @@ authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" [dependencies] -objc-encode = "1.1.0" +objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" } [features] mac_os_10_7_support = [] # backwards compatibility diff --git a/core-foundation-sys/src/array.rs b/core-foundation-sys/src/array.rs index e29fd5e1f..fa94da432 100644 --- a/core-foundation-sys/src/array.rs +++ b/core-foundation-sys/src/array.rs @@ -35,8 +35,8 @@ pub struct __CFArray(c_void); pub type CFArrayRef = *const __CFArray; pub type CFMutableArrayRef = *mut __CFArray; -unsafe impl ::objc_encode::Encode for &'_ __CFArray { - const ENCODING: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; +unsafe impl ::objc_encode::RefEncode for __CFArray { + const ENCODING_REF: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; } extern { diff --git a/core-foundation-sys/src/attributed_string.rs b/core-foundation-sys/src/attributed_string.rs index 0b02e4915..5cafcc905 100644 --- a/core-foundation-sys/src/attributed_string.rs +++ b/core-foundation-sys/src/attributed_string.rs @@ -18,8 +18,8 @@ pub struct __CFAttributedString(c_void); pub type CFAttributedStringRef = *const __CFAttributedString; pub type CFMutableAttributedStringRef = *const __CFAttributedString; -unsafe impl ::objc_encode::Encode for &'_ __CFAttributedString { - const ENCODING: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; +unsafe impl ::objc_encode::RefEncode for __CFAttributedString { + const ENCODING_REF: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; } extern { diff --git a/core-foundation-sys/src/dictionary.rs b/core-foundation-sys/src/dictionary.rs index aadc9cf5d..801fff221 100644 --- a/core-foundation-sys/src/dictionary.rs +++ b/core-foundation-sys/src/dictionary.rs @@ -47,8 +47,8 @@ pub struct __CFDictionary(c_void); pub type CFDictionaryRef = *const __CFDictionary; pub type CFMutableDictionaryRef = *mut __CFDictionary; -unsafe impl ::objc_encode::Encode for &'_ __CFDictionary { - const ENCODING: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; +unsafe impl ::objc_encode::RefEncode for __CFDictionary { + const ENCODING_REF: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; } extern { diff --git a/core-foundation-sys/src/string.rs b/core-foundation-sys/src/string.rs index 78856b320..cb8b06897 100644 --- a/core-foundation-sys/src/string.rs +++ b/core-foundation-sys/src/string.rs @@ -192,8 +192,8 @@ pub struct __CFString(c_void); pub type CFStringRef = *const __CFString; -unsafe impl ::objc_encode::Encode for &'_ __CFString { - const ENCODING: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; +unsafe impl ::objc_encode::RefEncode for __CFString { + const ENCODING_REF: ::objc_encode::Encoding<'static> = ::objc_encode::Encoding::Object; } extern { diff --git a/core-graphics-types/Cargo.toml b/core-graphics-types/Cargo.toml index af75c610c..9a2e20deb 100644 --- a/core-graphics-types/Cargo.toml +++ b/core-graphics-types/Cargo.toml @@ -12,7 +12,7 @@ bitflags = "1.0" core-foundation = { path = "../core-foundation", version = "0.9" } foreign-types = "0.3.0" libc = "0.2" -objc-encode = "1.1.0" +objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" } [package.metadata.docs.rs] default-target = "x86_64-apple-darwin" diff --git a/core-graphics/Cargo.toml b/core-graphics/Cargo.toml index 202f1ce18..1cf777268 100644 --- a/core-graphics/Cargo.toml +++ b/core-graphics/Cargo.toml @@ -18,7 +18,7 @@ core-foundation = { path = "../core-foundation", version = "0.9" } core-graphics-types = { path = "../core-graphics-types", version = "0.1" } foreign-types = "0.3.0" libc = "0.2" -objc-encode = "1.1.0" +objc-encode = { version = "=2.0.0-pre.1", package = "objc2-encode" } [package.metadata.docs.rs] default-target = "x86_64-apple-darwin" diff --git a/core-graphics/src/sys.rs b/core-graphics/src/sys.rs index 80f24a13e..807630280 100644 --- a/core-graphics/src/sys.rs +++ b/core-graphics/src/sys.rs @@ -1,6 +1,6 @@ use std::os::raw::c_void; -use objc_encode::{Encode, Encoding}; +use objc_encode::{Encoding, RefEncode}; pub enum CGImage {} pub type CGImageRef = *mut CGImage; @@ -8,8 +8,8 @@ pub type CGImageRef = *mut CGImage; #[repr(C)] pub struct __CGColor(c_void); -unsafe impl Encode for &'_ __CGColor { - const ENCODING: Encoding<'static> = Encoding::Unknown; +unsafe impl RefEncode for __CGColor { + const ENCODING_REF: Encoding<'static> = Encoding::Unknown; } pub type CGColorRef = *const __CGColor; @@ -20,8 +20,8 @@ pub type CGColorSpaceRef = *mut CGColorSpace; pub enum CGPath {} pub type CGPathRef = *mut CGPath; -unsafe impl Encode for &'_ CGPath { - const ENCODING: Encoding<'static> = Encoding::Unknown; +unsafe impl RefEncode for CGPath { + const ENCODING_REF: Encoding<'static> = Encoding::Unknown; } pub enum CGDataProvider {} @@ -33,8 +33,8 @@ pub type CGFontRef = *mut CGFont; pub enum CGContext {} pub type CGContextRef = *mut CGContext; -unsafe impl Encode for &'_ CGContext { - const ENCODING: Encoding<'static> = Encoding::Unknown; +unsafe impl RefEncode for CGContext { + const ENCODING_REF: Encoding<'static> = Encoding::Unknown; } pub enum CGGradient {}