5
5
use std:: ffi:: c_void;
6
6
7
7
use block:: Block ;
8
- use objc:: runtime:: { Class , Object , Sel } ;
8
+ use objc:: runtime:: { Bool , Class , Object , Sel } ;
9
9
use objc:: { msg_send, sel} ;
10
10
use url:: Url ;
11
11
@@ -14,7 +14,7 @@ use crate::appkit::printing::PrintSettings;
14
14
#[ cfg( feature = "cloudkit" ) ]
15
15
use crate :: cloudkit:: share:: CKShareMetaData ;
16
16
use crate :: error:: Error ;
17
- use crate :: foundation:: { id, load_or_register_class, nil, to_bool , NSArray , NSString , NSUInteger , BOOL , NO , YES } ;
17
+ use crate :: foundation:: { id, load_or_register_class, nil, NSArray , NSString , NSUInteger } ;
18
18
use crate :: user_activity:: UserActivity ;
19
19
20
20
/// A handy method for grabbing our `AppDelegate` from the pointer. This is different from our
@@ -99,11 +99,8 @@ extern "C" fn did_update<T: AppDelegate>(this: &Object, _: Sel, _: id) {
99
99
100
100
/// Fires when the Application Delegate receives a
101
101
/// `applicationShouldHandleReopen:hasVisibleWindows:` notification.
102
- extern "C" fn should_handle_reopen < T : AppDelegate > ( this : & Object , _: Sel , _: id , has_visible_windows : BOOL ) -> BOOL {
103
- match app :: < T > ( this) . should_handle_reopen ( to_bool ( has_visible_windows) ) {
104
- true => YES ,
105
- false => NO
106
- }
102
+ extern "C" fn should_handle_reopen < T : AppDelegate > ( this : & Object , _: Sel , _: id , has_visible_windows : Bool ) -> Bool {
103
+ Bool :: new ( app :: < T > ( this) . should_handle_reopen ( has_visible_windows. as_bool ( ) ) )
107
104
}
108
105
109
106
/// Fires when the application delegate receives a `applicationDockMenu:` request.
@@ -128,29 +125,23 @@ extern "C" fn did_change_screen_parameters<T: AppDelegate>(this: &Object, _: Sel
128
125
129
126
/// Fires when the application receives a `application:willContinueUserActivityWithType:`
130
127
/// notification.
131
- extern "C" fn will_continue_user_activity_with_type < T : AppDelegate > ( this : & Object , _: Sel , _: id , activity_type : id ) -> BOOL {
128
+ extern "C" fn will_continue_user_activity_with_type < T : AppDelegate > ( this : & Object , _: Sel , _: id , activity_type : id ) -> Bool {
132
129
let activity = NSString :: retain ( activity_type) ;
133
130
134
- match app :: < T > ( this) . will_continue_user_activity ( activity. to_str ( ) ) {
135
- true => YES ,
136
- false => NO
137
- }
131
+ Bool :: new ( app :: < T > ( this) . will_continue_user_activity ( activity. to_str ( ) ) )
138
132
}
139
133
140
134
/// Fires when the application receives a `application:continueUserActivity:restorationHandler:` notification.
141
- extern "C" fn continue_user_activity < T : AppDelegate > ( this : & Object , _: Sel , _: id , activity : id , handler : id ) -> BOOL {
135
+ extern "C" fn continue_user_activity < T : AppDelegate > ( this : & Object , _: Sel , _: id , activity : id , handler : id ) -> Bool {
142
136
// @TODO: This needs to support restorable objects, but it involves a larger question about how
143
137
// much `NSObject` retainping we want to do here. For now, pass the handler for whenever it's
144
138
// useful.
145
139
let activity = UserActivity :: with_inner ( activity) ;
146
140
147
- match app :: < T > ( this) . continue_user_activity ( activity, || unsafe {
141
+ Bool :: new ( app :: < T > ( this) . continue_user_activity ( activity, || unsafe {
148
142
let handler = handler as * const Block < ( id , ) , ( ) > ;
149
143
( * handler) . call ( ( nil, ) ) ;
150
- } ) {
151
- true => YES ,
152
- false => NO
153
- }
144
+ } ) )
154
145
}
155
146
156
147
/// Fires when the application receives a
@@ -199,57 +190,39 @@ extern "C" fn open_urls<T: AppDelegate>(this: &Object, _: Sel, _: id, file_urls:
199
190
}
200
191
201
192
/// Fires when the application receives an `application:openFileWithoutUI:` message.
202
- extern "C" fn open_file_without_ui < T : AppDelegate > ( this : & Object , _: Sel , _: id , file : id ) -> BOOL {
193
+ extern "C" fn open_file_without_ui < T : AppDelegate > ( this : & Object , _: Sel , _: id , file : id ) -> Bool {
203
194
let filename = NSString :: retain ( file) ;
204
195
205
- match app :: < T > ( this) . open_file_without_ui ( filename. to_str ( ) ) {
206
- true => YES ,
207
- false => NO
208
- }
196
+ Bool :: new ( app :: < T > ( this) . open_file_without_ui ( filename. to_str ( ) ) )
209
197
}
210
198
211
199
/// Fired when the application receives an `applicationShouldOpenUntitledFile:` message.
212
- extern "C" fn should_open_untitled_file < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> BOOL {
213
- match app :: < T > ( this) . should_open_untitled_file ( ) {
214
- true => YES ,
215
- false => NO
216
- }
200
+ extern "C" fn should_open_untitled_file < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> Bool {
201
+ Bool :: new ( app :: < T > ( this) . should_open_untitled_file ( ) )
217
202
}
218
203
219
204
/// Fired when the application receives an `applicationShouldTerminateAfterLastWindowClosed:` message.
220
- extern "C" fn should_terminate_after_last_window_closed < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> BOOL {
221
- match app :: < T > ( this) . should_terminate_after_last_window_closed ( ) {
222
- true => YES ,
223
- false => NO
224
- }
205
+ extern "C" fn should_terminate_after_last_window_closed < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> Bool {
206
+ Bool :: new ( app :: < T > ( this) . should_terminate_after_last_window_closed ( ) )
225
207
}
226
208
227
209
/// Fired when the application receives an `applicationOpenUntitledFile:` message.
228
- extern "C" fn open_untitled_file < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> BOOL {
229
- match app :: < T > ( this) . open_untitled_file ( ) {
230
- true => YES ,
231
- false => NO
232
- }
210
+ extern "C" fn open_untitled_file < T : AppDelegate > ( this : & Object , _: Sel , _: id ) -> Bool {
211
+ Bool :: new ( app :: < T > ( this) . open_untitled_file ( ) )
233
212
}
234
213
235
214
/// Fired when the application receives an `application:openTempFile:` message.
236
- extern "C" fn open_temp_file < T : AppDelegate > ( this : & Object , _: Sel , _: id , filename : id ) -> BOOL {
215
+ extern "C" fn open_temp_file < T : AppDelegate > ( this : & Object , _: Sel , _: id , filename : id ) -> Bool {
237
216
let filename = NSString :: retain ( filename) ;
238
217
239
- match app :: < T > ( this) . open_temp_file ( filename. to_str ( ) ) {
240
- true => YES ,
241
- false => NO
242
- }
218
+ Bool :: new ( app :: < T > ( this) . open_temp_file ( filename. to_str ( ) ) )
243
219
}
244
220
245
221
/// Fired when the application receives an `application:printFile:` message.
246
- extern "C" fn print_file < T : AppDelegate > ( this : & Object , _: Sel , _: id , file : id ) -> BOOL {
222
+ extern "C" fn print_file < T : AppDelegate > ( this : & Object , _: Sel , _: id , file : id ) -> Bool {
247
223
let filename = NSString :: retain ( file) ;
248
224
249
- match app :: < T > ( this) . print_file ( filename. to_str ( ) ) {
250
- true => YES ,
251
- false => NO
252
- }
225
+ Bool :: new ( app :: < T > ( this) . print_file ( filename. to_str ( ) ) )
253
226
}
254
227
255
228
/// Fired when the application receives an `application:printFiles:withSettings:showPrintPanels:`
@@ -260,7 +233,7 @@ extern "C" fn print_files<T: AppDelegate>(
260
233
_: id ,
261
234
files : id ,
262
235
settings : id ,
263
- show_print_panels : BOOL
236
+ show_print_panels : Bool
264
237
) -> NSUInteger {
265
238
let files = NSArray :: retain ( files)
266
239
. iter ( )
@@ -269,7 +242,9 @@ extern "C" fn print_files<T: AppDelegate>(
269
242
270
243
let settings = PrintSettings :: with_inner ( settings) ;
271
244
272
- app :: < T > ( this) . print_files ( files, settings, to_bool ( show_print_panels) ) . into ( )
245
+ app :: < T > ( this)
246
+ . print_files ( files, settings, show_print_panels. as_bool ( ) )
247
+ . into ( )
273
248
}
274
249
275
250
/// Called when the application's occlusion state has changed.
@@ -280,13 +255,10 @@ extern "C" fn did_change_occlusion_state<T: AppDelegate>(this: &Object, _: Sel,
280
255
/// Called when the application receives an `application:delegateHandlesKey:` message.
281
256
/// Note: this may not fire in sandboxed applications. Apple's documentation is unclear on the
282
257
/// matter.
283
- extern "C" fn delegate_handles_key < T : AppDelegate > ( this : & Object , _: Sel , _: id , key : id ) -> BOOL {
258
+ extern "C" fn delegate_handles_key < T : AppDelegate > ( this : & Object , _: Sel , _: id , key : id ) -> Bool {
284
259
let key = NSString :: retain ( key) ;
285
260
286
- match app :: < T > ( this) . delegate_handles_key ( key. to_str ( ) ) {
287
- true => YES ,
288
- false => NO
289
- }
261
+ Bool :: new ( app :: < T > ( this) . delegate_handles_key ( key. to_str ( ) ) )
290
262
}
291
263
292
264
/// Registers an `NSObject` application delegate, and configures it for the various callbacks and
0 commit comments