Skip to content

Commit 4f2298f

Browse files
committed
More idiomatic usage of objc2
Changes argument and return types that were previously BOOL to bool
1 parent 923e6e4 commit 4f2298f

File tree

9 files changed

+651
-660
lines changed

9 files changed

+651
-660
lines changed

cocoa-foundation/src/base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use objc2::runtime;
1111

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

1415
pub type Class = *mut runtime::Class;

cocoa-foundation/src/foundation.rs

+149-148
Large diffs are not rendered by default.

cocoa/examples/color.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate cocoa;
22

3-
use cocoa::base::{selector, id, nil, NO};
3+
use cocoa::base::{selector, id, nil};
44

55
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
66
NSString};
@@ -78,7 +78,7 @@ unsafe fn create_window(title: id, color: id) -> id {
7878
NSWindowStyleMask::NSMiniaturizableWindowMask |
7979
NSWindowStyleMask::NSUnifiedTitleAndToolbarWindowMask,
8080
NSBackingStoreType::NSBackingStoreBuffered,
81-
NO
81+
false
8282
).autorelease();
8383

8484
window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));

cocoa/examples/fullscreen.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate core_graphics;
44
#[macro_use]
55
extern crate objc2;
66

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

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

2020
fn main() {
2121
unsafe {
@@ -45,7 +45,7 @@ fn main() {
4545

4646
// Create NSWindowDelegate
4747
let superclass = class!(NSObject);
48-
let mut decl = ClassDecl::new("MyWindowDelegate", superclass).unwrap();
48+
let mut decl = ClassBuilder::new("MyWindowDelegate", superclass).unwrap();
4949

5050
extern fn will_use_fillscreen_presentation_options(_: &Object, _: Sel, _: id, _: NSUInteger) -> NSUInteger {
5151
// Set initial presentation options for fullscreen
@@ -81,7 +81,7 @@ fn main() {
8181
.initWithContentRect_styleMask_backing_defer_(NSRect::new(NSPoint::new(0., 0.), size),
8282
NSWindowStyleMask::NSTitledWindowMask,
8383
NSBackingStoreBuffered,
84-
NO)
84+
false)
8585
.autorelease();
8686
window.setDelegate_(delegate_object);
8787
let title = NSString::alloc(nil).init_str("Fullscreen!");

cocoa/examples/hello_world.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate cocoa;
22

3-
use cocoa::base::{selector, nil, NO};
3+
use cocoa::base::{selector, nil};
44
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
55
NSString};
66
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular, NSWindow,
@@ -39,7 +39,7 @@ fn main() {
3939
NSSize::new(200., 200.)),
4040
NSWindowStyleMask::NSTitledWindowMask,
4141
NSBackingStoreBuffered,
42-
NO)
42+
false)
4343
.autorelease();
4444
window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));
4545
window.center();

cocoa/examples/tab_view.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate cocoa;
22

3-
use cocoa::base::{selector, id, nil, NO};
3+
use cocoa::base::{selector, id, nil};
44

55

66
use cocoa::foundation::{NSRect, NSPoint, NSSize, NSAutoreleasePool, NSProcessInfo,
@@ -71,7 +71,7 @@ unsafe fn create_app(title: id, content: id) -> id {
7171
NSWindowStyleMask::NSMiniaturizableWindowMask |
7272
NSWindowStyleMask::NSUnifiedTitleAndToolbarWindowMask,
7373
NSBackingStoreType::NSBackingStoreBuffered,
74-
NO
74+
false
7575
).autorelease();
7676
window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.));
7777
window.center();

0 commit comments

Comments
 (0)