Index: .fossil-settings/clean-glob ================================================================== --- .fossil-settings/clean-glob +++ .fossil-settings/clean-glob @@ -45,10 +45,11 @@ tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds tests/tests.nro +tests/tests.rpx utils/objfw-config utils/ofarc/ofarc utils/ofdns/ofdns utils/ofhash/ofhash utils/ofhttp/ofhttp Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -50,10 +50,11 @@ tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds tests/tests.nro +tests/tests.rpx utils/objfw-config utils/ofarc/ofarc utils/ofdns/ofdns utils/ofhash/ofhash utils/ofhttp/ofhttp Index: .gitignore ================================================================== --- .gitignore +++ .gitignore @@ -50,10 +50,11 @@ tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds tests/tests.nro +tests/tests.rpx utils/objfw-config utils/ofarc/ofarc utils/ofdns/ofdns utils/ofhash/ofhash utils/ofhttp/ofhttp Index: PLATFORMS.md ================================================================== --- PLATFORMS.md +++ PLATFORMS.md @@ -210,10 +210,21 @@ * Architectures: PowerPC * Compilers: GCC 4.6.3 (devkitPPC release 26) * Runtimes: ObjFW * Limitations: No threads + +Wii U +----- + + * OS Versions: Cemu 12.26.2f + * Architectures: PowerPC + * Compilers: gcc version 12.1.0 (devkitPPC release 41) + * Runtimes: ObjFW + * Limitations: No files, no threads, no sockets, no shared libraries, not + tested on real hardware + Windows ------- * OS Versions: 98 SE, NT 4.0, XP (x86), 7 (x64), 8 (x64), 8.1 (x64), 10, 11, Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -180,19 +180,43 @@ flags="-mrvl -mcpu=750 -meabi -mhard-float" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float" LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc" TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte" enable_shared="no" enable_threads="no" # TODO with_tls="no" AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" + AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) +]) + +AC_ARG_WITH(wii-u, + AS_HELP_STRING([--with-wii-u], [build for Wii U])) +AS_IF([test x"$with_wii_u" = x"yes"], [ + AS_IF([test x"$DEVKITPRO" = x""], [ + AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.]) + ]) + + flags="-mcpu=750 -meabi -mhard-float" + OBJCFLAGS="$OBJCFLAGS $flags" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" + CPPFLAGS="-isystem $DEVKITPRO/wut/include -D__WIIU__ -D__WUT__" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -isystem \$DEVKITPRO/wut/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__WIIU__ -D__WUT__" + LDFLAGS="-specs=$DEVKITPRO/wut/share/wut.specs" + LIBS="-L$DEVKITPRO/wut/lib -L$DEVKITPRO/wut/lib/stubs -lwut" + enable_files="no" # TODO + enable_shared="no" # TODO + enable_threads="no" # TODO + enable_sockets="no" # TODO + + AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U]) AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(nds, AS_HELP_STRING([--with-nds], [build for Nintendo DS])) @@ -203,20 +227,20 @@ flags="-march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DARM9 -I$DEVKITPRO/libnds/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -I\$DEVKITPRO/libnds/include" ASFLAGS="$ASFLAGS -march=armv5te" 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 check_pedantic="no" AC_DEFINE(OF_NINTENDO_DS, 1, [Whether we are compiling for Nintendo DS]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -I\$DEVKITPRO/libnds/include" AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(3ds, AS_HELP_STRING([--with-3ds], [build for Nintendo 3DS])) @@ -228,10 +252,11 @@ flags="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft" flags="$flags -mword-relocations" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DARM11 -I$DEVKITPRO/libctru/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include" ASFLAGS="$ASFLAGS -march=armv6k" LDFLAGS="$LDFLAGS -specs=3dsx.specs -march=armv6k -mtune=mpcore" LDFLAGS="$LDFLAGS -mfloat-abi=hard -mtp=soft -mword-relocations" LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru" enable_shared="no" @@ -239,11 +264,10 @@ with_tls="no" check_pedantic="no" AC_DEFINE(OF_NINTENDO_3DS, 1, [Whether we are compiling for Nintendo 3DS]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include" AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(nintendo-switch, AS_HELP_STRING([--with-nintendo-switch], [build for Nintendo Switch])) Index: src/OFStdIOStream+Private.h ================================================================== --- src/OFStdIOStream+Private.h +++ src/OFStdIOStream+Private.h @@ -17,14 +17,16 @@ OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS @interface OFStdIOStream () -#ifndef OF_AMIGAOS -- (instancetype)of_initWithFileDescriptor: (int)fd OF_METHOD_FAMILY(init); -#else +#if defined(OF_AMIGAOS) - (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable OF_METHOD_FAMILY(init); +#elif defined(OF_WII_U) +- (instancetype)of_init OF_METHOD_FAMILY(init); +#else +- (instancetype)of_initWithFileDescriptor: (int)fd OF_METHOD_FAMILY(init); #endif @end OF_ASSUME_NONNULL_END Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -36,19 +36,19 @@ */ #ifdef OF_STDIO_STREAM_WIN32_CONSOLE_H OF_SUBCLASSING_RESTRICTED #endif @interface OFStdIOStream: OFStream -#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) +#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && !defined(OF_WII_U) #endif { -#ifndef OF_AMIGAOS - int _fd; -#else +#if defined(OF_AMIGAOS) BPTR _handle; bool _closable; +#elif !defined(OF_WII_U) + int _fd; #endif bool _atEndOfStream; } /** Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -49,10 +49,16 @@ #ifdef OF_AMIGAOS # include # include # undef HAVE_ISATTY #endif + +#ifdef OF_WII_U +# define BOOL WUT_BOOL +# include +# undef BOOL +#endif /* References for static linking */ #ifdef OF_WINDOWS void _reference_to_OFWin32ConsoleStdIOStream(void) @@ -106,11 +112,11 @@ date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) static int colorToANSI(OFColor *color) { if ([color isEqual: [OFColor black]]) return 30; @@ -154,22 +160,11 @@ + (void)load { if (self != [OFStdIOStream class]) return; -# ifndef OF_AMIGAOS - int fd; - - if ((fd = fileno(stdin)) >= 0) - OFStdIn = [[OFStdIOStream alloc] of_initWithFileDescriptor: fd]; - if ((fd = fileno(stdout)) >= 0) - OFStdOut = [[OFStdIOStream alloc] - of_initWithFileDescriptor: fd]; - if ((fd = fileno(stderr)) >= 0) - OFStdErr = [[OFStdIOStream alloc] - of_initWithFileDescriptor: fd]; -# else +# if defined(OF_AMIGAOS) BPTR input, output, error; bool inputClosable = false, outputClosable = false, errorClosable = false; input = Input(); @@ -195,69 +190,112 @@ closable: inputClosable]; OFStdOut = [[OFStdIOStream alloc] of_initWithHandle: output closable: outputClosable]; OFStdErr = [[OFStdIOStream alloc] of_initWithHandle: error closable: errorClosable]; +# elif defined(OF_WII_U) + OFStdOut = [[OFStdIOStream alloc] of_init]; + OFStdErr = [[OFStdIOStream alloc] of_init]; +# else + int fd; + + if ((fd = fileno(stdin)) >= 0) + OFStdIn = [[OFStdIOStream alloc] of_initWithFileDescriptor: fd]; + if ((fd = fileno(stdout)) >= 0) + OFStdOut = [[OFStdIOStream alloc] + of_initWithFileDescriptor: fd]; + if ((fd = fileno(stderr)) >= 0) + OFStdErr = [[OFStdIOStream alloc] + of_initWithFileDescriptor: fd]; # endif } #endif - (instancetype)init { OF_INVALID_INIT_METHOD } -#ifndef OF_AMIGAOS -- (instancetype)of_initWithFileDescriptor: (int)fd -{ - self = [super init]; - - _fd = fd; - - return self; -} -#else +#if defined(OF_AMIGAOS) - (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable { self = [super init]; _handle = handle; _closable = closable; return self; } +#elif defined(OF_WII_U) +- (instancetype)of_init +{ + return [super init]; +} +#else +- (instancetype)of_initWithFileDescriptor: (int)fd +{ + self = [super init]; + + _fd = fd; + + return self; +} #endif - (void)dealloc { -#ifndef OF_AMIGAOS - if (_fd != -1) -#else +#if defined(OF_AMIGAOS) if (_handle != 0) -#endif + [self close]; +#elif !defined(OF_WII_U) + if (_fd != -1) [self close]; +#endif [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { -#ifndef OF_AMIGAOS - if (_fd == -1) -#else +#if defined(OF_AMIGAOS) if (_handle == 0) -#endif + @throw [OFNotOpenException exceptionWithObject: self]; +#elif !defined(OF_WII_U) + if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; +#endif return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { +#if defined(OF_AMIGAOS) + ssize_t ret; + + if (_handle == 0) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (length > LONG_MAX) + @throw [OFOutOfRangeException exception]; + + if ((ret = Read(_handle, buffer, length)) < 0) + @throw [OFReadFailedException exceptionWithObject: self + requestedLength: length + errNo: EIO]; + + if (ret == 0) + _atEndOfStream = true; + + return ret; +#elif defined(OF_WII_U) + @throw [OFReadFailedException exceptionWithObject: self + requestedLength: length + errNo: EOPNOTSUPP]; +#else ssize_t ret; -#ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS if ((ret = read(_fd, buffer, length)) < 0) @@ -271,32 +309,41 @@ if ((ret = read(_fd, buffer, (unsigned int)length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; # endif -#else - if (_handle == 0) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (length > LONG_MAX) - @throw [OFOutOfRangeException exception]; - - if ((ret = Read(_handle, buffer, length)) < 0) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length - errNo: EIO]; -#endif if (ret == 0) _atEndOfStream = true; return ret; +#endif } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { -#ifndef OF_AMIGAOS +#if defined(OF_AMIGAOS) + LONG bytesWritten; + + if (_handle == 0) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (length > SSIZE_MAX) + @throw [OFOutOfRangeException exception]; + + if ((bytesWritten = Write(_handle, (void *)buffer, length)) < 0) + @throw [OFWriteFailedException exceptionWithObject: self + requestedLength: length + bytesWritten: 0 + errNo: EIO]; + + return (size_t)bytesWritten; +#elif defined(OF_WII_U) + OSConsoleWrite(buffer, length); + + return length; +#else if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS ssize_t bytesWritten; @@ -319,30 +366,16 @@ @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: errno]; # endif -#else - LONG bytesWritten; - - if (_handle == 0) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (length > SSIZE_MAX) - @throw [OFOutOfRangeException exception]; - - if ((bytesWritten = Write(_handle, (void *)buffer, length)) < 0) - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length - bytesWritten: 0 - errNo: EIO]; -#endif return (size_t)bytesWritten; +#endif } -#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) +#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && !defined(OF_WII_U) - (int)fileDescriptorForReading { return _fd; } @@ -352,24 +385,24 @@ } #endif - (void)close { -#ifndef OF_AMIGAOS - if (_fd == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - close(_fd); - _fd = -1; -#else +#if defined(OF_AMIGAOS) if (_handle == 0) @throw [OFNotOpenException exceptionWithObject: self]; if (_closable) Close(_handle); _handle = 0; +#elif !defined(OF_WII_U) + if (_fd == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + close(_fd); + _fd = -1; #endif [super close]; } @@ -392,20 +425,21 @@ return OFMaxRetainCount; } - (bool)hasTerminal { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) return isatty(_fd); #else return false; #endif } - (int)columns { -#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && \ + !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; @@ -415,11 +449,12 @@ #endif } - (int)rows { -#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS) +#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && \ + !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; @@ -429,11 +464,11 @@ #endif } - (void)setForegroundColor: (OFColor *)color { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) int code; if (!isatty(_fd)) return; @@ -444,11 +479,11 @@ #endif } - (void)setBackgroundColor: (OFColor *)color { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) int code; if (!isatty(_fd)) return; @@ -459,41 +494,41 @@ #endif } - (void)reset { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; [self writeString: @"\033[0m"]; #endif } - (void)clear { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; [self writeString: @"\033[2J"]; #endif } - (void)eraseLine { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; [self writeString: @"\033[2K"]; #endif } - (void)setCursorColumn: (unsigned int)column { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; [self writeFormat: @"\033[%uG", column + 1]; #endif @@ -502,11 +537,11 @@ - (void)setCursorPosition: (OFPoint)position { if (position.x < 0 || position.y < 0) @throw [OFInvalidArgumentException exception]; -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; @@ -513,11 +548,11 @@ #endif } - (void)setRelativeCursorPosition: (OFPoint)position { -#ifdef HAVE_ISATTY +#if defined(HAVE_ISATTY) && !defined(OF_WII_U) if (!isatty(_fd)) return; if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; Index: src/objfw-defs.h.in ================================================================== --- src/objfw-defs.h.in +++ src/objfw-defs.h.in @@ -46,5 +46,6 @@ #undef OF_NINTENDO_SWITCH #undef OF_NO_SHARED #undef OF_OBJFW_RUNTIME #undef OF_UNIVERSAL #undef OF_WII +#undef OF_WII_U Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -7,10 +7,11 @@ CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ + ${PROG_NOINST}.rpx serialization_xml.m \ testfile_bin.m DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} @@ -227,11 +228,14 @@ cp testfile.bin testfile.txt testfile.ini serialization.xml romfs nacptool --create "ObjFW tests" "Jonathan Schleifer" \ "${PACKAGE_VERSION}" tests.nacp elf2nro ${PROG_NOINST} $@ --nacp=tests.nacp --romfsdir=romfs rm -fr romfs tests.nacp + +${PROG_NOINST}.rpx: ${PROG_NOINST} + elf2rpl $< $@ CPPFLAGS += -I../src -I../src/exceptions -I../src/runtime -I.. -DSTDOUT OBJCFLAGS_RuntimeARCTests.m = -fobjc-arc -fobjc-arc-exceptions LIBS := ${TESTS_LIBS} ${LIBS} LDFLAGS += ${MAP_LDFLAGS} LD = ${OBJC} Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -164,12 +164,13 @@ # ifdef OF_HAVE_FILES [[OFFileManager defaultManager] changeCurrentDirectoryPath: @"romfs:/"]; # endif #endif -#if defined(OF_WII) || defined(OF_PSP) || defined(OF_NINTENDO_DS) || \ - defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH) +#if defined(OF_WII) || defined(OF_WII_U) || defined(OF_PSP) || \ + defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \ + defined(OF_NINTENDO_SWITCH) @try { return OFApplicationMain(&argc, &argv, [[TestsAppDelegate alloc] init]); } @catch (id e) { OFString *string = [OFString stringWithFormat: