43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
id <OFApplicationDelegate> delegate = [app delegate];
[delegate applicationWillTerminate];
[(id)delegate release];
}
int
of_application_main(int *argc, char **argv[], Class cls)
{
OFApplication *app = [OFApplication sharedApplication];
id <OFApplicationDelegate> delegate = [[cls alloc] init];
[app setArgumentCount: argc
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
id <OFApplicationDelegate> delegate = [app delegate];
[delegate applicationWillTerminate];
[(id)delegate release];
}
#define SIGNAL_HANDLER(sig) \
static void \
handle##sig(int signal) \
{ \
app->sig##Handler(app->delegate, \
@selector(applicationDidReceive##sig)); \
}
SIGNAL_HANDLER(SIGINT)
SIGNAL_HANDLER(SIGHUP)
SIGNAL_HANDLER(SIGUSR1)
SIGNAL_HANDLER(SIGUSR2)
#undef SIGNAL_HANDLER
int
of_application_main(int *argc, char **argv[], Class cls)
{
OFApplication *app = [OFApplication sharedApplication];
id <OFApplicationDelegate> delegate = [[cls alloc] init];
[app setArgumentCount: argc
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
{
return delegate;
}
- (void)setDelegate: (id <OFApplicationDelegate>)delegate_
{
delegate = delegate_;
}
- (void)run
{
[delegate applicationDidFinishLaunching];
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
{
return delegate;
}
- (void)setDelegate: (id <OFApplicationDelegate>)delegate_
{
delegate = delegate_;
#define REGISTER_SIGNAL(sig) \
sig##Handler = (void(*)(id, SEL))[(id)delegate methodForSelector: \
@selector(applicationDidReceive##sig)]; \
if (sig##Handler != (void(*)(id, SEL))[OFObject \
instanceMethodForSelector: \
@selector(applicationDidReceive##sig)]) \
signal(sig, handle##sig); \
else \
signal(sig, SIG_DFL);
REGISTER_SIGNAL(SIGINT)
REGISTER_SIGNAL(SIGHUP)
REGISTER_SIGNAL(SIGUSR1)
REGISTER_SIGNAL(SIGUSR2)
#undef REGISTER_SIGNAL
}
- (void)run
{
[delegate applicationDidFinishLaunching];
}
|
268
269
270
271
272
273
274
275
|
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)applicationWillTerminate
{
}
@end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)applicationWillTerminate
{
}
- (void)applicationDidReceiveSIGINT
{
}
- (void)applicationDidReceiveSIGHUP
{
}
- (void)applicationDidReceiveSIGUSR1
{
}
- (void)applicationDidReceiveSIGUSR2
{
}
@end
|