︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
-
+
+
-
+
-
+
|
#ifdef HAVE_SIGACTION
# ifndef SA_RESTART
# define SA_RESTART 0
# endif
#endif
@interface OFApplication ()
- (instancetype)OF_init OF_METHOD_FAMILY(init);
- (void)OF_setArgumentCount: (int *)argc
- (instancetype)of_init OF_METHOD_FAMILY(init);
- (void)of_setArgumentCount: (int *)argc
andArgumentValues: (char **[])argv;
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
- (void)of_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t *[])argv;
#endif
- (void)OF_run;
- (void)of_run;
@end
static OFApplication *app = nil;
static void
atexitHandler(void)
{
|
︙ | | |
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
-
+
-
+
-
+
-
+
|
"application delegate!\n Most likely, you wanted to "
"subclass OFObject instead or specified\n the wrong class "
"with OF_APPLICATION_DELEGATE().\n",
class_getName(cls), class_getName(cls));
exit(1);
}
app = [[OFApplication alloc] OF_init];
app = [[OFApplication alloc] of_init];
[app OF_setArgumentCount: argc
[app of_setArgumentCount: argc
andArgumentValues: argv];
#ifdef OF_WINDOWS
__wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si);
[app OF_setArgumentCount: wargc
[app of_setArgumentCount: wargc
andWideArgumentValues: wargv];
#endif
delegate = [[cls alloc] init];
[app setDelegate: delegate];
[app OF_run];
[app of_run];
[delegate release];
return 0;
}
@implementation OFApplication
|
︙ | | |
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
-
+
|
#endif
- init
{
OF_INVALID_INIT_METHOD
}
- OF_init
- of_init
{
self = [super init];
@try {
void *pool;
OFMutableDictionary *environment;
#if defined(OF_MACOS)
|
︙ | | |
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
-
+
|
{
[_arguments release];
[_environment release];
[super dealloc];
}
- (void)OF_setArgumentCount: (int *)argc
- (void)of_setArgumentCount: (int *)argc
andArgumentValues: (char ***)argv
{
#ifndef OF_WINDOWS
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
of_string_encoding_t encoding;
|
︙ | | |
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
-
+
|
#else
_argc = argc;
_argv = argv;
#endif
}
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
- (void)of_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t **)argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
if (argc > 0) {
_programName = [[OFString alloc] initWithUTF16String: argv[0]];
|
︙ | | |
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
-
+
-
+
-
+
-
+
|
#ifdef SIGUSR2
REGISTER_SIGNAL(SIGUSR2)
#endif
#undef REGISTER_SIGNAL
}
- (void)OF_run
- (void)of_run
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop;
#ifdef OF_HAVE_THREADS
[OFThread OF_createMainThread];
[OFThread of_createMainThread];
runLoop = [OFRunLoop currentRunLoop];
#else
runLoop = [[[OFRunLoop alloc] init] autorelease];
#endif
[OFRunLoop OF_setMainRunLoop: runLoop];
[OFRunLoop of_setMainRunLoop: runLoop];
objc_autoreleasePoolPop(pool);
/*
* Note: runLoop is still valid after the release of the pool, as
* OF_setMainRunLoop: retained it. However, we only have a weak
* of_setMainRunLoop: retained it. However, we only have a weak
* reference to it now, whereas we had a strong reference before.
*/
pool = objc_autoreleasePoolPush();
[_delegate applicationDidFinishLaunching];
objc_autoreleasePoolPop(pool);
|
︙ | | |