Skip to content

Commit

Permalink
More idiomatic usage of objc2
Browse files Browse the repository at this point in the history
Changes argument and return types that were previously BOOL to bool
  • Loading branch information
madsmtm committed Aug 29, 2022
1 parent c6dc521 commit 01bc687
Show file tree
Hide file tree
Showing 9 changed files with 571 additions and 582 deletions.
1 change: 1 addition & 0 deletions cocoa-foundation/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use objc2::runtime;

#[allow(deprecated)]
pub use objc2::runtime::{BOOL, NO, YES};

pub type Class = *mut runtime::Class;
Expand Down
275 changes: 138 additions & 137 deletions cocoa-foundation/src/foundation.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cocoa/examples/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate cocoa;

use cocoa::base::{selector, id, nil, NO};
use cocoa::base::{selector, id, nil};

use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
NSString};
Expand Down Expand Up @@ -78,7 +78,7 @@ unsafe fn create_window(title: id, color: id) -> id {
NSWindowStyleMask::NSMiniaturizableWindowMask |
NSWindowStyleMask::NSUnifiedTitleAndToolbarWindowMask,
NSBackingStoreType::NSBackingStoreBuffered,
NO
false
).autorelease();

window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));
Expand Down
8 changes: 4 additions & 4 deletions cocoa/examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate core_graphics;
#[macro_use]
extern crate objc2;

use cocoa::base::{selector, nil, NO, id};
use cocoa::base::{selector, nil, id};
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
NSString, NSUInteger};
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow,
Expand All @@ -15,7 +15,7 @@ use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular,
use core_graphics::display::CGDisplay;

use objc2::runtime::{Object, Sel};
use objc2::declare::ClassDecl;
use objc2::declare::ClassBuilder;

fn main() {
unsafe {
Expand Down Expand Up @@ -45,7 +45,7 @@ fn main() {

// Create NSWindowDelegate
let superclass = class!(NSObject);
let mut decl = ClassDecl::new("MyWindowDelegate", superclass).unwrap();
let mut decl = ClassBuilder::new("MyWindowDelegate", superclass).unwrap();

extern fn will_use_fillscreen_presentation_options(_: &Object, _: Sel, _: id, _: NSUInteger) -> NSUInteger {
// Set initial presentation options for fullscreen
Expand Down Expand Up @@ -81,7 +81,7 @@ fn main() {
.initWithContentRect_styleMask_backing_defer_(NSRect::new(NSPoint::new(0., 0.), size),
NSWindowStyleMask::NSTitledWindowMask,
NSBackingStoreBuffered,
NO)
false)
.autorelease();
window.setDelegate_(delegate_object);
let title = NSString::alloc(nil).init_str("Fullscreen!");
Expand Down
4 changes: 2 additions & 2 deletions cocoa/examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate cocoa;

use cocoa::base::{selector, nil, NO};
use cocoa::base::{selector, nil};
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
NSString};
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow,
Expand Down Expand Up @@ -39,7 +39,7 @@ fn main() {
NSSize::new(200., 200.)),
NSWindowStyleMask::NSTitledWindowMask,
NSBackingStoreBuffered,
NO)
false)
.autorelease();
window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));
window.center();
Expand Down
4 changes: 2 additions & 2 deletions cocoa/examples/tab_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate cocoa;

use cocoa::base::{selector, id, nil, NO};
use cocoa::base::{selector, id, nil};


use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
Expand Down Expand Up @@ -71,7 +71,7 @@ unsafe fn create_app(title: id, content: id) -> id {
NSWindowStyleMask::NSMiniaturizableWindowMask |
NSWindowStyleMask::NSUnifiedTitleAndToolbarWindowMask,
NSBackingStoreType::NSBackingStoreBuffered,
NO
false
).autorelease();
window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));
window.center();
Expand Down
Loading

0 comments on commit 01bc687

Please sign in to comment.