ObjFW  Check-in [cd0a632472]

Overview
Comment:Initial Nintendo DS port
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cd0a63247204b97af3f49ea078bd6b490e284def00632e0301b2194b8b08d0cd
User & Date: js on 2014-04-27 19:34:42
Other Links: manifest | tags
Context
2014-04-30
18:57
PLATFORMS.md: Add SPARC check-in: 3decb68088 user: js tags: trunk
2014-04-27
19:34
Initial Nintendo DS port check-in: cd0a632472 user: js tags: trunk
16:32
Update Xcode project check-in: 81e75db3b1 user: js tags: trunk
Changes

Modified .gitignore from [f461153544] to [14d942218d].

28
29
30
31
32
33
34

35

36
37
38
39
40
41
ObjFW.xcodeproj/*.mode1v3
ObjFW.xcodeproj/*.pbxuser
ObjFW.xcodeproj/project.xcworkspace
ObjFW.xcodeproj/xcuserdata
src/objfw-defs.h
src/ObjFW
tests/tests

tests/tests.exe

tests/EBOOT.PBP
tests/PARAM.SFO
tests/objc_sync/objc_sync
utils/objfw-config
utils/ofzip
utils/ofzip.exe







>

>






28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
ObjFW.xcodeproj/*.mode1v3
ObjFW.xcodeproj/*.pbxuser
ObjFW.xcodeproj/project.xcworkspace
ObjFW.xcodeproj/xcuserdata
src/objfw-defs.h
src/ObjFW
tests/tests
tests/tests.arm9
tests/tests.exe
tests/tests.nds
tests/EBOOT.PBP
tests/PARAM.SFO
tests/objc_sync/objc_sync
utils/objfw-config
utils/ofzip
utils/ofzip.exe

Modified PLATFORMS.md from [b411d4c4d0] to [830579461f].

80
81
82
83
84
85
86










87
88
89
90
91
92
93
------

  * OS Versions: 5.1-6.1
  * Architectures: x86, x86_64
  * Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3
  * Runtimes: ObjFW












OpenBSD
-------

  * OS Versions: 5.2-5.4
  * Architectures: MIPS64, PPC, SPARC64, x86_64
  * Compilers: GCC 4.2.1







>
>
>
>
>
>
>
>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
------

  * OS Versions: 5.1-6.1
  * Architectures: x86, x86_64
  * Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3
  * Runtimes: ObjFW


Nintendo DS
-----------

  * Architectures: ARM (EABI)
  * Compilers: GCC 4.8.2 (devkitARM release 42)
  * Runtimes: ObjFW
  * Limitations: No threads, no sockets
  * Note: File support requires an argv-compatible launcher (such as HBMenu)


OpenBSD
-------

  * OS Versions: 5.2-5.4
  * Architectures: MIPS64, PPC, SPARC64, x86_64
  * Compilers: GCC 4.2.1

Modified configure.ac from [a5eb40f200] to [5cee4b1b52].

53
54
55
56
57
58
59




















60
61
62
63
64
65
66
	TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
	enable_shared="no"
	enable_threads="no"	# TODO

	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])






















CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions -funwind-tables"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"

AX_CHECK_COMPILER_FLAGS(-std=c11, [







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
	TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
	enable_shared="no"
	enable_threads="no"	# TODO

	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])

AC_ARG_WITH(nds,
	AS_HELP_STRING([--with-nds], [build for Nintendo DS]))
AS_IF([test x"$with_nds" = x"yes"], [
	AS_IF([test x"$DEVKITPRO" = x""], [
		AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.])
	])

	OBJCFLAGS="$OBJCFLAGS -march=armv5te -mtune=arm946e-s"
	OBJCFLAGS="$OBJCFLAGS -mthumb -mthumb-interwork"
	CPPFLAGS="$CPPFLAGS -DARM9 -I$DEVKITPRO/libnds/include"
	LDFLAGS="$LDFLAGS -specs=ds_arm9.specs"
	LIBS="$LIBS -L$DEVKITPRO/libnds/lib -lfilesystem -lfat -lnds9"
	enable_shared="no"
	enable_threads="no"	# TODO
	enable_sockets="no"	# TODO

	AC_DEFINE(OF_NINTENDO_DS, 1,
		[Whether we are compiling for the Nintendo DS])
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])

CPP="$OBJCPP"
CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions -funwind-tables"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"

AX_CHECK_COMPILER_FLAGS(-std=c11, [

Modified src/OFApplication.m from [666509d895] to [ba9e0c219a].

45
46
47
48
49
50
51






52
53
54
55
56
57
58
extern char **environ;
#endif

#ifdef _PSP
# include <pspkerneltypes.h>
# include <psploadexec.h>
#endif







@interface OFApplication (OF_PRIVATE_CATEGORY)
- (void)OF_setArgumentCount: (int*)argc
	  andArgumentValues: (char**[])argv;
#ifdef _WIN32
- (void)OF_setArgumentCount: (int)argc
      andWideArgumentValues: (wchar_t*[])argv;







>
>
>
>
>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
extern char **environ;
#endif

#ifdef _PSP
# include <pspkerneltypes.h>
# include <psploadexec.h>
#endif

#ifdef OF_NINTENDO_DS
# define asm __asm__
# include <nds.h>
# undef asm
#endif

@interface OFApplication (OF_PRIVATE_CATEGORY)
- (void)OF_setArgumentCount: (int*)argc
	  andArgumentValues: (char**[])argv;
#ifdef _WIN32
- (void)OF_setArgumentCount: (int)argc
      andWideArgumentValues: (wchar_t*[])argv;
331
332
333
334
335
336
337




338
339
340

341
342

343
344
345
346


347
348
349
350
351
352
353
354
	of_string_encoding_t encoding;

	_argc = argc;
	_argv = argv;

	encoding = [OFString nativeOSEncoding];





	_programName = [[OFString alloc] initWithCString: (*argv)[0]
						encoding: encoding];
	arguments = [[OFMutableArray alloc] init];


	for (i = 1; i < *argc; i++)

		[arguments addObject: [OFString stringWithCString: (*argv)[i]
							 encoding: encoding]];

	[arguments makeImmutable];


	_arguments = arguments;

	objc_autoreleasePoolPop(pool);
#else
	_argc = argc;
	_argv = argv;
#endif
}







>
>
>
>
|
|
|
>

|
>
|
|

|
>
>
|







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
	of_string_encoding_t encoding;

	_argc = argc;
	_argv = argv;

	encoding = [OFString nativeOSEncoding];

# ifdef OF_NINTENDO_DS
	if (__system_argv->argvMagic == ARGV_MAGIC &&
	    __system_argv->argc >= 1) {
# endif
		_programName = [[OFString alloc] initWithCString: (*argv)[0]
							encoding: encoding];
		arguments = [[OFMutableArray alloc] init];
		_arguments = arguments;

		for (i = 1; i < *argc; i++)
			[arguments addObject:
			    [OFString stringWithCString: (*argv)[i]
					       encoding: encoding]];

		[arguments makeImmutable];
# ifdef OF_NINTENDO_DS
	}
# endif

	objc_autoreleasePoolPop(pool);
#else
	_argc = argc;
	_argv = argv;
#endif
}

Modified src/OFFile.m from [c90f56e169] to [8a5121abb8].

21
22
23
24
25
26
27

28
29
30
31
32
33
34
#include "config.h"

/* Work around a bug with Clang + glibc */
#ifdef __clang__
# define _HAVE_STRING_ARCH_strcmp
#endif


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include <unistd.h>








>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "config.h"

/* Work around a bug with Clang + glibc */
#ifdef __clang__
# define _HAVE_STRING_ARCH_strcmp
#endif

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include <unistd.h>

43
44
45
46
47
48
49




50
51
52
53
54
55
56
#endif

#ifdef __wii__
# define BOOL OGC_BOOL
# include <fat.h>
# undef BOOL
#endif





#import "OFFile.h"
#import "OFString.h"
#import "OFArray.h"
#ifdef OF_HAVE_THREADS
# import "threading.h"
#endif







>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#endif

#ifdef __wii__
# define BOOL OGC_BOOL
# include <fat.h>
# undef BOOL
#endif

#ifdef OF_NINTENDO_DS
# include <filesystem.h>
#endif

#import "OFFile.h"
#import "OFString.h"
#import "OFArray.h"
#ifdef OF_HAVE_THREADS
# import "threading.h"
#endif
175
176
177
178
179
180
181






182
183
184
185
186
187
188
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif

#ifdef __wii__
	if (!fatInitDefault())






		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif
}

+ (instancetype)fileWithPath: (OFString*)path
			mode: (OFString*)mode







>
>
>
>
>
>







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
	if (!of_mutex_new(&mutex))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif

#ifdef __wii__
	if (!fatInitDefault())
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif

#ifdef OF_NINTENDO_DS
	if (!nitroFSInit(NULL))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif
}

+ (instancetype)fileWithPath: (OFString*)path
			mode: (OFString*)mode

Modified src/OFString.m from [9584b4567b] to [f4d00fc2db].

827
828
829
830
831
832
833



834
835
836
837
838
839
840
		encoding: (of_string_encoding_t)encoding
{
	char *tmp;
	struct stat st;

	@try {
		OFFile *file;




		if (stat([path cStringWithEncoding: [OFString
		    nativeOSEncoding]], &st) == -1)
			@throw [OFOpenFileFailedException
			    exceptionWithPath: path
					 mode: @"rb"];








>
>
>







827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
		encoding: (of_string_encoding_t)encoding
{
	char *tmp;
	struct stat st;

	@try {
		OFFile *file;

		/* Make sure the file system is initialized */
		[OFFile class];

		if (stat([path cStringWithEncoding: [OFString
		    nativeOSEncoding]], &st) == -1)
			@throw [OFOpenFileFailedException
			    exceptionWithPath: path
					 mode: @"rb"];

Modified src/OFThread.m from [21b3bcf0e5] to [d65d9ab0c1].

45
46
47
48
49
50
51






52
53
54
55
56
57
58
#import "OFDictionary.h"
#import "OFAutoreleasePool.h"
#import "OFAutoreleasePool+Private.h"

#ifdef _WIN32
# include <windows.h>
#endif







#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"
#ifdef OF_HAVE_THREADS
# import "OFThreadJoinFailedException.h"







>
>
>
>
>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import "OFDictionary.h"
#import "OFAutoreleasePool.h"
#import "OFAutoreleasePool+Private.h"

#ifdef _WIN32
# include <windows.h>
#endif

#ifdef OF_NINTENDO_DS
# define asm __asm__
# include <nds.h>
# undef asm
#endif

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"
#ifdef OF_HAVE_THREADS
# import "OFThreadJoinFailedException.h"
191
192
193
194
195
196
197









198
199
200
201
202
203
204
	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(timeInterval))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);









#else
	if (timeInterval > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)timeInterval);
	usleep((useconds_t)lrint(
	    (timeInterval - floor(timeInterval)) * 1000000));







>
>
>
>
>
>
>
>
>







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(timeInterval))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif defined(OF_NINTENDO_DS)
	uint64_t counter;

	if (timeInterval > UINT64_MAX / 60)
		@throw [OFOutOfRangeException exception];

	counter = timeInterval * 60;
	while (counter--)
		swiWaitForVBlank();
#else
	if (timeInterval > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)timeInterval);
	usleep((useconds_t)lrint(
	    (timeInterval - floor(timeInterval)) * 1000000));

Modified src/forwarding/forwarding-arm-elf.S from [fe09c3766a] to [f030577b5a].

140
141
142
143
144
145
146

147



148
149
150
151
152
153
154
sel_forwardingTargetForSelector_$indirect_.L0:
	.long sel_forwardingTargetForSelector_-(.L0+8)
sel_forwardingTargetForSelector_$indirect_.L1:
	.long sel_forwardingTargetForSelector_-(.L1+8)
module$indirect_.L2:
	.long module-(.L2+8)


.section .ctors, "aw", %progbits



	.long init

.section .rodata
str_forwardingTargetForSelector_:
	.asciz "forwardingTargetForSelector:"

.section .data







>

>
>
>







140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
sel_forwardingTargetForSelector_$indirect_.L0:
	.long sel_forwardingTargetForSelector_-(.L0+8)
sel_forwardingTargetForSelector_$indirect_.L1:
	.long sel_forwardingTargetForSelector_-(.L1+8)
module$indirect_.L2:
	.long module-(.L2+8)

#ifndef OF_NINTENDO_DS
.section .ctors, "aw", %progbits
#else
.section .init_array, "aw", %init_array
#endif
	.long init

.section .rodata
str_forwardingTargetForSelector_:
	.asciz "forwardingTargetForSelector:"

.section .data

Modified src/objfw-defs.h.in from [aa4090a098] to [ff70a225ad].

21
22
23
24
25
26
27

28
29
30
#undef OF_HAVE_PTHREAD_SPINLOCKS
#undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES
#undef OF_HAVE_SCHED_YIELD
#undef OF_HAVE_SOCKETS
#undef OF_HAVE_SYMLINK
#undef OF_HAVE_SYS_SOCKET_H
#undef OF_HAVE_THREADS

#undef OF_OBJFW_RUNTIME
#undef OF_UNIVERSAL
#undef SIZE_MAX







>



21
22
23
24
25
26
27
28
29
30
31
#undef OF_HAVE_PTHREAD_SPINLOCKS
#undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES
#undef OF_HAVE_SCHED_YIELD
#undef OF_HAVE_SOCKETS
#undef OF_HAVE_SYMLINK
#undef OF_HAVE_SYS_SOCKET_H
#undef OF_HAVE_THREADS
#undef OF_NINTENDO_DS
#undef OF_OBJFW_RUNTIME
#undef OF_UNIVERSAL
#undef SIZE_MAX

Modified src/runtime/exception.m from [bf6c15d416] to [31b6c4d655].

464
465
466
467
468
469
470

471

472
473
474
475
476
477
478

#if defined(__arm__) || defined(__ARM__)
			tmp = lsda->typestable - (filter * 4);
			c = *(uintptr_t*)(void*)tmp;

			if (c != 0) {
				c += (uintptr_t)tmp;

				c = *(uintptr_t*)c;

			}
#else
			uintptr_t i;

			i = filter * size_for_encoding(lsda->typestable_enc);
			tmp = lsda->typestable - i;
			c = (uintptr_t)read_value(lsda->typestable_enc, &tmp);







>

>







464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480

#if defined(__arm__) || defined(__ARM__)
			tmp = lsda->typestable - (filter * 4);
			c = *(uintptr_t*)(void*)tmp;

			if (c != 0) {
				c += (uintptr_t)tmp;
# if defined(__linux__) || defined(__NetBSD__)
				c = *(uintptr_t*)c;
# endif
			}
#else
			uintptr_t i;

			i = filter * size_for_encoding(lsda->typestable_enc);
			tmp = lsda->typestable - i;
			c = (uintptr_t)read_value(lsda->typestable_enc, &tmp);

Modified tests/Makefile from [11cd785529] to [62b8ef2dc3].

1
2
3





4
5
6
7
8
9
10
include ../extra.mk

SUBDIRS = ${TESTPLUGIN}






PROG_NOINST = tests${PROG_SUFFIX}
SRCS = ForwardingTests.m		\
       OFArrayTests.m			\
       ${OFBLOCKTESTS_M}		\
       OFDataArrayTests.m		\
       OFDateTests.m			\



>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

CLEAN = EBOOT.PBP		\
	boot.dol		\
	${PROG_NOINST}.arm9	\
	${PROG_NOINST}.nds

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = ForwardingTests.m		\
       OFArrayTests.m			\
       ${OFBLOCKTESTS_M}		\
       OFDataArrayTests.m		\
       OFDateTests.m			\
102
103
104
105
106
107
108










109
110
111
112
113
114
115
116
117
	psp-fixup-imports ${PROG_NOINST}
	mksfo "ObjFW Tests" PARAM.SFO
	psp-strip ${PROG_NOINST}
	pack-pbp $@ PARAM.SFO NULL NULL NULL NULL NULL ${PROG_NOINST} NULL

boot.dol: ${PROG_NOINST}
	elf2dol ${PROG_NOINST} $@











include ../buildsys.mk

${PROG_NOINST}: ${LIBOBJFW_DEP}

CPPFLAGS += -I../src -I../src/exceptions -I../src/runtime -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${TESTS_LIBS} ${LIBS}
LDFLAGS += ${MAP_LDFLAGS}
LD = ${OBJC}







>
>
>
>
>
>
>
>
>
>









107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	psp-fixup-imports ${PROG_NOINST}
	mksfo "ObjFW Tests" PARAM.SFO
	psp-strip ${PROG_NOINST}
	pack-pbp $@ PARAM.SFO NULL NULL NULL NULL NULL ${PROG_NOINST} NULL

boot.dol: ${PROG_NOINST}
	elf2dol ${PROG_NOINST} $@

${PROG_NOINST}.arm9: ${PROG_NOINST}
	arm-none-eabi-objcopy -O binary $< $@

${PROG_NOINST}.nds: ${PROG_NOINST}.arm9
	rm -fr nds-data
	mkdir -p nds-data
	cp testfile.bin testfile.txt testfile.ini serialization.xml nds-data
	ndstool -c $@ -9 $< -d nds-data
	rm -fr nds-data

include ../buildsys.mk

${PROG_NOINST}: ${LIBOBJFW_DEP}

CPPFLAGS += -I../src -I../src/exceptions -I../src/runtime -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${TESTS_LIBS} ${LIBS}
LDFLAGS += ${MAP_LDFLAGS}
LD = ${OBJC}

Modified tests/OFINIFileTests.m from [44c1f538da] to [7ea6705870].

104
105
106
107
108
109
110


111
112
113
114



115
116
117
118
	category = [file categoryForName: @"foobar"];

	TEST(@"-[removeValueForKey:]",
	    R([category removeValueForKey: @"quxqux"]))

	module = @"OFINIFile";



	TEST(@"-[writeToFile:]", R([file writeToFile: @"tmpfile.ini"]) &&
	    [[OFString stringWithContentsOfFile: @"tmpfile.ini"]
	    isEqual: output])
	[OFFile removeItemAtPath: @"tmpfile.ini"];




	[pool drain];
}
@end







>
>




>
>
>




104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	category = [file categoryForName: @"foobar"];

	TEST(@"-[removeValueForKey:]",
	    R([category removeValueForKey: @"quxqux"]))

	module = @"OFINIFile";

	/* FIXME: Find a way to write files on Nintendo DS */
#ifndef OF_NINTENDO_DS
	TEST(@"-[writeToFile:]", R([file writeToFile: @"tmpfile.ini"]) &&
	    [[OFString stringWithContentsOfFile: @"tmpfile.ini"]
	    isEqual: output])
	[OFFile removeItemAtPath: @"tmpfile.ini"];
#else
	(void)output;
#endif

	[pool drain];
}
@end

Modified tests/TestsAppDelegate.m from [173f7e8f11] to [a4559247b9].

40
41
42
43
44
45
46






47
48
49
50
51
52
53
# define asm __asm__
# include <gccore.h>
# include <wiiuse/wpad.h>
# undef BOOL
# undef asm
#endif







enum {
	NO_COLOR,
	RED,
	GREEN,
	YELLOW
};








>
>
>
>
>
>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# define asm __asm__
# include <gccore.h>
# include <wiiuse/wpad.h>
# undef BOOL
# undef asm
#endif

#ifdef OF_NINTENDO_DS
# define asm __asm__
# include <nds.h>
# undef asm
#endif

enum {
	NO_COLOR,
	RED,
	GREEN,
	YELLOW
};

115
116
117
118
119
120
121




122
123
124
125
126
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
156
157
158
159
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	if ((tid = sceKernelCreateThread("update_thread", callback_thread,
	    0x11, 0xFA0, 0, 0)) >= 0)
		sceKernelStartThread(tid, 0, 0);
#endif





#if defined(__wii__) || defined(_PSP)
	@try {
		return of_application_main(&argc, &argv,
		    [TestsAppDelegate class]);
	} @catch (id e) {
		TestsAppDelegate *delegate =
		    [[OFApplication sharedApplication] delegate];
		OFString *string = [OFString stringWithFormat:
		    @"\nRuntime error: Unhandled exception:\n%@\n", e];
		OFString *backtrace = [OFString stringWithFormat:
		    @"\nBacktrace:\n  %@\n\n",
		    [[e backtrace] componentsJoinedByString: @"\n  "]];

		[delegate outputString: string
			       inColor: RED];
		[delegate outputString: backtrace
			       inColor: RED];
# if defined(__wii__)
		[delegate outputString: @"Press home button to exit!\n"
			       inColor: NO_COLOR];

		for (;;) {
			WPAD_ScanPads();

			if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
				[OFApplication terminateWithStatus: 1];

			VIDEO_WaitVSync();
		}
# elif defined(_PSP)
		sceKernelSleepThreadCB();









# else
		abort();
# endif
	}
#else
	return of_application_main(&argc, &argv, [TestsAppDelegate class]);
#endif







>
>
>
>
|



















<










>
>
>
>
>
>
>
>
>







121
122
123
124
125
126
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

	if ((tid = sceKernelCreateThread("update_thread", callback_thread,
	    0x11, 0xFA0, 0, 0)) >= 0)
		sceKernelStartThread(tid, 0, 0);
#endif

#ifdef OF_NINTENDO_DS
	consoleDemoInit();
#endif

#if defined(__wii__) || defined(_PSP) || defined(OF_NINTENDO_DS)
	@try {
		return of_application_main(&argc, &argv,
		    [TestsAppDelegate class]);
	} @catch (id e) {
		TestsAppDelegate *delegate =
		    [[OFApplication sharedApplication] delegate];
		OFString *string = [OFString stringWithFormat:
		    @"\nRuntime error: Unhandled exception:\n%@\n", e];
		OFString *backtrace = [OFString stringWithFormat:
		    @"\nBacktrace:\n  %@\n\n",
		    [[e backtrace] componentsJoinedByString: @"\n  "]];

		[delegate outputString: string
			       inColor: RED];
		[delegate outputString: backtrace
			       inColor: RED];
# if defined(__wii__)
		[delegate outputString: @"Press home button to exit!\n"
			       inColor: NO_COLOR];

		for (;;) {
			WPAD_ScanPads();

			if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
				[OFApplication terminateWithStatus: 1];

			VIDEO_WaitVSync();
		}
# elif defined(_PSP)
		sceKernelSleepThreadCB();
# elif defined(OF_NINTENDO_DS)
		[delegate outputString: @"Press start button to exit!"
			       inColor: NO_COLOR];
		for (;;) {
			swiWaitForVBlank();
			scanKeys();
			if (keysDown() & KEY_START)
				[OFApplication terminateWithStatus: 1];
		}
# else
		abort();
# endif
	}
#else
	return of_application_main(&argc, &argv, [TestsAppDelegate class]);
#endif
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

	pspDebugScreenSetXY(0, y);
	pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
	switch (color) {
	case NO_COLOR:
		[of_stdout writeString: @"\r\033[K"];
# ifdef __wii__
		[of_stdout writeString: @"\033[37m"];
# endif
		break;
	case RED:
		[of_stdout writeString: @"\r\033[K\033[31;1m"];
		break;
	case GREEN:







|







206
207
208
209
210
211
212
213
214
215
216
217
218
219
220

	pspDebugScreenSetXY(0, y);
	pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
	switch (color) {
	case NO_COLOR:
		[of_stdout writeString: @"\r\033[K"];
# if defined(__wii__) || defined(OF_NINTENDO_DS)
		[of_stdout writeString: @"\033[37m"];
# endif
		break;
	case RED:
		[of_stdout writeString: @"\r\033[K\033[31;1m"];
		break;
	case GREEN:
280
281
282
283
284
285
286










287
288
289
290
291
292
293
			for (;;) {
				sceCtrlReadBufferPositive(&pad, 1);
				if (!(pad.Buttons & PSP_CTRL_CROSS))
				    return;
			}
		}
	}










# endif
#else
	[self outputString: @"failed\n"
		   inColor: RED];
#endif
}








>
>
>
>
>
>
>
>
>
>







298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
			for (;;) {
				sceCtrlReadBufferPositive(&pad, 1);
				if (!(pad.Buttons & PSP_CTRL_CROSS))
				    return;
			}
		}
	}
# endif
# ifdef OF_NINTENDO_DS
	[self outputString: @"Press A to continue!"
		   inColor: NO_COLOR];
	for (;;) {
		swiWaitForVBlank();
		scanKeys();
		if (keysDown() & KEY_A)
			break;
	}
# endif
#else
	[self outputString: @"failed\n"
		   inColor: RED];
#endif
}

353
354
355
356
357
358
359









360
361
362
363
364
		VIDEO_WaitVSync();
	}
#elif defined(_PSP)
	[self outputString: [OFString stringWithFormat: @"%d tests failed!",
							_fails]
		   inColor: NO_COLOR];
	sceKernelSleepThreadCB();









#else
	[OFApplication terminateWithStatus: _fails];
#endif
}
@end







>
>
>
>
>
>
>
>
>





381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
		VIDEO_WaitVSync();
	}
#elif defined(_PSP)
	[self outputString: [OFString stringWithFormat: @"%d tests failed!",
							_fails]
		   inColor: NO_COLOR];
	sceKernelSleepThreadCB();
#elif defined(OF_NINTENDO_DS)
	[self outputString: @"Press start button to exit!"
		   inColor: NO_COLOR];
	for (;;) {
		swiWaitForVBlank();
		scanKeys();
		if (keysDown() & KEY_START)
			[OFApplication terminateWithStatus: _fails];
	}
#else
	[OFApplication terminateWithStatus: _fails];
#endif
}
@end