ObjFW  Check-in [2713b481a1]

Overview
Comment:Initial Wii port.

Threads and sockets still missing.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2713b481a1472825e1f0f38968bd90588f3a14b954af552b6b4329ee78f51e4f
User & Date: js on 2013-04-27 02:22:43
Other Links: manifest | tags
Context
2013-04-27
17:57
Wii: Link only tests with libwiiuse and libbte. check-in: daa4869d18 user: js tags: trunk
02:22
Initial Wii port. check-in: 2713b481a1 user: js tags: trunk
01:26
Add OFStdIOStream. check-in: 085bfc12a0 user: js tags: trunk
Changes

Modified .gitignore from [08a5bca3ec] to [7fbc43bc98].

1
2
3
4

5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
10
11
12




+







*.a
*.bundle
*.dll
*.dylib
*.map
*.o
*.orig
*.so
*~
.deps
aclocal.m4
autom4te.cache

Modified configure.ac from [9d0442e687] to [1fd9ad620c].

17
18
19
20
21
22
23








24
25
26
27
28
29
30
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38







+
+
+
+
+
+
+
+







AC_PROG_INSTALL
AC_PROG_EGREP

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

AC_ARG_WITH(wii,
	AS_HELP_STRING([--with-wii], [build for Wii]))
AS_IF([test x"$with_wii" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
	LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
	LIBS="-lfat -lwiiuse -lbte -logc"
])

AX_CHECK_COMPILER_FLAGS(-std=gnu99, [OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
case $OBJC in
	*clang*)
		;;
	*)
		AX_CHECK_COMPILER_FLAGS([-fgnu89-inline -Werror],
811
812
813
814
815
816
817




818
819
820
821
822
823
824
825
826
827
828
829
830
831












832
833
834
835
836
837
838
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862







+
+
+
+














+
+
+
+
+
+
+
+
+
+
+
+







	], [
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT(yes)
		OBJCFLAGS="$old_OBJCFLAGS"
	])
])

AS_IF([test x"$with_wii" = x"yes"], [
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$$(basename $@).map'])
])

AS_IF([test x"$cross_compiling" = x"yes"], [
	AC_SUBST(BIN_PREFIX, "$host-")

	case "$host" in
		*-*-mingw*)
			AC_CHECK_PROG(WINE, wine, wine)

			AS_IF([test x"$WINE" != x""], [
				AC_SUBST(TESTS, "tests")
				AC_SUBST(TEST_LAUNCHER, "$WINE")
			])
			;;
	esac

	AS_IF([test x"$with_wii" = x"yes"], [
		dnl Keep this lowercase, as WIILOAD is a variable used by
		dnl wiiload and thus likely already set by the user to something
		dnl that is not the path to the binary.
		AC_CHECK_PROG(wiiload, wiiload, wiiload)

		AS_IF([test x"$wiiload" != x""], [
			AC_SUBST(TESTS, "tests")
			AC_SUBST(TEST_LAUNCHER, "$wiiload")
		])
	])
], [
	AC_SUBST(TESTS, "tests")
])

BUILDSYS_INIT
BUILDSYS_TOUCH_DEPS

Modified extra.mk.in from [21378e8fd2] to [f968c25685].

18
19
20
21
22
23
24

25
26
27
28
29
30
31
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32







+







EXCEPTIONS_EXCEPTIONS_A = @EXCEPTIONS_EXCEPTIONS_A@
EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
FORWARDING_S = @FORWARDING_S@
FOUNDATION_COMPAT_M = @FOUNDATION_COMPAT_M@
INSTANCE_M = @INSTANCE_M@
LOOKUP_S = @LOOKUP_S@
MAP_LDFLAGS = @MAP_LDFLAGS@
OFBLOCKTESTS_M = @OFBLOCKTESTS_M@
OFHTTPCLIENTTESTS_M = @OFHTTPCLIENTTESTS_M@
OFPROCESS_M = @OFPROCESS_M@
OFSTREAMOBSERVER_KQUEUE_M = @OFSTREAMOBSERVER_KQUEUE_M@
OFSTREAMOBSERVER_POLL_M = @OFSTREAMOBSERVER_POLL_M@
OFSTREAMOBSERVER_SELECT_M = @OFSTREAMOBSERVER_SELECT_M@
PROPERTIESTESTS_M = @PROPERTIESTESTS_M@

Modified src/OFFile.m from [8a99cd99a6] to [4b255af215].

37
38
39
40
41
42
43






44
45
46
47
48
49
50
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+
+
+
+
+
+








#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#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
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
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







-





+



+
-
+
+
+
+
+

+







	if (!strcmp(mode, "ab+") || !strcmp(mode, "a+b"))
		return O_RDWR | O_CREAT | O_APPEND | O_BINARY;

	return -1;
}

@implementation OFFile
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
+ (void)initialize
{
	if (self != [OFFile class])
		return;

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
	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
{
	return [[[self alloc] initWithPath: path
				      mode: mode] autorelease];
}

Modified src/of_asprintf.m from [1e3eba5867] to [2e133e3806].

193
194
195
196
197
198
199
200
201


202



203
204

205
206
207
208
209
210
211
212
213


214



215
216

217
218
219
220
221
222
223
224
225


226



227
228

229
230
231
232
233
234
235
193
194
195
196
197
198
199


200
201
202
203
204
205
206

207
208
209
210
211
212
213
214


215
216
217
218
219
220
221

222
223
224
225
226
227
228
229


230
231
232
233
234
235
236

237
238
239
240
241
242
243
244







-
-
+
+

+
+
+

-
+







-
-
+
+

+
+
+

-
+







-
-
+
+

+
+
+

-
+







				return false;

			ctx->length_modifier = LENGTH_MODIFIER_L;
		}

		break;
	case 'j':
#ifndef _WIN32
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
#if defined(_WIN32)
		if (!append_subformat(ctx, "I64", 3))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "ll", 2))
			return false;
#else
		if (!append_subformat(ctx, "I64", 3))
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_J;

		break;
	case 'z':
#ifndef _WIN32
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, "I", 1))
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_Z;

		break;
	case 't':
#ifndef _WIN32
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, "I", 1))
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_T;

		break;
	case 'L':

Modified tests/Makefile from [6d4f7847a4] to [b55530a95c].

93
94
95
96
97
98
99

100
93
94
95
96
97
98
99
100
101







+

	psp-strip ${PROG_NOINST}
	pack-pbp $@ PARAM.SFO NULL NULL NULL NULL NULL ${PROG_NOINST} NULL

include ../buildsys.mk

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

Modified tests/TestsAppDelegate.m from [67d2f603dc] to [949d72dfbf].

16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32














33
34
35
36
37
38
39
40
41
42
43












































44

45
46
47
48
49
50
51
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111







+










+
+
+
+
+
+
+
+
+
+
+
+
+
+











+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+








#include "config.h"

#include <stdlib.h>

#import "OFString.h"
#import "OFStdIOStream.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

#ifdef _PSP
# include <pspmoduleinfo.h>
# include <pspkernel.h>
# include <pspdebug.h>
PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0);
#endif

#ifdef __wii__
# define BOOL OGC_BOOL
# include <gccore.h>
# include <wiiuse/wpad.h>
# undef BOOL
#endif

enum {
	NO_COLOR,
	RED,
	GREEN,
	YELLOW
};

int
main(int argc, char *argv[])
{
#ifdef OF_OBJFW_RUNTIME
	atexit(objc_exit);
#endif

	/* We need deterministic hashes for tests */
	of_hash_seed = 0;

#ifdef __wii__
	GXRModeObj *rmode;
	void *xfb;

	VIDEO_Init();
	WPAD_Init();

	rmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();

	VIDEO_WaitVSync();
	if (rmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();

	CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20);
	VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);

	@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];

		[delegate outputString: string
			     withColor: RED];
		[delegate outputString: @"Press home button to exit!\n"
			     withColor: NO_COLOR];
		for (;;) {
			WPAD_ScanPads();

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

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

@implementation TestsAppDelegate
- (void)outputString: (OFString*)str
	   withColor: (int)color
{
#if defined(_PSP)
68
69
70
71
72
73
74






75
76


77
78
79


80
81
82


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
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
133
134
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
178
179
180
181
182
183
184

185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216







+
+
+
+
+
+
-
-
+
+

-
-
+
+

-
-
+
+
















-
+









-
+









-
+

+
+
+
+
+
+
+
+
+
+
+
+
+







+
+
+







		break;
	}

	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 0:
		[of_stdout writeString: @"\r\033[K\033[1;33m"];
	case RED:
		[of_stdout writeString: @"\r\033[K\033[31;1m"];
		break;
	case 1:
		[of_stdout writeString: @"\r\033[K\033[1;32m"];
	case GREEN:
		[of_stdout writeString: @"\r\033[K\033[32;1m"];
		break;
	case 2:
		[of_stdout writeString: @"\r\033[K\033[1;31m"];
	case YELLOW:
		[of_stdout writeString: @"\r\033[K\033[33;1m"];
		break;
	}

	[of_stdout writeString: str];
	[of_stdout writeString: @"\033[m"];
#else
# error No output method!
#endif
}

- (void)outputTesting: (OFString*)test
	     inModule: (OFString*)module
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	[self outputString: [OFString stringWithFormat: @"[%@] %@: testing...",
							module, test]
		 withColor: 0];
		 withColor: YELLOW];
	[pool release];
}

- (void)outputSuccess: (OFString*)test
	     inModule: (OFString*)module
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	[self outputString: [OFString stringWithFormat: @"[%@] %@: ok\n",
							module, test]
		 withColor: 1];
		 withColor: GREEN];
	[pool release];
}

- (void)outputFailure: (OFString*)test
	     inModule: (OFString*)module
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	[self outputString: [OFString stringWithFormat: @"[%@] %@: failed\n",
							module, test]
		 withColor: 2];
		 withColor: RED];
	[pool release];

#ifdef __wii__
	[self outputString: @"Press A to continue!\n"
		 withColor: NO_COLOR];
	for (;;) {
		WPAD_ScanPads();

		if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A)
			return;

		VIDEO_WaitVSync();
	}
#endif
}

- (void)applicationDidFinishLaunching
{
#ifdef _PSP
	pspDebugScreenInit();
#endif
#ifdef __wii__
	[OFFile changeToDirectoryAtPath: @"/objfw-tests"];
#endif

	[self objectTests];
#ifdef OF_HAVE_BLOCKS
	[self blockTests];
#endif
	[self MD5HashTests];
	[self SHA1HashTests];
160
161
162
163
164
165
166







167
168







169
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264







+
+
+
+
+
+
+

-
+
+
+
+
+
+
+

	[self pluginTests];
#endif
	[self forwardingTests];
#ifdef OF_HAVE_PROPERTIES
	[self propertiesTests];
#endif

#ifdef __wii__
	[self outputString: @"Press home button to exit!\n"
		 withColor: NO_COLOR];
	for (;;) {
		WPAD_ScanPads();

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

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