@@ -48,25 +48,31 @@ /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id #endif + +#ifdef OF_AMIGAOS +extern unsigned long *OFHashSeedRef(void); +#else +extern unsigned long OFHashSeed; +#endif #ifdef OF_PSP static int -exit_cb(int arg1, int arg2, void *arg) +exitCallback(int arg1, int arg2, void *arg) { sceKernelExitGame(); return 0; } static int -callback_thread(SceSize args, void *argp) +threadCallback(SceSize args, void *argp) { sceKernelRegisterExitCallback( - sceKernelCreateCallback("Exit Callback", exit_cb, NULL)); + sceKernelCreateCallback("Exit Callback", exitCallback, NULL)); sceKernelSleepThreadCB(); return 0; } #endif @@ -81,18 +87,22 @@ #if defined(OF_OBJFW_RUNTIME) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) /* * This does not work on Win32 if ObjFW is built as a DLL. * * On AmigaOS, some destructors need to be able to send messages. - * Calling objc_exit() via atexit() would result in the runtime being + * Calling objc_deinit() via atexit() would result in the runtime being * destructed before for the destructors ran. */ - atexit(objc_exit); + atexit(objc_deinit); #endif /* We need deterministic hashes for tests */ - of_hash_seed = 0; +#ifdef OF_AMIGAOS + *OFHashSeedRef() = 0; +#else + OFHashSeed = 0; +#endif #ifdef OF_WII GXRModeObj *rmode; void *xfb; @@ -118,11 +128,11 @@ pspDebugScreenInit(); sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); - if ((tid = sceKernelCreateThread("update_thread", callback_thread, + if ((tid = sceKernelCreateThread("update_thread", threadCallback, 0x11, 0xFA0, 0, 0)) >= 0) sceKernelStartThread(tid, 0, 0); #endif #ifdef OF_NINTENDO_DS @@ -137,26 +147,26 @@ #endif #if defined(OF_WII) || defined(OF_PSP) || defined(OF_NINTENDO_DS) || \ defined(OF_NINTENDO_3DS) @try { - return of_application_main(&argc, &argv, + return OFApplicationMain(&argc, &argv, [[TestsAppDelegate alloc] init]); } @catch (id e) { OFString *string = [OFString stringWithFormat: @"\nRuntime error: Unhandled exception:\n%@\n", e]; OFString *backtrace = [OFString stringWithFormat: @"\nBacktrace:\n %@\n\n", [[e backtrace] componentsJoinedByString: @"\n "]]; - [of_stdout setForegroundColor: [OFColor red]]; - [of_stdout writeString: string]; - [of_stdout writeString: backtrace]; + [OFStdOut setForegroundColor: [OFColor red]]; + [OFStdOut writeString: string]; + [OFStdOut writeString: backtrace]; # if defined(OF_WII) - [of_stdout reset]; - [of_stdout writeString: @"Press home button to exit!"]; + [OFStdOut reset]; + [OFStdOut writeString: @"Press home button to exit!"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) @@ -165,22 +175,22 @@ VIDEO_WaitVSync(); } # elif defined(OF_PSP) sceKernelSleepThreadCB(); # elif defined(OF_NINTENDO_DS) - [of_stdout reset]; - [of_stdout writeString: @"Press start button to exit!"]; + [OFStdOut reset]; + [OFStdOut writeString: @"Press start button to exit!"]; for (;;) { swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_START) [OFApplication terminateWithStatus: 1]; } # elif defined(OF_NINTENDO_3DS) - [of_stdout reset]; - [of_stdout writeString: @"Press start button to exit!"]; + [OFStdOut reset]; + [OFStdOut writeString: @"Press start button to exit!"]; for (;;) { hidScanInput(); if (hidKeysDown() & KEY_START) @@ -191,48 +201,44 @@ # else abort(); # endif } #else - return of_application_main(&argc, &argv, - [[TestsAppDelegate alloc] init]); + return OFApplicationMain(&argc, &argv, [[TestsAppDelegate alloc] init]); #endif } @implementation TestsAppDelegate -- (void)outputTesting: (OFString *)test - inModule: (OFString *)module -{ - if (of_stdout.hasTerminal) { - [of_stdout setForegroundColor: [OFColor yellow]]; - [of_stdout writeFormat: @"[%@] %@: testing...", module, test]; - } else - [of_stdout writeFormat: @"[%@] %@: ", module, test]; -} - -- (void)outputSuccess: (OFString *)test - inModule: (OFString *)module -{ - if (of_stdout.hasTerminal) { - [of_stdout setForegroundColor: [OFColor lime]]; - [of_stdout eraseLine]; - [of_stdout writeFormat: @"\r[%@] %@: ok\n", module, test]; - } else - [of_stdout writeLine: @"ok"]; -} - -- (void)outputFailure: (OFString *)test - inModule: (OFString *)module -{ - if (of_stdout.hasTerminal) { - [of_stdout setForegroundColor: [OFColor red]]; - [of_stdout eraseLine]; - [of_stdout writeFormat: @"\r[%@] %@: failed\n", module, test]; - -#ifdef OF_WII - [of_stdout reset]; - [of_stdout writeLine: @"Press A to continue!"]; +- (void)outputTesting: (OFString *)test inModule: (OFString *)module +{ + if (OFStdOut.hasTerminal) { + [OFStdOut setForegroundColor: [OFColor yellow]]; + [OFStdOut writeFormat: @"[%@] %@: testing...", module, test]; + } else + [OFStdOut writeFormat: @"[%@] %@: ", module, test]; +} + +- (void)outputSuccess: (OFString *)test inModule: (OFString *)module +{ + if (OFStdOut.hasTerminal) { + [OFStdOut setForegroundColor: [OFColor lime]]; + [OFStdOut eraseLine]; + [OFStdOut writeFormat: @"\r[%@] %@: ok\n", module, test]; + } else + [OFStdOut writeLine: @"ok"]; +} + +- (void)outputFailure: (OFString *)test inModule: (OFString *)module +{ + if (OFStdOut.hasTerminal) { + [OFStdOut setForegroundColor: [OFColor red]]; + [OFStdOut eraseLine]; + [OFStdOut writeFormat: @"\r[%@] %@: failed\n", module, test]; + +#ifdef OF_WII + [OFStdOut reset]; + [OFStdOut writeLine: @"Press A to continue!"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) @@ -240,12 +246,12 @@ VIDEO_WaitVSync(); } #endif #ifdef OF_PSP - [of_stdout reset]; - [of_stdout writeLine: @"Press X to continue!"]; + [OFStdOut reset]; + [OFStdOut writeLine: @"Press X to continue!"]; for (;;) { SceCtrlData pad; sceCtrlReadBufferPositive(&pad, 1); @@ -257,23 +263,23 @@ } } } #endif #ifdef OF_NINTENDO_DS - [of_stdout reset]; - [of_stdout writeString: @"Press A to continue!"]; + [OFStdOut reset]; + [OFStdOut writeString: @"Press A to continue!"]; for (;;) { swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_A) break; } #endif #ifdef OF_NINTENDO_3DS - [of_stdout reset]; - [of_stdout writeString: @"Press A to continue!"]; + [OFStdOut reset]; + [OFStdOut writeString: @"Press A to continue!"]; for (;;) { hidScanInput(); if (hidKeysDown() & KEY_A) @@ -281,15 +287,15 @@ gspWaitForVBlank(); } #endif - [of_stdout writeString: @"\r"]; - [of_stdout reset]; - [of_stdout eraseLine]; + [OFStdOut writeString: @"\r"]; + [OFStdOut reset]; + [OFStdOut eraseLine]; } else - [of_stdout writeLine: @"failed"]; + [OFStdOut writeLine: @"failed"]; } - (void)applicationDidFinishLaunching { #if defined(OF_IOS) && defined(OF_HAVE_FILES) @@ -297,11 +303,11 @@ CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); UInt8 resourcesPath[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, true, resourcesPath, PATH_MAX)) { - [of_stderr writeString: @"Failed to locate resources!\n"]; + [OFStdErr writeString: @"Failed to locate resources!\n"]; [OFApplication terminateWithStatus: 1]; } [[OFFileManager defaultManager] changeCurrentDirectoryPath: [OFString stringWithUTF8String: (const char *)resourcesPath]]; @@ -350,13 +356,10 @@ #endif #ifdef OF_HAVE_SOCKETS [self socketTests]; [self TCPSocketTests]; [self UDPSocketTests]; -# ifdef OF_HAVE_SCTP - [self SCTPSocketTests]; -# endif # ifdef OF_HAVE_IPX [self IPXSocketTests]; [self SPXSocketTests]; [self SPXStreamSocketTests]; # endif @@ -379,12 +382,10 @@ #ifdef OF_HAVE_FILES [self serializationTests]; #endif [self JSONTests]; [self propertyListTests]; - [self ASN1DERParsingTests]; - [self ASN1DERRepresentationTests]; #if defined(OF_HAVE_PLUGINS) [self pluginTests]; #endif #ifdef OF_WINDOWS [self windowsRegistryKeyTests]; @@ -394,17 +395,17 @@ [self DNSResolverTests]; #endif [self systemInfoTests]; [self localeTests]; - [of_stdout reset]; + [OFStdOut reset]; #if defined(OF_IOS) - [of_stdout writeFormat: @"%d tests failed!", _fails]; + [OFStdOut writeFormat: @"%d tests failed!", _fails]; [OFApplication terminateWithStatus: _fails]; #elif defined(OF_WII) - [of_stdout writeString: @"Press home button to exit!"]; + [OFStdOut writeString: @"Press home button to exit!"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) @@ -411,24 +412,24 @@ [OFApplication terminateWithStatus: _fails]; VIDEO_WaitVSync(); } #elif defined(OF_PSP) - [of_stdout writeFormat: @"%d tests failed!", _fails]; + [OFStdOut writeFormat: @"%d tests failed!", _fails]; sceKernelSleepThreadCB(); #elif defined(OF_NINTENDO_DS) - [of_stdout writeString: @"Press start button to exit!"]; + [OFStdOut writeString: @"Press start button to exit!"]; for (;;) { swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_START) [OFApplication terminateWithStatus: _fails]; } #elif defined(OF_NINTENDO_3DS) - [of_stdout writeString: @"Press start button to exit!"]; + [OFStdOut writeString: @"Press start button to exit!"]; for (;;) { hidScanInput(); if (hidKeysDown() & KEY_START)