Skip to content

Commit

Permalink
Update to objc2 v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 31, 2023
1 parent e821678 commit bfcc2b3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cocoa-foundation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ license = "MIT OR Apache-2.0"
default-target = "x86_64-apple-darwin"

[dependencies]
block2 = "0.2.0"
block2 = "0.3.0"
bitflags = "1.0"
libc = "0.2"
core-foundation = { path = "../core-foundation", version = "0.9" }
core-graphics-types = { path = "../core-graphics-types", version = "0.1", features = ["objc2"] }
objc2 = "0.4.0"
objc2 = "0.4.1"
4 changes: 2 additions & 2 deletions cocoa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ license = "MIT OR Apache-2.0"
default-target = "x86_64-apple-darwin"

[dependencies]
block2 = "0.2.0"
block2 = "0.3.0"
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.23" }
foreign-types = "0.5"
objc2 = "0.4.0"
objc2 = { version = "0.4.1", features = ["relax-void-encoding"] }
6 changes: 3 additions & 3 deletions cocoa/examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cocoa::foundation::{
use core_graphics::display::CGDisplay;

use objc2::declare::ClassBuilder;
use objc2::runtime::{Object, Sel};
use objc2::runtime::{AnyObject, Sel};
use objc2::{class, msg_send, sel};

fn main() {
Expand Down Expand Up @@ -50,7 +50,7 @@ fn main() {
let mut decl = ClassBuilder::new("MyWindowDelegate", superclass).unwrap();

extern "C" fn will_use_fillscreen_presentation_options(
_: &Object,
_: &AnyObject,
_: Sel,
_: id,
_: NSUInteger,
Expand All @@ -63,7 +63,7 @@ fn main() {
options.bits()
}

extern "C" fn window_entering_fullscreen(_: &Object, _: Sel, _: id) {
extern "C" fn window_entering_fullscreen(_: &AnyObject, _: Sel, _: id) {
// Reset HideDock and HideMenuBar settings during/after we entered fullscreen.
let options = NSApplicationPresentationOptions::NSApplicationPresentationHideDock
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar;
Expand Down
20 changes: 7 additions & 13 deletions cocoa/src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use foundation::{
NSInteger, NSPoint, NSRange, NSRect, NSRectEdge, NSSize, NSTimeInterval, NSUInteger,
};
use libc;
use objc2::encode::{Encode, Encoding};

pub use core_graphics::base::CGFloat;
pub use core_graphics::geometry::CGPoint;
Expand Down Expand Up @@ -4581,13 +4580,6 @@ pub trait NSColorSpace: Sized {
unsafe fn localizedName(self) -> id;
}

#[repr(transparent)]
struct CGColorSpaceRef(*const c_void);

unsafe impl Encode for CGColorSpaceRef {
const ENCODING: Encoding = Encoding::Pointer(&Encoding::Struct("CGColorSpace", &[]));
}

impl NSColorSpace for id {
unsafe fn deviceRGBColorSpace(_: Self) -> id {
msg_send![class!(NSColorSpace), deviceRGBColorSpace]
Expand Down Expand Up @@ -4630,12 +4622,14 @@ impl NSColorSpace for id {
msg_send![class!(NSColorSpace), alloc]
}

unsafe fn initWithCGColorSpace_(self, cg_color_space: *const c_void) -> id {
msg_send![self, initWithCGColorSpace: CGColorSpaceRef(cg_color_space)]
unsafe fn initWithCGColorSpace_(
self,
cg_color_space: *const c_void, /* (CGColorSpaceRef) */
) -> id {
msg_send![self, initWithCGColorSpace: cg_color_space]
}
unsafe fn CGColorSpace(self) -> *const c_void {
let res: CGColorSpaceRef = msg_send![self, CGColorSpace];
res.0
unsafe fn CGColorSpace(self) -> *const c_void /* (CGColorSpaceRef) */ {
msg_send![self, CGColorSpace]
}
unsafe fn localizedName(self) -> id {
msg_send![self, localizedName]
Expand Down
2 changes: 1 addition & 1 deletion core-graphics-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
bitflags = "1.0"
core-foundation = { path = "../core-foundation", version = "0.9" }
libc = "0.2"
objc2 = { version = "0.4.0", optional = true }
objc2 = { version = "0.4.1", optional = true }

[package.metadata.docs.rs]
default-target = "x86_64-apple-darwin"

0 comments on commit bfcc2b3

Please sign in to comment.