From 6d166681d39812ad6c1fc1889245b3f103d3ec19 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 16 Jun 2022 01:51:53 +0200 Subject: [PATCH] More idiomatic usage of objc2 Changes argument and return types that were previously BOOL to bool --- cocoa-foundation/src/base.rs | 1 + cocoa-foundation/src/foundation.rs | 297 +++++----- cocoa/examples/color.rs | 4 +- cocoa/examples/fullscreen.rs | 8 +- cocoa/examples/hello_world.rs | 4 +- cocoa/examples/tab_view.rs | 4 +- cocoa/src/appkit.rs | 888 +++++++++++++++-------------- cocoa/src/macros.rs | 2 +- cocoa/src/quartzcore.rs | 103 ++-- 9 files changed, 651 insertions(+), 660 deletions(-) diff --git a/cocoa-foundation/src/base.rs b/cocoa-foundation/src/base.rs index 4cebe99b1..3530c8a3b 100644 --- a/cocoa-foundation/src/base.rs +++ b/cocoa-foundation/src/base.rs @@ -9,6 +9,7 @@ use objc2::runtime; +#[allow(deprecated)] pub use objc2::runtime::{BOOL, NO, YES}; pub type Class = *mut runtime::Class; diff --git a/cocoa-foundation/src/foundation.rs b/cocoa-foundation/src/foundation.rs index ba04996ba..c63c3ac87 100644 --- a/cocoa-foundation/src/foundation.rs +++ b/cocoa-foundation/src/foundation.rs @@ -11,7 +11,8 @@ use std::ptr; use std::os::raw::c_void; -use base::{id, BOOL, NO, SEL, nil}; +use base::{id, SEL, nil}; +use objc2::runtime::Bool; use block::Block; use libc; use objc2_encode::{Encode, Encoding, RefEncode}; @@ -256,8 +257,7 @@ impl NSProcessInfo for id { } unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool { - let res: BOOL = msg_send![self, isOperatingSystemAtLeastVersion: version]; - res != NO + msg_send_bool![self, isOperatingSystemAtLeastVersion: version] } } @@ -269,7 +269,7 @@ pub trait NSArray: Sized { } unsafe fn arrayWithObjects(_: Self, objects: &[id]) -> id { - msg_send![class!(NSArray), arrayWithObjects:objects.as_ptr() + msg_send![class!(NSArray), arrayWithObjects:objects.as_ptr(), count:objects.len()] } @@ -326,15 +326,15 @@ pub trait NSDictionary: Sized { } unsafe fn dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id { - msg_send![class!(NSDictionary), dictionaryWithObject:anObject forKey:aKey] + msg_send![class!(NSDictionary), dictionaryWithObject: anObject, forKey: aKey] } unsafe fn dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id { - msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys] + msg_send![class!(NSDictionary), dictionaryWithObjects: objects, forKeys: keys] } unsafe fn dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id { - msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys count:count] + msg_send![class!(NSDictionary), dictionaryWithObjects: objects, forKeys: keys, count: count] } unsafe fn dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id { @@ -345,7 +345,7 @@ pub trait NSDictionary: Sized { unsafe fn initWithContentsOfFile_(self, path: id) -> id; unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; unsafe fn initWithDictionary_(self, otherDicitonary: id) -> id; - unsafe fn initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id; + unsafe fn initWithDictionary_copyItems_(self, otherDicitonary: id, flag: bool) -> id; unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id; unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id; unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id; @@ -356,7 +356,7 @@ pub trait NSDictionary: Sized { unsafe fn count(self) -> NSUInteger; - unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL; + unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> bool; unsafe fn allKeys(self) -> id; unsafe fn allKeysForObject_(self, anObject: id) -> id; @@ -368,27 +368,27 @@ pub trait NSDictionary: Sized { unsafe fn keyEnumerator(self) -> id; unsafe fn objectEnumerator(self) -> id; - unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>); + unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut Bool), ()>); unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, - block: *mut Block<(id, id, *mut BOOL), ()>); + block: *mut Block<(id, id, *mut Bool), ()>); unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id; unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id; unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id; - unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; + unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut Bool), Bool>) -> id; unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, - predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; + predicate: *mut Block<(id, id, *mut Bool), Bool>) -> id; - unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL; - unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL; + unsafe fn writeToFile_atomically_(self, path: id, flag: bool) -> bool; + unsafe fn writeToURL_atomically_(self, aURL: id, flag: bool) -> bool; unsafe fn fileCreationDate(self) -> id; - unsafe fn fileExtensionHidden(self) -> BOOL; + unsafe fn fileExtensionHidden(self) -> bool; unsafe fn fileGroupOwnerAccountID(self) -> id; unsafe fn fileGroupOwnerAccountName(self) -> id; - unsafe fn fileIsAppendOnly(self) -> BOOL; - unsafe fn fileIsImmutable(self) -> BOOL; + unsafe fn fileIsAppendOnly(self) -> bool; + unsafe fn fileIsImmutable(self) -> bool; unsafe fn fileModificationDate(self) -> id; unsafe fn fileOwnerAccountID(self) -> id; unsafe fn fileOwnerAccountName(self) -> id; @@ -421,16 +421,16 @@ impl NSDictionary for id { msg_send![self, initWithDictionary:otherDictionary] } - unsafe fn initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id { - msg_send![self, initWithDictionary:otherDictionary copyItems:flag] + unsafe fn initWithDictionary_copyItems_(self, otherDictionary: id, flag: bool) -> id { + msg_send![self, initWithDictionary: otherDictionary, copyItems: Bool::from(flag)] } unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id { - msg_send![self, initWithObjects:objects forKeys:keys] + msg_send![self, initWithObjects: objects, forKeys: keys] } unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id { - msg_send![self, initWithObjects:objects forKeys:keys count:count] + msg_send![self, initWithObjects: objects, forKeys: keys, count: count] } unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id { @@ -441,8 +441,8 @@ impl NSDictionary for id { msg_send![self, count] } - unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL { - msg_send![self, isEqualToDictionary:otherDictionary] + unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> bool { + msg_send_bool![self, isEqualToDictionary:otherDictionary] } unsafe fn allKeys(self) -> id { @@ -466,7 +466,7 @@ impl NSDictionary for id { } unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id { - msg_send![self, objectsForKeys:keys notFoundMarker:anObject] + msg_send![self, objectsForKeys: keys, notFoundMarker: anObject] } unsafe fn valueForKey_(self, key: id) -> id { @@ -481,13 +481,13 @@ impl NSDictionary for id { msg_send![self, objectEnumerator] } - unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>) { + unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut Bool), ()>) { msg_send![self, enumerateKeysAndObjectsUsingBlock:block] } unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, - block: *mut Block<(id, id, *mut BOOL), ()>) { - msg_send![self, enumerateKeysAndObjectsWithOptions:opts usingBlock:block] + block: *mut Block<(id, id, *mut Bool), ()>) { + msg_send![self, enumerateKeysAndObjectsWithOptions:opts, usingBlock:block] } unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id { @@ -499,33 +499,33 @@ impl NSDictionary for id { } unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id { - let rv: id = msg_send![self, keysSortedByValueWithOptions:opts usingComparator:cmptr]; + let rv: id = msg_send![self, keysSortedByValueWithOptions:opts, usingComparator:cmptr]; rv } - unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { + unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut Bool), Bool>) -> id { msg_send![self, keysOfEntriesPassingTest:predicate] } unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, - predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { - msg_send![self, keysOfEntriesWithOptions:opts PassingTest:predicate] + predicate: *mut Block<(id, id, *mut Bool), Bool>) -> id { + msg_send![self, keysOfEntriesWithOptions:opts, PassingTest:predicate] } - unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL { - msg_send![self, writeToFile:path atomically:flag] + unsafe fn writeToFile_atomically_(self, path: id, flag: bool) -> bool { + msg_send_bool![self, writeToFile:path, atomically: Bool::from(flag)] } - unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL { - msg_send![self, writeToURL:aURL atomically:flag] + unsafe fn writeToURL_atomically_(self, aURL: id, flag: bool) -> bool { + msg_send_bool![self, writeToURL: aURL, atomically: Bool::from(flag)] } unsafe fn fileCreationDate(self) -> id { msg_send![self, fileCreationDate] } - unsafe fn fileExtensionHidden(self) -> BOOL { - msg_send![self, fileExtensionHidden] + unsafe fn fileExtensionHidden(self) -> bool { + msg_send_bool![self, fileExtensionHidden] } unsafe fn fileGroupOwnerAccountID(self) -> id { @@ -536,12 +536,12 @@ impl NSDictionary for id { msg_send![self, fileGroupOwnerAccountName] } - unsafe fn fileIsAppendOnly(self) -> BOOL { - msg_send![self, fileIsAppendOnly] + unsafe fn fileIsAppendOnly(self) -> bool { + msg_send_bool![self, fileIsAppendOnly] } - unsafe fn fileIsImmutable(self) -> BOOL { - msg_send![self, fileIsImmutable] + unsafe fn fileIsImmutable(self) -> bool { + msg_send_bool![self, fileIsImmutable] } unsafe fn fileModificationDate(self) -> id { @@ -589,7 +589,7 @@ impl NSDictionary for id { } unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id { - msg_send![self, descriptionWithLocale:locale indent:indent] + msg_send![self, descriptionWithLocale:locale, indent:indent] } } @@ -630,8 +630,7 @@ pub trait NSString: Sized { impl NSString for id { unsafe fn isEqualToString(self, other: &str) -> bool { let other = NSString::alloc(nil).init_str(other); - let rv: BOOL = msg_send![self, isEqualToString:other]; - rv != NO + msg_send_bool![self, isEqualToString: other] } unsafe fn stringByAppendingString_(self, other: id) -> id { @@ -639,10 +638,12 @@ impl NSString for id { } unsafe fn init_str(self, string: &str) -> id { - return msg_send![self, - initWithBytes:string.as_ptr() as *const c_void - length:string.len() - encoding:UTF8_ENCODING]; + msg_send![ + self, + initWithBytes: string.as_ptr() as *const c_void, + length: string.len(), + encoding: UTF8_ENCODING, + ] } unsafe fn len(self) -> usize { @@ -713,7 +714,7 @@ impl Iterator for NSFastIterator { fn next(&mut self) -> Option { if self.idx >= self.len { self.len = unsafe { - msg_send![self.object, countByEnumeratingWithState:&mut self.state objects:self.buffer.as_mut_ptr() count:NS_FAST_ENUM_BUF_SIZE] + msg_send![self.object, countByEnumeratingWithState:&mut self.state, objects:self.buffer.as_mut_ptr(), count:NS_FAST_ENUM_BUF_SIZE] }; self.idx = 0; } @@ -783,10 +784,10 @@ impl NSRunLoop for id { anArgument: id, order: NSUInteger, modes: id) { - msg_send![self, performSelector:aSelector - target:target - argument:anArgument - order:order + msg_send![self, performSelector:aSelector, + target:target, + argument:anArgument, + order:order, modes:modes] } } @@ -822,18 +823,18 @@ pub trait NSURL: Sized { unsafe fn initWithString_(self, string: id) -> id; unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id; unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id; - unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id; - unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id; + unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: bool) -> id; + unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: bool) -> id; unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id; unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id; - unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id; - unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id; + unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: bool, url: id) -> id; + unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: bool, url: id) -> id; unsafe fn fileURLWithPath_(_:Self, path: id) -> id; unsafe fn initFileURLWithPath_(self, path: id) -> id; unsafe fn fileURLWithPathComponents_(_:Self, path_components: id /* (NSArray*) */) -> id; unsafe fn URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id /* (NSError _Nullable) */) -> id; - unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id; - unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id; + unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut Bool, error: *mut id /* (NSError _Nullable) */) -> id; + unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut Bool, error: *mut id /* (NSError _Nullable) */) -> id; // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ // unsafe fn getFileSystemRepresentation_maxLength_ // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ @@ -843,11 +844,11 @@ pub trait NSURL: Sized { unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id; unsafe fn dataRepresentation(self) -> id /* (NSData) */; - unsafe fn isEqual_(self, id: id) -> BOOL; + unsafe fn isEqual_(self, id: id) -> bool; - unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL; - unsafe fn isFileReferenceURL(self) -> BOOL; - unsafe fn isFileURL(self) -> BOOL; + unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> bool; + unsafe fn isFileReferenceURL(self) -> bool; + unsafe fn isFileURL(self) -> bool; unsafe fn absoluteString(self) -> id /* (NSString) */; unsafe fn absoluteURL(self) -> id /* (NSURL) */; @@ -882,19 +883,19 @@ pub trait NSURL: Sized { unsafe fn filePathURL(self) -> id; unsafe fn fileReferenceURL(self) -> id; unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id; - unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id; + unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: bool) -> id; unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id; unsafe fn URLByDeletingLastPathComponent(self) -> id; unsafe fn URLByDeletingPathExtension(self) -> id; unsafe fn URLByResolvingSymlinksInPath(self) -> id; unsafe fn URLByStandardizingPath(self) -> id; - unsafe fn hasDirectoryPath(self) -> BOOL; + unsafe fn hasDirectoryPath(self) -> bool; unsafe fn bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */; unsafe fn bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id /* (NSArray) */, relative_to_url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */; // unsafe fn resourceValuesForKeys_fromBookmarkData_ unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id; - unsafe fn startAccessingSecurityScopedResource(self) -> BOOL; + unsafe fn startAccessingSecurityScopedResource(self) -> bool; unsafe fn stopAccessingSecurityScopedResource(self); unsafe fn NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions; unsafe fn NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions; @@ -920,28 +921,28 @@ impl NSURL for id { msg_send![self, initWithString:string] } unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id { - msg_send![class!(NSURL), URLWithString: string relativeToURL:url] + msg_send![class!(NSURL), URLWithString: string, relativeToURL: url] } unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id { - msg_send![self, initWithString:string relativeToURL:url] + msg_send![self, initWithString:string, relativeToURL:url] } - unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id { - msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir] + unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: bool) -> id { + msg_send![class!(NSURL), fileURLWithPath: path, isDirectory: Bool::from(is_dir)] } - unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id { - msg_send![self, initFileURLWithPath:path isDirectory:is_dir] + unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: bool) -> id { + msg_send![self, initFileURLWithPath: path, isDirectory: Bool::from(is_dir)] } unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id { - msg_send![class!(NSURL), fileURLWithPath:path relativeToURL:url] + msg_send![class!(NSURL), fileURLWithPath:path, relativeToURL:url] } unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id { - msg_send![self, initFileURLWithPath:path relativeToURL:url] + msg_send![self, initFileURLWithPath:path, relativeToURL:url] } - unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id { - msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir relativeToURL:url] + unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: bool, url: id) -> id { + msg_send![class!(NSURL), fileURLWithPath: path, isDirectory: Bool::from(is_dir), relativeToURL: url] } - unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id { - msg_send![self, initFileURLWithPath:path isDirectory:is_dir relativeToURL:url] + unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: bool, url: id) -> id { + msg_send![self, initFileURLWithPath: path, isDirectory: Bool::from(is_dir), relativeToURL: url] } unsafe fn fileURLWithPath_(_:Self, path: id) -> id { msg_send![class!(NSURL), fileURLWithPath:path] @@ -953,45 +954,45 @@ impl NSURL for id { msg_send![class!(NSURL), fileURLWithPathComponents:path_components] } unsafe fn URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id /* (NSError _Nullable) */) -> id { - msg_send![class!(NSURL), URLByResolvingAliasFileAtURL:url options:options error:error] + msg_send![class!(NSURL), URLByResolvingAliasFileAtURL: url, options: options, error: error] } - unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id { - msg_send![class!(NSURL), URLByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] + unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut Bool, error: *mut id /* (NSError _Nullable) */) -> id { + msg_send![class!(NSURL), URLByResolvingBookmarkData: data, options: options, relativeToURL: relative_to_url, bookmarkDataIsStale: is_stale, error: error] } - unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id { - msg_send![self, initByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] + unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut Bool, error: *mut id /* (NSError _Nullable) */) -> id { + msg_send![self, initByResolvingBookmarkData: data, options: options, relativeToURL: relative_to_url, bookmarkDataIsStale: is_stale, error: error] } // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ // unsafe fn getFileSystemRepresentation_maxLength_ // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ unsafe fn absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { - msg_send![class!(NSURL), absoluteURLWithDataRepresentation:data relativeToURL:url] + msg_send![class!(NSURL), absoluteURLWithDataRepresentation:data, relativeToURL:url] } unsafe fn initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { - msg_send![self, initAbsoluteURLWithDataRepresentation:data relativeToURL:url] + msg_send![self, initAbsoluteURLWithDataRepresentation:data, relativeToURL:url] } unsafe fn URLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { - msg_send![class!(NSURL), URLWithDataRepresentation:data relativeToURL:url] + msg_send![class!(NSURL), URLWithDataRepresentation:data, relativeToURL:url] } unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { - msg_send![self, initWithDataRepresentation:data relativeToURL:url] + msg_send![self, initWithDataRepresentation:data, relativeToURL:url] } unsafe fn dataRepresentation(self) -> id /* (NSData) */ { msg_send![self, dataRepresentation] } - unsafe fn isEqual_(self, id: id) -> BOOL { - msg_send![self, isEqual:id] + unsafe fn isEqual_(self, id: id) -> bool { + msg_send_bool![self, isEqual:id] } - unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL { - msg_send![self, checkResourceIsReachableAndReturnError:error] + unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> bool { + msg_send_bool![self, checkResourceIsReachableAndReturnError:error] } - unsafe fn isFileReferenceURL(self) -> BOOL { - msg_send![self, isFileReferenceURL] + unsafe fn isFileReferenceURL(self) -> bool { + msg_send_bool![self, isFileReferenceURL] } - unsafe fn isFileURL(self) -> BOOL { - msg_send![self, isFileURL] + unsafe fn isFileURL(self) -> bool { + msg_send_bool![self, isFileURL] } unsafe fn absoluteString(self) -> id /* (NSString) */ { @@ -1073,8 +1074,8 @@ impl NSURL for id { unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id { msg_send![self, URLByAppendingPathComponent:path_component] } - unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id { - msg_send![self, URLByAppendingPathComponent:path_component isDirectory:is_dir] + unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: bool) -> id { + msg_send![self, URLByAppendingPathComponent:path_component, isDirectory: Bool::from(is_dir)] } unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id { msg_send![self, URLByAppendingPathExtension:extension] @@ -1091,22 +1092,22 @@ impl NSURL for id { unsafe fn URLByStandardizingPath(self) -> id { msg_send![self, URLByStandardizingPath] } - unsafe fn hasDirectoryPath(self) -> BOOL { - msg_send![self, hasDirectoryPath] + unsafe fn hasDirectoryPath(self) -> bool { + msg_send_bool![self, hasDirectoryPath] } unsafe fn bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */ { - msg_send![class!(NSURL), bookmarkDataWithContentsOfURL:url error:error] + msg_send![class!(NSURL), bookmarkDataWithContentsOfURL:url, error:error] } unsafe fn bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id /* (NSArray) */, relative_to_url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */ { - msg_send![self, bookmarkDataWithOptions:options includingResourceValuesForKeys:resource_value_for_keys relativeToURL:relative_to_url error:error] + msg_send![self, bookmarkDataWithOptions:options, includingResourceValuesForKeys:resource_value_for_keys, relativeToURL:relative_to_url, error:error] } // unsafe fn resourceValuesForKeys_fromBookmarkData_ unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id { - msg_send![class!(NSURL), writeBookmarkData:data toURL:to_url options:options error:error] + msg_send![class!(NSURL), writeBookmarkData:data, toURL:to_url, options:options, error:error] } - unsafe fn startAccessingSecurityScopedResource(self) -> BOOL { - msg_send![self, startAccessingSecurityScopedResource] + unsafe fn startAccessingSecurityScopedResource(self) -> bool { + msg_send_bool![self, startAccessingSecurityScopedResource] } unsafe fn stopAccessingSecurityScopedResource(self) { msg_send![self, stopAccessingSecurityScopedResource] @@ -1135,7 +1136,7 @@ pub trait NSBundle: Sized { unsafe fn loadNibNamed_owner_topLevelObjects_(self, name: id /* NSString */, owner: id, - topLevelObjects: *mut id /* NSArray */) -> BOOL; + topLevelObjects: *mut id /* NSArray */) -> bool; unsafe fn bundleIdentifier(self) -> id /* NSString */; @@ -1150,9 +1151,9 @@ impl NSBundle for id { unsafe fn loadNibNamed_owner_topLevelObjects_(self, name: id /* NSString */, owner: id, - topLevelObjects: *mut id /* NSArray* */) -> BOOL { - msg_send![self, loadNibNamed:name - owner:owner + topLevelObjects: *mut id /* NSArray* */) -> bool { + msg_send_bool![self, loadNibNamed:name, + owner:owner, topLevelObjects:topLevelObjects] } @@ -1171,16 +1172,16 @@ pub trait NSData: Sized { } unsafe fn dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { - msg_send![class!(NSData), dataWithBytes:bytes length:length] + msg_send![class!(NSData), dataWithBytes:bytes, length:length] } unsafe fn dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { - msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length] + msg_send![class!(NSData), dataWithBytesNoCopy:bytes, length:length] } unsafe fn dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, - length: NSUInteger, freeWhenDone: BOOL) -> id { - msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] + length: NSUInteger, freeWhenDone: bool) -> id { + msg_send![class!(NSData), dataWithBytesNoCopy: bytes, length: length, freeWhenDone: Bool::from(freeWhenDone)] } unsafe fn dataWithContentsOfFile_(_: Self, path: id) -> id { @@ -1189,7 +1190,7 @@ pub trait NSData: Sized { unsafe fn dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id { - msg_send![class!(NSData), dataWithContentsOfFile:path options:mask error:errorPtr] + msg_send![class!(NSData), dataWithContentsOfFile: path, options: mask, error: errorPtr] } unsafe fn dataWithContentsOfURL_(_: Self, aURL: id) -> id { @@ -1198,7 +1199,7 @@ pub trait NSData: Sized { unsafe fn dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id { - msg_send![class!(NSData), dataWithContentsOfURL:aURL options:mask error:errorPtr] + msg_send![class!(NSData), dataWithContentsOfURL: aURL, options: mask, error: errorPtr] } unsafe fn dataWithData_(_: Self, aData: id) -> id { @@ -1215,7 +1216,7 @@ pub trait NSData: Sized { deallocator: *mut Block<(*const c_void, NSUInteger), ()>) -> id; unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, - length: NSUInteger, freeWhenDone: BOOL) -> id; + length: NSUInteger, freeWhenDone: bool) -> id; unsafe fn initWithContentsOfFile_(self, path: id) -> id; unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id; @@ -1226,7 +1227,7 @@ pub trait NSData: Sized { unsafe fn bytes(self) -> *const c_void; unsafe fn description(self) -> id; - unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>); + unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut Bool), ()>); unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger); unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange); unsafe fn subdataWithRange_(self, range: NSRange) -> id; @@ -1239,40 +1240,40 @@ pub trait NSData: Sized { unsafe fn isEqualToData_(self, otherData: id) -> id; unsafe fn length(self) -> NSUInteger; - unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL; - unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; - unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL; - unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; + unsafe fn writeToFile_atomically_(self, path: id, atomically: bool) -> bool; + unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> bool; + unsafe fn writeToURL_atomically_(self, aURL: id, atomically: bool) -> bool; + unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> bool; } impl NSData for id { unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) -> id { - msg_send![self, initWithBase64EncodedData:base64Data options:options] + msg_send![self, initWithBase64EncodedData: base64Data, options: options] } unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) -> id { - msg_send![self, initWithBase64EncodedString:base64String options:options] + msg_send![self, initWithBase64EncodedString: base64String, options: options] } unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id { - msg_send![self,initWithBytes:bytes length:length] + msg_send![self, initWithBytes: bytes, length: length] } unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id { - msg_send![self, initWithBytesNoCopy:bytes length:length] + msg_send![self, initWithBytesNoCopy: bytes, length: length] } unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, deallocator: *mut Block<(*const c_void, NSUInteger), ()>) -> id { - msg_send![self, initWithBytesNoCopy:bytes length:length deallocator:deallocator] + msg_send![self, initWithBytesNoCopy: bytes, length: length, deallocator: deallocator] } unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, - length: NSUInteger, freeWhenDone: BOOL) -> id { - msg_send![self, initWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] + length: NSUInteger, freeWhenDone: bool) -> id { + msg_send![self, initWithBytesNoCopy: bytes, length: length, freeWhenDone: Bool::from(freeWhenDone)] } unsafe fn initWithContentsOfFile_(self, path: id) -> id { @@ -1281,7 +1282,7 @@ impl NSData for id { unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id { - msg_send![self, initWithContentsOfFile:path options:mask error:errorPtr] + msg_send![self, initWithContentsOfFile: path, options: mask, error: errorPtr] } unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { @@ -1290,7 +1291,7 @@ impl NSData for id { unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id { - msg_send![self, initWithContentsOfURL:aURL options:mask error:errorPtr] + msg_send![self, initWithContentsOfURL: aURL, options: mask, error: errorPtr] } unsafe fn initWithData_(self, data: id) -> id { @@ -1305,16 +1306,16 @@ impl NSData for id { msg_send![self, description] } - unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>) { + unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut Bool), ()>) { msg_send![self, enumerateByteRangesUsingBlock:block] } unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger) { - msg_send![self, getBytes:buffer length:length] + msg_send![self, getBytes: buffer, length: length] } unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange) { - msg_send![self, getBytes:buffer range:range] + msg_send![self, getBytes: buffer, range: range] } unsafe fn subdataWithRange_(self, range: NSRange) -> id { @@ -1323,7 +1324,7 @@ impl NSData for id { unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) -> NSRange { - msg_send![self, rangeOfData:dataToFind options:options range:searchRange] + msg_send![self, rangeOfData: dataToFind, options: options, range: searchRange] } unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { @@ -1342,20 +1343,20 @@ impl NSData for id { msg_send![self, length] } - unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL { - msg_send![self, writeToFile:path atomically:atomically] + unsafe fn writeToFile_atomically_(self, path: id, atomically: bool) -> bool { + msg_send_bool![self, writeToFile: path, atomically: Bool::from(atomically)] } - unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { - msg_send![self, writeToFile:path options:mask error:errorPtr] + unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> bool { + msg_send_bool![self, writeToFile: path, options: mask, error: errorPtr] } - unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL { - msg_send![self, writeToURL:aURL atomically:atomically] + unsafe fn writeToURL_atomically_(self, aURL: id, atomically: bool) -> bool { + msg_send_bool![self, writeToURL: aURL, atomically: Bool::from(atomically)] } - unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { - msg_send![self, writeToURL:aURL options:mask error:errorPtr] + unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> bool { + msg_send_bool![self, writeToURL: aURL, options: mask, error: errorPtr] } } @@ -1409,8 +1410,8 @@ impl_Encode!(NSDataSearchOptions, libc::c_ulonglong); pub trait NSUserDefaults { unsafe fn standardUserDefaults() -> Self; - unsafe fn setBool_forKey_(self, value: BOOL, key: id); - unsafe fn bool_forKey_(self, key: id) -> BOOL; + unsafe fn setBool_forKey_(self, value: bool, key: id); + unsafe fn bool_forKey_(self, key: id) -> bool; unsafe fn removeObject_forKey_(self, key: id); } @@ -1420,12 +1421,12 @@ impl NSUserDefaults for id { msg_send![class!(NSUserDefaults), standardUserDefaults] } - unsafe fn setBool_forKey_(self, value: BOOL, key: id) { - msg_send![self, setBool:value forKey:key] + unsafe fn setBool_forKey_(self, value: bool, key: id) { + msg_send![self, setBool: Bool::from(value), forKey: key] } - unsafe fn bool_forKey_(self, key: id) -> BOOL { - msg_send![self, boolForKey: key] + unsafe fn bool_forKey_(self, key: id) -> bool { + msg_send_bool![self, boolForKey: key] } unsafe fn removeObject_forKey_(self, key: id) { diff --git a/cocoa/examples/color.rs b/cocoa/examples/color.rs index af31514dd..f8140ce44 100644 --- a/cocoa/examples/color.rs +++ b/cocoa/examples/color.rs @@ -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}; @@ -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.)); diff --git a/cocoa/examples/fullscreen.rs b/cocoa/examples/fullscreen.rs index b64aad02e..db8b69cce 100644 --- a/cocoa/examples/fullscreen.rs +++ b/cocoa/examples/fullscreen.rs @@ -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, @@ -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 { @@ -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 @@ -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!"); diff --git a/cocoa/examples/hello_world.rs b/cocoa/examples/hello_world.rs index 4d5c1b08c..d135d27f4 100644 --- a/cocoa/examples/hello_world.rs +++ b/cocoa/examples/hello_world.rs @@ -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, @@ -39,7 +39,7 @@ fn main() { NSSize::new(200., 200.)), NSWindowStyleMask::NSTitledWindowMask, NSBackingStoreBuffered, - NO) + false) .autorelease(); window.cascadeTopLeftFromPoint_(NSPoint::new(20., 20.)); window.center(); diff --git a/cocoa/examples/tab_view.rs b/cocoa/examples/tab_view.rs index 985487f75..f9a2c6d39 100644 --- a/cocoa/examples/tab_view.rs +++ b/cocoa/examples/tab_view.rs @@ -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, @@ -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(); diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index 0a7383f7f..176c0e563 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -9,10 +9,11 @@ #![allow(non_upper_case_globals)] -use base::{id, BOOL, SEL}; +use base::{id, SEL}; use block::Block; use foundation::{NSInteger, NSUInteger, NSTimeInterval, NSPoint, NSSize, NSRect, NSRange, NSRectEdge}; +use objc2::runtime::Bool; use libc; pub use core_graphics::base::CGFloat; @@ -429,22 +430,22 @@ pub trait NSApplication: Sized { } unsafe fn mainMenu(self) -> id; - unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> BOOL; - unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> BOOL; + unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> bool; + unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> bool; unsafe fn presentationOptions_(self) -> NSApplicationPresentationOptions; unsafe fn setMainMenu_(self, menu: id); unsafe fn setServicesMenu_(self, menu: id); unsafe fn setWindowsMenu_(self, menu: id); - unsafe fn activateIgnoringOtherApps_(self, ignore: BOOL); + unsafe fn activateIgnoringOtherApps_(self, ignore: bool); unsafe fn run(self); unsafe fn finishLaunching(self); unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue_(self, mask: NSUInteger, expiration: id, in_mode: id, - dequeue: BOOL) -> id; + dequeue: bool) -> id; unsafe fn sendEvent_(self, an_event: id); - unsafe fn postEvent_atStart_(self, anEvent: id, flag: BOOL); + unsafe fn postEvent_atStart_(self, anEvent: id, flag: bool); unsafe fn stop_(self, sender: id); unsafe fn setApplicationIconImage_(self, image: id); unsafe fn requestUserAttention_(self, requestType: NSRequestUserAttentionType); @@ -455,12 +456,12 @@ impl NSApplication for id { msg_send![self, mainMenu] } - unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> BOOL { - msg_send![self, setActivationPolicy:policy as NSInteger] + unsafe fn setActivationPolicy_(self, policy: NSApplicationActivationPolicy) -> bool { + msg_send_bool![self, setActivationPolicy:policy as NSInteger] } - unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> BOOL { - msg_send![self, setPresentationOptions:options.bits] + unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> bool { + msg_send_bool![self, setPresentationOptions:options.bits] } unsafe fn presentationOptions_(self) -> NSApplicationPresentationOptions { @@ -480,8 +481,8 @@ impl NSApplication for id { msg_send![self, setWindowsMenu:menu] } - unsafe fn activateIgnoringOtherApps_(self, ignore: BOOL) { - msg_send![self, activateIgnoringOtherApps:ignore] + unsafe fn activateIgnoringOtherApps_(self, ignore: bool) { + msg_send![self, activateIgnoringOtherApps: Bool::from(ignore)] } unsafe fn run(self) { @@ -496,19 +497,19 @@ impl NSApplication for id { mask: NSUInteger, expiration: id, in_mode: id, - dequeue: BOOL) -> id { - msg_send![self, nextEventMatchingMask:mask - untilDate:expiration - inMode:in_mode - dequeue:dequeue] + dequeue: bool) -> id { + msg_send![self, nextEventMatchingMask:mask, + untilDate:expiration, + inMode:in_mode, + dequeue:Bool::from(dequeue)] } unsafe fn sendEvent_(self, an_event: id) { msg_send![self, sendEvent:an_event] } - unsafe fn postEvent_atStart_(self, anEvent: id, flag: BOOL) { - msg_send![self, postEvent:anEvent atStart:flag] + unsafe fn postEvent_atStart_(self, anEvent: id, flag: bool) { + msg_send![self, postEvent: anEvent, atStart: Bool::from(flag)] } unsafe fn stop_(self, sender: id) { @@ -529,7 +530,7 @@ pub trait NSRunningApplication: Sized { msg_send![class!(NSRunningApplication), currentApplication] } - unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> BOOL; + unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> bool; unsafe fn runningApplicationWithProcessIdentifier(_: Self, pid: libc::pid_t) -> id { msg_send![class!(NSRunningApplication), runningApplicationWithProcessIdentifier:pid] @@ -537,8 +538,8 @@ pub trait NSRunningApplication: Sized { } impl NSRunningApplication for id { - unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> BOOL { - msg_send![self, activateWithOptions:options as NSUInteger] + unsafe fn activateWithOptions_(self, options: NSApplicationActivationOptions) -> bool { + msg_send_bool![self, activateWithOptions:options as NSUInteger] } } @@ -548,7 +549,7 @@ pub trait NSPasteboard: Sized { } unsafe fn pasteboardByFilteringData_ofType(_: Self, data: id, _type: id) -> id { - msg_send![class!(NSPasteboard), pasteboardByFilteringData:data ofType:_type] + msg_send![class!(NSPasteboard), pasteboardByFilteringData:data, ofType:_type] } unsafe fn pasteboardByFilteringFile(_: Self, file: id) -> id { @@ -570,10 +571,10 @@ pub trait NSPasteboard: Sized { unsafe fn releaseGlobally(self); unsafe fn clearContents(self) -> NSInteger; - unsafe fn writeObjects(self, objects: id) -> BOOL; - unsafe fn setData_forType(self, data: id, dataType: id) -> BOOL; - unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> BOOL; - unsafe fn setString_forType(self, string: id, dataType: id) -> BOOL; + unsafe fn writeObjects(self, objects: id) -> bool; + unsafe fn setData_forType(self, data: id, dataType: id) -> bool; + unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> bool; + unsafe fn setString_forType(self, string: id, dataType: id) -> bool; unsafe fn readObjectsForClasses_options(self, classArray: id, options: id) -> id; unsafe fn pasteboardItems(self) -> id; @@ -583,8 +584,8 @@ pub trait NSPasteboard: Sized { unsafe fn stringForType(self, dataType: id) -> id; unsafe fn availableTypeFromArray(self, types: id) -> id; - unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> BOOL; - unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> BOOL; + unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> bool; + unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> bool; unsafe fn types(self) -> id; unsafe fn typesFilterableTo(_: Self, _type: id) -> id { msg_send![class!(NSPasteboard), typesFilterableTo:_type] @@ -595,8 +596,8 @@ pub trait NSPasteboard: Sized { unsafe fn declareTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger; unsafe fn addTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger; - unsafe fn writeFileContents(self, filename: id) -> BOOL; - unsafe fn writeFileWrapper(self, wrapper: id) -> BOOL; + unsafe fn writeFileContents(self, filename: id) -> bool; + unsafe fn writeFileWrapper(self, wrapper: id) -> bool; unsafe fn readFileContentsType_toFile(self, _type: id, filename: id) -> id; unsafe fn readFileWrapper(self) -> id; @@ -611,24 +612,24 @@ impl NSPasteboard for id { msg_send![self, clearContents] } - unsafe fn writeObjects(self, objects: id) -> BOOL { - msg_send![self, writeObjects:objects] + unsafe fn writeObjects(self, objects: id) -> bool { + msg_send_bool![self, writeObjects:objects] } - unsafe fn setData_forType(self, data: id, dataType: id) -> BOOL { - msg_send![self, setData:data forType:dataType] + unsafe fn setData_forType(self, data: id, dataType: id) -> bool { + msg_send_bool![self, setData: data, forType: dataType] } - unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> BOOL { - msg_send![self, setPropertyList:plist forType:dataType] + unsafe fn setPropertyList_forType(self, plist: id, dataType: id) -> bool { + msg_send_bool![self, setPropertyList: plist, forType: dataType] } - unsafe fn setString_forType(self, string: id, dataType: id) -> BOOL { - msg_send![self, setString:string forType:dataType] + unsafe fn setString_forType(self, string: id, dataType: id) -> bool { + msg_send_bool![self, setString: string, forType: dataType] } unsafe fn readObjectsForClasses_options(self, classArray: id, options: id) -> id { - msg_send![self, readObjectsForClasses:classArray options:options] + msg_send![self, readObjectsForClasses: classArray, options: options] } unsafe fn pasteboardItems(self) -> id { @@ -655,12 +656,12 @@ impl NSPasteboard for id { msg_send![self, availableTypeFromArray:types] } - unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> BOOL { - msg_send![self, canReadItemWithDataConformingToTypes:types] + unsafe fn canReadItemWithDataConformingToTypes(self, types: id) -> bool { + msg_send_bool![self, canReadItemWithDataConformingToTypes:types] } - unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> BOOL { - msg_send![self, canReadObjectForClasses:classArray options:options] + unsafe fn canReadObjectForClasses_options(self, classArray: id, options: id) -> bool { + msg_send_bool![self, canReadObjectForClasses: classArray, options: options] } unsafe fn types(self) -> id { @@ -676,23 +677,23 @@ impl NSPasteboard for id { } unsafe fn declareTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger { - msg_send![self, declareTypes:newTypes owner:newOwner] + msg_send![self, declareTypes: newTypes, owner: newOwner] } unsafe fn addTypes_owner(self, newTypes: id, newOwner: id) -> NSInteger { - msg_send![self, addTypes:newTypes owner:newOwner] + msg_send![self, addTypes: newTypes, owner: newOwner] } - unsafe fn writeFileContents(self, filename: id) -> BOOL { - msg_send![self, writeFileContents:filename] + unsafe fn writeFileContents(self, filename: id) -> bool { + msg_send_bool![self, writeFileContents:filename] } - unsafe fn writeFileWrapper(self, wrapper: id) -> BOOL { - msg_send![self, writeFileWrapper:wrapper] + unsafe fn writeFileWrapper(self, wrapper: id) -> bool { + msg_send_bool![self, writeFileWrapper:wrapper] } unsafe fn readFileContentsType_toFile(self, _type: id, filename: id) -> id { - msg_send![self, readFileContentsType:_type toFile:filename] + msg_send![self, readFileContentsType: _type, toFile: filename] } unsafe fn readFileWrapper(self) -> id { @@ -704,10 +705,10 @@ impl NSPasteboard for id { pub trait NSPasteboardItem: Sized { unsafe fn types(self) -> id; - unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> BOOL; - unsafe fn setData_forType(self, data: id, _type: id) -> BOOL; - unsafe fn setString_forType(self, string: id, _type: id) -> BOOL; - unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> BOOL; + unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> bool; + unsafe fn setData_forType(self, data: id, _type: id) -> bool; + unsafe fn setString_forType(self, string: id, _type: id) -> bool; + unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> bool; unsafe fn dataForType(self, _type: id) -> id; unsafe fn stringForType(self, _type: id) -> id; @@ -719,20 +720,20 @@ impl NSPasteboardItem for id { msg_send![self, types] } - unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> BOOL { - msg_send![self, setDataProvider:dataProvider forTypes:types] + unsafe fn setDataProvider_forTypes(self, dataProvider: id, types: id) -> bool { + msg_send_bool![self, setDataProvider: dataProvider, forTypes: types] } - unsafe fn setData_forType(self, data: id, _type: id) -> BOOL { - msg_send![self, setData:data forType:_type] + unsafe fn setData_forType(self, data: id, _type: id) -> bool { + msg_send_bool![self, setData: data, forType: _type] } - unsafe fn setString_forType(self, string: id, _type: id) -> BOOL { - msg_send![self, setString:string forType:_type] + unsafe fn setString_forType(self, string: id, _type: id) -> bool { + msg_send_bool![self, setString: string, forType: _type] } - unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> BOOL { - msg_send![self, setPropertyList:propertyList forType:_type] + unsafe fn setPropertyList_forType(self, propertyList: id, _type: id) -> bool { + msg_send_bool![self, setPropertyList: propertyList, forType: _type] } unsafe fn dataForType(self, _type: id) -> id { @@ -755,7 +756,7 @@ pub trait NSPasteboardItemDataProvider: Sized { impl NSPasteboardItemDataProvider for id { unsafe fn pasteboard_item_provideDataForType(self, pasteboard: id, item: id, _type: id) { - msg_send![self, pasteboard:pasteboard item:item provideDataForType:_type] + msg_send![self, pasteboard: pasteboard, item: item, provideDataForType: _type] } unsafe fn pasteboardFinishedWithDataProvider(self, pasteboard: id) { @@ -776,7 +777,7 @@ impl NSPasteboardWriting for id { } unsafe fn writingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardWritingOptions { - msg_send![self, writingOptionsForType:_type pasteboard:pasteboard] + msg_send![self, writingOptionsForType: _type, pasteboard: pasteboard] } unsafe fn pasteboardPropertyListForType(self, _type: id) -> id { @@ -793,7 +794,7 @@ pub trait NSPasteboardReading: Sized { impl NSPasteboardReading for id { unsafe fn initWithPasteboardPropertyList_ofType(self, propertyList: id, _type: id) -> id { - msg_send![self, initWithPasteboardPropertyList:propertyList ofType:_type] + msg_send![self, initWithPasteboardPropertyList: propertyList, ofType: _type] } unsafe fn readableTypesForPasteboard(self, pasteboard: id) -> id { @@ -802,7 +803,7 @@ impl NSPasteboardReading for id { } unsafe fn readingOptionsForType_pasteboard(self, _type: id, pasteboard: id) -> NSPasteboardReadingOptions { let class: id = msg_send![self, class]; - msg_send![class, readingOptionsForType:_type pasteboard:pasteboard] + msg_send![class, readingOptionsForType: _type, pasteboard: pasteboard] } } @@ -835,7 +836,7 @@ pub trait NSMenu: Sized { } unsafe fn initWithTitle_(self, title: id /* NSString */) -> id; - unsafe fn setAutoenablesItems(self, state: BOOL); + unsafe fn setAutoenablesItems(self, state: bool); unsafe fn addItem_(self, menu_item: id); unsafe fn addItemWithTitle_action_keyEquivalent(self, title: id, action: SEL, key: id) -> id; @@ -847,8 +848,8 @@ impl NSMenu for id { msg_send![self, initWithTitle:title] } - unsafe fn setAutoenablesItems(self, state: BOOL) { - msg_send![self, setAutoenablesItems: state] + unsafe fn setAutoenablesItems(self, state: bool) { + msg_send![self, setAutoenablesItems: Bool::from(state)] } unsafe fn addItem_(self, menu_item: id) { @@ -856,7 +857,7 @@ impl NSMenu for id { } unsafe fn addItemWithTitle_action_keyEquivalent(self, title: id, action: SEL, key: id) -> id { - msg_send![self, addItemWithTitle:title action:action keyEquivalent:key] + msg_send![self, addItemWithTitle: title, action: action, keyEquivalent: key] } unsafe fn itemAtIndex_(self, index: NSInteger) -> id { @@ -885,7 +886,7 @@ pub trait NSMenuItem: Sized { impl NSMenuItem for id { unsafe fn initWithTitle_action_keyEquivalent_(self, title: id, action: SEL, key: id) -> id { - msg_send![self, initWithTitle:title action:action keyEquivalent:key] + msg_send![self, initWithTitle: title, action: action, keyEquivalent: key] } unsafe fn setKeyEquivalentModifierMask_(self, mask: NSEventModifierFlags) { @@ -941,19 +942,19 @@ pub trait NSWindow: Sized { rect: NSRect, style: NSWindowStyleMask, backing: NSBackingStoreType, - defer: BOOL) -> id; + defer: bool) -> id; unsafe fn initWithContentRect_styleMask_backing_defer_screen_(self, rect: NSRect, style: NSWindowStyleMask, backing: NSBackingStoreType, - defer: BOOL, + defer: bool, screen: id) -> id; // Configuring Windows unsafe fn styleMask(self) -> NSWindowStyleMask; unsafe fn setStyleMask_(self, styleMask: NSWindowStyleMask); unsafe fn toggleFullScreen_(self, sender: id); - unsafe fn worksWhenModal(self) -> BOOL; + unsafe fn worksWhenModal(self) -> bool; unsafe fn alphaValue(self) -> CGFloat; unsafe fn setAlphaValue_(self, windowAlpha: CGFloat); unsafe fn backgroundColor(self) -> id; @@ -962,26 +963,26 @@ pub trait NSWindow: Sized { unsafe fn setColorSpace_(self, colorSpace: id); unsafe fn contentView(self) -> id; unsafe fn setContentView_(self, view: id); - unsafe fn canHide(self) -> BOOL; - unsafe fn setCanHide_(self, canHide: BOOL); - unsafe fn hidesOnDeactivate(self) -> BOOL; - unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: BOOL); + unsafe fn canHide(self) -> bool; + unsafe fn setCanHide_(self, canHide: bool); + unsafe fn hidesOnDeactivate(self) -> bool; + unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: bool); unsafe fn collectionBehavior(self) -> NSWindowCollectionBehavior; unsafe fn setCollectionBehavior_(self, collectionBehavior: NSWindowCollectionBehavior); - unsafe fn setOpaque_(self, opaque: BOOL); - unsafe fn hasShadow(self) -> BOOL; - unsafe fn setHasShadow_(self, hasShadow: BOOL); + unsafe fn setOpaque_(self, opaque: bool); + unsafe fn hasShadow(self) -> bool; + unsafe fn setHasShadow_(self, hasShadow: bool); unsafe fn invalidateShadow(self); - unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> BOOL; + unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> bool; unsafe fn setAutorecalculatesContentBorderThickness_forEdge_(self, - autorecalculateContentBorderThickness: BOOL, - edge: NSRectEdge) -> BOOL; + autorecalculateContentBorderThickness: bool, + edge: NSRectEdge) -> bool; unsafe fn contentBorderThicknessForEdge_(self, edge: NSRectEdge) -> CGFloat; unsafe fn setContentBorderThickness_forEdge_(self, borderThickness: CGFloat, edge: NSRectEdge); unsafe fn delegate(self) -> id; unsafe fn setDelegate_(self, delegate: id); - unsafe fn preventsApplicationTerminationWhenModal(self) -> BOOL; - unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: BOOL); + unsafe fn preventsApplicationTerminationWhenModal(self) -> bool; + unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: bool); // TODO: Accessing Window Information @@ -1005,8 +1006,8 @@ pub trait NSWindow: Sized { unsafe fn setFrameTopLeftPoint_(self, point: NSPoint); unsafe fn constrainFrameRect_toScreen_(self, frameRect: NSRect, screen: id); unsafe fn cascadeTopLeftFromPoint_(self, topLeft: NSPoint) -> NSPoint; - unsafe fn setFrame_display_(self, windowFrame: NSRect, display: BOOL); - unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: BOOL); + unsafe fn setFrame_display_(self, windowFrame: NSRect, display: bool); + unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: bool); unsafe fn aspectRatio(self) -> NSSize; unsafe fn setAspectRatio_(self, aspectRatio: NSSize); unsafe fn minSize(self) -> NSSize; @@ -1016,13 +1017,13 @@ pub trait NSWindow: Sized { unsafe fn performZoom_(self, sender: id); unsafe fn zoom_(self, sender: id); unsafe fn resizeFlags(self) -> NSInteger; - unsafe fn showsResizeIndicator(self) -> BOOL; - unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: BOOL); + unsafe fn showsResizeIndicator(self) -> bool; + unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: bool); unsafe fn resizeIncrements(self) -> NSSize; unsafe fn setResizeIncrements_(self, resizeIncrements: NSSize); - unsafe fn preservesContentDuringLiveResize(self) -> BOOL; - unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: BOOL); - unsafe fn inLiveResize(self) -> BOOL; + unsafe fn preservesContentDuringLiveResize(self) -> bool; + unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: bool); + unsafe fn inLiveResize(self) -> bool; // Sizing Content unsafe fn contentAspectRatio(self) -> NSSize; @@ -1037,7 +1038,7 @@ pub trait NSWindow: Sized { unsafe fn setContentResizeIncrements_(self, contentResizeIncrements: NSSize); // Managing Window Visibility and Occlusion State - unsafe fn isVisible(self) -> BOOL; // NOTE: Deprecated in 10.9 + unsafe fn isVisible(self) -> bool; // NOTE: Deprecated in 10.9 unsafe fn occlusionState(self) -> NSWindowOcclusionState; // Managing Window Layers @@ -1050,15 +1051,15 @@ pub trait NSWindow: Sized { unsafe fn setLevel_(self, level: NSInteger); // Managing Key Status - unsafe fn isKeyWindow(self) -> BOOL; - unsafe fn canBecomeKeyWindow(self) -> BOOL; + unsafe fn isKeyWindow(self) -> bool; + unsafe fn canBecomeKeyWindow(self) -> bool; unsafe fn makeKeyWindow(self); unsafe fn makeKeyAndOrderFront_(self, sender: id); // skipped: becomeKeyWindow (should not be invoked directly, according to Apple's documentation) // skipped: resignKeyWindow (should not be invoked directly, according to Apple's documentation) // Managing Main Status - unsafe fn canBecomeMainWindow(self) -> BOOL; + unsafe fn canBecomeMainWindow(self) -> bool; unsafe fn makeMainWindow(self); // skipped: becomeMainWindow (should not be invoked directly, according to Apple's documentation) // skipped: resignMainWindow (should not be invoked directly, according to Apple's documentation) @@ -1079,8 +1080,8 @@ pub trait NSWindow: Sized { unsafe fn standardWindowButton_(self, windowButtonKind: NSWindowButton) -> id; // Managing Window Tabs - unsafe fn allowsAutomaticWindowTabbing(_: Self) -> BOOL; - unsafe fn setAllowsAutomaticWindowTabbing_(_: Self, allowsAutomaticWindowTabbing: BOOL); + unsafe fn allowsAutomaticWindowTabbing(_: Self) -> bool; + unsafe fn setAllowsAutomaticWindowTabbing_(_: Self, allowsAutomaticWindowTabbing: bool); unsafe fn tabbingIdentifier(self) -> id; unsafe fn tabbingMode(self) -> NSWindowTabbingMode; unsafe fn setTabbingMode_(self, tabbingMode: NSWindowTabbingMode); @@ -1094,7 +1095,7 @@ pub trait NSWindow: Sized { unsafe fn initialFirstResponder(self) -> id; unsafe fn firstResponder(self) -> id; unsafe fn setInitialFirstResponder_(self, responder: id); - unsafe fn makeFirstResponder_(self, responder: id) -> BOOL; + unsafe fn makeFirstResponder_(self, responder: id) -> bool; // TODO: Managing the Key View Loop @@ -1102,11 +1103,11 @@ pub trait NSWindow: Sized { unsafe fn keyDown_(self, event: id); // Handling Mouse Events - unsafe fn acceptsMouseMovedEvents(self) -> BOOL; - unsafe fn ignoresMouseEvents(self) -> BOOL; - unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: BOOL); + unsafe fn acceptsMouseMovedEvents(self) -> bool; + unsafe fn ignoresMouseEvents(self) -> bool; + unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: bool); unsafe fn mouseLocationOutsideOfEventStream(self) -> NSPoint; - unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: BOOL); + unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: bool); unsafe fn windowNumberAtPoint_belowWindowWithWindowNumber_(_: Self, point: NSPoint, windowNumber: NSInteger) -> NSInteger; @@ -1127,15 +1128,15 @@ pub trait NSWindow: Sized { unsafe fn convertRectFromScreen_(self, rect: NSRect) -> NSRect; // Accessing Edited Status - unsafe fn isDocumentEdited(self) -> BOOL; - unsafe fn setDocumentEdited_(self, documentEdited: BOOL); + unsafe fn isDocumentEdited(self) -> bool; + unsafe fn setDocumentEdited_(self, documentEdited: bool); // Managing Titles unsafe fn title(self) -> id; unsafe fn setTitle_(self, title: id); unsafe fn setTitleWithRepresentedFilename_(self, filePath: id); unsafe fn setTitleVisibility_(self, visibility: NSWindowTitleVisibility); - unsafe fn setTitlebarAppearsTransparent_(self, transparent: BOOL); + unsafe fn setTitlebarAppearsTransparent_(self, transparent: bool); unsafe fn representedFilename(self) -> id; unsafe fn setRepresentedFilename_(self, filePath: id); unsafe fn representedURL(self) -> id; @@ -1144,18 +1145,18 @@ pub trait NSWindow: Sized { // Accessing Screen Information unsafe fn screen(self) -> id; unsafe fn deepestScreen(self) -> id; - unsafe fn displaysWhenScreenProfileChanges(self) -> BOOL; - unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: BOOL); + unsafe fn displaysWhenScreenProfileChanges(self) -> bool; + unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: bool); // Moving Windows - unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: BOOL); - unsafe fn setMovable_(self, movable: BOOL); + unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: bool); + unsafe fn setMovable_(self, movable: bool); unsafe fn center(self); // Closing Windows unsafe fn performClose_(self, sender: id); unsafe fn close(self); - unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: BOOL); + unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: bool); // Minimizing Windows unsafe fn performMiniaturize_(self, sender: id); @@ -1182,23 +1183,23 @@ impl NSWindow for id { rect: NSRect, style: NSWindowStyleMask, backing: NSBackingStoreType, - defer: BOOL) -> id { - msg_send![self, initWithContentRect:rect - styleMask:style.bits - backing:backing as NSUInteger - defer:defer] + defer: bool) -> id { + msg_send![self, initWithContentRect:rect, + styleMask:style.bits, + backing:backing as NSUInteger, + defer:Bool::from(defer)] } unsafe fn initWithContentRect_styleMask_backing_defer_screen_(self, rect: NSRect, style: NSWindowStyleMask, backing: NSBackingStoreType, - defer: BOOL, + defer: bool, screen: id) -> id { - msg_send![self, initWithContentRect:rect - styleMask:style.bits - backing:backing as NSUInteger - defer:defer + msg_send![self, initWithContentRect:rect, + styleMask:style.bits, + backing:backing as NSUInteger, + defer:Bool::from(defer), screen:screen] } @@ -1216,8 +1217,8 @@ impl NSWindow for id { msg_send![self, toggleFullScreen:sender] } - unsafe fn worksWhenModal(self) -> BOOL { - msg_send![self, worksWhenModal] + unsafe fn worksWhenModal(self) -> bool { + msg_send_bool![self, worksWhenModal] } unsafe fn alphaValue(self) -> CGFloat { @@ -1252,20 +1253,20 @@ impl NSWindow for id { msg_send![self, setContentView:view] } - unsafe fn canHide(self) -> BOOL { - msg_send![self, canHide] + unsafe fn canHide(self) -> bool { + msg_send_bool![self, canHide] } - unsafe fn setCanHide_(self, canHide: BOOL) { - msg_send![self, setCanHide:canHide] + unsafe fn setCanHide_(self, canHide: bool) { + msg_send![self, setCanHide: Bool::from(canHide)] } - unsafe fn hidesOnDeactivate(self) -> BOOL { - msg_send![self, hidesOnDeactivate] + unsafe fn hidesOnDeactivate(self) -> bool { + msg_send_bool![self, hidesOnDeactivate] } - unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: BOOL) { - msg_send![self, setHidesOnDeactivate:hideOnDeactivate] + unsafe fn setHidesOnDeactivate_(self, hideOnDeactivate: bool) { + msg_send![self, setHidesOnDeactivate: Bool::from(hideOnDeactivate)] } unsafe fn collectionBehavior(self) -> NSWindowCollectionBehavior { @@ -1276,31 +1277,31 @@ impl NSWindow for id { msg_send![self, setCollectionBehavior:collectionBehavior] } - unsafe fn setOpaque_(self, opaque: BOOL) { - msg_send![self, setOpaque:opaque] + unsafe fn setOpaque_(self, opaque: bool) { + msg_send![self, setOpaque: Bool::from(opaque)] } - unsafe fn hasShadow(self) -> BOOL { - msg_send![self, hasShadow] + unsafe fn hasShadow(self) -> bool { + msg_send_bool![self, hasShadow] } - unsafe fn setHasShadow_(self, hasShadow: BOOL) { - msg_send![self, setHasShadow:hasShadow] + unsafe fn setHasShadow_(self, hasShadow: bool) { + msg_send![self, setHasShadow: Bool::from(hasShadow)] } unsafe fn invalidateShadow(self) { msg_send![self, invalidateShadow] } - unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> BOOL { - msg_send![self, autorecalculatesContentBorderThicknessForEdge:edge] + unsafe fn autorecalculatesContentBorderThicknessForEdge_(self, edge: NSRectEdge) -> bool { + msg_send_bool![self, autorecalculatesContentBorderThicknessForEdge:edge] } unsafe fn setAutorecalculatesContentBorderThickness_forEdge_(self, - autorecalculateContentBorderThickness: BOOL, - edge: NSRectEdge) -> BOOL { - msg_send![self, setAutorecalculatesContentBorderThickness: - autorecalculateContentBorderThickness forEdge:edge] + autorecalculateContentBorderThickness: bool, + edge: NSRectEdge) -> bool { + msg_send_bool![self, setAutorecalculatesContentBorderThickness: + Bool::from(autorecalculateContentBorderThickness), forEdge:edge] } unsafe fn contentBorderThicknessForEdge_(self, edge: NSRectEdge) -> CGFloat { @@ -1308,7 +1309,7 @@ impl NSWindow for id { } unsafe fn setContentBorderThickness_forEdge_(self, borderThickness: CGFloat, edge: NSRectEdge) { - msg_send![self, setContentBorderThickness:borderThickness forEdge:edge] + msg_send![self, setContentBorderThickness:borderThickness, forEdge:edge] } unsafe fn delegate(self) -> id { @@ -1319,12 +1320,12 @@ impl NSWindow for id { msg_send![self, setDelegate:delegate] } - unsafe fn preventsApplicationTerminationWhenModal(self) -> BOOL { - msg_send![self, preventsApplicationTerminationWhenModal] + unsafe fn preventsApplicationTerminationWhenModal(self) -> bool { + msg_send_bool![self, preventsApplicationTerminationWhenModal] } - unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: BOOL) { - msg_send![self, setPreventsApplicationTerminationWhenModal:flag] + unsafe fn setPreventsApplicationTerminationWhenModal_(self, flag: bool) { + msg_send![self, setPreventsApplicationTerminationWhenModal: Bool::from(flag)] } // TODO: Accessing Window Information @@ -1332,15 +1333,15 @@ impl NSWindow for id { // Getting Layout Information unsafe fn contentRectForFrameRect_styleMask_(self, windowFrame: NSRect, windowStyle: NSWindowStyleMask) -> NSRect { - msg_send![self, contentRectForFrameRect:windowFrame styleMask:windowStyle.bits] + msg_send![self, contentRectForFrameRect: windowFrame, styleMask: windowStyle.bits] } unsafe fn frameRectForContentRect_styleMask_(self, windowContentRect: NSRect, windowStyle: NSWindowStyleMask) -> NSRect { - msg_send![self, frameRectForContentRect:windowContentRect styleMask:windowStyle.bits] + msg_send![self, frameRectForContentRect: windowContentRect, styleMask: windowStyle.bits] } unsafe fn minFrameWidthWithTitle_styleMask_(self, windowTitle: id, windowStyle: NSWindowStyleMask) -> CGFloat { - msg_send![self, minFrameWidthWithTitle:windowTitle styleMask:windowStyle.bits] + msg_send![self, minFrameWidthWithTitle: windowTitle, styleMask: windowStyle.bits] } unsafe fn contentRectForFrameRect_(self, windowFrame: NSRect) -> NSRect { @@ -1382,19 +1383,19 @@ impl NSWindow for id { } unsafe fn constrainFrameRect_toScreen_(self, frameRect: NSRect, screen: id) { - msg_send![self, constrainFrameRect:frameRect toScreen:screen] + msg_send![self, constrainFrameRect: frameRect, toScreen: screen] } unsafe fn cascadeTopLeftFromPoint_(self, topLeft: NSPoint) -> NSPoint { msg_send![self, cascadeTopLeftFromPoint:topLeft] } - unsafe fn setFrame_display_(self, windowFrame: NSRect, display: BOOL) { - msg_send![self, setFrame:windowFrame display:display] + unsafe fn setFrame_display_(self, windowFrame: NSRect, display: bool) { + msg_send![self, setFrame: windowFrame, display: Bool::from(display)] } - unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: BOOL) { - msg_send![self, setFrame:windowFrame displayViews:display] + unsafe fn setFrame_displayViews_(self, windowFrame: NSRect, display: bool) { + msg_send![self, setFrame: windowFrame, displayViews: Bool::from(display)] } unsafe fn aspectRatio(self) -> NSSize { @@ -1433,12 +1434,12 @@ impl NSWindow for id { msg_send![self, resizeFlags] } - unsafe fn showsResizeIndicator(self) -> BOOL { - msg_send![self, showsResizeIndicator] + unsafe fn showsResizeIndicator(self) -> bool { + msg_send_bool![self, showsResizeIndicator] } - unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: BOOL) { - msg_send![self, setShowsResizeIndicator:showsResizeIndicator] + unsafe fn setShowsResizeIndicator_(self, showsResizeIndicator: bool) { + msg_send![self, setShowsResizeIndicator: Bool::from(showsResizeIndicator)] } unsafe fn resizeIncrements(self) -> NSSize { @@ -1449,16 +1450,16 @@ impl NSWindow for id { msg_send![self, setResizeIncrements:resizeIncrements] } - unsafe fn preservesContentDuringLiveResize(self) -> BOOL { - msg_send![self, preservesContentDuringLiveResize] + unsafe fn preservesContentDuringLiveResize(self) -> bool { + msg_send_bool![self, preservesContentDuringLiveResize] } - unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: BOOL) { - msg_send![self, setPreservesContentDuringLiveResize:preservesContentDuringLiveResize] + unsafe fn setPreservesContentDuringLiveResize_(self, preservesContentDuringLiveResize: bool) { + msg_send![self, setPreservesContentDuringLiveResize: Bool::from(preservesContentDuringLiveResize)] } - unsafe fn inLiveResize(self) -> BOOL { - msg_send![self, inLiveResize] + unsafe fn inLiveResize(self) -> bool { + msg_send_bool![self, inLiveResize] } // Sizing Content @@ -1505,8 +1506,8 @@ impl NSWindow for id { // Managing Window Visibility and Occlusion State - unsafe fn isVisible(self) -> BOOL { - msg_send![self, isVisible] + unsafe fn isVisible(self) -> bool { + msg_send_bool![self, isVisible] } unsafe fn occlusionState(self) -> NSWindowOcclusionState { @@ -1532,7 +1533,7 @@ impl NSWindow for id { } unsafe fn orderFrontWindow_relativeTo_(self, ordering_mode: NSWindowOrderingMode, other_window_number: NSInteger) { - msg_send![self, orderWindow:ordering_mode relativeTo:other_window_number] + msg_send![self, orderWindow: ordering_mode, relativeTo: other_window_number] } unsafe fn level(self) -> NSInteger { @@ -1545,12 +1546,12 @@ impl NSWindow for id { // Managing Key Status - unsafe fn isKeyWindow(self) -> BOOL { - msg_send![self, isKeyWindow] + unsafe fn isKeyWindow(self) -> bool { + msg_send_bool![self, isKeyWindow] } - unsafe fn canBecomeKeyWindow(self) -> BOOL { - msg_send![self, canBecomeKeyWindow] + unsafe fn canBecomeKeyWindow(self) -> bool { + msg_send_bool![self, canBecomeKeyWindow] } unsafe fn makeKeyWindow(self) { @@ -1563,8 +1564,8 @@ impl NSWindow for id { // Managing Main Status - unsafe fn canBecomeMainWindow(self) -> BOOL { - msg_send![self, canBecomeMainWindow] + unsafe fn canBecomeMainWindow(self) -> bool { + msg_send_bool![self, canBecomeMainWindow] } unsafe fn makeMainWindow(self) { @@ -1599,12 +1600,12 @@ impl NSWindow for id { } // Managing Window Tabs - unsafe fn allowsAutomaticWindowTabbing(_: Self) -> BOOL { - msg_send![class!(NSWindow), allowsAutomaticWindowTabbing] + unsafe fn allowsAutomaticWindowTabbing(_: Self) -> bool { + msg_send_bool![class!(NSWindow), allowsAutomaticWindowTabbing] } - unsafe fn setAllowsAutomaticWindowTabbing_(_: Self, allowsAutomaticWindowTabbing: BOOL) { - msg_send![class!(NSWindow), setAllowsAutomaticWindowTabbing:allowsAutomaticWindowTabbing] + unsafe fn setAllowsAutomaticWindowTabbing_(_: Self, allowsAutomaticWindowTabbing: bool) { + msg_send![class!(NSWindow), setAllowsAutomaticWindowTabbing: Bool::from(allowsAutomaticWindowTabbing)] } unsafe fn tabbingIdentifier(self) -> id { @@ -1620,7 +1621,7 @@ impl NSWindow for id { } unsafe fn addTabbedWindow_ordered_(self, window: id, ordering_mode: NSWindowOrderingMode) { - msg_send![self, addTabbedWindow:window ordered: ordering_mode] + msg_send![self, addTabbedWindow: window, ordered: ordering_mode] } unsafe fn toggleTabBar_(self, sender: id) { @@ -1643,8 +1644,8 @@ impl NSWindow for id { msg_send![self, setInitialFirstResponder:responder] } - unsafe fn makeFirstResponder_(self, responder: id) -> BOOL { - msg_send![self, makeFirstResponder:responder] + unsafe fn makeFirstResponder_(self, responder: id) -> bool { + msg_send_bool![self, makeFirstResponder:responder] } // TODO: Managing the Key View Loop @@ -1657,30 +1658,30 @@ impl NSWindow for id { // Handling Mouse Events - unsafe fn acceptsMouseMovedEvents(self) -> BOOL { - msg_send![self, acceptsMouseMovedEvents] + unsafe fn acceptsMouseMovedEvents(self) -> bool { + msg_send_bool![self, acceptsMouseMovedEvents] } - unsafe fn ignoresMouseEvents(self) -> BOOL { - msg_send![self, ignoresMouseEvents] + unsafe fn ignoresMouseEvents(self) -> bool { + msg_send_bool![self, ignoresMouseEvents] } - unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: BOOL) { - msg_send![self, setIgnoresMouseEvents:ignoreMouseEvents] + unsafe fn setIgnoresMouseEvents_(self, ignoreMouseEvents: bool) { + msg_send![self, setIgnoresMouseEvents: Bool::from(ignoreMouseEvents)] } unsafe fn mouseLocationOutsideOfEventStream(self) -> NSPoint { msg_send![self, mouseLocationOutsideOfEventStream] } - unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: BOOL) { - msg_send![self, setAcceptsMouseMovedEvents:acceptMouseMovedEvents] + unsafe fn setAcceptsMouseMovedEvents_(self, acceptMouseMovedEvents: bool) { + msg_send![self, setAcceptsMouseMovedEvents: Bool::from(acceptMouseMovedEvents)] } unsafe fn windowNumberAtPoint_belowWindowWithWindowNumber_(_: Self, point: NSPoint, windowNumber: NSInteger) -> NSInteger { - msg_send![class!(NSWindow), windowNumberAtPoint:point belowWindowWithWindowNumber:windowNumber] + msg_send![class!(NSWindow), windowNumberAtPoint: point, belowWindowWithWindowNumber: windowNumber] } // Converting Coordinates @@ -1690,7 +1691,7 @@ impl NSWindow for id { } unsafe fn backingAlignedRect_options_(self, rect: NSRect, options: NSAlignmentOptions) -> NSRect { - msg_send![self, backingAlignedRect:rect options:options] + msg_send![self, backingAlignedRect: rect, options: options] } unsafe fn convertRectFromBacking_(self, rect: NSRect) -> NSRect { @@ -1711,12 +1712,12 @@ impl NSWindow for id { // Accessing Edited Status - unsafe fn isDocumentEdited(self) -> BOOL { - msg_send![self, isDocumentEdited] + unsafe fn isDocumentEdited(self) -> bool { + msg_send_bool![self, isDocumentEdited] } - unsafe fn setDocumentEdited_(self, documentEdited: BOOL) { - msg_send![self, setDocumentEdited:documentEdited] + unsafe fn setDocumentEdited_(self, documentEdited: bool) { + msg_send![self, setDocumentEdited: Bool::from(documentEdited)] } // Managing Titles @@ -1737,8 +1738,8 @@ impl NSWindow for id { msg_send![self, setTitleVisibility:visibility] } - unsafe fn setTitlebarAppearsTransparent_(self, transparent: BOOL) { - msg_send![self, setTitlebarAppearsTransparent:transparent] + unsafe fn setTitlebarAppearsTransparent_(self, transparent: bool) { + msg_send![self, setTitlebarAppearsTransparent: Bool::from(transparent)] } unsafe fn representedFilename(self) -> id { @@ -1767,22 +1768,22 @@ impl NSWindow for id { msg_send![self, deepestScreen] } - unsafe fn displaysWhenScreenProfileChanges(self) -> BOOL { - msg_send![self, displaysWhenScreenProfileChanges] + unsafe fn displaysWhenScreenProfileChanges(self) -> bool { + msg_send_bool![self, displaysWhenScreenProfileChanges] } - unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: BOOL) { - msg_send![self, setDisplaysWhenScreenProfileChanges:displaysWhenScreenProfileChanges] + unsafe fn setDisplaysWhenScreenProfileChanges_(self, displaysWhenScreenProfileChanges: bool) { + msg_send![self, setDisplaysWhenScreenProfileChanges: Bool::from(displaysWhenScreenProfileChanges)] } // Moving Windows - unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: BOOL) { - msg_send![self, setMovableByWindowBackground:movableByWindowBackground] + unsafe fn setMovableByWindowBackground_(self, movableByWindowBackground: bool) { + msg_send![self, setMovableByWindowBackground: Bool::from(movableByWindowBackground)] } - unsafe fn setMovable_(self, movable: BOOL) { - msg_send![self, setMovable:movable] + unsafe fn setMovable_(self, movable: bool) { + msg_send![self, setMovable: Bool::from(movable)] } unsafe fn center(self) { @@ -1799,8 +1800,8 @@ impl NSWindow for id { msg_send![self, close] } - unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: BOOL) { - msg_send![self, setReleasedWhenClosed:releasedWhenClosed] + unsafe fn setReleasedWhenClosed_(self, releasedWhenClosed: bool) { + msg_send![self, setReleasedWhenClosed: Bool::from(releasedWhenClosed)] } // Minimizing Windows @@ -1849,34 +1850,34 @@ pub trait NSPanel: Sized { // NSPanel subclasses NSWindow, hence we only add the added methods // https://developer.apple.com/documentation/appkit/nspanel - unsafe fn setBecomesKeyOnlyIfNeeded(self, becomesKeyOnlyIfNeeded: BOOL); - unsafe fn becomesKeyOnlyIfNeeded(self) -> BOOL; - unsafe fn setFloatingPanel(self, floatingPanel: BOOL); - unsafe fn floatingPanel(self) -> BOOL; - unsafe fn setWorksWhenModal(self, worksWithPanel: BOOL); + unsafe fn setBecomesKeyOnlyIfNeeded(self, becomesKeyOnlyIfNeeded: bool); + unsafe fn becomesKeyOnlyIfNeeded(self) -> bool; + unsafe fn setFloatingPanel(self, floatingPanel: bool); + unsafe fn floatingPanel(self) -> bool; + unsafe fn setWorksWhenModal(self, worksWithPanel: bool); } impl NSPanel for id { // NSPanel subclasses NSWindow, hence we only add the added methods // https://developer.apple.com/documentation/appkit/nspanel - unsafe fn setBecomesKeyOnlyIfNeeded(self, becomesKeyOnlyIfNeeded: BOOL) { - msg_send![self, setBecomesKeyOnlyIfNeeded: becomesKeyOnlyIfNeeded] + unsafe fn setBecomesKeyOnlyIfNeeded(self, becomesKeyOnlyIfNeeded: bool) { + msg_send![self, setBecomesKeyOnlyIfNeeded: Bool::from(becomesKeyOnlyIfNeeded)] } - unsafe fn becomesKeyOnlyIfNeeded(self) -> BOOL { - msg_send![self, becomesKeyOnlyIfNeeded] + unsafe fn becomesKeyOnlyIfNeeded(self) -> bool { + msg_send_bool![self, becomesKeyOnlyIfNeeded] } - unsafe fn setFloatingPanel(self, floatingPanel: BOOL) { - msg_send![self, setFloatingPanel: floatingPanel] + unsafe fn setFloatingPanel(self, floatingPanel: bool) { + msg_send![self, setFloatingPanel: Bool::from(floatingPanel)] } - unsafe fn floatingPanel(self) -> BOOL { - msg_send![self, isFloatingPanel] + unsafe fn floatingPanel(self) -> bool { + msg_send_bool![self, isFloatingPanel] } - unsafe fn setWorksWhenModal(self, worksWhenModal: BOOL) { - msg_send![self, setWorksWhenModal: worksWhenModal] + unsafe fn setWorksWhenModal(self, worksWhenModal: bool) { + msg_send![self, setWorksWhenModal: Bool::from(worksWhenModal)] } } @@ -1895,7 +1896,7 @@ pub trait NSSavePanel: Sized { } unsafe fn setDirectoryURL(self, url: id); - unsafe fn setCanCreateDirectories(self, canCreateDirectories: BOOL); + unsafe fn setCanCreateDirectories(self, canCreateDirectories: bool); unsafe fn URL(self) -> id; unsafe fn runModal(self) -> NSModalResponse; } @@ -1905,8 +1906,8 @@ impl NSSavePanel for id { msg_send![self, setDirectoryURL: url] } - unsafe fn setCanCreateDirectories(self, canCreateDirectories: BOOL) { - msg_send![self, setCanCreateDirectories: canCreateDirectories] + unsafe fn setCanCreateDirectories(self, canCreateDirectories: bool) { + msg_send![self, setCanCreateDirectories: Bool::from(canCreateDirectories)] } unsafe fn URL(self) -> id { @@ -1923,28 +1924,28 @@ pub trait NSOpenPanel: NSSavePanel { msg_send![class!(NSOpenPanel), openPanel] } - unsafe fn setCanChooseFiles_(self, canChooseFiles: BOOL); - unsafe fn setCanChooseDirectories_(self, canChooseDirectories: BOOL); - unsafe fn setResolvesAliases_(self, resolvesAliases: BOOL); - unsafe fn setAllowsMultipleSelection_(self, allowsMultipleSelection: BOOL); + unsafe fn setCanChooseFiles_(self, canChooseFiles: bool); + unsafe fn setCanChooseDirectories_(self, canChooseDirectories: bool); + unsafe fn setResolvesAliases_(self, resolvesAliases: bool); + unsafe fn setAllowsMultipleSelection_(self, allowsMultipleSelection: bool); unsafe fn URLs(self) -> id; } impl NSOpenPanel for id { - unsafe fn setCanChooseFiles_(self, canChooseFiles: BOOL) { - msg_send![self, setCanChooseFiles: canChooseFiles] + unsafe fn setCanChooseFiles_(self, canChooseFiles: bool) { + msg_send![self, setCanChooseFiles: Bool::from(canChooseFiles)] } - unsafe fn setCanChooseDirectories_(self, canChooseDirectories: BOOL) { - msg_send![self, setCanChooseDirectories: canChooseDirectories] + unsafe fn setCanChooseDirectories_(self, canChooseDirectories: bool) { + msg_send![self, setCanChooseDirectories: Bool::from(canChooseDirectories)] } - unsafe fn setResolvesAliases_(self, resolvesAliases: BOOL) { - msg_send![self, setResolvesAliases: resolvesAliases] + unsafe fn setResolvesAliases_(self, resolvesAliases: bool) { + msg_send![self, setResolvesAliases: Bool::from(resolvesAliases)] } - unsafe fn setAllowsMultipleSelection_(self, allowsMultipleSelection: BOOL) { - msg_send![self, setAllowsMultipleSelection: allowsMultipleSelection] + unsafe fn setAllowsMultipleSelection_(self, allowsMultipleSelection: bool) { + msg_send![self, setAllowsMultipleSelection: Bool::from(allowsMultipleSelection)] } unsafe fn URLs(self) -> id { @@ -1983,15 +1984,15 @@ pub trait NSView: Sized { unsafe fn setFrameSize(self, frameSize: NSSize); unsafe fn setFrameOrigin(self, frameOrigin: NSPoint); unsafe fn display_(self); - unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: BOOL); + unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: bool); unsafe fn convertPoint_fromView_(self, point: NSPoint, view: id) -> NSPoint; unsafe fn addSubview_(self, view: id); unsafe fn superview(self) -> id; unsafe fn removeFromSuperview(self); unsafe fn setAutoresizingMask_(self, autoresizingMask: NSAutoresizingMaskOptions); - unsafe fn wantsLayer(self) -> BOOL; - unsafe fn setWantsLayer(self, wantsLayer: BOOL); + unsafe fn wantsLayer(self) -> bool; + unsafe fn setWantsLayer(self, wantsLayer: bool); unsafe fn layer(self) -> id; unsafe fn setLayer(self, layer: id); @@ -2032,12 +2033,12 @@ impl NSView for id { msg_send![self, display] } - unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: BOOL) { - msg_send![self, setWantsBestResolutionOpenGLSurface:flag] + unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: bool) { + msg_send![self, setWantsBestResolutionOpenGLSurface: Bool::from(flag)] } unsafe fn convertPoint_fromView_(self, point: NSPoint, view: id) -> NSPoint { - msg_send![self, convertPoint:point fromView:view] + msg_send![self, convertPoint: point, fromView: view] } unsafe fn addSubview_(self, view: id) { @@ -2056,12 +2057,12 @@ impl NSView for id { msg_send![self, setAutoresizingMask:autoresizingMask] } - unsafe fn wantsLayer(self) -> BOOL { - msg_send![self, wantsLayer] + unsafe fn wantsLayer(self) -> bool { + msg_send_bool![self, wantsLayer] } - unsafe fn setWantsLayer(self, wantsLayer: BOOL) { - msg_send![self, setWantsLayer:wantsLayer] + unsafe fn setWantsLayer(self, wantsLayer: bool) { + msg_send![self, setWantsLayer: Bool::from(wantsLayer)] } unsafe fn layer(self) -> id { @@ -2116,7 +2117,7 @@ pub trait NSOpenGLView: Sized { impl NSOpenGLView for id { unsafe fn initWithFrame_pixelFormat_(self, frameRect: NSRect, format: id) -> id { - msg_send![self, initWithFrame:frameRect pixelFormat:format] + msg_send![self, initWithFrame: frameRect, pixelFormat: format] } unsafe fn display_(self) { @@ -2158,7 +2159,7 @@ impl NSOpenGLPixelFormat for id { // Managing the Pixel Format unsafe fn getValues_forAttribute_forVirtualScreen_(self, val: *mut GLint, attrib: NSOpenGLPixelFormatAttribute, screen: GLint) { - msg_send![self, getValues:val forAttribute:attrib forVirtualScreen:screen] + msg_send![self, getValues: val, forAttribute: attrib, forVirtualScreen:screen] } unsafe fn numberOfVirtualScreens(self) -> GLint { @@ -2205,7 +2206,7 @@ impl NSOpenGLContext for id { // Context Creation unsafe fn initWithFormat_shareContext_(self, format: id /* (NSOpenGLPixelFormat *) */, shareContext: id /* (NSOpenGLContext *) */) -> id /* (instancetype) */ { - msg_send![self, initWithFormat:format shareContext:shareContext] + msg_send![self, initWithFormat: format, shareContext: shareContext] } unsafe fn initWithCGLContextObj_(self, context: CGLContextObj) -> id /* (instancetype) */ { @@ -2253,11 +2254,11 @@ impl NSOpenGLContext for id { // Context Parameter Handling unsafe fn setValues_forParameter_(self, vals: *const GLint, param: NSOpenGLContextParameter) { - msg_send![self, setValues:vals forParameter:param] + msg_send![self, setValues: vals, forParameter: param] } unsafe fn getValues_forParameter_(self, vals: *mut GLint, param: NSOpenGLContextParameter) { - msg_send![self, getValues:vals forParameter:param] + msg_send![self, getValues: vals, forParameter: param] } // Working with Virtual Screens @@ -2546,7 +2547,7 @@ pub trait NSEvent: Sized { context: id /* (NSGraphicsContext *) */, characters: id /* (NSString *) */, unmodCharacters: id /* (NSString *) */, - repeatKey: BOOL, + repeatKey: bool, code: libc::c_ushort) -> id /* (NSEvent *) */; unsafe fn mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_( _: Self, @@ -2604,7 +2605,7 @@ pub trait NSEvent: Sized { unsafe fn characters(self) -> id /* (NSString *) */; unsafe fn charactersIgnoringModifiers(self) -> id /* (NSString *) */; unsafe fn keyCode(self) -> libc::c_ushort; - unsafe fn isARepeat(self) -> BOOL; + unsafe fn isARepeat(self) -> bool; // Getting Mouse Event Information unsafe fn pressedMouseButtons(_: Self) -> NSUInteger; @@ -2614,8 +2615,8 @@ pub trait NSEvent: Sized { unsafe fn clickCount(self) -> NSInteger; unsafe fn pressure(self) -> libc::c_float; unsafe fn stage(self) -> NSInteger; - unsafe fn setMouseCoalescingEnabled_(_: Self, flag: BOOL); - unsafe fn isMouseCoalescingEnabled(_: Self) -> BOOL; + unsafe fn setMouseCoalescingEnabled_(_: Self, flag: bool); + unsafe fn isMouseCoalescingEnabled(_: Self) -> bool; // Getting Mouse-Tracking Event Information unsafe fn eventNumber(self) -> NSInteger; @@ -2662,7 +2663,7 @@ pub trait NSEvent: Sized { // Getting Touch and Gesture Information unsafe fn magnification(self) -> CGFloat; unsafe fn touchesMatchingPhase_inView_(self, phase: NSTouchPhase, view: id /* (NSView *) */) -> id /* (NSSet *) */; - unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> BOOL; + unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> bool; // Monitoring Application Events // TODO: addGlobalMonitorForEventsMatchingMask_handler_ (unsure how to bind to blocks) @@ -2670,7 +2671,7 @@ pub trait NSEvent: Sized { unsafe fn removeMonitor_(_: Self, eventMonitor: id); // Scroll Wheel and Flick Events - unsafe fn hasPreciseScrollingDeltas(self) -> BOOL; + unsafe fn hasPreciseScrollingDeltas(self) -> bool; unsafe fn scrollingDeltaX(self) -> CGFloat; unsafe fn scrollingDeltaY(self) -> CGFloat; unsafe fn momentumPhase(self) -> NSEventPhase; @@ -2694,18 +2695,18 @@ impl NSEvent for id { context: id /* (NSGraphicsContext *) */, characters: id /* (NSString *) */, unmodCharacters: id /* (NSString *) */, - repeatKey: BOOL, + repeatKey: bool, code: libc::c_ushort) -> id /* (NSEvent *) */ { - msg_send![class!(NSEvent), keyEventWithType:eventType - location:location - modifierFlags:modifierFlags - timestamp:timestamp - windowNumber:windowNumber - context:context - characters:characters - charactersIgnoringModifiers:unmodCharacters - isARepeat:repeatKey + msg_send![class!(NSEvent), keyEventWithType:eventType, + location:location, + modifierFlags:modifierFlags, + timestamp:timestamp, + windowNumber:windowNumber, + context:context, + characters:characters, + charactersIgnoringModifiers:unmodCharacters, + isARepeat:Bool::from(repeatKey), keyCode:code] } @@ -2721,14 +2722,14 @@ impl NSEvent for id { clickCount: NSInteger, pressure: libc::c_float) -> id /* (NSEvent *) */ { - msg_send![class!(NSEvent), mouseEventWithType:eventType - location:location - modifierFlags:modifierFlags - timestamp:timestamp - windowNumber:windowNumber - context:context - eventNumber:eventNumber - clickCount:clickCount + msg_send![class!(NSEvent), mouseEventWithType:eventType, + location:location, + modifierFlags:modifierFlags, + timestamp:timestamp, + windowNumber:windowNumber, + context:context, + eventNumber:eventNumber, + clickCount:clickCount, pressure:pressure] } @@ -2744,14 +2745,14 @@ impl NSEvent for id { trackingNumber: NSInteger, userData: *mut c_void) -> id /* (NSEvent *) */ { - msg_send![class!(NSEvent), enterExitEventWithType:eventType - location:location - modifierFlags:modifierFlags - timestamp:timestamp - windowNumber:windowNumber - context:context - eventNumber:eventNumber - trackingNumber:trackingNumber + msg_send![class!(NSEvent), enterExitEventWithType:eventType, + location:location, + modifierFlags:modifierFlags, + timestamp:timestamp, + windowNumber:windowNumber, + context:context, + eventNumber:eventNumber, + trackingNumber:trackingNumber, userData:userData] } @@ -2767,14 +2768,14 @@ impl NSEvent for id { data1: NSInteger, data2: NSInteger) -> id /* (NSEvent *) */ { - msg_send![class!(NSEvent), otherEventWithType:eventType - location:location - modifierFlags:modifierFlags - timestamp:timestamp - windowNumber:windowNumber - context:context - subtype:subtype - data1:data1 + msg_send![class!(NSEvent), otherEventWithType:eventType, + location:location, + modifierFlags:modifierFlags, + timestamp:timestamp, + windowNumber:windowNumber, + context:context, + subtype:subtype, + data1:data1, data2:data2] } @@ -2853,8 +2854,8 @@ impl NSEvent for id { msg_send![self, keyCode] } - unsafe fn isARepeat(self) -> BOOL { - msg_send![self, isARepeat] + unsafe fn isARepeat(self) -> bool { + msg_send_bool![self, isARepeat] } // Getting Mouse Event Information @@ -2887,12 +2888,12 @@ impl NSEvent for id { msg_send![self, stage] } - unsafe fn setMouseCoalescingEnabled_(_: Self, flag: BOOL) { - msg_send![class!(NSEvent), setMouseCoalescingEnabled:flag] + unsafe fn setMouseCoalescingEnabled_(_: Self, flag: bool) { + msg_send![class!(NSEvent), setMouseCoalescingEnabled: Bool::from(flag)] } - unsafe fn isMouseCoalescingEnabled(_: Self) -> BOOL { - msg_send![class!(NSEvent), isMouseCoalescingEnabled] + unsafe fn isMouseCoalescingEnabled(_: Self) -> bool { + msg_send_bool![class!(NSEvent), isMouseCoalescingEnabled] } // Getting Mouse-Tracking Event Information @@ -3020,7 +3021,7 @@ impl NSEvent for id { // Requesting and Stopping Periodic Events unsafe fn startPeriodicEventsAfterDelay_withPeriod_(_: Self, delaySeconds: NSTimeInterval, periodSeconds: NSTimeInterval) { - msg_send![class!(NSEvent), startPeriodicEventsAfterDelay:delaySeconds withPeriod:periodSeconds] + msg_send![class!(NSEvent), startPeriodicEventsAfterDelay: delaySeconds, withPeriod: periodSeconds] } unsafe fn stopPeriodicEvents(_: Self) { @@ -3034,11 +3035,11 @@ impl NSEvent for id { } unsafe fn touchesMatchingPhase_inView_(self, phase: NSTouchPhase, view: id /* (NSView *) */) -> id /* (NSSet *) */ { - msg_send![self, touchesMatchingPhase:phase inView:view] + msg_send![self, touchesMatchingPhase: phase, inView: view] } - unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> BOOL { - msg_send![class!(NSEvent), isSwipeTrackingFromScrollEventsEnabled] + unsafe fn isSwipeTrackingFromScrollEventsEnabled(_: Self) -> bool { + msg_send_bool![class!(NSEvent), isSwipeTrackingFromScrollEventsEnabled] } // Monitoring Application Events @@ -3052,8 +3053,8 @@ impl NSEvent for id { // Scroll Wheel and Flick Events - unsafe fn hasPreciseScrollingDeltas(self) -> BOOL { - msg_send![self, hasPreciseScrollingDeltas] + unsafe fn hasPreciseScrollingDeltas(self) -> bool { + msg_send_bool![self, hasPreciseScrollingDeltas] } unsafe fn scrollingDeltaX(self) -> CGFloat { @@ -3093,7 +3094,7 @@ pub trait NSScreen: Sized { unsafe fn deviceDescription(self) -> id /* (NSDictionary *) */; unsafe fn visibleFrame(self) -> NSRect; unsafe fn colorSpace(self) -> id /* (NSColorSpace *) */; - unsafe fn screensHaveSeparateSpaces(_: Self) -> BOOL; + unsafe fn screensHaveSeparateSpaces(_: Self) -> bool; // Screen Backing Coordinate Conversion unsafe fn backingAlignedRect_options_(self, aRect: NSRect, options: NSAlignmentOptions) -> NSRect; @@ -3143,14 +3144,14 @@ impl NSScreen for id { msg_send![self, colorSpace] } - unsafe fn screensHaveSeparateSpaces(_: Self) -> BOOL { - msg_send![class!(NSScreen), screensHaveSeparateSpaces] + unsafe fn screensHaveSeparateSpaces(_: Self) -> bool { + msg_send_bool![class!(NSScreen), screensHaveSeparateSpaces] } // Screen Backing Coordinate Conversion unsafe fn backingAlignedRect_options_(self, aRect: NSRect, options: NSAlignmentOptions) -> NSRect { - msg_send![self, backingAlignedRect:aRect options:options] + msg_send![self, backingAlignedRect: aRect, options: options] } unsafe fn backingScaleFactor(self) -> CGFloat { @@ -3172,19 +3173,19 @@ pub trait NSControl: Sized { msg_send![class!(NSControl), alloc] } unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; - unsafe fn isEnabled_(self) -> BOOL; - unsafe fn setEnabled_(self, enabled: BOOL) -> BOOL; + unsafe fn isEnabled_(self) -> bool; + unsafe fn setEnabled_(self, enabled: bool) -> bool; } impl NSControl for id { unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { msg_send![self, initWithFrame:frameRect] } - unsafe fn isEnabled_(self) -> BOOL { - msg_send![self, isEnabled] + unsafe fn isEnabled_(self) -> bool { + msg_send_bool![self, isEnabled] } - unsafe fn setEnabled_(self, enabled: BOOL) -> BOOL { - msg_send![self, setEnabled:enabled] + unsafe fn setEnabled_(self, enabled: bool) -> bool { + msg_send_bool![self, setEnabled: Bool::from(enabled)] } } @@ -3250,8 +3251,8 @@ pub trait NSImage: Sized { unsafe fn initWithDataIgnoringOrientation_(self, data: id /* (NSData *) */) -> id; unsafe fn initWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> id; unsafe fn initWithSize_flipped_drawingHandler_(self, size: NSSize, - drawingHandlerShouldBeCalledWithFlippedContext: BOOL, - drawingHandler: *mut Block<(NSRect,), BOOL>); + drawingHandlerShouldBeCalledWithFlippedContext: bool, + drawingHandler: *mut Block<(NSRect,), Bool>); unsafe fn initWithSize_(self, aSize: NSSize) -> id; unsafe fn imageNamed_(_: Self, name: id /* (NSString *) */) -> id { @@ -3259,12 +3260,12 @@ pub trait NSImage: Sized { } unsafe fn name(self) -> id /* (NSString *) */; - unsafe fn setName_(self, name: id /* (NSString *) */) -> BOOL; + unsafe fn setName_(self, name: id /* (NSString *) */) -> bool; unsafe fn size(self) -> NSSize; - unsafe fn template(self) -> BOOL; + unsafe fn template(self) -> bool; - unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> BOOL; + unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> bool; unsafe fn imageTypes(self) -> id /* (NSArray ) */; unsafe fn imageUnfilteredTypes(self) -> id /* (NSArray ) */; @@ -3276,9 +3277,9 @@ pub trait NSImage: Sized { referenceContext: id /* (NSGraphicsContext *) */, hints: id /* (NSDictionary *) */) -> id /* (NSImageRep *) */; - unsafe fn prefersColorMatch(self) -> BOOL; - unsafe fn usesEPSOnResolutionMismatch(self) -> BOOL; - unsafe fn matchesOnMultipleResolution(self) -> BOOL; + unsafe fn prefersColorMatch(self) -> bool; + unsafe fn usesEPSOnResolutionMismatch(self) -> bool; + unsafe fn matchesOnMultipleResolution(self) -> bool; unsafe fn drawInRect_(self, rect: NSRect); unsafe fn drawAtPoint_fromRect_operation_fraction_(self, point: NSPoint, srcRect: NSRect, @@ -3286,15 +3287,15 @@ pub trait NSImage: Sized { unsafe fn drawInRect_fromRect_operation_fraction_(self, dstRect: NSRect, srcRect: NSRect, op: NSCompositingOperation, delta: CGFloat); unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints_(self, dstSpacePortionRect: NSRect, - srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: BOOL, + srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: bool, hints: id /* (NSDictionary *) */); unsafe fn drawRepresentation_inRect_(self, imageRep: id /* (NSImageRep *) */, dstRect: NSRect); - unsafe fn isValid(self) -> BOOL; + unsafe fn isValid(self) -> bool; unsafe fn backgroundColor(self) -> id /* (NSColor *) */; unsafe fn lockFocus(self); - unsafe fn lockFocusFlipped_(self, flipped: BOOL); + unsafe fn lockFocusFlipped_(self, flipped: bool); unsafe fn unlockFocus(self); unsafe fn alignmentRect(self) -> NSRect; @@ -3312,14 +3313,14 @@ pub trait NSImage: Sized { unsafe fn hitTestRect_withImageDestinationRect_context_hints_flipped_(self, testRectDestSpace: NSRect, imageRectDestSpace: NSRect, referenceContext: id /* (NSGraphicsContext *) */, - hints: id /* (NSDictionary *) */, flipped: BOOL) -> BOOL; + hints: id /* (NSDictionary *) */, flipped: bool) -> bool; unsafe fn accessibilityDescription(self) -> id /* (NSString *) */; unsafe fn layerContentsForContentsScale_(self, layerContentsScale: CGFloat) -> id /* (id) */; unsafe fn recommendedLayerContentsScale_(self, preferredContentsScale: CGFloat) -> CGFloat; - unsafe fn matchesOnlyOnBestFittingAxis(self) -> BOOL; + unsafe fn matchesOnlyOnBestFittingAxis(self) -> bool; } impl NSImage for id { @@ -3344,10 +3345,10 @@ impl NSImage for id { } unsafe fn initWithSize_flipped_drawingHandler_(self, size: NSSize, - drawingHandlerShouldBeCalledWithFlippedContext: BOOL, - drawingHandler: *mut Block<(NSRect,), BOOL>) { - msg_send![self, initWithSize:size - flipped:drawingHandlerShouldBeCalledWithFlippedContext + drawingHandlerShouldBeCalledWithFlippedContext: bool, + drawingHandler: *mut Block<(NSRect,), Bool>) { + msg_send![self, initWithSize:size, + flipped:Bool::from(drawingHandlerShouldBeCalledWithFlippedContext), drawingHandler:drawingHandler] } @@ -3359,20 +3360,20 @@ impl NSImage for id { msg_send![self, name] } - unsafe fn setName_(self, name: id /* (NSString *) */) -> BOOL { - msg_send![self, setName:name] + unsafe fn setName_(self, name: id /* (NSString *) */) -> bool { + msg_send_bool![self, setName:name] } unsafe fn size(self) -> NSSize { msg_send![self, size] } - unsafe fn template(self) -> BOOL { - msg_send![self, template] + unsafe fn template(self) -> bool { + msg_send_bool![self, template] } - unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> BOOL { - msg_send![self, canInitWithPasteboard:pasteboard] + unsafe fn canInitWithPasteboard_(self, pasteboard: id /* (NSPasteboard *) */) -> bool { + msg_send_bool![self, canInitWithPasteboard:pasteboard] } unsafe fn imageTypes(self) -> id /* (NSArray ) */ { @@ -3403,19 +3404,19 @@ impl NSImage for id { referenceContext: id /* (NSGraphicsContext *) */, hints: id /* (NSDictionary *) */) -> id /* (NSImageRep *) */ { - msg_send![self, bestRepresentationForRect:rect context:referenceContext hints:hints] + msg_send![self, bestRepresentationForRect: rect, context: referenceContext, hints: hints] } - unsafe fn prefersColorMatch(self) -> BOOL { - msg_send![self, prefersColorMatch] + unsafe fn prefersColorMatch(self) -> bool { + msg_send_bool![self, prefersColorMatch] } - unsafe fn usesEPSOnResolutionMismatch(self) -> BOOL { - msg_send![self, usesEPSOnResolutionMismatch] + unsafe fn usesEPSOnResolutionMismatch(self) -> bool { + msg_send_bool![self, usesEPSOnResolutionMismatch] } - unsafe fn matchesOnMultipleResolution(self) -> BOOL { - msg_send![self, matchesOnMultipleResolution] + unsafe fn matchesOnMultipleResolution(self) -> bool { + msg_send_bool![self, matchesOnMultipleResolution] } unsafe fn drawInRect_(self, rect: NSRect) { @@ -3424,31 +3425,31 @@ impl NSImage for id { unsafe fn drawAtPoint_fromRect_operation_fraction_(self, point: NSPoint, srcRect: NSRect, op: NSCompositingOperation, delta: CGFloat) { - msg_send![self, drawAtPoint:point fromRect:srcRect operation:op fraction:delta] + msg_send![self, drawAtPoint: point, fromRect: srcRect, operation: op, fraction: delta] } unsafe fn drawInRect_fromRect_operation_fraction_(self, dstRect: NSRect, srcRect: NSRect, op: NSCompositingOperation, delta: CGFloat) { - msg_send![self, drawInRect:dstRect fromRect:srcRect operation:op fraction:delta] + msg_send![self, drawInRect: dstRect, fromRect: srcRect, operation: op, fraction: delta] } unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints_(self, dstSpacePortionRect: NSRect, - srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: BOOL, + srcSpacePortionRect: NSRect, op: NSCompositingOperation, delta: CGFloat, respectContextIsFlipped: bool, hints: id /* (NSDictionary *) */) { - msg_send![self, drawInRect:dstSpacePortionRect - fromRect:srcSpacePortionRect - operation:op - fraction:delta - respectFlipped:respectContextIsFlipped + msg_send![self, drawInRect:dstSpacePortionRect, + fromRect:srcSpacePortionRect, + operation:op, + fraction:delta, + respectFlipped:Bool::from(respectContextIsFlipped), hints:hints] } unsafe fn drawRepresentation_inRect_(self, imageRep: id /* (NSImageRep *) */, dstRect: NSRect) { - msg_send![self, drawRepresentation:imageRep inRect:dstRect] + msg_send![self, drawRepresentation: imageRep, inRect: dstRect] } - unsafe fn isValid(self) -> BOOL { - msg_send![self, isValid] + unsafe fn isValid(self) -> bool { + msg_send_bool![self, isValid] } unsafe fn backgroundColor(self) -> id /* (NSColor *) */ { @@ -3459,8 +3460,8 @@ impl NSImage for id { msg_send![self, lockFocus] } - unsafe fn lockFocusFlipped_(self, flipped: BOOL) { - msg_send![self, lockFocusFlipped:flipped] + unsafe fn lockFocusFlipped_(self, flipped: bool) { + msg_send![self, lockFocusFlipped: Bool::from(flipped)] } unsafe fn unlockFocus(self) { @@ -3489,7 +3490,7 @@ impl NSImage for id { unsafe fn TIFFRepresentationUsingCompression_factor_(self, comp: NSTIFFCompression, aFloat: f32) -> id /* (NSData *) */ { - msg_send![self, TIFFRepresentationUsingCompression:comp factor:aFloat] + msg_send![self, TIFFRepresentationUsingCompression: comp, factor: aFloat] } unsafe fn cancelIncrementalLoad(self) { @@ -3498,12 +3499,12 @@ impl NSImage for id { unsafe fn hitTestRect_withImageDestinationRect_context_hints_flipped_(self, testRectDestSpace: NSRect, imageRectDestSpace: NSRect, referenceContext: id /* (NSGraphicsContext *) */, - hints: id /* (NSDictionary *) */, flipped: BOOL) -> BOOL { - msg_send![self, hitTestRect:testRectDestSpace - withImageDestinationRect:imageRectDestSpace - context:referenceContext - hints:hints - flipped:flipped] + hints: id /* (NSDictionary *) */, flipped: bool) -> bool { + msg_send_bool![self, hitTestRect:testRectDestSpace, + withImageDestinationRect:imageRectDestSpace, + context:referenceContext, + hints:hints, + flipped:Bool::from(flipped)] } unsafe fn accessibilityDescription(self) -> id /* (NSString *) */ { @@ -3518,8 +3519,8 @@ impl NSImage for id { msg_send![self, recommendedLayerContentsScale:preferredContentsScale] } - unsafe fn matchesOnlyOnBestFittingAxis(self) -> BOOL { - msg_send![self, matchesOnlyOnBestFittingAxis] + unsafe fn matchesOnlyOnBestFittingAxis(self) -> bool { + msg_send_bool![self, matchesOnlyOnBestFittingAxis] } } @@ -3657,19 +3658,19 @@ pub enum NSImageLoadStatus { impl_Encode!(NSImageLoadStatus, usize); pub trait NSSound: Sized { - unsafe fn canInitWithPasteboard_(_: Self, pasteboard: id) -> BOOL { - msg_send![class!(NSSound), canInitWithPasteboard:pasteboard] + unsafe fn canInitWithPasteboard_(_: Self, pasteboard: id) -> bool { + msg_send_bool![class!(NSSound), canInitWithPasteboard:pasteboard] } - unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: BOOL) -> id; - unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: BOOL) -> id; + unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: bool) -> id; + unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: bool) -> id; unsafe fn initWithData_(self, audioData: id) -> id; unsafe fn initWithPasteboard_(self, pasteboard: id) -> id; unsafe fn name(self) -> id; unsafe fn volume(self) -> f32; unsafe fn currentTime(self) -> NSTimeInterval; - unsafe fn loops(self) -> BOOL; + unsafe fn loops(self) -> bool; unsafe fn playbackDeviceIdentifier(self) -> id; unsafe fn delegate(self) -> id; @@ -3683,22 +3684,22 @@ pub trait NSSound: Sized { unsafe fn duration(self) -> NSTimeInterval; - unsafe fn playing(self) -> BOOL; - unsafe fn pause(self) -> BOOL; - unsafe fn play(self) -> BOOL; - unsafe fn resume(self) -> BOOL; - unsafe fn stop(self) -> BOOL; + unsafe fn playing(self) -> bool; + unsafe fn pause(self) -> bool; + unsafe fn play(self) -> bool; + unsafe fn resume(self) -> bool; + unsafe fn stop(self) -> bool; unsafe fn writeToPasteboard_(self, pasteboard: id); } impl NSSound for id { - unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: BOOL) -> id { - msg_send![self, initWithContentsOfFile:filepath withReference:byRef] + unsafe fn initWithContentsOfFile_withReference_(self, filepath: id, byRef: bool) -> id { + msg_send![self, initWithContentsOfFile: filepath, withReference: Bool::from(byRef)] } - unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: BOOL) -> id { - msg_send![self, initWithContentsOfURL:fileUrl withReference:byRef] + unsafe fn initWithContentsOfURL_withReference_(self, fileUrl: id, byRef: bool) -> id { + msg_send![self, initWithContentsOfURL: fileUrl, withReference: Bool::from(byRef)] } unsafe fn initWithData_(self, audioData: id) -> id { @@ -3721,8 +3722,8 @@ impl NSSound for id { msg_send![self, currentTime] } - unsafe fn loops(self) -> BOOL { - msg_send![self, loops] + unsafe fn loops(self) -> bool { + msg_send_bool![self, loops] } unsafe fn playbackDeviceIdentifier(self) -> id { @@ -3737,24 +3738,24 @@ impl NSSound for id { msg_send![self, duration] } - unsafe fn playing(self) -> BOOL { - msg_send![self, playing] + unsafe fn playing(self) -> bool { + msg_send_bool![self, playing] } - unsafe fn pause(self) -> BOOL { - msg_send![self, pause] + unsafe fn pause(self) -> bool { + msg_send_bool![self, pause] } - unsafe fn play(self) -> BOOL { - msg_send![self, play] + unsafe fn play(self) -> bool { + msg_send_bool![self, play] } - unsafe fn resume(self) -> BOOL { - msg_send![self, resume] + unsafe fn resume(self) -> bool { + msg_send_bool![self, resume] } - unsafe fn stop(self) -> BOOL { - msg_send![self, stop] + unsafe fn stop(self) -> bool { + msg_send_bool![self, stop] } unsafe fn writeToPasteboard_(self, pasteboard: id) { @@ -3807,7 +3808,7 @@ pub trait NSStatusBar: Sized { unsafe fn statusItemWithLength_(self, length: CGFloat) -> id /* (NSStatusItem *) */; unsafe fn removeStatusItem_(self, item: id /* (NSStatusItem *) */); - unsafe fn isVertical(self) -> BOOL; + unsafe fn isVertical(self) -> bool; } impl NSStatusBar for id { @@ -3819,8 +3820,8 @@ impl NSStatusBar for id { msg_send![self, removeStatusItem:item] } - unsafe fn isVertical(self) -> BOOL { - msg_send![self, isVertical] + unsafe fn isVertical(self) -> bool { + msg_send_bool![self, isVertical] } } @@ -3833,7 +3834,7 @@ pub trait NSTextField: Sized { msg_send![class!(NSTextField), alloc] } unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; - unsafe fn setEditable_(self, editable: BOOL); + unsafe fn setEditable_(self, editable: bool); unsafe fn setStringValue_(self, label: id /* NSString */); } @@ -3841,8 +3842,8 @@ impl NSTextField for id { unsafe fn initWithFrame_(self, frameRect: NSRect) -> id { msg_send![self, initWithFrame:frameRect] } - unsafe fn setEditable_(self, editable: BOOL) { - msg_send![self, setEditable:editable] + unsafe fn setEditable_(self, editable: bool) { + msg_send![self, setEditable: Bool::from(editable)] } unsafe fn setStringValue_(self, label: id) { msg_send![self, setStringValue:label] @@ -3891,14 +3892,14 @@ pub trait NSTabView: Sized { unsafe fn setTabViewType_(self,tabViewType: NSTabViewType); unsafe fn controlTint(self) -> id; unsafe fn setControlTint_(self,controlTint:id); - unsafe fn drawsBackground(self) -> BOOL; - unsafe fn setDrawsBackground_(self,drawsBackground:BOOL); + unsafe fn drawsBackground(self) -> bool; + unsafe fn setDrawsBackground_(self,drawsBackground: bool); unsafe fn minimumSize(self) -> id; unsafe fn contentRect(self) -> id; unsafe fn controlSize(self) -> id; unsafe fn setControlSize_(self,controlSize:id); - unsafe fn allowsTruncatedLabels(self) -> BOOL; - unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels:BOOL); + unsafe fn allowsTruncatedLabels(self) -> bool; + unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels: bool); unsafe fn setDelegate_(self, delegate:id); unsafe fn delegate(self) -> id; unsafe fn tabViewAtPoint_(self, point:id) -> id; @@ -3913,7 +3914,7 @@ impl NSTabView for id { msg_send![self, addTabViewItem:tabViewItem] } unsafe fn insertTabViewItem_atIndex_(self, tabViewItem: id,index:NSInteger) { - msg_send![self, addTabViewItem:tabViewItem atIndex:index] + msg_send![self, addTabViewItem: tabViewItem, atIndex: index] } unsafe fn removeTabViewItem_(self,tabViewItem:id){ msg_send![self, removeTabViewItem:tabViewItem] @@ -3991,11 +3992,11 @@ impl NSTabView for id { msg_send![self, setControlTint:controlTint] } - unsafe fn drawsBackground(self) -> BOOL{ - msg_send![self, drawsBackground] + unsafe fn drawsBackground(self) -> bool { + msg_send_bool![self, drawsBackground] } - unsafe fn setDrawsBackground_(self,drawsBackground:BOOL){ - msg_send![self, setDrawsBackground:drawsBackground as libc::c_int] + unsafe fn setDrawsBackground_(self, drawsBackground: bool) { + msg_send![self, setDrawsBackground: Bool::from(drawsBackground)] } unsafe fn minimumSize(self) -> id{ @@ -4011,11 +4012,11 @@ impl NSTabView for id { msg_send![self, setControlSize:controlSize] } - unsafe fn allowsTruncatedLabels(self) -> BOOL{ - msg_send![self, allowsTruncatedLabels] + unsafe fn allowsTruncatedLabels(self) -> bool { + msg_send_bool![self, allowsTruncatedLabels] } - unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels:BOOL){ - msg_send![self, setAllowsTruncatedLabels:allowTruncatedLabels as libc::c_int] + unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels: bool) { + msg_send![self, setAllowsTruncatedLabels: Bool::from(allowTruncatedLabels)] } unsafe fn setDelegate_(self, delegate:id){ @@ -4048,10 +4049,10 @@ pub trait NSTabViewItem: Sized { } unsafe fn initWithIdentifier_(self, identifier:id) -> id; - unsafe fn drawLabel_inRect_(self,shouldTruncateLabel:BOOL,labelRect:NSRect); + unsafe fn drawLabel_inRect_(self, shouldTruncateLabel: bool, labelRect:NSRect); unsafe fn label(self) -> id; unsafe fn setLabel_(self,label:id); - unsafe fn sizeOfLabel_(self, computeMin:BOOL); + unsafe fn sizeOfLabel_(self, computeMin: bool); unsafe fn tabState(self) -> NSTabState; unsafe fn identifier(self)-> id; unsafe fn setIdentifier_(self,identifier:id); @@ -4071,8 +4072,8 @@ impl NSTabViewItem for id { msg_send![self, initWithIdentifier:identifier] } - unsafe fn drawLabel_inRect_(self, shouldTruncateLabel:BOOL,labelRect:NSRect){ - msg_send![self, drawLabel:shouldTruncateLabel as libc::c_int inRect:labelRect] + unsafe fn drawLabel_inRect_(self, shouldTruncateLabel: bool, labelRect: NSRect) { + msg_send![self, drawLabel: Bool::from(shouldTruncateLabel), inRect: labelRect] } unsafe fn label(self)->id{ @@ -4082,8 +4083,8 @@ impl NSTabViewItem for id { msg_send![self, setLabel:label] } - unsafe fn sizeOfLabel_(self,computeMin:BOOL){ - msg_send![self, sizeOfLabel:computeMin as libc::c_int] + unsafe fn sizeOfLabel_(self, computeMin: bool) { + msg_send![self, sizeOfLabel: Bool::from(computeMin)] } unsafe fn tabState(self) -> NSTabState{ @@ -4268,19 +4269,19 @@ impl NSColor for id { msg_send![class!(NSColor), clearColor] } unsafe fn colorWithRed_green_blue_alpha_(_:Self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> id { - msg_send![class!(NSColor), colorWithRed:r green:g blue:b alpha:a] + msg_send![class!(NSColor), colorWithRed: r, green: g, blue: b, alpha: a] } unsafe fn colorWithSRGBRed_green_blue_alpha_(_:Self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> id { - msg_send![class!(NSColor), colorWithSRGBRed:r green:g blue:b alpha:a] + msg_send![class!(NSColor), colorWithSRGBRed: r, green: g, blue: b, alpha: a] } unsafe fn colorWithDeviceRed_green_blue_alpha_(_:Self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> id { - msg_send![class!(NSColor), colorWithDeviceRed:r green:g blue:b alpha:a] + msg_send![class!(NSColor), colorWithDeviceRed: r, green: g, blue: b, alpha: a] } unsafe fn colorWithDisplayP3Red_green_blue_alpha_(_:Self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> id { - msg_send![class!(NSColor), colorWithDisplayP3Red:r green:g blue:b alpha:a] + msg_send![class!(NSColor), colorWithDisplayP3Red: r, green: g, blue: b, alpha: a] } unsafe fn colorWithCalibratedRed_green_blue_alpha_(_:Self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> id { - msg_send![class!(NSColor), colorWithCalibratedRed:r green:g blue:b alpha:a] + msg_send![class!(NSColor), colorWithCalibratedRed: r, green: g, blue: b, alpha: a] } unsafe fn colorUsingColorSpace_(self, color_space: id) -> id { @@ -4333,8 +4334,8 @@ pub trait NSToolbar: Sized { unsafe fn init_(self) -> id /* NSToolbar */; unsafe fn initWithIdentifier_(self, identifier: id) -> id /* NSToolbar */; - unsafe fn showsBaselineSeparator(self) -> BOOL; - unsafe fn setShowsBaselineSeparator_(self, value: BOOL); + unsafe fn showsBaselineSeparator(self) -> bool; + unsafe fn setShowsBaselineSeparator_(self, value: bool); } impl NSToolbar for id { @@ -4346,12 +4347,12 @@ impl NSToolbar for id { msg_send![self, initWithIdentifier:identifier] } - unsafe fn showsBaselineSeparator(self) -> BOOL { - msg_send![self, showsBaselineSeparator] + unsafe fn showsBaselineSeparator(self) -> bool { + msg_send_bool![self, showsBaselineSeparator] } - unsafe fn setShowsBaselineSeparator_(self, value: BOOL) { - msg_send![self, setShowsBaselineSeparator:value] + unsafe fn setShowsBaselineSeparator_(self, value: bool) { + msg_send![self, setShowsBaselineSeparator: Bool::from(value)] } } @@ -4365,7 +4366,7 @@ pub trait NSSpellChecker : Sized { stringToCheck: id, startingOffset: NSInteger, language: id, - wrapFlag: BOOL, + wrapFlag: bool, tag: NSInteger) -> (NSRange, NSInteger); unsafe fn uniqueSpellDocumentTag(_: Self) -> NSInteger; unsafe fn closeSpellDocumentWithTag(self, tag: NSInteger); @@ -4380,7 +4381,7 @@ impl NSSpellChecker for id { unsafe fn checkSpellingOfString_startingAt(self, stringToCheck: id, startingOffset: NSInteger) -> NSRange { - msg_send![self, checkSpellingOfString:stringToCheck startingAt:startingOffset] + msg_send![self, checkSpellingOfString: stringToCheck, startingAt: startingOffset] } unsafe fn checkSpellingOfString_startingAt_language_wrap_inSpellDocumentWithTag_wordCount( @@ -4388,16 +4389,17 @@ impl NSSpellChecker for id { stringToCheck: id, startingOffset: NSInteger, language: id, - wrapFlag: BOOL, + wrapFlag: bool, tag: NSInteger) -> (NSRange, NSInteger) { let mut wordCount = 0; - let range = msg_send![self, - checkSpellingOfString:stringToCheck - startingAt:startingOffset - language:language - wrap:wrapFlag - inSpellDocumentWithTag:tag - wordCount:&mut wordCount + let range = msg_send![ + self, + checkSpellingOfString:stringToCheck, + startingAt:startingOffset, + language:language, + wrap:Bool::from(wrapFlag), + inSpellDocumentWithTag:tag, + wordCount:&mut wordCount, ]; (range, wordCount) } @@ -4411,7 +4413,7 @@ impl NSSpellChecker for id { } unsafe fn ignoreWord_inSpellDocumentWithTag(self, wordToIgnore: id, tag: NSInteger) { - msg_send![self, ignoreWord:wordToIgnore inSpellDocumentWithTag:tag] + msg_send![self, ignoreWord: wordToIgnore, inSpellDocumentWithTag: tag] } } @@ -4425,7 +4427,7 @@ pub trait NSNib: Sized { impl NSNib for id { unsafe fn initWithNibNamed_bundle_(self, name: id, bundle: id) -> id { - msg_send![self, initWithNibNamed:name bundle:bundle] + msg_send![self, initWithNibNamed: name, bundle: bundle] } } diff --git a/cocoa/src/macros.rs b/cocoa/src/macros.rs index 58a4c6d94..b17aba988 100644 --- a/cocoa/src/macros.rs +++ b/cocoa/src/macros.rs @@ -57,7 +57,7 @@ macro_rules! delegate { $( ($($sel:ident :)+) => $func:expr),* } ) => ({ - let mut decl = objc2::declare::ClassDecl::new($name, class!(NSObject)).unwrap(); + let mut decl = objc2::declare::ClassBuilder::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 c5ba88ce7..435b8a752 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -25,8 +25,9 @@ use std::ops::Mul; use std::ptr; use appkit::CGLContextObj; -use base::{BOOL, id, nil, YES}; +use base::{id, nil}; use foundation::NSUInteger; +use objc2::runtime::Bool; // CABase.h @@ -108,16 +109,14 @@ impl CALayer { #[inline] pub fn needs_display_for_key(key: &CFString) -> bool { unsafe { - let flag: BOOL = msg_send![class!(CALayer), needsDisplayForKey:(key.as_CFTypeRef())]; - flag == YES + msg_send_bool![class!(CALayer), needsDisplayForKey:(key.as_CFTypeRef())] } } #[inline] pub fn should_archive_value_for_key(key: &CFString) -> bool { unsafe { - let flag: BOOL = msg_send![class!(CALayer), shouldArchiveValueForKey:(key.as_CFTypeRef())]; - flag == YES + msg_send_bool![class!(CALayer), shouldArchiveValueForKey:(key.as_CFTypeRef())] } } @@ -236,53 +235,49 @@ impl CALayer { #[inline] pub fn is_hidden(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), isHidden]; - flag == YES + msg_send_bool![self.id(), isHidden] } } #[inline] pub fn set_hidden(&self, hidden: bool) { unsafe { - msg_send![self.id(), setHidden:hidden as BOOL] + msg_send![self.id(), setHidden: Bool::from(hidden)] } } #[inline] pub fn is_double_sided(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), isDoubleSided]; - flag == YES + msg_send_bool![self.id(), isDoubleSided] } } #[inline] pub fn set_double_sided(&self, double_sided: bool) { unsafe { - msg_send![self.id(), setDoubleSided:double_sided as BOOL] + msg_send![self.id(), setDoubleSided: Bool::from(double_sided)] } } #[inline] pub fn is_geometry_flipped(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), isGeometryFlipped]; - flag == YES + msg_send_bool![self.id(), isGeometryFlipped] } } #[inline] pub fn set_geometry_flipped(&self, geometry_flipped: bool) { unsafe { - msg_send![self.id(), setGeometryFlipped:geometry_flipped as BOOL] + msg_send![self.id(), setGeometryFlipped: Bool::from(geometry_flipped)] } } #[inline] pub fn contents_are_flipped(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), contentsAreFlipped]; - flag == YES + msg_send_bool![self.id(), contentsAreFlipped] } } @@ -323,28 +318,28 @@ impl CALayer { #[inline] pub fn insert_sublayer_at_index(&self, sublayer: &CALayer, index: u32) { unsafe { - msg_send![self.id(), insertSublayer:sublayer.id() atIndex:index] + msg_send![self.id(), insertSublayer: sublayer.id(), atIndex: index] } } #[inline] pub fn insert_sublayer_below(&self, sublayer: &CALayer, sibling: &CALayer) { unsafe { - msg_send![self.id(), insertSublayer:sublayer.id() below:sibling.id()] + msg_send![self.id(), insertSublayer: sublayer.id(), below: sibling.id()] } } #[inline] pub fn insert_sublayer_above(&self, sublayer: &CALayer, sibling: &CALayer) { unsafe { - msg_send![self.id(), insertSublayer:sublayer.id() above:sibling.id()] + msg_send![self.id(), insertSublayer: sublayer.id(), above: sibling.id()] } } #[inline] pub fn replace_sublayer_with(&self, old_layer: &CALayer, new_layer: &CALayer) { unsafe { - msg_send![self.id(), replaceSublayer:old_layer.id() with:new_layer.id()] + msg_send![self.id(), replaceSublayer: old_layer.id(), with: new_layer.id()] } } @@ -387,15 +382,14 @@ impl CALayer { #[inline] pub fn masks_to_bounds(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), masksToBounds]; - flag == YES + msg_send_bool![self.id(), masksToBounds] } } #[inline] pub fn set_masks_to_bounds(&self, flag: bool) { unsafe { - msg_send![self.id(), setMasksToBounds:flag as BOOL] + msg_send![self.id(), setMasksToBounds: Bool::from(flag)] } } @@ -406,7 +400,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertPoint:*point fromLayer:layer] + msg_send![self.id(), convertPoint: *point, fromLayer: layer] } } @@ -417,7 +411,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertPoint:*point toLayer:layer] + msg_send![self.id(), convertPoint: *point, toLayer: layer] } } @@ -428,7 +422,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertRect:*rect fromLayer:layer] + msg_send![self.id(), convertRect: *rect, fromLayer: layer] } } @@ -439,7 +433,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertRect:*rect toLayer:layer] + msg_send![self.id(), convertRect: *rect, toLayer: layer] } } @@ -451,7 +445,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertTime:time fromLayer:layer] + msg_send![self.id(), convertTime: time, fromLayer: layer] } } @@ -463,7 +457,7 @@ impl CALayer { None => nil, Some(ref layer) => layer.id(), }; - msg_send![self.id(), convertTime:time toLayer:layer] + msg_send![self.id(), convertTime: time, toLayer: layer] } } @@ -482,8 +476,7 @@ impl CALayer { #[inline] pub fn contains_point(&self, point: &CGPoint) -> bool { unsafe { - let result: BOOL = msg_send![self.id(), containsPoint:*point]; - result == YES + msg_send_bool![self.id(), containsPoint:*point] } } @@ -622,15 +615,14 @@ impl CALayer { #[inline] pub fn is_opaque(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), isOpaque]; - flag == YES + msg_send_bool![self.id(), isOpaque] } } #[inline] pub fn set_opaque(&self, opaque: bool) { unsafe { - msg_send![self.id(), setOpaque:opaque as BOOL] + msg_send![self.id(), setOpaque: Bool::from(opaque)] } } @@ -658,8 +650,7 @@ impl CALayer { #[inline] pub fn needs_display(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), needsDisplay]; - flag == YES + msg_send_bool![self.id(), needsDisplay] } } @@ -673,30 +664,28 @@ impl CALayer { #[inline] pub fn needs_display_on_bounds_change(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), needsDisplayOnBoundsChange]; - flag == YES + msg_send_bool![self.id(), needsDisplayOnBoundsChange] } } #[inline] pub fn set_needs_display_on_bounds_change(&self, flag: bool) { unsafe { - msg_send![self.id(), setNeedsDisplayOnBoundsChange:flag as BOOL] + msg_send![self.id(), setNeedsDisplayOnBoundsChange: Bool::from(flag)] } } #[inline] pub fn draws_asynchronously(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), drawsAsynchronously]; - flag == YES + msg_send_bool![self.id(), drawsAsynchronously] } } #[inline] pub fn set_draws_asynchronously(&self, flag: bool) { unsafe { - msg_send![self.id(), setDrawsAsynchronously:flag as BOOL] + msg_send![self.id(), setDrawsAsynchronously: Bool::from(flag)] } } @@ -883,15 +872,14 @@ impl CALayer { #[inline] pub fn should_rasterize(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), shouldRasterize]; - flag == YES + msg_send_bool![self.id(), shouldRasterize] } } #[inline] pub fn set_should_rasterize(&self, flag: bool) { unsafe { - msg_send![self.id(), setShouldRasterize:(flag as BOOL)] + msg_send![self.id(), setShouldRasterize: Bool::from(flag)] } } @@ -1044,8 +1032,7 @@ impl CALayer { #[inline] pub fn needs_layout(&self) -> bool { unsafe { - let flag: BOOL = msg_send![self.id(), needsLayout]; - flag == YES + msg_send_bool![self.id(), needsLayout] } } @@ -1115,7 +1102,7 @@ impl CALayer { Some(ref for_key) => for_key.as_CFTypeRef(), None => ptr::null(), }; - msg_send![self.id(), addAnimation:animation forKey:for_key] + msg_send![self.id(), addAnimation: animation, forKey: for_key] } #[inline] @@ -1218,7 +1205,7 @@ impl CALayer { #[inline] pub fn set_contents_opaque(&self, opaque: bool) { unsafe { - msg_send![self.id(), setContentsOpaque:opaque as BOOL] + msg_send![self.id(), setContentsOpaque: Bool::from(opaque)] } } } @@ -1415,7 +1402,7 @@ impl CARenderer { let options: CFDictionary = CFDictionary::from_CFType_pairs(&pairs); let renderer: id = - msg_send![class!(CARenderer), rendererWithCGLContext:context + msg_send![class!(CARenderer), rendererWithCGLContext:context, options:options.as_CFTypeRef()]; debug_assert!(renderer != nil); CARenderer(renderer) @@ -1438,8 +1425,8 @@ impl CARenderer { let options: CFDictionary = CFDictionary::from_CFType_pairs(&pairs); let renderer: id = - msg_send![class!(CARenderer), rendererWithMTLTexture:metal_texture - options:options.as_CFTypeRef()]; + msg_send![class!(CARenderer), rendererWithMTLTexture: metal_texture, + options: options.as_CFTypeRef()]; debug_assert!(renderer != nil); CARenderer(renderer) } @@ -1484,7 +1471,7 @@ impl CARenderer { #[inline] pub fn begin_frame_at(&self, time: CFTimeInterval, timestamp: Option<&CVTimeStamp>) { unsafe { - msg_send![self.id(), beginFrameAtTime:time timeStamp:timestamp] + msg_send![self.id(), beginFrameAtTime: time, timeStamp: timestamp] } } @@ -1539,7 +1526,8 @@ pub mod transaction { use core_foundation::date::CFTimeInterval; use core_foundation::string::CFString; - use base::{BOOL, YES, id}; + use base::id; + use objc2::runtime::Bool; #[inline] pub fn begin() { @@ -1605,15 +1593,14 @@ pub mod transaction { #[inline] pub fn disable_actions() -> bool { unsafe { - let flag: BOOL = msg_send![class!(CATransaction), disableActions]; - flag == YES + msg_send_bool![class!(CATransaction), disableActions] } } #[inline] pub fn set_disable_actions(flag: bool) { unsafe { - msg_send![class!(CATransaction), setDisableActions:flag as BOOL] + msg_send![class!(CATransaction), setDisableActions: Bool::from(flag)] } } @@ -1651,7 +1638,7 @@ pub mod transaction { pub fn set_value_for_key(value: id, key: &str) { unsafe { let key: CFString = CFString::from(key); - msg_send![class!(CATransaction), setValue: value forKey: key.as_concrete_TypeRef()] + msg_send![class!(CATransaction), setValue: value, forKey: key.as_concrete_TypeRef()] } } }