Differences From Artifact [788679a7cf]:
- File src/OFApplication.m — part of check-in [e3e464fc6e] at 2017-05-06 21:31:03 on branch trunk — OFApplication: Only handle defined signals (user: js, size: 11705) [annotate] [blame] [check-ins using]
To Artifact [f1ddeada14]:
- File
src/OFApplication.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 11725) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
41 42 43 44 45 46 47 | #if defined(OF_MACOS) # include <crt_externs.h> #elif defined(OF_WINDOWS) # include <windows.h> extern int _CRT_glob; | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #if defined(OF_MACOS) # include <crt_externs.h> #elif defined(OF_WINDOWS) # include <windows.h> extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); #elif !defined(OF_IOS) extern char **environ; #endif #ifdef OF_PSP # include <pspkerneltypes.h> # include <psploadexec.h> |
︙ | ︙ | |||
64 65 66 67 68 69 70 | #ifdef HAVE_SIGACTION # ifndef SA_RESTART # define SA_RESTART 0 # endif #endif @interface OFApplication () | | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #ifdef HAVE_SIGACTION # ifndef SA_RESTART # define SA_RESTART 0 # endif #endif @interface OFApplication () - (void)OF_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv; #ifdef OF_WINDOWS - (void)OF_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t *[])argv; #endif - (void)OF_run; @end static OFApplication *app = nil; static void |
︙ | ︙ | |||
151 152 153 154 155 156 157 | return 0; } @implementation OFApplication @synthesize programName = _programName, arguments = _arguments; @synthesize environment = _environment; | | | | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | return 0; } @implementation OFApplication @synthesize programName = _programName, arguments = _arguments; @synthesize environment = _environment; + (OFApplication *)sharedApplication { return app; } + (OFString *)programName { return [app programName]; } + (OFArray *)arguments { return [app arguments]; } + (OFDictionary *)environment { return [app environment]; } + (void)terminate { [self terminateWithStatus: EXIT_SUCCESS]; |
︙ | ︙ | |||
190 191 192 193 194 195 196 | sceKernelExitGame(); OF_UNREACHABLE #endif } #ifdef OF_HAVE_SANDBOX | | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | sceKernelExitGame(); OF_UNREACHABLE #endif } #ifdef OF_HAVE_SANDBOX + (void)activateSandbox: (OFSandbox *)sandbox { [app activateSandbox: sandbox]; } #endif - init { |
︙ | ︙ | |||
355 356 357 358 359 360 361 | { [_arguments release]; [_environment release]; [super dealloc]; } | | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | { [_arguments release]; [_environment release]; [super dealloc]; } - (void)OF_setArgumentCount: (int *)argc andArgumentValues: (char ***)argv { #ifndef OF_WINDOWS void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; of_string_encoding_t encoding; _argc = argc; |
︙ | ︙ | |||
396 397 398 399 400 401 402 | _argc = argc; _argv = argv; #endif } #ifdef OF_WINDOWS - (void)OF_setArgumentCount: (int)argc | | | | | | | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | _argc = argc; _argv = argv; #endif } #ifdef OF_WINDOWS - (void)OF_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t **)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; if (argc > 0) { _programName = [[OFString alloc] initWithUTF16String: argv[0]]; arguments = [[OFMutableArray alloc] init]; for (int i = 1; i < argc; i++) [arguments addObject: [OFString stringWithUTF16String: argv[i]]]; [arguments makeImmutable]; _arguments = arguments; } objc_autoreleasePoolPop(pool); } #endif - (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv { *argc = _argc; *argv = _argv; } - (id <OFApplicationDelegate>)delegate { return _delegate; } - (void)setDelegate: (id <OFApplicationDelegate>)delegate { #ifdef HAVE_SIGACTION struct sigaction sa = { .sa_flags = SA_RESTART }; sigemptyset(&sa.sa_mask); # define REGISTER_SIGNAL(sig) \ if ([delegate respondsToSelector: \ @selector(applicationDidReceive##sig)]) { \ _##sig##Handler = (void (*)(id, SEL))[(id)delegate \ methodForSelector: \ @selector(applicationDidReceive##sig)]; \ \ sa.sa_handler = handle##sig; \ } else \ sa.sa_handler = SIG_DFL; \ \ OF_ENSURE(sigaction(sig, &sa, NULL) == 0); #else # define REGISTER_SIGNAL(sig) \ if ([delegate respondsToSelector: \ @selector(applicationDidReceive##sig)]) { \ _##sig##Handler = (void (*)(id, SEL))[(id)delegate \ methodForSelector: \ @selector(applicationDidReceive##sig)]; \ signal(sig, handle##sig); \ } else \ signal(sig, SIG_DFL); #endif |
︙ | ︙ | |||
519 520 521 522 523 524 525 | { [[self class] terminateWithStatus: status]; OF_UNREACHABLE } #ifdef OF_HAVE_SANDBOX | | | 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | { [[self class] terminateWithStatus: status]; OF_UNREACHABLE } #ifdef OF_HAVE_SANDBOX - (void)activateSandbox: (OFSandbox *)sandbox { # ifdef OF_HAVE_PLEDGE void *pool = objc_autoreleasePoolPush(); const char *promises = [[sandbox pledgeString] cStringWithEncoding: [OFLocalization encoding]]; if (pledge(promises, NULL) != 0) |
︙ | ︙ |