Index: .fossil-settings/clean-glob ================================================================== --- .fossil-settings/clean-glob +++ .fossil-settings/clean-glob @@ -6,10 +6,11 @@ *.exe *.framework *.library *.map *.o +*.sl *.so *.so.* */.deps .deps aclocal.m4 @@ -21,17 +22,18 @@ config.log config.status configure docs extra.mk -generators/gen_tables +generators/library/gen_libraries +generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist +src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist -src/runtime/amiga-library-functable.inc -src/runtime/inline.h +src/runtime/libobjfwrt.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/objc_sync/objc_sync Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -7,10 +7,11 @@ *.framework *.library *.map *.o *.orig +*.sl *.so *.so.* */.deps .deps .git @@ -23,17 +24,18 @@ config.log config.status configure docs extra.mk -generators/gen_tables +generators/library/gen_libraries +generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist +src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist -src/runtime/amiga-library-functable.inc -src/runtime/inline.h +src/runtime/libobjfwrt.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser Index: .github/ISSUE_TEMPLATE/config.yml ================================================================== --- .github/ISSUE_TEMPLATE/config.yml +++ .github/ISSUE_TEMPLATE/config.yml @@ -29,8 +29,13 @@ about: Please use this for interactive questions and support - it is bridged to the Matrix room above. - name: ObjFW Telegram Room url: https://t.me/objfw + about: + Please use this for interactive questions and support - it is bridged to + the Matrix room above. + - name: ObjFW Gitter Room + url: https://gitter.im/ObjFW/ObjFW about: Please use this for interactive questions and support - it is bridged to the Matrix room above. Index: .gitignore ================================================================== --- .gitignore +++ .gitignore @@ -7,10 +7,11 @@ *.framework *.library *.map *.o *.orig +*.sl *.so *.so.* .deps .fslckout _FOSSIL_ @@ -23,17 +24,18 @@ config.log config.status configure docs extra.mk -generators/gen_tables +generators/library/gen_libraries +generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist +src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist -src/runtime/amiga-library-functable.inc -src/runtime/inline.h +src/runtime/libobjfwrt.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser DELETED .travis.yml Index: .travis.yml ================================================================== --- .travis.yml +++ /dev/null @@ -1,247 +0,0 @@ -language: c - -matrix: - include: - # Linux - - os: linux - compiler: clang - dist: precise - sudo: required - - - os: linux - compiler: gcc - dist: precise - sudo: required - - - os: linux - arch: arm64 - compiler: clang - dist: precise - sudo: required - - - os: linux - arch: arm64 - compiler: gcc - dist: precise - sudo: required - - - os: linux - arch: ppc64le - compiler: clang - dist: precise - sudo: required - - - os: linux - arch: ppc64le - compiler: gcc - dist: precise - sudo: required - - # Clang seems to have broken exceptions on s390x - #- os: linux - # arch: s390x - # compiler: clang - # dist: precise - # sudo: required - - - os: linux - arch: s390x - compiler: gcc - dist: precise - sudo: required - - - os: linux - compiler: clang - dist: trusty - sudo: required - - - os: linux - compiler: gcc - dist: trusty - sudo: required - - - os: linux - compiler: clang - dist: xenial - sudo: required - - - os: linux - compiler: gcc - dist: xenial - sudo: required - - - os: linux - compiler: clang - dist: bionic - sudo: required - - - os: linux - compiler: gcc - dist: bionic - sudo: required - - # macOS - - os: osx - osx_image: xcode11.2 - language: objective-c - env: - - no32bit=1 - - os: osx - osx_image: xcode11.1 - language: objective-c - env: - - no32bit=1 - - os: osx - osx_image: xcode11 - language: objective-c - env: - - no32bit=1 - - os: osx - osx_image: xcode10.3 - language: objective-c - env: - - no32bit=1 - - os: osx - osx_image: xcode10.2 - language: objective-c - env: - - no32bit=1 - - os: osx - osx_image: xcode10.1 - language: objective-c - - os: osx - osx_image: xcode10 - language: objective-c - - os: osx - osx_image: xcode9.4 - language: objective-c - - os: osx - osx_image: xcode9.3 - language: objective-c - - os: osx - osx_image: xcode9.2 - language: objective-c - - os: osx - osx_image: xcode9.1 - language: objective-c - - os: osx - osx_image: xcode9 - language: objective-c - - os: osx - osx_image: xcode8.3 - language: objective-c - - os: osx - osx_image: xcode8 - language: objective-c - - os: osx - osx_image: xcode7.3 - language: objective-c - - # iOS - - os: osx - osx_image: xcode11.2 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode11.1 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode11 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode10.3 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode10.2 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode10.1 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode10 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode9.4 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode9.3 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode9.2 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode9.1 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode9 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode8.3 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode8 - language: objective-c - env: - - config=ios - - os: osx - osx_image: xcode7.3 - language: objective-c - env: - - config=ios - - # AmigaOS - - os: linux - dist: trusty - env: - - config=amigaos - - # Nintendo 3DS - - os: linux - dist: bionic - env: - - config=nintendo_3ds - - # Nintendo DS - - os: linux - dist: bionic - env: - - config=nintendo_ds - - # Nintendo Wii - - os: linux - dist: bionic - env: - - config=wii - -services: docker - -before_install: - - .travis/before_install.sh - -script: - - .travis/script.sh DELETED .travis/before_install.sh Index: .travis/before_install.sh ================================================================== --- .travis/before_install.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -if [ "$TRAVIS_OS_NAME" = "linux" -a -z "$config" ]; then - case "$TRAVIS_CPU_ARCH" in - amd64 | s390x) - pkgs="gobjc-multilib" - ;; - *) - pkgs="gobjc" - ;; - esac - - if grep precise /etc/lsb-release >/dev/null; then - pkgs="$pkgs ipx" - fi - - # We don't need any of them and they're often broken. - sudo rm -f /etc/apt/sources.list.d/* - - if ! sudo apt-get -qq update >/tmp/apt_log 2>&1; then - cat /tmp/apt_log - exit 1 - fi - - if ! sudo apt-get -qq install -y $pkgs >>/tmp/apt_log 2>&1; then - cat /tmp/apt_log - exit 1 - fi - - if grep precise /etc/lsb-release >/dev/null; then - sudo ipx_internal_net add 1234 123456 - fi -fi - -if [ "$config" = "nintendo_3ds" -o "$config" = "nintendo_ds" ]; then - docker pull devkitpro/devkitarm -fi - -if [ "$config" = "wii" ]; then - docker pull devkitpro/devkitppc -fi - -if [ "$config" = "amigaos" ]; then - wget -q https://franke.ms/download/amiga-gcc.tgz - tar -C / -xzf amiga-gcc.tgz -fi DELETED .travis/build.sh Index: .travis/build.sh ================================================================== --- .travis/build.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -cd $(dirname $0)/.. - -echo ">> Configuring with $@" -if ! ./configure ac_cv_path_TPUT= "$@"; then - cat config.log - exit 1 -fi - -echo ">> Building (configured with $@)" -if ! make -j4 >/tmp/make_log 2>&1; then - cat /tmp/make_log - exit 1 -fi - -echo ">> Installing (configured with $@)" -if ! sudo PATH="$PATH" make install >/tmp/install_log 2>&1; then - cat /tmp/install_log - exit 1 -fi DELETED .travis/script.sh Index: .travis/script.sh ================================================================== --- .travis/script.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh -build() { - if ! git clean -fxd >/tmp/clean_log 2>&1; then - cat /tmp/clean_log - exit 1 - fi - - ./autogen.sh || exit 1 - .travis/build.sh "$@" || exit 1 -} - -if [ "$TRAVIS_OS_NAME" = "linux" -a -z "$config" ]; then - build_32_64() { - build OBJC="$CC" $@ - - case "$TRAVIS_CPU_ARCH" in - amd64) - build OBJC="$CC -m32" \ - --host=i686-pc-linux-gnu $@ - ;; - s390x) - build OBJC="$CC -m31" \ - --host=s390-pc-linux-gnu $@ - ;; - esac - } - - build_32_64 - build_32_64 --enable-seluid24 - build_32_64 --disable-compiler-tls - - # The following are not CPU-dependent, so only run them on amd64 - if [ "$TRAVIS_CPU_ARCH" = "amd64" ]; then - build_32_64 --disable-threads - build_32_64 --disable-threads --disable-sockets - build_32_64 --disable-threads --disable-files - build_32_64 --disable-threads --disable-sockets --disable-files - build_32_64 --disable-sockets - build_32_64 --disable-sockets --disable-files - build_32_64 --disable-files - build_32_64 --disable-shared - build_32_64 --disable-shared --enable-seluid24 - build_32_64 --disable-compiler-tls --disable-threads - fi -fi - -if [ "$TRAVIS_OS_NAME" = "osx" -a -z "$config" ]; then - build_mac_32_64() { - build $@ - - if [ -z "$no32bit" ]; then - build OBJC="clang -m32" --host=i386-apple-darwin $@ - fi - } - - if xcodebuild -version | grep 'Xcode 6' >/dev/null; then - export CPPFLAGS="-D_Null_unspecified=__null_unspecified" - export CPPFLAGS="$CPPFLAGS -D_Nullable=__nullable" - export CPPFLAGS="$CPPFLAGS -D_Nonnull=__nonnull" - fi - - build_mac_32_64 - build_mac_32_64 --disable-threads - build_mac_32_64 --disable-threads --disable-sockets - build_mac_32_64 --disable-threads --disable-files - build_mac_32_64 --disable-threads --disable-sockets --disable-files - build_mac_32_64 --disable-sockets - build_mac_32_64 --disable-sockets --disable-files - build_mac_32_64 --disable-files - build_mac_32_64 --disable-shared -fi - -if [ "$config" = "ios" ]; then - if xcodebuild -version | grep 'Xcode 6' >/dev/null; then - export CPPFLAGS="-D_Null_unspecified=__null_unspecified" - export CPPFLAGS="$CPPFLAGS -D_Nullable=__nullable" - export CPPFLAGS="$CPPFLAGS -D_Nonnull=__nonnull" - fi - - export IPHONEOS_DEPLOYMENT_TARGET="9.0" - clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" - export OBJC="$clang -arch armv7 -arch arm64" - export OBJCPP="$clang -arch armv7 -E" - build --host=arm-apple-darwin --enable-static - - sysroot="$(xcrun --sdk iphonesimulator --show-sdk-path)" - clang="clang -isysroot $sysroot" - export OBJC="$clang -arch i386 -arch x86_64" - export OBJCPP="$clang -arch i386 -E" - build WRAPPER=true --host=i386-apple-darwin --enable-static -fi - -if [ "$config" = "amigaos" ]; then - export PATH="/opt/amiga/bin:$PATH" - - build --host=m68k-amigaos - build --host=m68k-amigaos --disable-amiga-lib - build --host=m68k-amigaos --enable-static -fi - -if [ "$config" = "nintendo_3ds" ]; then - ./autogen.sh - docker run -e DEVKITPRO=/opt/devkitpro \ - -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \ - -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitarm \ - /objfw/.travis/build.sh --host=arm-none-eabi --with-3ds -fi - -if [ "$config" = "nintendo_ds" ]; then - ./autogen.sh - docker run -e DEVKITPRO=/opt/devkitpro \ - -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \ - -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitarm \ - /objfw/.travis/build.sh --host=arm-none-eabi --with-nds -fi - -if [ "$config" = "wii" ]; then - ./autogen.sh - docker run -e DEVKITPRO=/opt/devkitpro \ - -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \ - -v $TRAVIS_BUILD_DIR:/objfw devkitpro/devkitppc \ - /objfw/.travis/build.sh ac_cv_prog_wiiload= \ - --host=powerpc-eabi --with-wii -fi Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -23,12 +23,11 @@ release: docs echo "Generating tarball for version ${PACKAGE_VERSION}..." rm -fr objfw-${PACKAGE_VERSION} objfw-${PACKAGE_VERSION}.tar \ objfw-${PACKAGE_VERSION}.tar.gz fossil tarball --name objfw-${PACKAGE_VERSION} current - \ - --exclude '.cirrus*,.fossil*,.git*,.travis*' | \ - ofarc -ttgz -xq - + --exclude '.cirrus*,.fossil*,.git*' | ofarc -ttgz -xq - cp configure config.h.in objfw-${PACKAGE_VERSION}/ ofarc -cq objfw-${PACKAGE_VERSION}.tar \ $$(find objfw-${PACKAGE_VERSION} | sort) rm -fr objfw-${PACKAGE_VERSION} gzip -9 objfw-${PACKAGE_VERSION}.tar Index: PLATFORMS.md ================================================================== --- PLATFORMS.md +++ PLATFORMS.md @@ -65,10 +65,21 @@ * OS version: r1-alpha4 * Architectures: x86 * Compilers: Clang 3.2, GCC 4.6.3 * Runtimes: ObjFW + +HP-UX +----- + + * OS versions: 11i v1 (PA-RISC 2.0), 11i v3 (Itanium) + * Architectures: Itanium, PA-RISC 2.0 + * Compilers: GCC 4.7.2, GCC 7.5.0 + * Runtimes: ObjFW + * Notes: Exception handling on Itanium in 32 bit mode is broken, you need to + use 64 bit mode by passing `OBJC="gcc -mlp64"` to `configure`. + iOS --- * Architectures: ARMv7, ARM64 Index: README.md ================================================================== --- README.md +++ README.md @@ -363,10 +363,12 @@ * A [Slack channel](https://objfw.nil.im/slack), bridged to the Matrix room above * A [Discord channel](https://objfw.nil.im/discord), bridged to the Matrix room above * A [Telegram room](https://t.me/objfw), bridged to the Matrix room above + * A [Gitter room](https://gitter.im/ObjFW/ObjFW), bridged to the Matrix room + above Please don't hesitate to join any or all of those!

Commercial use

Index: build-aux/m4/buildsys.m4 ================================================================== --- build-aux/m4/buildsys.m4 +++ build-aux/m4/buildsys.m4 @@ -1,8 +1,8 @@ dnl dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, -dnl 2018, 2020 +dnl 2018, 2020, 2021 dnl Jonathan Schleifer dnl dnl https://fossil.nil.im/buildsys dnl dnl Permission to use, copy, modify, and/or distribute this software for any @@ -25,17 +25,24 @@ AC_DEFUN([BUILDSYS_INIT], [ AC_REQUIRE([AC_CANONICAL_BUILD]) AC_REQUIRE([AC_CANONICAL_HOST]) case "$build_os" in + darwin*) + case "$host_os" in darwin*) - case "$host_os" in - darwin*) - AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes) - ;; - esac + AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes) ;; + esac + ;; + esac + + AC_PROG_INSTALL + case "$INSTALL" in + ./build-aux/install-sh*) + INSTALL="$PWD/$INSTALL" + ;; esac AC_CONFIG_COMMANDS_PRE([ AS_IF([test x"$GCC" = x"yes"], [AC_SUBST(DEP_CFLAGS, '-MD -MF $${out%.o}.dep')]) @@ -48,20 +55,19 @@ AC_SUBST(AMIGA_LIB_CFLAGS) AC_SUBST(AMIGA_LIB_LDFLAGS) case "$build_os" in - morphos*) - dnl Don't use tput on MorphOS: The colored - dnl output is quite unreadable and in some - dnl MorphOS versions, the output from tput is - dnl not 8-bit safe, with awk (for AC_SUBST) - dnl failing as a result. - ;; - *) - AC_PATH_PROG(TPUT, tput) - ;; + morphos*) + dnl Don't use tput on MorphOS: The colored output is + dnl quite unreadable and in some MorphOS versions the + dnl output from tput is not 8-bit safe, with awk (for + dnl AC_SUBST) failing as a result. + ;; + *) + AC_PATH_PROG(TPUT, tput) + ;; esac AS_IF([test x"$TPUT" != x""], [ if x=$($TPUT el 2>/dev/null); then AC_SUBST(TERM_EL, "$x") @@ -121,45 +127,44 @@ ]) ]) AC_DEFUN([BUILDSYS_CHECK_IOS], [ case "$host_os" in - darwin*) - AC_MSG_CHECKING(whether host is iOS) - AC_EGREP_CPP(yes, [ - #include - - #if (defined(TARGET_OS_IPHONE) && \ - TARGET_OS_IPHONE) || \ - (defined(TARGET_OS_SIMULATOR) && \ - TARGET_OS_SIMULATOR) - yes - #endif - ], [ - host_is_ios="yes" - ], [ - host_is_ios="no" - ]) - AC_MSG_RESULT($host_is_ios) - ;; + darwin*) + AC_MSG_CHECKING(whether host is iOS) + AC_EGREP_CPP(yes, [ + #include + + #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \ + (defined(TARGET_OS_SIMULATOR) && \ + TARGET_OS_SIMULATOR) + yes + #endif + ], [ + host_is_ios="yes" + ], [ + host_is_ios="no" + ]) + AC_MSG_RESULT($host_is_ios) + ;; esac ]) AC_DEFUN([BUILDSYS_PROG_IMPLIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_MSG_CHECKING(whether we need an implib) case "$host_os" in - cygwin* | mingw*) - AC_MSG_RESULT(yes) - PROG_IMPLIB_NEEDED='yes' - PROG_IMPLIB_LDFLAGS='-Wl,--export-all-symbols,--out-implib,lib${PROG}.a' - ;; - *) - AC_MSG_RESULT(no) - PROG_IMPLIB_NEEDED='no' - PROG_IMPLIB_LDFLAGS='' - ;; + cygwin* | mingw*) + AC_MSG_RESULT(yes) + PROG_IMPLIB_NEEDED='yes' + PROG_IMPLIB_LDFLAGS='-Wl,--export-all-symbols,--out-implib,lib${PROG}.a' + ;; + *) + AC_MSG_RESULT(no) + PROG_IMPLIB_NEEDED='no' + PROG_IMPLIB_LDFLAGS='' + ;; esac AC_SUBST(PROG_IMPLIB_NEEDED) AC_SUBST(PROG_IMPLIB_LDFLAGS) ]) @@ -167,130 +172,169 @@ AC_DEFUN([BUILDSYS_SHARED_LIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([BUILDSYS_CHECK_IOS]) AC_MSG_CHECKING(for shared library system) - case "$host_os" in - darwin*) - AC_MSG_RESULT(Darwin) - LIB_CFLAGS='-fPIC -DPIC' - LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' - LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib' - LIB_PREFIX='lib' - LIB_SUFFIX='.dylib' - LDFLAGS_RPATH='-Wl,-rpath,${libdir}' - PLUGIN_CFLAGS='-fPIC -DPIC' - PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}' - PLUGIN_SUFFIX='.bundle' - AS_IF([test x"$host_is_ios" = x"yes"], [ - LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out' - ], [ - LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out' - ]) - INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib' - INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/' - UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='' - ;; - mingw* | cygwin*) - AC_MSG_RESULT(MinGW / Cygwin) - LIB_CFLAGS='' - LIB_LDFLAGS='-shared -Wl,--export-all-symbols,--out-implib,lib${SHARED_LIB}.a' - LIB_LDFLAGS_INSTALL_NAME='' - LIB_PREFIX='' - LIB_SUFFIX='.dll' - LDFLAGS_RPATH='-Wl,-rpath,${libdir}' - PLUGIN_CFLAGS='' - PLUGIN_LDFLAGS='-shared' - PLUGIN_SUFFIX='.dll' - LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' - INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$$i.a ${DESTDIR}${libdir}/lib$$i.a' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$$i.a' - INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' - UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='${SHARED_LIB}.a' - ;; - openbsd* | mirbsd*) - AC_MSG_RESULT(OpenBSD) - LIB_CFLAGS='-fPIC -DPIC' - LIB_LDFLAGS='-shared' - LIB_LDFLAGS_INSTALL_NAME='' - LIB_PREFIX='lib' - LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}' - LDFLAGS_RPATH='-Wl,-rpath,${libdir}' - PLUGIN_CFLAGS='-fPIC -DPIC' - PLUGIN_LDFLAGS='-shared' - PLUGIN_SUFFIX='.so' - LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' - INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i' - INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' - UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='' - ;; - solaris*) - AC_MSG_RESULT(Solaris) - LIB_CFLAGS='-fPIC -DPIC' - LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}.${LIB_MINOR}' - LIB_LDFLAGS_INSTALL_NAME='' - LIB_PREFIX='lib' - LIB_SUFFIX='.so' - LDFLAGS_RPATH='-Wl,-rpath,${libdir}' - PLUGIN_CFLAGS='-fPIC -DPIC' - PLUGIN_LDFLAGS='-shared' - PLUGIN_SUFFIX='.so' - LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' - INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}' - INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' - UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='' - ;; - *-android*) - AC_MSG_RESULT(Android) - LIB_CFLAGS='-fPIC -DPIC' - LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}' - LIB_LDFLAGS_INSTALL_NAME='' - LIB_PREFIX='lib' - LIB_SUFFIX='.so' - LDFLAGS_RPATH='' - PLUGIN_CFLAGS='-fPIC -DPIC' - PLUGIN_LDFLAGS='-shared' - PLUGIN_SUFFIX='.so' - LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' - INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0' - INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' - UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='' - ;; - *) - AC_MSG_RESULT(ELF) - LIB_CFLAGS='-fPIC -DPIC' - LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}' - LIB_LDFLAGS_INSTALL_NAME='' - LIB_PREFIX='lib' - LIB_SUFFIX='.so' - LDFLAGS_RPATH='-Wl,-rpath,${libdir}' - PLUGIN_CFLAGS='-fPIC -DPIC' - PLUGIN_LDFLAGS='-shared' - PLUGIN_SUFFIX='.so' - LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' - INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i' - UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0' - INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' - UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' - CLEAN_LIB='' - ;; + case "$host" in + *-*-darwin*) + AC_MSG_RESULT(Darwin) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' + LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib' + LIB_PREFIX='lib' + LIB_SUFFIX='.dylib' + LDFLAGS_RPATH='-Wl,-rpath,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}' + PLUGIN_SUFFIX='.bundle' + AS_IF([test x"$host_is_ios" = x"yes"], [ + LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out' + ], [ + LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out' + ]) + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib' + INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/' + UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + *-*-mingw* | *-*-cygwin*) + AC_MSG_RESULT(MinGW / Cygwin) + LIB_CFLAGS='' + LIB_LDFLAGS='-shared -Wl,--export-all-symbols,--out-implib,lib$$out.a' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='' + LIB_SUFFIX='.dll' + LDFLAGS_RPATH='-Wl,-rpath,${libdir}' + PLUGIN_CFLAGS='' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.dll' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$$i.a ${DESTDIR}${libdir}/lib$$i.a' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$$i.a' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a' + ;; + *-*-openbsd* | *-*-mirbsd*) + AC_MSG_RESULT(OpenBSD) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}' + LDFLAGS_RPATH='-Wl,-rpath,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.so' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + *-*-solaris*) + AC_MSG_RESULT(Solaris) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.so' + LDFLAGS_RPATH='-Wl,-rpath,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.so' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + *-*-android*) + AC_MSG_RESULT(Android) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.so' + LDFLAGS_RPATH='' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.so' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + hppa*-*-hpux*) + AC_MSG_RESULT([HP-UX (PA-RISC)]) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared -Wl,+h,$$out' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.${LIB_MAJOR}' + LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl' + LDFLAGS_RPATH='-Wl,+b,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.sl' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.sl' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + ia64*-*-hpux*) + AC_MSG_RESULT([HP-UX (Itanium)]) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared -Wl,+h,$$out' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.${LIB_MAJOR}' + LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so' + LDFLAGS_RPATH='-Wl,+b,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.so' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.so' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; + *) + AC_MSG_RESULT(ELF) + LIB_CFLAGS='-fPIC -DPIC' + LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}' + LIB_LDFLAGS_INSTALL_NAME='' + LIB_PREFIX='lib' + LIB_SUFFIX='.so' + LDFLAGS_RPATH='-Wl,-rpath,${libdir}' + PLUGIN_CFLAGS='-fPIC -DPIC' + PLUGIN_LDFLAGS='-shared' + PLUGIN_SUFFIX='.so' + LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' + INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i' + UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0' + INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' + UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' + CLEAN_LIB='' + ;; esac AC_SUBST(LIB_CFLAGS) AC_SUBST(LIB_LDFLAGS) AC_SUBST(LIB_LDFLAGS_INSTALL_NAME) AC_SUBST(LIB_PREFIX) AC_SUBST(LIB_SUFFIX) + AC_SUBST(LINK_LIB) AC_SUBST(LDFLAGS_RPATH) AC_SUBST(PLUGIN_CFLAGS) AC_SUBST(PLUGIN_LDFLAGS) AC_SUBST(PLUGIN_SUFFIX) AC_SUBST(LINK_PLUGIN) @@ -307,22 +351,22 @@ AC_REQUIRE([BUILDSYS_SHARED_LIB]) AC_CHECK_TOOL(CODESIGN, codesign) case "$host_os" in - darwin*) - AS_IF([test x"$host_is_ios" = x"yes"], [ - FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' - FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}' - ], [ - FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' - FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}' - ]) - - AC_SUBST(FRAMEWORK_LDFLAGS) - AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME) - AC_SUBST(FRAMEWORK_LIBS) - - $1 - ;; + darwin*) + AS_IF([test x"$host_is_ios" = x"yes"], [ + FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' + FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}' + ], [ + FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' + FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}' + ]) + + AC_SUBST(FRAMEWORK_LDFLAGS) + AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME) + AC_SUBST(FRAMEWORK_LIBS) + + $1 + ;; esac ]) Index: buildsys.mk.in ================================================================== --- buildsys.mk.in +++ buildsys.mk.in @@ -1,8 +1,8 @@ # # Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, -# 2017, 2018, 2020 +# 2017, 2018, 2020, 2021 # Jonathan Schleifer # # https://fossil.nil.im/buildsys # # Permission to use, copy, modify, and/or distribute this software for any @@ -54,10 +54,11 @@ LIB_CFLAGS = @LIB_CFLAGS@ LIB_LDFLAGS = @LIB_LDFLAGS@ LIB_LDFLAGS_INSTALL_NAME = @LIB_LDFLAGS_INSTALL_NAME@ LIB_PREFIX = @LIB_PREFIX@ LIB_SUFFIX = @LIB_SUFFIX@ +LINK_LIB = @LINK_LIB@ AMIGA_LIB_CFLAGS = @AMIGA_LIB_CFLAGS@ AMIGA_LIB_LDFLAGS = @AMIGA_LIB_LDFLAGS@ PLUGIN_CFLAGS = @PLUGIN_CFLAGS@ PLUGIN_LDFLAGS = @PLUGIN_LDFLAGS@ PLUGIN_SUFFIX = @PLUGIN_SUFFIX@ @@ -147,11 +148,12 @@ ${DIR_LEAVE}; \ done depend: pre-depend : >.deps - for i in ${DEPS}; do \ + for i in "" ${DEPS}; do \ + test x"$$i" = x"" && continue; \ echo "-include \$${.CURDIR}/$$i" >>.deps; \ done pre-depend: @@ -181,11 +183,11 @@ fi ${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LINK_STATUS} out="$@"; \ - if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} ${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS}; then \ + if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} ${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS} ${LINK_LIB}; then \ ${LINK_OK}; \ else \ ${LINK_FAILED}; \ fi @@ -247,16 +249,16 @@ out="$@"; \ objs=""; \ ars=""; \ for i in ${OBJS} ${OBJS_EXTRA}; do \ case $$i in \ - *.a) \ - ars="$$ars $$i" \ - ;; \ - *.o) \ - objs="$$objs $$i" \ - ;; \ + *.a) \ + ars="$$ars $$i" \ + ;; \ + *.o) \ + objs="$$objs $$i" \ + ;; \ esac \ done; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ @@ -294,16 +296,16 @@ out="$@"; \ objs=""; \ ars=""; \ for i in ${LIB_OBJS} ${LIB_OBJS_EXTRA}; do \ case $$i in \ - *.a) \ - ars="$$ars $$i" \ - ;; \ - *.o) \ - objs="$$objs $$i" \ - ;; \ + *.a) \ + ars="$$ars $$i" \ + ;; \ + *.o) \ + objs="$$objs $$i" \ + ;; \ esac \ done; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ @@ -333,16 +335,16 @@ out="$@"; \ objs=""; \ ars=""; \ for i in ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}; do \ case $$i in \ - *.a) \ - ars="$$ars $$i" \ - ;; \ - *.o) \ - objs="$$objs $$i" \ - ;; \ + *.a) \ + ars="$$ars $$i" \ + ;; \ + *.o) \ + objs="$$objs $$i" \ + ;; \ esac \ done; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ @@ -884,11 +886,11 @@ ${DIR_LEAVE}; \ done : >.deps - for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} ${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \ + for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_START} ${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} ${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \ test x"$$i" = x"" && continue; \ if test -f $$i -o -d $$i; then \ if rm -fr $$i; then \ ${DELETE_OK}; \ else \ Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -20,124 +20,122 @@ dnl Used to disable checking for -pedantic on some platforms where it's broken check_pedantic="yes" case "$host" in - arm-*-riscos*) - AS_IF([test x"$OBJCFLAGS" = x""], [ - OBJCFLAGS="-O2 -g" - ]) - flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl" - ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp" - OBJCFLAGS="$OBJCFLAGS $flags" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" - LDFLAGS="$LDFLAGS $flags" - - enable_shared="no" - enable_threads="no" - enable_sockets="no" - enable_files="no" - ;; - m68k-*-amigaos*) - AS_IF([test x"$OBJCFLAGS" = x""], [ - OBJCFLAGS="-O0" - ]) - OBJCFLAGS="$OBJCFLAGS -noixemul" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" - CPPFLAGS="$CPPFLAGS -D__NO_NET_API" - LDFLAGS="$LDFLAGS -noixemul" - LIBS="$LIBS -ldebug" - - enable_files="yes" # Required for reading ENV: - enable_shared="no" - supports_amiga_lib="yes" - - AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library) - AC_SUBST(SFDC_TARGET, m68k-amigaos) - AC_SUBST(SFD_FILE, amigaos3.sfd) - AC_SUBST(SFDC_INLINE_H, inline.h) - dnl For 68000, GCC emits calls to helper functions that - dnl do not work properly in a library. - t="-mcpu=68020 -fbaserel -noixemul" - AC_SUBST(AMIGA_LIB_CFLAGS, "$t -ffreestanding") - t="$t -resident -nostartfiles -nodefaultlibs" - t="$t -ldebug -lc" - AC_SUBST(AMIGA_LIB_LDFLAGS, $t) - ]) - - AC_SUBST(LIBBASES_M, libbases.m) - ;; - powerpc-*-amigaos*) - CPPFLAGS="$CPPFLAGS -D__USE_INLINE__" - - enable_files="yes" # Required for reading ENV: - enable_shared="no" - - AC_SUBST(LIBBASES_M, libbases.m) - ;; - *-morphos*) - AS_IF([test x"$OBJCFLAGS" = x""], [ - OBJCFLAGS="-O2 -g" - ]) - OBJCFLAGS="$OBJCFLAGS -noixemul" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" - LDFLAGS="$LDFLAGS -noixemul" - LIBS="$LIBS -ldebug" - - enable_files="yes" # Required for reading ENV: - enable_shared="no" - supports_amiga_lib="yes" - check_pedantic="no" # Breaks generated inlines - - AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library) - AC_SUBST(CVINCLUDE_INLINE_H, inline.h) - t="-mresident32 -ffreestanding -noixemul" - AC_SUBST(AMIGA_LIB_CFLAGS, $t) - t="-mresident32 -nostartfiles -nodefaultlibs" - t="$t -noixemul -ldebug -lc" - AC_SUBST(AMIGA_LIB_LDFLAGS, $t) - ]) - - AC_SUBST(LIBBASES_M, libbases.m) - ;; - *-msdosdjgpp*) - enable_shared="no" - enable_threads="no" - enable_sockets="no" - ;; - *-*-mingw*) - LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition" - LIBS="$LIBS -lversion" - - AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}') - ;; - *-psp-*) - AS_IF([test x"$DEVKITPSP" = x""], [ - AC_MSG_ERROR( - [DEVKITPSP is not set! Please set DEVKITPSP.]) - ]) - - AS_IF([test x"$OBJCFLAGS" = x""], [ - OBJCFLAGS="-O2" - ]) - OBJCFLAGS="$OBJCFLAGS -G0" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0" - CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include" - LDFLAGS="$LDFLAGS -G0" - LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay" - LIBS="$LIBS -lpspge -lpspctrl -lpspsdk -lc -lpspnet" - LIBS="$LIBS -lpspnet_inet -lpspnet_apctl -lpspnet_resolver" - LIBS="$LIBS -lpsputility -lpspuser -lpspkernel -lgcc -lpsplibc" - enable_shared="no" - enable_threads="no" # TODO - enable_sockets="no" # TODO - check_pedantic="no" - - AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) - ;; +arm-*-riscos*) + AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"]) + flags="-mfloat-abi=softfp -mfpu=vfp -mlibscl" + ASFLAGS="$ASFLAGS -mfloat-abi=softfp -mfpu=vfp" + OBJCFLAGS="$OBJCFLAGS $flags" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" + LDFLAGS="$LDFLAGS $flags" + + enable_shared="no" + enable_threads="no" + enable_sockets="no" + enable_files="no" + ;; +m68k-*-amigaos*) + AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O0"]) + OBJCFLAGS="$OBJCFLAGS -noixemul" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" + CPPFLAGS="$CPPFLAGS -D__NO_NET_API" + LDFLAGS="$LDFLAGS -noixemul" + LIBS="$LIBS -ldebug" + + enable_files="yes" # Required for reading ENV: + enable_shared="no" + supports_amiga_lib="yes" + + AS_IF([test x"$enable_amiga_lib" != x"no"], [ + AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library) + dnl For 68000, GCC emits calls to helper functions that + dnl do not work properly in a library. + t="-mcpu=68020 -fbaserel -noixemul -ffreestanding" + AC_SUBST(AMIGA_LIB_CFLAGS, $t) + t="$t -resident -nostartfiles -nodefaultlibs -ldebug -lc" + AC_SUBST(AMIGA_LIB_LDFLAGS, $t) + ]) + + AC_SUBST(LIBBASES_M, libbases.m) + ;; +powerpc-*-amigaos*) + CPPFLAGS="$CPPFLAGS -D__USE_INLINE__" + + enable_files="yes" # Required for reading ENV: + enable_shared="no" + + AC_SUBST(LIBBASES_M, libbases.m) + ;; +*-morphos*) + AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"]) + OBJCFLAGS="$OBJCFLAGS -noixemul" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" + LDFLAGS="$LDFLAGS -noixemul" + LIBS="$LIBS -ldebug" + + enable_files="yes" # Required for reading ENV: + enable_shared="no" + supports_amiga_lib="yes" + + AS_IF([test x"$enable_amiga_lib" != x"no"], [ + AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library) + t="-mresident32 -ffreestanding -noixemul" + AC_SUBST(AMIGA_LIB_CFLAGS, $t) + t="-mresident32 -nostartfiles -nodefaultlibs -noixemul -ldebug" + AC_SUBST(AMIGA_LIB_LDFLAGS, "$t -lc") + ]) + + AC_SUBST(LIBBASES_M, libbases.m) + ;; +*-msdosdjgpp*) + enable_shared="no" + enable_threads="no" + enable_sockets="no" + ;; +*-*-mingw*) + LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition" + LIBS="$LIBS -lversion" + + AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}') + ;; +*-psp-*) + AS_IF([test x"$DEVKITPSP" = x""], [ + AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.]) + ]) + + AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"]) + OBJCFLAGS="$OBJCFLAGS -G0" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -G0" + CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include" + LDFLAGS="$LDFLAGS -G0" + LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay" + LIBS="$LIBS -lpspge -lpspctrl -lpspsdk -lc -lpspnet" + LIBS="$LIBS -lpspnet_inet -lpspnet_apctl -lpspnet_resolver" + LIBS="$LIBS -lpsputility -lpspuser -lpspkernel -lgcc -lpsplibc" + enable_shared="no" + enable_threads="no" # TODO + enable_sockets="no" # TODO + check_pedantic="no" + + AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) + ;; +hppa*-*-hpux*) + dnl Don't default to -g: It creates errors from the assembler and breaks + dnl exceptions. + AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2"]) + dnl HP-UX 11.11's inttypes.h defines UINTPTR_MAX etc. to nothing. GCC's + dnl stdint.h defines those correctly, but if inttypes.h gets included + dnl after something included stdint.h, it gets broken again. Therefore, + dnl always include inttypes.h as the very first thing. + dnl We need to put this into OBJCFLAGS and not CPPFLAGS as CPPFLAGS are + dnl also used for .S files. + OBJCFLAGS="$OBJCFLAGS -include inttypes.h" + dnl We need -latomic for GCC's atomics to work. + LIBS="$LIBS -latomic" + ;; esac AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [ dnl Hack to make configure find these on DOS. : ${AR:=ar.exe} @@ -145,23 +143,22 @@ : ${RANLIB:=ranlib.exe} ]) AC_LANG([Objective C]) case "$host_os" in - morphos*) - dnl Don't use clang on MorphOS - it does not support baserel, - dnl which is required for the .library. - potential_compilers="gcc" - ;; - *) - potential_compilers="clang egcc gcc" - ;; +morphos*) + dnl Don't use clang on MorphOS - it does not support baserel, which is + dnl required for the .library. + potential_compilers="gcc" + ;; +*) + potential_compilers="clang egcc gcc" + ;; esac AC_PROG_OBJC($potential_compilers) AC_PROG_OBJCPP AC_PROG_LN_S -AC_PROG_INSTALL AC_PROG_EGREP BUILDSYS_CHECK_IOS AC_ARG_WITH(wii, @@ -245,44 +242,43 @@ dnl amiga-gcc requires -fexceptions in LDFLAGS in order to link in the glue code dnl for registering the frames. LDFLAGS="$LDFLAGS -fexceptions" case "$OBJC" in - *clang*) - case "$host" in - dnl Clang generates MIPS assembly not accepted by GNU - dnl as, however, Clang's integrated assembler doesn't - dnl accept everything used in ObjFW's assembly files. - dnl Therefore, use the integrated assembler for ObjC - dnl files, but not for assembly files. - mips*-*-*) - flag="-integrated-as" - OBJCFLAGS="$OBJCFLAGS $flag" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" - ;; - dnl Don't use -no-integrated-as on Darwin. It breaks - dnl building for the iOS simulator. - i?86-*-darwin* | x86_64-*-darwin*) - ;; - dnl Many older Clang versions don't support jmp short. - i?86-*-* | x86_64-*-*) - ASFLAGS="$ASFLAGS -no-integrated-as" - ;; - dnl Clang's assembler on Windows is not complete yet - dnl and cannot compile all .S files. - *-*-mingw*) - ASFLAGS="$ASFLAGS -no-integrated-as" - ;; - dnl Clang generates assembly output on SPARC64 that - dnl OpenBSD's assembler does not accept. - sparc64-*-*openbsd*) - flag="-integrated-as" - OBJCFLAGS="$OBJCFLAGS $flag" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" - ;; - esac - ;; +*clang*) + case "$host" in + mips*-*-*) + dnl Clang generates MIPS assembly not accepted by GNU as, + dnl however, Clang's integrated assembler doesn't accept + dnl everything used in ObjFW's assembly files. Therefore, use + dnl the integrated assembler for ObjC files, but not for + dnl assembly files. + OBJCFLAGS="$OBJCFLAGS -integrated-as" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -integrated-as" + ;; + i?86-*-darwin* | x86_64-*-darwin*) + dnl Don't use -no-integrated-as on Darwin. It breaks building + dnl for the iOS simulator. + ;; + i?86-*-* | x86_64-*-*) + dnl Many older Clang versions don't support jmp short. + ASFLAGS="$ASFLAGS -no-integrated-as" + ;; + *-*-mingw*) + dnl Clang's assembler on Windows is not complete yet and cannot + dnl compile all .S files. + ASFLAGS="$ASFLAGS -no-integrated-as" + ;; + sparc64-*-*openbsd*) + dnl Clang generates assembly output on SPARC64 that OpenBSD's + dnl assembler does not accept. + flag="-integrated-as" + OBJCFLAGS="$OBJCFLAGS $flag" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" + ;; + esac + ;; esac AX_CHECK_COMPILER_FLAGS(-std=gnu11, [ OBJCFLAGS="$OBJCFLAGS -std=gnu11" ], [ @@ -292,18 +288,11 @@ AX_CHECK_COMPILER_FLAGS(-std=gnu99, [OBJCFLAGS="$OBJCFLAGS -std=gnu99"]) ]) ]) -case "$build_os" in - morphos*) - # MorphOS 3.10 has a buggy ixemul that does not work with -pipe. - ;; - *) - AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) - ;; -esac +AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-cfstrings, [ flag="-Xclang -fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS $flag" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" @@ -324,15 +313,14 @@ [OBJCFLAGS="$OBJCFLAGS -Wobjc-missing-property-synthesis"]) AX_CHECK_COMPILER_FLAGS([-Wmissing-method-return-type -Werror], [OBJCFLAGS="$OBJCFLAGS -Wmissing-method-return-type"]) case "$host" in - m68k-*-amigaos*) - dnl The inline headers generate code that triggers - dnl -Wpointer-sign. - OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign" - ;; +m68k-*-amigaos*) + dnl The inline headers generate code that triggers -Wpointer-sign. + OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign" + ;; esac AC_MSG_CHECKING(whether Objective C compiler supports properties) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ @@ -445,13 +433,13 @@ ], [ AC_MSG_RESULT(no) ]) case "$host_os" in - solaris*) - CPPFLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS" - ;; +solaris*) + CPPFLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS $CPPFLAGS" + ;; esac objc_runtime="ObjFW runtime" AC_CHECK_HEADER(objc/objc.h) AC_MSG_CHECKING(which Objective C runtime to use) @@ -473,220 +461,218 @@ ]) ]) AC_MSG_RESULT($objc_runtime) case "$objc_runtime" in - "ObjFW runtime") - AC_DEFINE(OF_OBJFW_RUNTIME, 1, - [Whether we use the ObjFW runtime]) - - AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported]) - - old_OBJCFLAGS="$OBJCFLAGS" - OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw" - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Test - + (void)test; - @end - - @implementation Test - + (void)test - { - } - @end - - void * - objc_msg_lookup(void *obj, void *sel) - { - return (void *)0; - } - - void - __objc_exec_class(void *module) - { - } - ], [[ - [Test test]; - ]]) - ], [ - flag="-Xclang -fobjc-runtime=objfw" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" - AC_MSG_RESULT(yes) - ], [ - flag="-fgnu-runtime" - OBJCFLAGS="$old_OBJCFLAGS $flag" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" - AC_MSG_RESULT(no) - old_compiler="yes" - ]) - - AC_SUBST(RUNTIME, "runtime") - AC_CONFIG_FILES(src/runtime/Info.plist) - - AS_IF([test x"$enable_shared" != x"no"], [ - AC_SUBST(OBJFWRT_SHARED_LIB, - "${LIB_PREFIX}objfwrt${LIB_SUFFIX}") - ]) - - AS_IF([test x"$enable_static" = x"yes"], [ - AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a") - ]) - - AS_IF([test x"$build_framework" = x"yes"], [ - AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework") - AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT") - ]) - - AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(RUNTIME_LIBS, "-lobjfwrt.library") - AC_SUBST(LINKLIB, linklib) - tmp="../src/runtime/linklib/libobjfwrt.library.a" - AC_SUBST(LIBOBJFWRT_DEP, "$tmp") - AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp") - ], [ - AC_SUBST(RUNTIME_LIBS, "-lobjfwrt") - ]) - - AS_IF([test x"$enable_shared" = x"no" \ - -a x"$enable_amiga_lib" = x"no"], [ - tmp="../src/runtime/libobjfwrt.a" - AC_SUBST(LIBOBJFWRT_DEP, "$tmp") - AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp") - ]) - - AS_IF([test x"$enable_seluid24" = x"yes"], [ - AC_DEFINE(OF_SELUID24, 1, - [Whether to use 24 bit selector UIDs]) - ]) - - AC_MSG_CHECKING(for exception type) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ - extern void foo(); - ], [ - @try { - foo(); - } @finally { - foo(); - } - ]) - ], [ - AS_IF([$EGREP __gnu_objc_personality_v0 \ - conftest.$ac_objext >/dev/null], [ - exception_type="DWARF" - ]) - AS_IF([$EGREP __gnu_objc_personality_sj0 \ - conftest.$ac_objext >/dev/null], [ - exception_type="SjLj" - ]) - AS_IF([$EGREP __gnu_objc_personality_seh0 \ - conftest.$ac_objext >/dev/null], [ - exception_type="SEH" - ]) - +"ObjFW runtime") + AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime]) + + AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported]) + + old_OBJCFLAGS="$OBJCFLAGS" + OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Test + + (void)test; + @end + + @implementation Test + + (void)test + { + } + @end + + void * + objc_msg_lookup(void *obj, void *sel) + { + return (void *)0; + } + + void + __objc_exec_class(void *module) + { + } + ], [[ + [Test test]; + ]]) + ], [ + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fobjc-runtime=objfw" + AC_MSG_RESULT(yes) + ], [ + OBJCFLAGS="$old_OBJCFLAGS -fgnu-runtime" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -fgnu-runtime" + AC_MSG_RESULT(no) + old_compiler="yes" + ]) + + AC_SUBST(RUNTIME, "runtime") + AC_CONFIG_FILES(src/runtime/Info.plist) + + AS_IF([test x"$enable_shared" != x"no"], [ + AC_SUBST(OBJFWRT_SHARED_LIB, + "${LIB_PREFIX}objfwrt${LIB_SUFFIX}") + ]) + + AS_IF([test x"$enable_static" = x"yes"], [ + AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a") + ]) + + AS_IF([test x"$build_framework" = x"yes"], [ + AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework") + AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT") + ]) + + AS_IF([test x"$enable_amiga_lib" != x"no"], [ + AC_SUBST(RUNTIME_LIBS, "-lobjfwrt.library") + AC_SUBST(LINKLIB, linklib) + tmp="../src/runtime/linklib/libobjfwrt.library.a" + AC_SUBST(LIBOBJFWRT_DEP, "$tmp") + AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp") + ], [ + AC_SUBST(RUNTIME_LIBS, "-lobjfwrt") + ]) + + AS_IF([test x"$enable_shared" = x"no" \ + -a x"$enable_amiga_lib" = x"no"], [ + AC_SUBST(LIBOBJFWRT_DEP, "../src/runtime/libobjfwrt.a") + AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../../src/runtime/libobjfwrt.a") + ]) + + AS_IF([test x"$enable_seluid24" = x"yes"], [ + AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs]) + ]) + + AC_MSG_CHECKING(for exception type) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + extern void foo(); + ], [ + @try { + foo(); + } @finally { + foo(); + } + ]) + ], [ + AS_IF([$EGREP __gnu_objc_personality_v0 conftest.$ac_objext \ + >/dev/null], [ + exception_type="DWARF" + ]) + AS_IF([$EGREP __gnu_objc_personality_sj0 conftest.$ac_objext \ + >/dev/null], [ + exception_type="SjLj" + ]) + AS_IF([$EGREP __gnu_objc_personality_seh0 conftest.$ac_objext \ + >/dev/null], [ + exception_type="SEH" + ]) + + case "$exception_type" in + DWARF) + AC_DEFINE(HAVE_DWARF_EXCEPTIONS, 1, + [Whether DWARF exceptions are used]) + raise_exception="_Unwind_RaiseException" + ;; + SjLj) + AC_DEFINE(HAVE_SJLJ_EXCEPTIONS, 1, + [Whether SjLj exceptions are used]) + raise_exception="_Unwind_SjLj_RaiseException" + ;; + SEH) + AC_DEFINE(HAVE_SEH_EXCEPTIONS, 1, + [Whether SEH exceptions are used]) raise_exception="_Unwind_RaiseException" - - case "$exception_type" in - DWARF) - AC_DEFINE(HAVE_DWARF_EXCEPTIONS, 1, - [Whether DWARF exceptions are used]) - ;; - SjLj) - AC_DEFINE(HAVE_SJLJ_EXCEPTIONS, 1, - [Whether SjLj exceptions are used]) - raise_exception="_Unwind_SjLj_RaiseException" - ;; - SEH) - AC_DEFINE(HAVE_SEH_EXCEPTIONS, 1, - [Whether SEH exceptions are used]) - ;; - *) - AC_MSG_RESULT(unknown) - AC_MSG_ERROR([Exception type not detected!]) - ;; - esac - - AC_MSG_RESULT($exception_type) - ], [ - AC_MSG_RESULT(exceptions unavailable!) - AC_MSG_ERROR([Exceptions not accepted by compiler!]) - ]) - - AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc], [ - dnl c++abi requires pthread on OpenBSD - AS_IF([test x"$ac_lib" = x"c++abi"], [ - LIBS="$LIBS -lpthread" - ]) - ], [ - AC_MSG_ERROR([$raise_exception missing!]) - ], [-lpthread]) - - AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase) - ;; - "Apple runtime") - AC_DEFINE(OF_APPLE_RUNTIME, 1, - [Whether we use the Apple ObjC runtime]) - - AC_CHECK_LIB(objc, objc_msgSend, [ - AC_SUBST(RUNTIME_LIBS, "-lobjc") - AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-lobjc") - ], [ - AC_MSG_ERROR([libobjc not found!]) - ]) - - old_OBJCFLAGS="$OBJCFLAGS" - OBJCFLAGS="$OBJCFLAGS -lobjc" - - AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [ - AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m") - ]) - AC_CHECK_FUNC(objc_constructInstance, [], [ - AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m") - ]) - - OBJCFLAGS="$old_OBJCFLAGS" - ;; -esac - -AC_CHECK_FUNCS(_Unwind_Backtrace) + ;; + *) + AC_MSG_RESULT(unknown) + AC_MSG_ERROR([Exception type not detected!]) + ;; + esac + + AC_MSG_RESULT($exception_type) + ], [ + AC_MSG_RESULT(exceptions unavailable!) + AC_MSG_ERROR([Exceptions not accepted by compiler!]) + ]) + + AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [ + dnl c++abi requires pthread on OpenBSD + AS_IF([test x"$ac_lib" = x"c++abi"], [LIBS="$LIBS -lpthread"]) + ], [ + AC_MSG_ERROR([$raise_exception missing!]) + ], [-lpthread]) + + AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase) + ;; +"Apple runtime") + AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime]) + + AC_CHECK_LIB(objc, objc_msgSend, [ + AC_SUBST(RUNTIME_LIBS, "-lobjc") + AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-lobjc") + ], [ + AC_MSG_ERROR([libobjc not found!]) + ]) + + old_OBJCFLAGS="$OBJCFLAGS" + OBJCFLAGS="$OBJCFLAGS -lobjc" + + AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [ + AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m") + ]) + AC_CHECK_FUNC(objc_constructInstance, [], [ + AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m") + ]) + + OBJCFLAGS="$old_OBJCFLAGS" + ;; +esac + +case "$host_os" in +hpux*) + dnl _Unwind_Backtrace() returns complete garbage on HP-UX. + ;; +*) + AC_CHECK_FUNCS(_Unwind_Backtrace) + ;; +esac case "$host_os" in - darwin*) - AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"]) - AS_IF([test x"$objc_runtime" = x"Apple runtime"], [ - AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"]) - AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, - ["-Wl,-reexport-lobjc"]) - LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber" - ]) - - AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [ - AS_IF([test x"$exception_type" = x"DWARF"], [ - LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0" - ]) - AS_IF([test x"$exception_type" = x"SjLj"], [ - LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_sj0" - ]) - AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"]) - AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, - ["-Wl,-reexport_framework,ObjFWRT"]) - ]) - - AC_CHECK_HEADERS(sysdir.h) - AC_CHECK_FUNCS(sysdir_start_search_path_enumeration) - - AS_IF([test x"$host_is_ios" = x"yes"], [ - AC_SUBST(TESTS_STATIC_LIB, tests.a) - TESTS_LIBS="$TESTS_LIBS -framework CoreFoundation" - ]) - ;; +darwin*) + AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"]) + AS_IF([test x"$objc_runtime" = x"Apple runtime"], [ + AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjc"]) + AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, ["-Wl,-reexport-lobjc"]) + LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber" + ]) + + AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [ + AS_IF([test x"$exception_type" = x"DWARF"], [ + LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0" + ]) + AS_IF([test x"$exception_type" = x"SjLj"], [ + LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_sj0" + ]) + AC_SUBST(REEXPORT_RUNTIME, ["-Wl,-reexport-lobjfwrt"]) + AC_SUBST(REEXPORT_RUNTIME_FRAMEWORK, + ["-Wl,-reexport_framework,ObjFWRT"]) + ]) + + AC_CHECK_HEADERS(sysdir.h) + AC_CHECK_FUNCS(sysdir_start_search_path_enumeration) + + AS_IF([test x"$host_is_ios" = x"yes"], [ + AC_SUBST(TESTS_STATIC_LIB, tests.a) + TESTS_LIBS="$TESTS_LIBS -framework CoreFoundation" + ]) + ;; esac AC_MSG_CHECKING(whether Objective C compiler supports ARC) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -fobjc-arc -fobjc-arc-exceptions" @@ -808,49 +794,48 @@ AS_IF([test x"$fp_endianess" = x"unknown"], [ AC_MSG_ERROR( [Floating point implementation does not conform to IEEE 754!])]) case "$host_cpu" in - arm* | earm*) - AC_MSG_CHECKING(for VFP2 or above) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([], [ - #if !defined(__arm64__) && \ - !defined(__aarch64__) && \ - !defined(__ARM64_ARCH_8__) - __asm__ __volatile__ ( - "vstmdb sp!, {d0-d7}" - ); - #endif - ]) - ], [ - AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above]) - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ]) - ;; +arm* | earm*) + AC_MSG_CHECKING(for VFP2 or above) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [ + #if !defined(__arm64__) && !defined(__aarch64__) && \ + !defined(__ARM64_ARCH_8__) + __asm__ __volatile__ ( + "vstmdb sp!, {d0-d7}" + ); + #endif + ]) + ], [ + AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above]) + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + ]) + ;; esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") +AC_CHECK_FUNCS(strtof truncf) + AC_CHECK_FUNC(asprintf, [ case "$host" in - *-*-mingw*) - dnl asprintf from MinGW is broken on older Windows - dnl versions - have_asprintf="no" - ;; - *-psp-*) - dnl asprintf is broken on the PSP - have_asprintf="no" - ;; - *) - have_asprintf="yes" - AC_DEFINE(HAVE_ASPRINTF, 1, - [Whether we have asprintf()]) + *-*-mingw*) + dnl asprintf from MinGW is broken on older Windows versions + have_asprintf="no" + ;; + *-psp-*) + dnl asprintf is broken on the PSP + have_asprintf="no" + ;; + *) + have_asprintf="yes" + AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf()]) ;; esac ], [ have_asprintf="no" ]) @@ -901,20 +886,20 @@ AS_IF([test x"$host_os" != x"morphos"], [ AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") ]) AC_CHECK_HEADERS_ONCE(dlfcn.h) case "$host_os" in - netbsd*) - dnl dladdr exists on NetBSD, but it is completely broken. - dnl When using it with code that uses __thread, it freezes the - dnl process so that it has to be killed using SIGKILL. - dnl When disabling __thread, it doesn't freeze, but all symbols - dnl are wrong. - ;; - *) - AC_CHECK_FUNCS(dladdr) - ;; +netbsd*) + dnl dladdr exists on NetBSD, but it is completely broken. + dnl When using it with code that uses __thread, it freezes the process + dnl so that it has to be killed using SIGKILL. + dnl When disabling __thread, it doesn't freeze, but all symbols are + dnl wrong. + ;; +*) + AC_CHECK_FUNCS(dladdr) + ;; esac AC_CHECK_HEADERS(sys/mman.h) AC_CHECK_FUNCS(mmap mlock) @@ -939,11 +924,11 @@ CPPFLAGS="$CPPFLAGS -Wp,-pthread" ], [ CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE" ]) - AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread") + AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread") AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #include ], [ @@ -993,22 +978,23 @@ AC_ARG_ENABLE(compiler-tls, AS_HELP_STRING([--disable-compiler-tls], [disable compiler thread local storage])) case "$host" in - aarch64*-*-android*) - # Compiler TLS is broken on AArch64 Android with Clang - enable_compiler_tls="no" - ;; - m68k-*-amigaos* | powerpc-*-amigaos*) - # Compiler TLS is broken on AmigaOS - enable_compiler_tls="no" - ;; - *-*-morphos*) - # Compiler TLS needs helpers that we don't want in the - # .library - enable_compiler_tls="no" + aarch64*-*-android*) + dnl Compiler TLS is broken on AArch64 Android with Clang + enable_compiler_tls="no" + ;; + m68k-*-amigaos* | powerpc-*-amigaos*) + dnl Compiler TLS is broken on AmigaOS + enable_compiler_tls="no" + ;; + *-*-morphos*) + dnl Compiler TLS needs helpers that we don't want in the + dnl .library + enable_compiler_tls="no" + ;; esac AS_IF([test x"$enable_compiler_tls" != x"no"], [ AC_CHECK_HEADER(threads.h, [ AC_DEFINE(OF_HAVE_THREADS_H, 1, @@ -1180,20 +1166,19 @@ AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(OFARC, "ofarc") AC_SUBST(OFHASH, "ofhash") case "$host_os" in - msdosdjgpp*) - dnl DJGPP has the type, but it's not really usable. - ;; - *) - AC_CHECK_TYPE(off64_t, [ - AC_DEFINE(OF_HAVE_OFF64_T, 1, - [Whether we have off64_t]) - AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64]) - ]) - ;; + msdosdjgpp*) + dnl DJGPP has the type, but it's not really usable. + ;; + *) + AC_CHECK_TYPE(off64_t, [ + AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t]) + AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64]) + ]) + ;; esac AC_CHECK_HEADERS([pwd.h grp.h]) AC_CHECK_FUNC(chmod, [ AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()]) @@ -1231,12 +1216,25 @@ AC_MSG_RESULT(no) ]) OBJCFLAGS="$old_OBJCFLAGS" ]) -AC_CHECK_HEADERS(fcntl.h dirent.h) -AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl]) +AC_CHECK_HEADERS(dirent.h) +AC_CHECK_FUNCS([sysconf gmtime_r localtime_r]) + +case "$host_os" in +amigaos* | morphos*) + dnl We don't want fcntl() or nanosleep() on AmigaOS / MorphOS, despite + dnl a symbol existing. The reason is that we cannot use fcntl() for + dnl sockets and that nanosleep() is yet another function that uses + dnl errno, so would need to be passed from the linklib. + ;; +*) + AC_CHECK_HEADERS(fcntl.h) + AC_CHECK_FUNCS([fcntl nanosleep]) + ;; +esac AC_CHECK_HEADERS(xlocale.h) AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l]) AS_IF([test x"$gnu_source" != x"yes" -a \( \ x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \ @@ -1304,21 +1302,21 @@ AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}') case "$host_os" in - amigaos*) - ;; - haiku*) - LIBS="$LIBS -lnetwork" - ;; - mingw*) - LIBS="$LIBS -lws2_32 -liphlpapi" - ;; - *) - AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") - ;; + amigaos* | morphos*) + ;; + haiku*) + LIBS="$LIBS -lnetwork" + ;; + mingw*) + LIBS="$LIBS -lws2_32 -liphlpapi" + ;; + *) + AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") + ;; esac AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) @@ -1485,25 +1483,24 @@ "OFPollKernelEventObserver.m") ]) ]) case "$host_os" in - amigaos* | mingw* | morphos*) + amigaos* | mingw* | morphos*) + AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar]) + AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, + "OFSelectKernelEventObserver.m") + ;; + *) + AC_CHECK_HEADERS(sys/select.h) + AC_CHECK_FUNC(select, [ AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar]) AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") - ;; - *) - AC_CHECK_HEADERS(sys/select.h) - AC_CHECK_FUNC(select, [ - AC_DEFINE(HAVE_SELECT, 1, - [Whether we have select() or similar]) - AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, - "OFSelectKernelEventObserver.m") - ]) - ;; + ]) + ;; esac AS_IF([test x"$enable_threads" != x"no"], [ AC_SUBST(OF_HTTP_CLIENT_TESTS_M, "OFHTTPClientTests.m") ]) @@ -1536,64 +1533,62 @@ CHECK_BUILTIN_BSWAP(16) CHECK_BUILTIN_BSWAP(32) CHECK_BUILTIN_BSWAP(64) case "$host_os" in - darwin*) - AC_MSG_CHECKING(whether we are compiling for macOS) - AC_EGREP_CPP(egrep_cpp_yes, [ - #include - - #if (!defined(TARGET_OS_IPHONE) || \ - !TARGET_OS_IPHONE) && \ - (!defined(TARGET_OS_SIMULATOR) || \ - !TARGET_OS_SIMULATOR) - egrep_cpp_yes - #endif - ], [ - AC_MSG_RESULT(yes) - have_processes="yes" - ], [ - AC_MSG_RESULT(no) - have_processes="no" - ]) - ;; - mingw*) - have_processes="yes" - ;; - msdosdjgpp*) - have_processes="no" - ;; - *) - AC_HEADER_SYS_WAIT - AC_CHECK_FUNCS(kill) - - AC_CHECK_FUNCS(posix_spawnp, [ - AS_IF([test x"$ac_cv_func_kill" = x"yes"], [ - have_processes="yes" - - AC_CHECK_HEADERS(spawn.h) - ]) - ], [ - AC_CHECK_FUNCS([vfork dup2 execvp _exit], [ - AS_IF([test x"$ac_cv_func_vfork" = x"yes" \ - -a x"$ac_cv_func_pipe" = x"yes" \ - -a x"$ac_cv_func_dup2" = x"yes" \ - -a x"$ac_cv_func_execvp" = x"yes" \ - -a x"$ac_cv_func_kill" = x"yes" \ - -a x"$ac_cv_func__exit" = x"yes"], [ - have_processes="yes" - ]) - ], [ - break - ]) - ]) - ;; -esac -AS_IF([test x"$have_processes" = x"yes"], [ - AC_SUBST(OF_PROCESS_M, "OFProcess.m") - AC_DEFINE(OF_HAVE_PROCESSES, 1, [Whether we have processes]) +darwin*) + AC_MSG_CHECKING(whether we are compiling for macOS) + AC_EGREP_CPP(egrep_cpp_yes, [ + #include + + #if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \ + (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR) + egrep_cpp_yes + #endif + ], [ + AC_MSG_RESULT(yes) + have_subprocesses="yes" + ], [ + AC_MSG_RESULT(no) + have_subprocesses="no" + ]) + ;; +mingw*) + have_subprocesses="yes" + ;; +msdosdjgpp*) + have_subprocesses="no" + ;; +*) + AC_HEADER_SYS_WAIT + AC_CHECK_FUNCS(kill) + + AC_CHECK_FUNCS(posix_spawnp, [ + AS_IF([test x"$ac_cv_func_kill" = x"yes"], [ + have_subprocesses="yes" + + AC_CHECK_HEADERS(spawn.h) + ]) + ], [ + AC_CHECK_FUNCS([vfork dup2 execvp _exit], [ + AS_IF([test x"$ac_cv_func_vfork" = x"yes" \ + -a x"$ac_cv_func_pipe" = x"yes" \ + -a x"$ac_cv_func_dup2" = x"yes" \ + -a x"$ac_cv_func_execvp" = x"yes" \ + -a x"$ac_cv_func_kill" = x"yes" \ + -a x"$ac_cv_func__exit" = x"yes"], [ + have_subprocesses="yes" + ]) + ], [ + break + ]) + ]) + ;; +esac +AS_IF([test x"$have_subprocesses" = x"yes"], [ + AC_SUBST(OF_SUBPROCESS_M, "OFSubprocess.m") + AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses]) ]) AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h]) AC_CHECK_FUNCS(isatty) @@ -1901,16 +1896,16 @@ AS_IF([test x"$cross_compiling" = x"yes"], [ AC_SUBST(BIN_PREFIX, "${host_alias}-") case "$host" in - i?86-*-mingw*) - AC_CHECK_PROG(WINE, wine, wine) - ;; - x86_64-*-mingw*) - AC_CHECK_PROG(WINE, wine64, wine64) - ;; + i?86-*-mingw*) + AC_CHECK_PROG(WINE, wine, wine) + ;; + x86_64-*-mingw*) + AC_CHECK_PROG(WINE, wine64, wine64) + ;; esac AS_IF([test x"$WINE" != x""], [ AC_SUBST(RUN_TESTS, "run") AC_SUBST(WRAPPER, "$WINE") @@ -1931,10 +1926,14 @@ ]) AC_ARG_WITH(fish_completions, AS_HELP_STRING([--with-fish-completions], [install completions for the fish shell])) +AS_IF([test x"$with_fish_completions" = x""], [ + AC_CHECK_PROG(FISH, fish, fish) + AS_IF([test x"$FISH" != x""], [with_fish_completions="yes"]) +]) AS_IF([test x"$with_fish_completions" = x"yes"], [ AC_SUBST(FISH_COMPLETIONS, fish) ]) dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -35,12 +35,12 @@ LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ LINKLIB = @LINKLIB@ LOOKUP_ASM_A = @LOOKUP_ASM_A@ -LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@ +LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ MAP_LDFLAGS = @MAP_LDFLAGS@ OFARC = @OFARC@ OFDNS = @OFDNS@ OFHASH = @OFHASH@ OFHTTP = @OFHTTP@ @@ -47,12 +47,12 @@ OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@ OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@ OF_HTTP_CLIENT_TESTS_M = @OF_HTTP_CLIENT_TESTS_M@ OF_KQUEUE_KERNEL_EVENT_OBSERVER_M = @OF_KQUEUE_KERNEL_EVENT_OBSERVER_M@ OF_POLL_KERNEL_EVENT_OBSERVER_M = @OF_POLL_KERNEL_EVENT_OBSERVER_M@ -OF_PROCESS_M = @OF_PROCESS_M@ OF_SELECT_KERNEL_EVENT_OBSERVER_M = @OF_SELECT_KERNEL_EVENT_OBSERVER_M@ +OF_SUBPROCESS_M = @OF_SUBPROCESS_M@ REEXPORT_RUNTIME = @REEXPORT_RUNTIME@ REEXPORT_RUNTIME_FRAMEWORK = @REEXPORT_RUNTIME_FRAMEWORK@ RUNTIME = @RUNTIME@ RUNTIME_ARC_TESTS_M = @RUNTIME_ARC_TESTS_M@ RUNTIME_AUTORELEASE_M = @RUNTIME_AUTORELEASE_M@ DELETED generators/Makefile Index: generators/Makefile ================================================================== --- generators/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -include ../extra.mk - -PROG_NOINST = gen_tables${PROG_SUFFIX} -SRCS = TableGenerator.m - -.PHONY: run -run: all - rm -f libobjfw.so.${OBJFW_LIB_MAJOR} - rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} - rm -f objfw.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib - rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} - rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} - rm -f objfwrt.dll libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib - rm -f ${OBJFWRT_AMIGA_LIB} - if test -f ../src/libobjfw.so; then \ - ${LN_S} ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ - ${LN_S} ../src/libobjfw.so \ - libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ - elif test -f ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ - ${LN_S} ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ - libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ - fi - if test -f ../src/objfw.dll; then \ - ${LN_S} ../src/objfw.dll objfw.dll; \ - fi - if test -f ../src/libobjfw.dylib; then \ - ${LN_S} ../src/libobjfw.dylib \ - libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ - fi - if test -f ../src/runtime/libobjfwrt.so; then \ - ${LN_S} ../src/runtime/libobjfwrt.so \ - libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ - ${LN_S} ../src/runtime/libobjfwrt.so \ - libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ - elif test -f ../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \ - ${LN_S} ../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ - fi - if test -f ../src/runtime/objfwrt.dll; then \ - ${LN_S} ../src/runtime/objfwrt.dll objfwrt.dll; \ - fi - if test -f ../src/runtime/libobjfwrt.dylib; then \ - ${LN_S} ../src/runtime/libobjfwrt.dylib \ - libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ - fi - if test -f ../src/runtime/${OBJFWRT_AMIGA_LIB}; then \ - ${LN_S} ../src/runtime/${OBJFWRT_AMIGA_LIB} \ - ${OBJFWRT_AMIGA_LIB}; \ - fi - LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ - DYLD_FRAMEWORK_PATH=../src:../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \ - DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ - LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ - ASAN_OPTIONS=allocator_may_return_null=1 \ - ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ - rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ - rm -f objfw.so.${OBJFW_LIB_MAJOR_MINOR} objfw.dll; \ - rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ - rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ - rm -f objfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} objfwrt.dll; \ - rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ - exit $$EXIT - -include ../buildsys.mk - -CPPFLAGS += -I../src -I../src/exceptions -I../src/runtime -I.. -LIBS := -L../src -lobjfw -L../src/runtime ${RUNTIME_LIBS} ${LIBS} -LD = ${OBJC} DELETED generators/TableGenerator.h Index: generators/TableGenerator.h ================================================================== --- generators/TableGenerator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFObject.h" -#import "OFHTTPClient.h" - -@class OFString; - -@interface TableGenerator: OFObject -{ - OFHTTPClient *_HTTPClient; - of_unichar_t _uppercaseTable[0x110000]; - of_unichar_t _lowercaseTable[0x110000]; - of_unichar_t _titlecaseTable[0x110000]; - of_unichar_t _casefoldingTable[0x110000]; - OFString *_decompositionTable[0x110000]; - OFString *_decompositionCompatTable[0x110000]; - char _uppercaseTableUsed[0x1100]; - char _lowercaseTableUsed[0x1100]; - char _titlecaseTableUsed[0x1100]; - char _casefoldingTableUsed[0x1100]; - char _decompositionTableUsed[0x1100]; - char _decompositionCompatTableUsed[0x1100]; - size_t _uppercaseTableSize; - size_t _lowercaseTableSize; - size_t _titlecaseTableSize; - size_t _casefoldingTableSize; - size_t _decompositionTableSize; - size_t _decompositionCompatTableSize; - enum { - STATE_UNICODE_DATA, - STATE_CASE_FOLDING - } _state; -} - -- (void)parseUnicodeData: (OFHTTPResponse *)response; -- (void)parseCaseFolding: (OFHTTPResponse *)response; -- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table; -- (void)writeFiles; -- (void)writeTablesToFile: (OFString *)path; -- (void)writeHeaderToFile: (OFString *)path; -@end DELETED generators/TableGenerator.m Index: generators/TableGenerator.m ================================================================== --- generators/TableGenerator.m +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#include - -#import "OFString.h" -#import "OFArray.h" -#import "OFApplication.h" -#import "OFURL.h" -#import "OFHTTPRequest.h" -#import "OFHTTPResponse.h" -#import "OFHTTPClient.h" -#import "OFFile.h" -#import "OFStdIOStream.h" - -#import "OFOutOfRangeException.h" - -#import "TableGenerator.h" -#import "copyright.h" - -#define UNICODE_DATA_URL \ - @"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt" -#define CASE_FOLDING_URL \ - @"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt" - -OF_APPLICATION_DELEGATE(TableGenerator) - -@implementation TableGenerator -- (instancetype)init -{ - self = [super init]; - - @try { - _HTTPClient = [[OFHTTPClient alloc] init]; - _HTTPClient.delegate = self; - - _uppercaseTableSize = SIZE_MAX; - _lowercaseTableSize = SIZE_MAX; - _titlecaseTableSize = SIZE_MAX; - _casefoldingTableSize = SIZE_MAX; - _decompositionTableSize = SIZE_MAX; - _decompositionCompatTableSize = SIZE_MAX; - } @catch (id e) { - @throw e; - [self release]; - } - - return self; -} - -- (void)applicationDidFinishLaunching -{ - OFHTTPRequest *request; - - [of_stdout writeString: @"Downloading UnicodeData.txt…"]; - _state = STATE_UNICODE_DATA; - request = [OFHTTPRequest requestWithURL: - [OFURL URLWithString: UNICODE_DATA_URL]]; - [_HTTPClient asyncPerformRequest: request]; -} - -- (void)client: (OFHTTPClient *)client - didPerformRequest: (OFHTTPRequest *)request - response: (OFHTTPResponse *)response - exception: (id)exception -{ - if (exception != nil) - @throw exception; - - [of_stdout writeLine: @" done"]; - - switch (_state) { - case STATE_UNICODE_DATA: - [self parseUnicodeData: response]; - break; - case STATE_CASE_FOLDING: - [self parseCaseFolding: response]; - break; - } -} - -- (void)parseUnicodeData: (OFHTTPResponse *)response -{ - OFString *line; - OFHTTPRequest *request; - - [of_stdout writeString: @"Parsing UnicodeData.txt…"]; - - while ((line = [response readLine]) != nil) { - void *pool2; - OFArray OF_GENERIC(OFString *) *components; - of_unichar_t codePoint; - - if (line.length == 0) - continue; - - pool2 = objc_autoreleasePoolPush(); - - components = [line componentsSeparatedByString: @";"]; - if (components.count != 15) { - of_log(@"Invalid line: %@\n", line); - [OFApplication terminateWithStatus: 1]; - } - - codePoint = (of_unichar_t)[[components objectAtIndex: 0] - unsignedLongLongValueWithBase: 16]; - - if (codePoint > 0x10FFFF) - @throw [OFOutOfRangeException exception]; - - _uppercaseTable[codePoint] = (of_unichar_t)[[components - objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; - _lowercaseTable[codePoint] = (of_unichar_t)[[components - objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; - _titlecaseTable[codePoint] = (of_unichar_t)[[components - objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; - - if ([[components objectAtIndex: 5] length] > 0) { - OFArray *decomposed = [[components objectAtIndex: 5] - componentsSeparatedByString: @" "]; - bool compat = false; - OFMutableString *string; - - if ([decomposed.firstObject hasPrefix: @"<"]) { - decomposed = [decomposed objectsInRange: - of_range(1, decomposed.count - 1)]; - compat = true; - } - - string = [OFMutableString string]; - - for (OFString *character in decomposed) { - of_unichar_t unichar = (of_unichar_t)[character - unsignedLongLongValueWithBase: 16]; - - [string appendCharacters: &unichar - length: 1]; - } - - [string makeImmutable]; - - if (!compat) - _decompositionTable[codePoint] = [string copy]; - _decompositionCompatTable[codePoint] = [string copy]; - } - - objc_autoreleasePoolPop(pool2); - } - - [self applyDecompositionRecursivelyForTable: _decompositionTable]; - [self applyDecompositionRecursivelyForTable: _decompositionCompatTable]; - - [of_stdout writeLine: @" done"]; - - [of_stdout writeString: @"Downloading CaseFolding.txt…"]; - _state = STATE_CASE_FOLDING; - request = [OFHTTPRequest requestWithURL: - [OFURL URLWithString: CASE_FOLDING_URL]]; - [_HTTPClient asyncPerformRequest: request]; -} - -- (void)parseCaseFolding: (OFHTTPResponse *)response -{ - OFString *line; - - [of_stdout writeString: @"Parsing CaseFolding.txt…"]; - - while ((line = [response readLine]) != nil) { - void *pool2; - OFArray OF_GENERIC(OFString *) *components; - of_unichar_t codePoint; - - if (line.length == 0 || [line hasPrefix: @"#"]) - continue; - - pool2 = objc_autoreleasePoolPush(); - - components = [line componentsSeparatedByString: @"; "]; - if (components.count != 4) { - of_log(@"Invalid line: %s\n", line); - [OFApplication terminateWithStatus: 1]; - } - - if (![[components objectAtIndex: 1] isEqual: @"S"] && - ![[components objectAtIndex: 1] isEqual: @"C"]) - continue; - - codePoint = (of_unichar_t)[[components objectAtIndex: 0] - unsignedLongLongValueWithBase: 16]; - - if (codePoint > 0x10FFFF) - @throw [OFOutOfRangeException exception]; - - _casefoldingTable[codePoint] = (of_unichar_t)[[components - objectAtIndex: 2] unsignedLongLongValueWithBase: 16]; - - objc_autoreleasePoolPop(pool2); - } - - [of_stdout writeLine: @" done"]; - - [self writeFiles]; -} - -- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table -{ - bool done; - - do { - done = true; - - for (of_unichar_t i = 0; i < 0x110000; i++) { - void *pool; - const of_unichar_t *characters; - size_t length; - OFMutableString *replacement; - bool changed = false; - - if (table[i] == nil) - continue; - - pool = objc_autoreleasePoolPush(); - characters = table[i].characters; - length = table[i].length; - replacement = [OFMutableString string]; - - for (size_t j = 0; j < length; j++) { - if (characters[j] > 0x10FFFF) - @throw [OFOutOfRangeException - exception]; - - if (table[characters[j]] == nil) - [replacement - appendCharacters: &characters[j] - length: 1]; - else { - [replacement - appendString: table[characters[j]]]; - changed = true; - } - } - - [replacement makeImmutable]; - - if (changed) { - [table[i] release]; - table[i] = [replacement copy]; - - done = false; - } - - objc_autoreleasePoolPop(pool); - } - } while (!done); -} - -- (void)writeFiles -{ - OFURL *URL; - - [of_stdout writeString: @"Writing files…"]; - - URL = [OFURL fileURLWithPath: @"../src/unicode.m"]; - [self writeTablesToFile: URL.fileSystemRepresentation]; - - URL = [OFURL fileURLWithPath: @"../src/unicode.h"]; - [self writeHeaderToFile: URL.fileSystemRepresentation]; - - [of_stdout writeLine: @" done"]; - - [OFApplication terminate]; -} - -- (void)writeTablesToFile: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFFile *file = [OFFile fileWithPath: path - mode: @"w"]; - - [file writeString: COPYRIGHT - @"#include \"config.h\"\n" - @"\n" - @"#import \"OFString.h\"\n\n" - @"static const of_unichar_t emptyPage[0x100] = { 0 };\n" - @"static const char *emptyDecompositionPage[0x100] = { NULL };\n" - @"\n"]; - - /* Write uppercasePage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_uppercaseTable[j] != 0) { - isEmpty = false; - _uppercaseTableSize = i >> 8; - _uppercaseTableUsed[_uppercaseTableSize] = 1; - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const of_unichar_t " - @"uppercasePage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j += 8) - [file writeFormat: - @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", - _uppercaseTable[j], - _uppercaseTable[j + 1], - _uppercaseTable[j + 2], - _uppercaseTable[j + 3], - _uppercaseTable[j + 4], - _uppercaseTable[j + 5], - _uppercaseTable[j + 6], - _uppercaseTable[j + 7]]; - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* Write lowercasePage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_lowercaseTable[j] != 0) { - isEmpty = false; - _lowercaseTableSize = i >> 8; - _lowercaseTableUsed[_lowercaseTableSize] = 1; - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const of_unichar_t " - @"lowercasePage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j += 8) - [file writeFormat: - @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", - _lowercaseTable[j], - _lowercaseTable[j + 1], - _lowercaseTable[j + 2], - _lowercaseTable[j + 3], - _lowercaseTable[j + 4], - _lowercaseTable[j + 5], - _lowercaseTable[j + 6], - _lowercaseTable[j + 7]]; - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* Write titlecasePage%u if it does NOT match uppercasePage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_titlecaseTable[j] != 0) { - isEmpty = !memcmp(_uppercaseTable + i, - _titlecaseTable + i, - 256 * sizeof(of_unichar_t)); - _titlecaseTableSize = i >> 8; - _titlecaseTableUsed[_titlecaseTableSize] = - (isEmpty ? 2 : 1); - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const of_unichar_t " - @"titlecasePage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j += 8) - [file writeFormat: - @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", - _titlecaseTable[j], - _titlecaseTable[j + 1], - _titlecaseTable[j + 2], - _titlecaseTable[j + 3], - _titlecaseTable[j + 4], - _titlecaseTable[j + 5], - _titlecaseTable[j + 6], - _titlecaseTable[j + 7]]; - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* Write casefoldingPage%u if it does NOT match lowercasePage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_casefoldingTable[j] != 0) { - isEmpty = !memcmp(_lowercaseTable + i, - _casefoldingTable + i, - 256 * sizeof(of_unichar_t)); - _casefoldingTableSize = i >> 8; - _casefoldingTableUsed[_casefoldingTableSize] = - (isEmpty ? 2 : 1); - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const of_unichar_t " - @"casefoldingPage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j += 8) - [file writeFormat: - @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", - _casefoldingTable[j], - _casefoldingTable[j + 1], - _casefoldingTable[j + 2], - _casefoldingTable[j + 3], - _casefoldingTable[j + 4], - _casefoldingTable[j + 5], - _casefoldingTable[j + 6], - _casefoldingTable[j + 7]]; - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* Write decompositionPage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_decompositionTable[j] != nil) { - isEmpty = false; - _decompositionTableSize = i >> 8; - _decompositionTableUsed[ - _decompositionTableSize] = 1; - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const char *const " - @"decompositionPage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if ((j - i) % 2 == 0) - [file writeString: @"\t"]; - else - [file writeString: @" "]; - - if (_decompositionTable[j] != nil) { - const char *UTF8String = - _decompositionTable[j].UTF8String; - size_t length = _decompositionTable[j] - .UTF8StringLength; - - [file writeString: @"\""]; - - for (size_t k = 0; k < length; k++) - [file writeFormat: - @"\\x%02X", - (uint8_t)UTF8String[k]]; - - [file writeString: @"\","]; - } else - [file writeString: @"NULL,"]; - - if ((j - i) % 2 == 1) - [file writeString: @"\n"]; - } - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* Write decompCompatPage%u if it does NOT match decompositionPage%u */ - for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { - bool isEmpty = true; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if (_decompositionCompatTable[j] != 0) { - /* - * We bulk-compare pointers via memcmp here. - * This is safe, as we always set the same - * pointer in both tables if both are the same. - */ - isEmpty = !memcmp(_decompositionTable + i, - _decompositionCompatTable + i, - 256 * sizeof(const char *)); - _decompositionCompatTableSize = i >> 8; - _decompositionCompatTableUsed[ - _decompositionCompatTableSize] = - (isEmpty ? 2 : 1); - - break; - } - } - - if (!isEmpty) { - void *pool2 = objc_autoreleasePoolPush(); - - [file writeFormat: @"static const char *const " - @"decompCompatPage%u[0x100] = {\n", - i >> 8]; - - for (of_unichar_t j = i; j < i + 0x100; j++) { - if ((j - i) % 2 == 0) - [file writeString: @"\t"]; - else - [file writeString: @" "]; - - if (_decompositionCompatTable[j] != nil) { - const char *UTF8String = - _decompositionCompatTable[j] - .UTF8String; - size_t length = - _decompositionCompatTable[j] - .UTF8StringLength; - - [file writeString: @"\""]; - - for (size_t k = 0; k < length; k++) - [file writeFormat: - @"\\x%02X", - (uint8_t)UTF8String[k]]; - - [file writeString: @"\","]; - } else - [file writeString: @"NULL,"]; - - if ((j - i) % 2 == 1) - [file writeString: @"\n"]; - } - - [file writeString: @"};\n\n"]; - - objc_autoreleasePoolPop(pool2); - } - } - - /* - * Those are currently set to the last index. - * But from now on, we need the size. - */ - _uppercaseTableSize++; - _lowercaseTableSize++; - _titlecaseTableSize++; - _casefoldingTableSize++; - _decompositionTableSize++; - _decompositionCompatTableSize++; - - /* Write of_unicode_uppercase_table */ - [file writeFormat: @"const of_unichar_t *const " - @"of_unicode_uppercase_table[0x%X] = {\n\t", - _uppercaseTableSize]; - - for (of_unichar_t i = 0; i < _uppercaseTableSize; i++) { - if (_uppercaseTableUsed[i]) - [file writeFormat: @"uppercasePage%u", i]; - else - [file writeString: @"emptyPage"]; - - if (i + 1 < _uppercaseTableSize) { - if ((i + 1) % 4 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n\n"]; - - /* Write of_unicode_lowercase_table */ - [file writeFormat: @"const of_unichar_t *const " - @"of_unicode_lowercase_table[0x%X] = {\n\t", - _lowercaseTableSize]; - - for (of_unichar_t i = 0; i < _lowercaseTableSize; i++) { - if (_lowercaseTableUsed[i]) - [file writeFormat: @"lowercasePage%u", i]; - else - [file writeString: @"emptyPage"]; - - if (i + 1 < _lowercaseTableSize) { - if ((i + 1) % 4 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n\n"]; - - /* Write of_unicode_titlecase_table */ - [file writeFormat: @"const of_unichar_t *const " - @"of_unicode_titlecase_table[0x%X] = {\n\t", - _titlecaseTableSize]; - - for (of_unichar_t i = 0; i < _titlecaseTableSize; i++) { - if (_titlecaseTableUsed[i] == 1) - [file writeFormat: @"titlecasePage%u", i]; - else if (_titlecaseTableUsed[i] == 2) - [file writeFormat: @"uppercasePage%u", i]; - else - [file writeString: @"emptyPage"]; - - if (i + 1 < _titlecaseTableSize) { - if ((i + 1) % 4 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n\n"]; - - /* Write of_unicode_casefolding_table */ - [file writeFormat: @"const of_unichar_t *const " - @"of_unicode_casefolding_table[0x%X] = {\n\t", - _casefoldingTableSize]; - - for (of_unichar_t i = 0; i < _casefoldingTableSize; i++) { - if (_casefoldingTableUsed[i] == 1) - [file writeFormat: @"casefoldingPage%u", i]; - else if (_casefoldingTableUsed[i] == 2) - [file writeFormat: @"lowercasePage%u", i]; - else - [file writeString: @"emptyPage"]; - - if (i + 1 < _casefoldingTableSize) { - if ((i + 1) % 3 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n\n"]; - - /* Write of_unicode_decomposition_table */ - [file writeFormat: @"const char *const " - @"*of_unicode_decomposition_table[0x%X] = {\n\t", - _decompositionTableSize]; - - for (of_unichar_t i = 0; i < _decompositionTableSize; i++) { - if (_decompositionTableUsed[i]) - [file writeFormat: @"decompositionPage%u", i]; - else - [file writeString: @"emptyDecompositionPage"]; - - if (i + 1 < _decompositionTableSize) { - if ((i + 1) % 3 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n\n"]; - - /* Write of_unicode_decomposition_compat_table */ - [file writeFormat: @"const char *const " - @"*of_unicode_decomposition_compat_table[0x%X] = {" - @"\n\t", - _decompositionCompatTableSize]; - - for (of_unichar_t i = 0; i < _decompositionCompatTableSize; i++) { - if (_decompositionCompatTableUsed[i] == 1) - [file writeFormat: @"decompCompatPage%u", i]; - else if (_decompositionCompatTableUsed[i] == 2) - [file writeFormat: @"decompositionPage%u", i]; - else - [file writeString: @"emptyDecompositionPage"]; - - if (i + 1 < _decompositionCompatTableSize) { - if ((i + 1) % 3 == 0) - [file writeString: @",\n\t"]; - else - [file writeString: @", "]; - } - } - - [file writeString: @"\n};\n"]; - - objc_autoreleasePoolPop(pool); -} - -- (void)writeHeaderToFile: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFFile *file = [OFFile fileWithPath: path - mode: @"w"]; - - [file writeString: COPYRIGHT - @"#import \"OFString.h\"\n\n"]; - - [file writeFormat: - @"#define OF_UNICODE_UPPERCASE_TABLE_SIZE 0x%X\n" - @"#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x%X\n" - @"#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x%X\n" - @"#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x%X\n" - @"#define OF_UNICODE_DECOMPOSITION_TABLE_SIZE 0x%X\n" - @"#define OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE 0x%X\n\n", - _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize, - _casefoldingTableSize, _decompositionTableSize, - _decompositionCompatTableSize]; - - [file writeString: - @"#ifdef __cplusplus\n" - @"extern \"C\" {\n" - @"#endif\n" - @"extern const of_unichar_t *const _Nonnull\n" - @" of_unicode_uppercase_table[" - @"OF_UNICODE_UPPERCASE_TABLE_SIZE];\n" - @"extern const of_unichar_t *const _Nonnull\n" - @" of_unicode_lowercase_table[" - @"OF_UNICODE_LOWERCASE_TABLE_SIZE];\n" - @"extern const of_unichar_t *const _Nonnull\n" - @" of_unicode_titlecase_table[" - @"OF_UNICODE_TITLECASE_TABLE_SIZE];\n" - @"extern const of_unichar_t *const _Nonnull\n" - @" of_unicode_casefolding_table[" - @"OF_UNICODE_CASEFOLDING_TABLE_SIZE];\n" - @"extern const char *const _Nullable *const _Nonnull\n" - @" of_unicode_decomposition_table[" - @"OF_UNICODE_DECOMPOSITION_TABLE_SIZE];\n" - @"extern const char *const _Nullable *const _Nonnull\n" - @" of_unicode_decomposition_compat_table[" - @"OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE];\n" - @"#ifdef __cplusplus\n" - @"}\n" - @"#endif\n"]; - - objc_autoreleasePoolPop(pool); -} -@end DELETED generators/copyright.h Index: generators/copyright.h ================================================================== --- generators/copyright.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFString.h" - -#define COPYRIGHT \ - @"/*\n" \ - @" * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, " \ - @"2017,\n" \ - @" * 2018, 2019, 2020\n" \ - @" * Jonathan Schleifer \n" \ - @" *\n" \ - @" * All rights reserved.\n" \ - @" *\n" \ - @" * This file is part of ObjFW. It may be distributed under the terms " \ - @"of the\n" \ - @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \ - @"included in\n" \ - @" * the packaging of this file.\n" \ - @" *\n" \ - @" * Alternatively, it may be distributed under the terms of the GNU " \ - @"General\n" \ - @" * Public License, either version 2 or 3, which can be found in the " \ - @"file\n" \ - @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \ - @"packaging of this\n" \ - @" * file.\n" \ - @" */\n" \ - @"\n" ADDED generators/library/FuncArrayGenerator.h Index: generators/library/FuncArrayGenerator.h ================================================================== --- /dev/null +++ generators/library/FuncArrayGenerator.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" + +#import "OFStream.h" +#import "OFXMLElement.h" + +@interface FuncArrayGenerator: OFObject +{ + OFXMLElement *_library; + OFStream *_include; +} + +- (instancetype)initWithLibrary: (OFXMLElement *)library + include: (OFStream *)include; +- (void)generate; +@end ADDED generators/library/FuncArrayGenerator.m Index: generators/library/FuncArrayGenerator.m ================================================================== --- /dev/null +++ generators/library/FuncArrayGenerator.m @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFArray.h" +#import "OFXMLAttribute.h" + +#import "FuncArrayGenerator.h" + +#import "OFInvalidFormatException.h" +#import "OFUnsupportedVersionException.h" + +#import "copyright.h" + +@implementation FuncArrayGenerator +- (instancetype)initWithLibrary: (OFXMLElement *)library + include: (OFStream *)include +{ + self = [super init]; + + @try { + OFXMLAttribute *version; + + if (![library.name isEqual: @"amiga-library"] || + library.namespace != nil) + @throw [OFInvalidFormatException exception]; + + if ((version = [library attributeForName: @"version"]) == nil) + @throw [OFInvalidFormatException exception]; + + if (![version.stringValue isEqual: @"1.0"]) + @throw [OFUnsupportedVersionException + exceptionWithVersion: version.stringValue]; + + _library = [library retain]; + _include = [include retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [_library release]; + [_include release]; + + [super dealloc]; +} + +- (void)generate +{ + [_include writeString: COPYRIGHT]; + [_include writeString: + @"/* This file is automatically generated from library.xml */\n" + @"\n"]; + + for (OFXMLElement *function in [_library elementsForName: @"function"]) + [_include writeFormat: + @"(CONST_APTR)glue_%@,\n", + [function attributeForName: @"name"].stringValue]; +} +@end ADDED generators/library/GlueGenerator.h Index: generators/library/GlueGenerator.h ================================================================== --- /dev/null +++ generators/library/GlueGenerator.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" + +#import "OFStream.h" +#import "OFXMLElement.h" + +@interface GlueGenerator: OFObject +{ + OFXMLElement *_library; + OFStream *_header, *_impl; +} + +- (instancetype)initWithLibrary: (OFXMLElement *)library + header: (OFStream *)header + implementation: (OFStream *)implementation; +- (void)generate; +@end ADDED generators/library/GlueGenerator.m Index: generators/library/GlueGenerator.m ================================================================== --- /dev/null +++ generators/library/GlueGenerator.m @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFArray.h" +#import "OFXMLAttribute.h" + +#import "GlueGenerator.h" + +#import "OFInvalidFormatException.h" +#import "OFUnsupportedVersionException.h" + +#import "copyright.h" + +@implementation GlueGenerator +- (instancetype)initWithLibrary: (OFXMLElement *)library + header: (OFStream *)header + implementation: (OFStream *)impl +{ + self = [super init]; + + @try { + OFXMLAttribute *version; + + if (![library.name isEqual: @"amiga-library"] || + library.namespace != nil) + @throw [OFInvalidFormatException exception]; + + if ((version = [library attributeForName: @"version"]) == nil) + @throw [OFInvalidFormatException exception]; + + if (![version.stringValue isEqual: @"1.0"]) + @throw [OFUnsupportedVersionException + exceptionWithVersion: version.stringValue]; + + _library = [library retain]; + _header = [header retain]; + _impl = [impl retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [_library release]; + [_header release]; + [_impl release]; + + [super dealloc]; +} + +- (void)generate +{ + [_header writeString: COPYRIGHT]; + [_impl writeString: COPYRIGHT]; + + [_header writeString: + @"/* This file is automatically generated from library.xml */\n" + @"\n"]; + + [_impl writeString: + @"/* This file is automatically generated from library.xml */\n" + @"\n" + @"#include \"config.h\"\n" + @"\n" + @"#import \"amiga-glue.h\"\n" + @"\n"]; + + for (OFXMLElement *include in [_library elementsForName: @"include"]) + [_header writeFormat: @"#import \"%@\"\n", include.stringValue]; + + [_header writeString: + @"\n" + @"#ifdef OF_AMIGAOS_M68K\n" + @"# define PPC_PARAMS(...) (void)\n" + @"# define M68K_ARG(type, name, reg)\t\t\\\n" + @"\tregister type reg##name __asm__(#reg);\t\\\n" + @"\ttype name = reg##name;\n" + @"#else\n" + @"# define PPC_PARAMS(...) (__VA_ARGS__)\n" + @"# define M68K_ARG(...)\n" + @"#endif\n" + @"\n"]; + [_impl writeString: + @"#ifdef OF_MORPHOS\n" + @"/* All __saveds functions in this file need to use the SysV " + @"ABI */\n" + @"__asm__ (\n" + @" \".section .text\\n\"\n" + @" \".align 2\\n\"\n" + @" \"__restore_r13:\\n\"\n" + @" \"\tlwz\t%r13, 44(%r12)\\n\"\n" + @" \"\tblr\\n\"\n" + @");\n" + @"#endif\n"]; + + for (OFXMLElement *function in + [_library elementsForName: @"function"]) { + OFString *name = + [function attributeForName: @"name"].stringValue; + OFString *returnType = + [function attributeForName: @"return-type"].stringValue; + OFArray OF_GENERIC(OFXMLElement *) *arguments = + [function elementsForName: @"argument"]; + size_t argumentIndex; + + if (returnType == nil) + returnType = @"void"; + + [_header writeFormat: + @"extern %@%@glue_%@", + returnType, + (![returnType hasSuffix: @"*"] ? @" " : @""), + name]; + + [_impl writeFormat: @"\n" + @"%@ __saveds\n" + @"glue_%@", + returnType, name]; + + if (arguments.count > 0) { + [_header writeString: @" PPC_PARAMS("]; + [_impl writeString: @" PPC_PARAMS("]; + } else { + [_header writeString: @"(void"]; + [_impl writeString: @"(void"]; + } + + argumentIndex = 0; + for (OFXMLElement *argument in arguments) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + OFString *argType = + [argument attributeForName: @"type"].stringValue; + + if (argumentIndex++ > 0) { + [_header writeString: @", "]; + [_impl writeString: @", "]; + } + + [_header writeString: argType]; + [_impl writeString: argType]; + if (![argType hasSuffix: @"*"]) { + [_header writeString: @" "]; + [_impl writeString: @" "]; + } + [_header writeString: argName]; + [_impl writeString: argName]; + } + + [_header writeString: @");\n"]; + + [_impl writeString: @")\n{\n"]; + for (OFXMLElement *argument in arguments) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + OFString *argType = + [argument attributeForName: @"type"].stringValue; + OFString *m68kReg = [argument + attributeForName: @"m68k-reg"].stringValue; + + [_impl writeFormat: @"\tM68K_ARG(%@, %@, %@)\n", + argType, argName, m68kReg]; + } + + if (arguments.count > 0) + [_impl writeString: @"\n"]; + + if (![returnType isEqual: @"void"]) + [_impl writeString: @"\treturn "]; + else + [_impl writeString: @"\t"]; + + [_impl writeFormat: @"%@(", name]; + + argumentIndex = 0; + for (OFXMLElement *argument in arguments) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argName]; + } + + [_impl writeString: @");\n}\n"]; + } +} +@end ADDED generators/library/LibraryGenerator.m Index: generators/library/LibraryGenerator.m ================================================================== --- /dev/null +++ generators/library/LibraryGenerator.m @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFApplication.h" +#import "OFFile.h" +#import "OFFileManager.h" +#import "OFURL.h" +#import "OFXMLElement.h" + +#import "FuncArrayGenerator.h" +#import "GlueGenerator.h" +#import "LinkLibGenerator.h" + +@interface LibraryGenerator: OFObject +@end + +OF_APPLICATION_DELEGATE(LibraryGenerator) + +@implementation LibraryGenerator +- (void)applicationDidFinishLaunching +{ + OFURL *sourcesURL = [[OFFileManager defaultManager].currentDirectoryURL + URLByAppendingPathComponent: @"../../src"]; + OFURL *runtimeLibraryURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/library.xml"]; + OFURL *runtimeLinkLibURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/linklib/linklib.m"]; + OFURL *runtimeGlueHeaderURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/amiga-glue.h"]; + OFURL *runtimeGlueURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/amiga-glue.m"]; + OFURL *runtimeFuncArrayURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/amiga-funcarray.inc"]; + OFXMLElement *runtimeLibrary = [OFXMLElement elementWithStream: + [OFFile fileWithURL: runtimeLibraryURL + mode: @"r"]]; + OFFile *runtimeLinkLib = [OFFile fileWithURL: runtimeLinkLibURL + mode: @"w"]; + OFFile *runtimeGlueHeader = [OFFile fileWithURL: runtimeGlueHeaderURL + mode: @"w"]; + OFFile *runtimeGlue = [OFFile fileWithURL: runtimeGlueURL + mode: @"w"]; + OFFile *runtimeFuncArray = [OFFile fileWithURL: runtimeFuncArrayURL + mode: @"w"]; + LinkLibGenerator *runtimeLinkLibGenerator = [[[LinkLibGenerator alloc] + initWithLibrary: runtimeLibrary + implementation: runtimeLinkLib] autorelease]; + GlueGenerator *runtimeGlueGenerator = [[[GlueGenerator alloc] + initWithLibrary: runtimeLibrary + header: runtimeGlueHeader + implementation: runtimeGlue] autorelease]; + FuncArrayGenerator *runtimeFuncArrayGenerator; + runtimeFuncArrayGenerator = [[[FuncArrayGenerator alloc] + initWithLibrary: runtimeLibrary + include: runtimeFuncArray] autorelease]; + + [runtimeLinkLibGenerator generate]; + [runtimeGlueGenerator generate]; + [runtimeFuncArrayGenerator generate]; + + [OFApplication terminate]; +} +@end ADDED generators/library/LinkLibGenerator.h Index: generators/library/LinkLibGenerator.h ================================================================== --- /dev/null +++ generators/library/LinkLibGenerator.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" +#import "OFStream.h" +#import "OFXMLElement.h" + +@interface LinkLibGenerator: OFObject +{ + OFXMLElement *_library; + OFStream *_impl; +} + +- (instancetype)initWithLibrary: (OFXMLElement *)library + implementation: (OFStream *)impl; +- (void)generate; +@end ADDED generators/library/LinkLibGenerator.m Index: generators/library/LinkLibGenerator.m ================================================================== --- /dev/null +++ generators/library/LinkLibGenerator.m @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFArray.h" +#import "OFXMLAttribute.h" + +#import "LinkLibGenerator.h" + +#import "OFInvalidFormatException.h" +#import "OFUnsupportedVersionException.h" + +#import "copyright.h" + +@implementation LinkLibGenerator +- (instancetype)initWithLibrary: (OFXMLElement *)library + implementation: (OFStream *)impl +{ + self = [super init]; + + @try { + OFXMLAttribute *version; + + if (![library.name isEqual: @"amiga-library"] || + library.namespace != nil) + @throw [OFInvalidFormatException exception]; + + if ((version = [library attributeForName: @"version"]) == nil) + @throw [OFInvalidFormatException exception]; + + if (![version.stringValue isEqual: @"1.0"]) + @throw [OFUnsupportedVersionException + exceptionWithVersion: version.stringValue]; + + _library = [library retain]; + _impl = [impl retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [_library release]; + [_impl release]; + + [super dealloc]; +} + +- (void)generate +{ + OFString *libBase = [_library attributeForName: @"base"].stringValue; + OFArray OF_GENERIC(OFXMLElement *) *functions; + size_t funcIndex = 0; + + [_impl writeString: COPYRIGHT]; + [_impl writeString: + @"/* This file is automatically generated from library.xml */\n" + @"\n" + @"#include \"config.h\"\n" + @"\n"]; + + for (OFXMLElement *include in [_library elementsForName: @"include"]) + [_impl writeFormat: @"#import \"%@\"\n", + include.stringValue]; + + [_impl writeFormat: @"\n" + @"extern struct Library *%@;\n" + @"\n", + libBase]; + + functions = [_library elementsForName: @"function"]; + for (OFXMLElement *function in functions) { + OFString *name = + [function attributeForName: @"name"].stringValue; + OFString *returnType = + [function attributeForName: @"return-type"].stringValue; + OFArray OF_GENERIC(OFXMLElement *) *arguments = + [function elementsForName: @"argument"]; + size_t argumentIndex; + + if (returnType == nil) + returnType = @"void"; + + [_impl writeFormat: @"%@\n%@(", returnType, name]; + + argumentIndex = 0; + for (OFXMLElement *argument in + [function elementsForName: @"argument"]) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + OFString *argType = + [argument attributeForName: @"type"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argType]; + if (![argType hasSuffix: @"*"]) + [_impl writeString: @" "]; + [_impl writeString: argName]; + } + + [_impl writeFormat: + @")\n" + @"{\n" + @"#if defined(OF_AMIGAOS_M68K)\n" + @"\tregister struct Library *a6 __asm__(\"a6\") = %@;\n" + @"\t(void)a6;\n" + @"\t", libBase]; + + if (![returnType isEqual: @"void"]) + [_impl writeString: @"return "]; + + [_impl writeString: @"(("]; + [_impl writeString: returnType]; + if (![returnType hasSuffix: @"*"]) + [_impl writeString: @" "]; + [_impl writeString: @"(*)("]; + + argumentIndex = 0; + for (OFXMLElement *argument in arguments) { + OFString *argType = + [argument attributeForName: @"type"].stringValue; + OFString *m68kReg = [argument + attributeForName: @"m68k-reg"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argType]; + if (![argType hasSuffix: @"*"]) + [_impl writeString: @" "]; + [_impl writeFormat: @"__asm__(\"%@\")", + m68kReg]; + } + + [_impl writeFormat: @"))(((uintptr_t)%@) - %zu))(", + libBase, 30 + funcIndex * 6]; + + argumentIndex = 0; + for (OFXMLElement *argument in + [function elementsForName: @"argument"]) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argName]; + } + + [_impl writeFormat: @");\n" + @"#elif defined(OF_MORPHOS)\n" + @"\t__asm__ __volatile__ (\n" + @"\t \"mr\t\t%%%%r12, %%0\"\n" + @"\t :: \"r\"(%@) : \"r12\"\n" + @"\t);\n" + @"\n" + @"\t", + libBase, libBase]; + + if (![returnType isEqual: @"void"]) + [_impl writeString: @"return "]; + + [_impl writeString: @"__extension__ (("]; + [_impl writeString: returnType]; + if (![returnType hasSuffix: @"*"]) + [_impl writeString: @" "]; + [_impl writeString: @"(*)("]; + + argumentIndex = 0; + for (OFXMLElement *argument in arguments) { + OFString *argType = + [argument attributeForName: @"type"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argType]; + } + + [_impl writeFormat: @"))*(void **)(((uintptr_t)%@) - %zu))(", + libBase, 28 + funcIndex * 6]; + + argumentIndex = 0; + for (OFXMLElement *argument in + [function elementsForName: @"argument"]) { + OFString *argName = + [argument attributeForName: @"name"].stringValue; + + if (argumentIndex++ > 0) + [_impl writeString: @", "]; + + [_impl writeString: argName]; + } + + [_impl writeString: @");\n" + @"#endif\n"]; + + if ([function attributeForName: @"noreturn"] != nil) + [_impl writeString: @"\n\tOF_UNREACHABLE\n"]; + + [_impl writeString: @"}\n"]; + + if (++funcIndex < functions.count) + [_impl writeString: @"\n"]; + } +} +@end ADDED generators/library/Makefile Index: generators/library/Makefile ================================================================== --- /dev/null +++ generators/library/Makefile @@ -0,0 +1,70 @@ +include ../../extra.mk + +PROG_NOINST = gen_libraries${PROG_SUFFIX} +SRCS = FuncArrayGenerator.m \ + GlueGenerator.m \ + LibraryGenerator.m \ + LinkLibGenerator.m + +.PHONY: run +run: all + rm -f libobjfw.so.${OBJFW_LIB_MAJOR} + rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} + rm -f objfw.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} + rm -f objfwrt.dll libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib + rm -f ${OBJFWRT_AMIGA_LIB} + if test -f ../../src/libobjfw.so; then \ + ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ + ${LN_S} ../../src/libobjfw.so \ + libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ + elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ + ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ + libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ + fi + if test -f ../../src/objfw.dll; then \ + ${LN_S} ../../src/objfw.dll objfw.dll; \ + fi + if test -f ../../src/libobjfw.dylib; then \ + ${LN_S} ../../src/libobjfw.dylib \ + libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ + fi + if test -f ../../src/runtime/libobjfwrt.so; then \ + ${LN_S} ../../src/runtime/libobjfwrt.so \ + libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ + ${LN_S} ../../src/runtime/libobjfwrt.so \ + libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ + elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \ + ${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ + fi + if test -f ../../src/runtime/objfwrt.dll; then \ + ${LN_S} ../../src/runtime/objfwrt.dll objfwrt.dll; \ + fi + if test -f ../../src/runtime/libobjfwrt.dylib; then \ + ${LN_S} ../../src/runtime/libobjfwrt.dylib \ + libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ + fi + if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \ + ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \ + ${OBJFWRT_AMIGA_LIB}; \ + fi + LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ + DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \ + DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ + LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ + ASAN_OPTIONS=allocator_may_return_null=1 \ + ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ + rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ + rm -f objfw.so.${OBJFW_LIB_MAJOR_MINOR} objfw.dll; \ + rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ + rm -f objfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} objfwrt.dll; \ + rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ + exit $$EXIT + +include ../../buildsys.mk + +CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. +LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} +LD = ${OBJC} ADDED generators/library/copyright.h Index: generators/library/copyright.h ================================================================== --- /dev/null +++ generators/library/copyright.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFString.h" + +#define COPYRIGHT \ + @"/*\n" \ + @" * Copyright (c) 2008-2021 Jonathan Schleifer \n" \ + @" *\n" \ + @" * All rights reserved.\n" \ + @" *\n" \ + @" * This file is part of ObjFW. It may be distributed under the terms " \ + @"of the\n" \ + @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \ + @"included in\n" \ + @" * the packaging of this file.\n" \ + @" *\n" \ + @" * Alternatively, it may be distributed under the terms of the GNU " \ + @"General\n" \ + @" * Public License, either version 2 or 3, which can be found in the " \ + @"file\n" \ + @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \ + @"packaging of this\n" \ + @" * file.\n" \ + @" */\n" \ + @"\n" ADDED generators/unicode/Makefile Index: generators/unicode/Makefile ================================================================== --- /dev/null +++ generators/unicode/Makefile @@ -0,0 +1,67 @@ +include ../../extra.mk + +PROG_NOINST = gen_tables${PROG_SUFFIX} +SRCS = TableGenerator.m + +.PHONY: run +run: all + rm -f libobjfw.so.${OBJFW_LIB_MAJOR} + rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} + rm -f objfw.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} + rm -f objfwrt.dll libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib + rm -f ${OBJFWRT_AMIGA_LIB} + if test -f ../../src/libobjfw.so; then \ + ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ + ${LN_S} ../../src/libobjfw.so \ + libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ + elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ + ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ + libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ + fi + if test -f ../../src/objfw.dll; then \ + ${LN_S} ../../src/objfw.dll objfw.dll; \ + fi + if test -f ../../src/libobjfw.dylib; then \ + ${LN_S} ../../src/libobjfw.dylib \ + libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ + fi + if test -f ../../src/runtime/libobjfwrt.so; then \ + ${LN_S} ../../src/runtime/libobjfwrt.so \ + libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ + ${LN_S} ../../src/runtime/libobjfwrt.so \ + libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ + elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \ + ${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ + fi + if test -f ../../src/runtime/objfwrt.dll; then \ + ${LN_S} ../../src/runtime/objfwrt.dll objfwrt.dll; \ + fi + if test -f ../../src/runtime/libobjfwrt.dylib; then \ + ${LN_S} ../../src/runtime/libobjfwrt.dylib \ + libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ + fi + if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \ + ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \ + ${OBJFWRT_AMIGA_LIB}; \ + fi + LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ + DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \ + DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ + LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ + ASAN_OPTIONS=allocator_may_return_null=1 \ + ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ + rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ + rm -f objfw.so.${OBJFW_LIB_MAJOR_MINOR} objfw.dll; \ + rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ + rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ + rm -f objfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} objfwrt.dll; \ + rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ + exit $$EXIT + +include ../../buildsys.mk + +CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. +LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} +LD = ${OBJC} ADDED generators/unicode/TableGenerator.h Index: generators/unicode/TableGenerator.h ================================================================== --- /dev/null +++ generators/unicode/TableGenerator.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" +#import "OFHTTPClient.h" + +@class OFString; + +@interface TableGenerator: OFObject +{ + OFHTTPClient *_HTTPClient; + of_unichar_t _uppercaseTable[0x110000]; + of_unichar_t _lowercaseTable[0x110000]; + of_unichar_t _titlecaseTable[0x110000]; + of_unichar_t _casefoldingTable[0x110000]; + OFString *_decompositionTable[0x110000]; + OFString *_decompositionCompatTable[0x110000]; + char _uppercaseTableUsed[0x1100]; + char _lowercaseTableUsed[0x1100]; + char _titlecaseTableUsed[0x1100]; + char _casefoldingTableUsed[0x1100]; + char _decompositionTableUsed[0x1100]; + char _decompositionCompatTableUsed[0x1100]; + size_t _uppercaseTableSize; + size_t _lowercaseTableSize; + size_t _titlecaseTableSize; + size_t _casefoldingTableSize; + size_t _decompositionTableSize; + size_t _decompositionCompatTableSize; + enum { + STATE_UNICODE_DATA, + STATE_CASE_FOLDING + } _state; +} + +- (void)parseUnicodeData: (OFHTTPResponse *)response; +- (void)parseCaseFolding: (OFHTTPResponse *)response; +- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table; +- (void)writeFiles; +- (void)writeTablesToFile: (OFString *)path; +- (void)writeHeaderToFile: (OFString *)path; +@end ADDED generators/unicode/TableGenerator.m Index: generators/unicode/TableGenerator.m ================================================================== --- /dev/null +++ generators/unicode/TableGenerator.m @@ -0,0 +1,774 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#include + +#import "OFString.h" +#import "OFArray.h" +#import "OFApplication.h" +#import "OFURL.h" +#import "OFHTTPRequest.h" +#import "OFHTTPResponse.h" +#import "OFHTTPClient.h" +#import "OFFile.h" +#import "OFStdIOStream.h" + +#import "OFOutOfRangeException.h" + +#import "TableGenerator.h" +#import "copyright.h" + +#define UNICODE_DATA_URL \ + @"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt" +#define CASE_FOLDING_URL \ + @"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt" + +OF_APPLICATION_DELEGATE(TableGenerator) + +@implementation TableGenerator +- (instancetype)init +{ + self = [super init]; + + @try { + _HTTPClient = [[OFHTTPClient alloc] init]; + _HTTPClient.delegate = self; + + _uppercaseTableSize = SIZE_MAX; + _lowercaseTableSize = SIZE_MAX; + _titlecaseTableSize = SIZE_MAX; + _casefoldingTableSize = SIZE_MAX; + _decompositionTableSize = SIZE_MAX; + _decompositionCompatTableSize = SIZE_MAX; + } @catch (id e) { + @throw e; + [self release]; + } + + return self; +} + +- (void)applicationDidFinishLaunching +{ + OFHTTPRequest *request; + + [of_stdout writeString: @"Downloading UnicodeData.txt…"]; + _state = STATE_UNICODE_DATA; + request = [OFHTTPRequest requestWithURL: + [OFURL URLWithString: UNICODE_DATA_URL]]; + [_HTTPClient asyncPerformRequest: request]; +} + +- (void)client: (OFHTTPClient *)client + didPerformRequest: (OFHTTPRequest *)request + response: (OFHTTPResponse *)response + exception: (id)exception +{ + if (exception != nil) + @throw exception; + + [of_stdout writeLine: @" done"]; + + switch (_state) { + case STATE_UNICODE_DATA: + [self parseUnicodeData: response]; + break; + case STATE_CASE_FOLDING: + [self parseCaseFolding: response]; + break; + } +} + +- (void)parseUnicodeData: (OFHTTPResponse *)response +{ + OFString *line; + OFHTTPRequest *request; + + [of_stdout writeString: @"Parsing UnicodeData.txt…"]; + + while ((line = [response readLine]) != nil) { + void *pool2; + OFArray OF_GENERIC(OFString *) *components; + of_unichar_t codePoint; + + if (line.length == 0) + continue; + + pool2 = objc_autoreleasePoolPush(); + + components = [line componentsSeparatedByString: @";"]; + if (components.count != 15) { + of_log(@"Invalid line: %@\n", line); + [OFApplication terminateWithStatus: 1]; + } + + codePoint = (of_unichar_t)[[components objectAtIndex: 0] + unsignedLongLongValueWithBase: 16]; + + if (codePoint > 0x10FFFF) + @throw [OFOutOfRangeException exception]; + + _uppercaseTable[codePoint] = (of_unichar_t)[[components + objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; + _lowercaseTable[codePoint] = (of_unichar_t)[[components + objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; + _titlecaseTable[codePoint] = (of_unichar_t)[[components + objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; + + if ([[components objectAtIndex: 5] length] > 0) { + OFArray *decomposed = [[components objectAtIndex: 5] + componentsSeparatedByString: @" "]; + bool compat = false; + OFMutableString *string; + + if ([decomposed.firstObject hasPrefix: @"<"]) { + decomposed = [decomposed objectsInRange: + of_range(1, decomposed.count - 1)]; + compat = true; + } + + string = [OFMutableString string]; + + for (OFString *character in decomposed) { + of_unichar_t unichar = (of_unichar_t)[character + unsignedLongLongValueWithBase: 16]; + + [string appendCharacters: &unichar + length: 1]; + } + + [string makeImmutable]; + + if (!compat) + _decompositionTable[codePoint] = [string copy]; + _decompositionCompatTable[codePoint] = [string copy]; + } + + objc_autoreleasePoolPop(pool2); + } + + [self applyDecompositionRecursivelyForTable: _decompositionTable]; + [self applyDecompositionRecursivelyForTable: _decompositionCompatTable]; + + [of_stdout writeLine: @" done"]; + + [of_stdout writeString: @"Downloading CaseFolding.txt…"]; + _state = STATE_CASE_FOLDING; + request = [OFHTTPRequest requestWithURL: + [OFURL URLWithString: CASE_FOLDING_URL]]; + [_HTTPClient asyncPerformRequest: request]; +} + +- (void)parseCaseFolding: (OFHTTPResponse *)response +{ + OFString *line; + + [of_stdout writeString: @"Parsing CaseFolding.txt…"]; + + while ((line = [response readLine]) != nil) { + void *pool2; + OFArray OF_GENERIC(OFString *) *components; + of_unichar_t codePoint; + + if (line.length == 0 || [line hasPrefix: @"#"]) + continue; + + pool2 = objc_autoreleasePoolPush(); + + components = [line componentsSeparatedByString: @"; "]; + if (components.count != 4) { + of_log(@"Invalid line: %s\n", line); + [OFApplication terminateWithStatus: 1]; + } + + if (![[components objectAtIndex: 1] isEqual: @"S"] && + ![[components objectAtIndex: 1] isEqual: @"C"]) + continue; + + codePoint = (of_unichar_t)[[components objectAtIndex: 0] + unsignedLongLongValueWithBase: 16]; + + if (codePoint > 0x10FFFF) + @throw [OFOutOfRangeException exception]; + + _casefoldingTable[codePoint] = (of_unichar_t)[[components + objectAtIndex: 2] unsignedLongLongValueWithBase: 16]; + + objc_autoreleasePoolPop(pool2); + } + + [of_stdout writeLine: @" done"]; + + [self writeFiles]; +} + +- (void)applyDecompositionRecursivelyForTable: (OFString *[0x110000])table +{ + bool done; + + do { + done = true; + + for (of_unichar_t i = 0; i < 0x110000; i++) { + void *pool; + const of_unichar_t *characters; + size_t length; + OFMutableString *replacement; + bool changed = false; + + if (table[i] == nil) + continue; + + pool = objc_autoreleasePoolPush(); + characters = table[i].characters; + length = table[i].length; + replacement = [OFMutableString string]; + + for (size_t j = 0; j < length; j++) { + if (characters[j] > 0x10FFFF) + @throw [OFOutOfRangeException + exception]; + + if (table[characters[j]] == nil) + [replacement + appendCharacters: &characters[j] + length: 1]; + else { + [replacement + appendString: table[characters[j]]]; + changed = true; + } + } + + [replacement makeImmutable]; + + if (changed) { + [table[i] release]; + table[i] = [replacement copy]; + + done = false; + } + + objc_autoreleasePoolPop(pool); + } + } while (!done); +} + +- (void)writeFiles +{ + OFURL *URL; + + [of_stdout writeString: @"Writing files…"]; + + URL = [OFURL fileURLWithPath: @"../../src/unicode.m"]; + [self writeTablesToFile: URL.fileSystemRepresentation]; + + URL = [OFURL fileURLWithPath: @"../../src/unicode.h"]; + [self writeHeaderToFile: URL.fileSystemRepresentation]; + + [of_stdout writeLine: @" done"]; + + [OFApplication terminate]; +} + +- (void)writeTablesToFile: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFFile *file = [OFFile fileWithPath: path + mode: @"w"]; + + [file writeString: COPYRIGHT + @"#include \"config.h\"\n" + @"\n" + @"#import \"OFString.h\"\n\n" + @"static const of_unichar_t emptyPage[0x100] = { 0 };\n" + @"static const char *emptyDecompositionPage[0x100] = { NULL };\n" + @"\n"]; + + /* Write uppercasePage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_uppercaseTable[j] != 0) { + isEmpty = false; + _uppercaseTableSize = i >> 8; + _uppercaseTableUsed[_uppercaseTableSize] = 1; + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const of_unichar_t " + @"uppercasePage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j += 8) + [file writeFormat: + @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", + _uppercaseTable[j], + _uppercaseTable[j + 1], + _uppercaseTable[j + 2], + _uppercaseTable[j + 3], + _uppercaseTable[j + 4], + _uppercaseTable[j + 5], + _uppercaseTable[j + 6], + _uppercaseTable[j + 7]]; + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* Write lowercasePage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_lowercaseTable[j] != 0) { + isEmpty = false; + _lowercaseTableSize = i >> 8; + _lowercaseTableUsed[_lowercaseTableSize] = 1; + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const of_unichar_t " + @"lowercasePage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j += 8) + [file writeFormat: + @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", + _lowercaseTable[j], + _lowercaseTable[j + 1], + _lowercaseTable[j + 2], + _lowercaseTable[j + 3], + _lowercaseTable[j + 4], + _lowercaseTable[j + 5], + _lowercaseTable[j + 6], + _lowercaseTable[j + 7]]; + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* Write titlecasePage%u if it does NOT match uppercasePage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_titlecaseTable[j] != 0) { + isEmpty = !memcmp(_uppercaseTable + i, + _titlecaseTable + i, + 256 * sizeof(of_unichar_t)); + _titlecaseTableSize = i >> 8; + _titlecaseTableUsed[_titlecaseTableSize] = + (isEmpty ? 2 : 1); + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const of_unichar_t " + @"titlecasePage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j += 8) + [file writeFormat: + @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", + _titlecaseTable[j], + _titlecaseTable[j + 1], + _titlecaseTable[j + 2], + _titlecaseTable[j + 3], + _titlecaseTable[j + 4], + _titlecaseTable[j + 5], + _titlecaseTable[j + 6], + _titlecaseTable[j + 7]]; + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* Write casefoldingPage%u if it does NOT match lowercasePage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_casefoldingTable[j] != 0) { + isEmpty = !memcmp(_lowercaseTable + i, + _casefoldingTable + i, + 256 * sizeof(of_unichar_t)); + _casefoldingTableSize = i >> 8; + _casefoldingTableUsed[_casefoldingTableSize] = + (isEmpty ? 2 : 1); + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const of_unichar_t " + @"casefoldingPage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j += 8) + [file writeFormat: + @"\t%u, %u, %u, %u, %u, %u, %u, %u,\n", + _casefoldingTable[j], + _casefoldingTable[j + 1], + _casefoldingTable[j + 2], + _casefoldingTable[j + 3], + _casefoldingTable[j + 4], + _casefoldingTable[j + 5], + _casefoldingTable[j + 6], + _casefoldingTable[j + 7]]; + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* Write decompositionPage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_decompositionTable[j] != nil) { + isEmpty = false; + _decompositionTableSize = i >> 8; + _decompositionTableUsed[ + _decompositionTableSize] = 1; + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const char *const " + @"decompositionPage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if ((j - i) % 2 == 0) + [file writeString: @"\t"]; + else + [file writeString: @" "]; + + if (_decompositionTable[j] != nil) { + const char *UTF8String = + _decompositionTable[j].UTF8String; + size_t length = _decompositionTable[j] + .UTF8StringLength; + + [file writeString: @"\""]; + + for (size_t k = 0; k < length; k++) + [file writeFormat: + @"\\x%02X", + (uint8_t)UTF8String[k]]; + + [file writeString: @"\","]; + } else + [file writeString: @"NULL,"]; + + if ((j - i) % 2 == 1) + [file writeString: @"\n"]; + } + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* Write decompCompatPage%u if it does NOT match decompositionPage%u */ + for (of_unichar_t i = 0; i < 0x110000; i += 0x100) { + bool isEmpty = true; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if (_decompositionCompatTable[j] != 0) { + /* + * We bulk-compare pointers via memcmp here. + * This is safe, as we always set the same + * pointer in both tables if both are the same. + */ + isEmpty = !memcmp(_decompositionTable + i, + _decompositionCompatTable + i, + 256 * sizeof(const char *)); + _decompositionCompatTableSize = i >> 8; + _decompositionCompatTableUsed[ + _decompositionCompatTableSize] = + (isEmpty ? 2 : 1); + + break; + } + } + + if (!isEmpty) { + void *pool2 = objc_autoreleasePoolPush(); + + [file writeFormat: @"static const char *const " + @"decompCompatPage%u[0x100] = {\n", + i >> 8]; + + for (of_unichar_t j = i; j < i + 0x100; j++) { + if ((j - i) % 2 == 0) + [file writeString: @"\t"]; + else + [file writeString: @" "]; + + if (_decompositionCompatTable[j] != nil) { + const char *UTF8String = + _decompositionCompatTable[j] + .UTF8String; + size_t length = + _decompositionCompatTable[j] + .UTF8StringLength; + + [file writeString: @"\""]; + + for (size_t k = 0; k < length; k++) + [file writeFormat: + @"\\x%02X", + (uint8_t)UTF8String[k]]; + + [file writeString: @"\","]; + } else + [file writeString: @"NULL,"]; + + if ((j - i) % 2 == 1) + [file writeString: @"\n"]; + } + + [file writeString: @"};\n\n"]; + + objc_autoreleasePoolPop(pool2); + } + } + + /* + * Those are currently set to the last index. + * But from now on, we need the size. + */ + _uppercaseTableSize++; + _lowercaseTableSize++; + _titlecaseTableSize++; + _casefoldingTableSize++; + _decompositionTableSize++; + _decompositionCompatTableSize++; + + /* Write of_unicode_uppercase_table */ + [file writeFormat: @"const of_unichar_t *const " + @"of_unicode_uppercase_table[0x%X] = {\n\t", + _uppercaseTableSize]; + + for (of_unichar_t i = 0; i < _uppercaseTableSize; i++) { + if (_uppercaseTableUsed[i]) + [file writeFormat: @"uppercasePage%u", i]; + else + [file writeString: @"emptyPage"]; + + if (i + 1 < _uppercaseTableSize) { + if ((i + 1) % 4 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n\n"]; + + /* Write of_unicode_lowercase_table */ + [file writeFormat: @"const of_unichar_t *const " + @"of_unicode_lowercase_table[0x%X] = {\n\t", + _lowercaseTableSize]; + + for (of_unichar_t i = 0; i < _lowercaseTableSize; i++) { + if (_lowercaseTableUsed[i]) + [file writeFormat: @"lowercasePage%u", i]; + else + [file writeString: @"emptyPage"]; + + if (i + 1 < _lowercaseTableSize) { + if ((i + 1) % 4 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n\n"]; + + /* Write of_unicode_titlecase_table */ + [file writeFormat: @"const of_unichar_t *const " + @"of_unicode_titlecase_table[0x%X] = {\n\t", + _titlecaseTableSize]; + + for (of_unichar_t i = 0; i < _titlecaseTableSize; i++) { + if (_titlecaseTableUsed[i] == 1) + [file writeFormat: @"titlecasePage%u", i]; + else if (_titlecaseTableUsed[i] == 2) + [file writeFormat: @"uppercasePage%u", i]; + else + [file writeString: @"emptyPage"]; + + if (i + 1 < _titlecaseTableSize) { + if ((i + 1) % 4 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n\n"]; + + /* Write of_unicode_casefolding_table */ + [file writeFormat: @"const of_unichar_t *const " + @"of_unicode_casefolding_table[0x%X] = {\n\t", + _casefoldingTableSize]; + + for (of_unichar_t i = 0; i < _casefoldingTableSize; i++) { + if (_casefoldingTableUsed[i] == 1) + [file writeFormat: @"casefoldingPage%u", i]; + else if (_casefoldingTableUsed[i] == 2) + [file writeFormat: @"lowercasePage%u", i]; + else + [file writeString: @"emptyPage"]; + + if (i + 1 < _casefoldingTableSize) { + if ((i + 1) % 3 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n\n"]; + + /* Write of_unicode_decomposition_table */ + [file writeFormat: @"const char *const " + @"*of_unicode_decomposition_table[0x%X] = {\n\t", + _decompositionTableSize]; + + for (of_unichar_t i = 0; i < _decompositionTableSize; i++) { + if (_decompositionTableUsed[i]) + [file writeFormat: @"decompositionPage%u", i]; + else + [file writeString: @"emptyDecompositionPage"]; + + if (i + 1 < _decompositionTableSize) { + if ((i + 1) % 3 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n\n"]; + + /* Write of_unicode_decomposition_compat_table */ + [file writeFormat: @"const char *const " + @"*of_unicode_decomposition_compat_table[0x%X] = {" + @"\n\t", + _decompositionCompatTableSize]; + + for (of_unichar_t i = 0; i < _decompositionCompatTableSize; i++) { + if (_decompositionCompatTableUsed[i] == 1) + [file writeFormat: @"decompCompatPage%u", i]; + else if (_decompositionCompatTableUsed[i] == 2) + [file writeFormat: @"decompositionPage%u", i]; + else + [file writeString: @"emptyDecompositionPage"]; + + if (i + 1 < _decompositionCompatTableSize) { + if ((i + 1) % 3 == 0) + [file writeString: @",\n\t"]; + else + [file writeString: @", "]; + } + } + + [file writeString: @"\n};\n"]; + + objc_autoreleasePoolPop(pool); +} + +- (void)writeHeaderToFile: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFFile *file = [OFFile fileWithPath: path + mode: @"w"]; + + [file writeString: COPYRIGHT + @"#import \"OFString.h\"\n\n"]; + + [file writeFormat: + @"#define OF_UNICODE_UPPERCASE_TABLE_SIZE 0x%X\n" + @"#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x%X\n" + @"#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x%X\n" + @"#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x%X\n" + @"#define OF_UNICODE_DECOMPOSITION_TABLE_SIZE 0x%X\n" + @"#define OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE 0x%X\n\n", + _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize, + _casefoldingTableSize, _decompositionTableSize, + _decompositionCompatTableSize]; + + [file writeString: + @"#ifdef __cplusplus\n" + @"extern \"C\" {\n" + @"#endif\n" + @"extern const of_unichar_t *const _Nonnull\n" + @" of_unicode_uppercase_table[" + @"OF_UNICODE_UPPERCASE_TABLE_SIZE];\n" + @"extern const of_unichar_t *const _Nonnull\n" + @" of_unicode_lowercase_table[" + @"OF_UNICODE_LOWERCASE_TABLE_SIZE];\n" + @"extern const of_unichar_t *const _Nonnull\n" + @" of_unicode_titlecase_table[" + @"OF_UNICODE_TITLECASE_TABLE_SIZE];\n" + @"extern const of_unichar_t *const _Nonnull\n" + @" of_unicode_casefolding_table[" + @"OF_UNICODE_CASEFOLDING_TABLE_SIZE];\n" + @"extern const char *const _Nullable *const _Nonnull\n" + @" of_unicode_decomposition_table[" + @"OF_UNICODE_DECOMPOSITION_TABLE_SIZE];\n" + @"extern const char *const _Nullable *const _Nonnull\n" + @" of_unicode_decomposition_compat_table[" + @"OF_UNICODE_DECOMPOSITION_COMPAT_TABLE_SIZE];\n" + @"#ifdef __cplusplus\n" + @"}\n" + @"#endif\n"]; + + objc_autoreleasePoolPop(pool); +} +@end ADDED generators/unicode/copyright.h Index: generators/unicode/copyright.h ================================================================== --- /dev/null +++ generators/unicode/copyright.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFString.h" + +#define COPYRIGHT \ + @"/*\n" \ + @" * Copyright (c) 2008-2021 Jonathan Schleifer \n" \ + @" *\n" \ + @" * All rights reserved.\n" \ + @" *\n" \ + @" * This file is part of ObjFW. It may be distributed under the terms " \ + @"of the\n" \ + @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \ + @"included in\n" \ + @" * the packaging of this file.\n" \ + @" *\n" \ + @" * Alternatively, it may be distributed under the terms of the GNU " \ + @"General\n" \ + @" * Public License, either version 2 or 3, which can be found in the " \ + @"file\n" \ + @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \ + @"packaging of this\n" \ + @" * file.\n" \ + @" */\n" \ + @"\n" Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -53,11 +53,10 @@ OFObject.m \ OFObject+KeyValueCoding.m \ OFObject+Serialization.m \ OFOptionsParser.m \ OFPair.m \ - ${OF_PROCESS_M} \ OFRIPEMD160Hash.m \ OFRunLoop.m \ OFSecureData.m \ OFSeekableStream.m \ OFSet.m \ @@ -77,10 +76,11 @@ OFString+PropertyListParsing.m \ OFString+Serialization.m \ OFString+URLEncoding.m \ OFString+XMLEscaping.m \ OFString+XMLUnescaping.m \ + ${OF_SUBUPROCESS_M} \ OFSystemInfo.m \ OFTarArchive.m \ OFTarArchiveEntry.m \ OFThread.m \ OFTimer.m \ Index: src/OFAdjacentArray.h ================================================================== --- src/OFAdjacentArray.h +++ src/OFAdjacentArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFAdjacentArray.m ================================================================== --- src/OFAdjacentArray.m +++ src/OFAdjacentArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -61,12 +59,11 @@ } return self; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { self = [self init]; @try { id object; @@ -109,12 +106,11 @@ @try { for (size_t i = 0; i < count; i++) [objects[i] retain]; - [_array addItems: objects - count: count]; + [_array addItems: objects count: count]; } @catch (id e) { for (size_t i = 0; i < count; i++) [objects[i] release]; /* Prevent double-release of objects */ @@ -126,12 +122,11 @@ } return self; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [self init]; @try { bool ok = true; @@ -144,12 +139,11 @@ } if (!ok) @throw [OFInvalidArgumentException exception]; - [_array addItems: objects - count: count]; + [_array addItems: objects count: count]; } @catch (id e) { for (size_t i = 0; i < count; i++) [objects[i] release]; [self release]; @@ -210,12 +204,11 @@ - (id)objectAtIndexedSubscript: (size_t)idx { return *((id *)[_array itemAtIndex: idx]); } -- (void)getObjects: (id *)buffer - inRange: (of_range_t)range +- (void)getObjects: (id *)buffer inRange: (of_range_t)range { id const *objects = _array.items; size_t count = _array.count; if (range.length > SIZE_MAX - range.location || @@ -272,12 +265,11 @@ if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray arrayWithObjects: (id *)_array.items + range.location count: range.length]; - return [OFAdjacentSubarray arrayWithArray: self - range: range]; + return [OFAdjacentSubarray arrayWithArray: self range: range]; } - (bool)isEqual: (id)object { OFArray *otherArray; Index: src/OFAdjacentSubarray.h ================================================================== --- src/OFAdjacentSubarray.h +++ src/OFAdjacentSubarray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFAdjacentSubarray.m ================================================================== --- src/OFAdjacentSubarray.m +++ src/OFAdjacentSubarray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -73,15 +71,13 @@ #endif OF_DIRECT_MEMBERS @interface OFApplication () - (instancetype)of_init OF_METHOD_FAMILY(init); -- (void)of_setArgumentCount: (int *)argc - andArgumentValues: (char **[])argv; +- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char **[])argv; #ifdef OF_WINDOWS -- (void)of_setArgumentCount: (int)argc - andWideArgumentValues: (wchar_t *[])argv; +- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t *[])argv; #endif - (void)of_run; @end static OFApplication *app = nil; @@ -116,16 +112,14 @@ app = [[OFApplication alloc] of_init]; #ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) { __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); - [app of_setArgumentCount: wargc - andWideArgumentValues: wargv]; + [app of_setArgumentCount: wargc andWideArgumentValues: wargv]; } else #endif - [app of_setArgumentCount: argc - andArgumentValues: argv]; + [app of_setArgumentCount: argc andArgumentValues: argv]; app.delegate = delegate; [app of_run]; @@ -260,13 +254,11 @@ continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsW(env0); @@ -304,13 +296,11 @@ continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } FreeEnvironmentStringsA(env0); @@ -335,17 +325,15 @@ path = [@"ENV:" stringByAppendingString: name]; if ([fileManager directoryExistsAtPath: path]) continue; - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; value = [file readLineWithEncoding: encoding]; if (value != nil) - [_environment setObject: value - forKey: name]; + [_environment setObject: value forKey: name]; objc_autoreleasePoolPop(pool2); } /* Local variables override global variables */ @@ -374,13 +362,11 @@ encoding: encoding]; value = [OFString stringWithCString: (const char *)iter->lv_Value encoding: encoding length: length]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; } objc_autoreleasePoolPop(pool); #elif !defined(OF_IOS) # ifndef OF_MACOS @@ -409,13 +395,11 @@ encoding: encoding length: sep - *env]; value = [OFString stringWithCString: sep + 1 encoding: encoding]; - - [_environment setObject: value - forKey: key]; + [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } } #else @@ -431,40 +415,35 @@ if ((env = getenv("HOME")) != NULL) { OFString *home = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: home - forKey: @"HOME"]; + [_environment setObject: home forKey: @"HOME"]; } if ((env = getenv("PATH")) != NULL) { OFString *path = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: path - forKey: @"PATH"]; + [_environment setObject: path forKey: @"PATH"]; } if ((env = getenv("SHELL")) != NULL) { OFString *shell = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: shell - forKey: @"SHELL"]; + [_environment setObject: shell forKey: @"SHELL"]; } if ((env = getenv("TMPDIR")) != NULL) { OFString *tmpdir = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: tmpdir - forKey: @"TMPDIR"]; + [_environment setObject: tmpdir forKey: @"TMPDIR"]; } if ((env = getenv("USER")) != NULL) { OFString *user = [[[OFString alloc] initWithUTF8StringNoCopy: env freeWhenDone: false] autorelease]; - [_environment setObject: user - forKey: @"USER"]; + [_environment setObject: user forKey: @"USER"]; } objc_autoreleasePoolPop(pool); #endif @@ -483,12 +462,11 @@ [_environment release]; [super dealloc]; } -- (void)of_setArgumentCount: (int *)argc - andArgumentValues: (char ***)argv +- (void)of_setArgumentCount: (int *)argc andArgumentValues: (char ***)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; of_string_encoding_t encoding; @@ -517,12 +495,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_WINDOWS -- (void)of_setArgumentCount: (int)argc - andWideArgumentValues: (wchar_t **)argv +- (void)of_setArgumentCount: (int)argc andWideArgumentValues: (wchar_t **)argv { void *pool = objc_autoreleasePoolPush(); OFMutableArray *arguments; if (argc > 0) { @@ -539,12 +516,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (void)getArgumentCount: (int **)argc - andArgumentValues: (char ****)argv +- (void)getArgumentCount: (int **)argc andArgumentValues: (char ****)argv { *argc = _argc; *argv = _argv; } Index: src/OFArray+Private.h ================================================================== --- src/OFArray+Private.h +++ src/OFArray+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -254,12 +252,11 @@ * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value - forKey: (OFString *)key; +- (void)setValue: (nullable id)value forKey: (OFString *)key; /** * @brief Copies the objects at the specified range to the specified buffer. * * @param buffer The buffer to copy the objects to Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -195,12 +193,11 @@ { id ret; va_list arguments; va_start(arguments, firstObject); - ret = [self initWithObject: firstObject - arguments: arguments]; + ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } @@ -229,12 +226,11 @@ - (size_t)count { OF_UNRECOGNIZED_SELECTOR } -- (void)getObjects: (id *)buffer - inRange: (of_range_t)range +- (void)getObjects: (id *)buffer inRange: (of_range_t)range { for (size_t i = 0; i < range.length; i++) buffer[i] = [self objectAtIndex: range.location + i]; } @@ -242,12 +238,11 @@ { size_t count = self.count; id *buffer = of_alloc(count, sizeof(id)); @try { - [self getObjects: buffer - inRange: of_range(0, count)]; + [self getObjects: buffer inRange: of_range(0, count)]; return [[OFData dataWithItemsNoCopy: buffer count: count itemSize: sizeof(id) freeWhenDone: true] items]; @@ -298,16 +293,14 @@ [ret makeImmutable]; return ret; } -- (void)setValue: (id)value - forKey: (OFString *)key +- (void)setValue: (id)value forKey: (OFString *)key { for (id object in self) - [object setValue: value - forKey: key]; + [object setValue: value forKey: key]; } - (size_t)indexOfObject: (id)object { size_t i = 0; @@ -378,20 +371,17 @@ if (range.length > SIZE_MAX - range.location || range.location + range.length < self.count) @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) - return [OFSubarray arrayWithArray: self - range: range]; + return [OFSubarray arrayWithArray: self range: range]; buffer = of_alloc(range.length, sizeof(*buffer)); @try { - [self getObjects: buffer - inRange: range]; + [self getObjects: buffer inRange: range]; - ret = [OFArray arrayWithObjects: buffer - count: range.length]; + ret = [OFArray arrayWithObjects: buffer count: range.length]; } @finally { free(buffer); } return ret; @@ -432,11 +422,11 @@ if (self.count == 0) return @""; if (self.count == 1) { OFString *component = - [[self firstObject] performSelector: selector]; + [[self objectAtIndex: 0] performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; return component; @@ -540,12 +530,11 @@ pool = objc_autoreleasePoolPush(); ret = [[self componentsJoinedByString: @",\n"] mutableCopy]; @try { [ret prependString: @"(\n"]; - [ret replaceOccurrencesOfString: @"\n" - withString: @"\n\t"]; + [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)"]; } @catch (id e) { [ret release]; @throw e; } @@ -584,18 +573,16 @@ return [element autorelease]; } - (OFString *)JSONRepresentation { - return [self of_JSONRepresentationWithOptions: 0 - depth: 0]; + return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { - return [self of_JSONRepresentationWithOptions: options - depth: 0]; + return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { @@ -669,19 +656,17 @@ } else if (count <= UINT16_MAX) { uint8_t type = 0xDC; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)count); [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (count <= UINT32_MAX) { uint8_t type = 0xDD; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count); [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); @@ -691,12 +676,11 @@ OFData *child; i++; child = [object messagePackRepresentation]; - [data addItems: child.items - count: child.count]; + [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } assert(i == count); @@ -716,61 +700,46 @@ - (void)makeObjectsPerformSelector: (SEL)selector withObject: (id)object { for (id objectIter in self) - [objectIter performSelector: selector - withObject: object]; + [objectIter performSelector: selector withObject: object]; } - (OFArray *)sortedArray { OFMutableArray *new = [[self mutableCopy] autorelease]; - [new sort]; - [new makeImmutable]; - return new; } - (OFArray *)sortedArrayUsingSelector: (SEL)selector options: (int)options { OFMutableArray *new = [[self mutableCopy] autorelease]; - - [new sortUsingSelector: selector - options: options]; - + [new sortUsingSelector: selector options: options]; [new makeImmutable]; - return new; } #ifdef OF_HAVE_BLOCKS - (OFArray *)sortedArrayUsingComparator: (of_comparator_t)comparator options: (int)options { OFMutableArray *new = [[self mutableCopy] autorelease]; - - [new sortUsingComparator: comparator - options: options]; - + [new sortUsingComparator: comparator options: options]; [new makeImmutable]; - return new; } #endif - (OFArray *)reversedArray { OFMutableArray *new = [[self mutableCopy] autorelease]; - [new reverse]; - [new makeImmutable]; - return new; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state objects: (id *)objects @@ -782,12 +751,11 @@ @throw [OFOutOfRangeException exception]; if (range.location + range.length > self.count) range.length = self.count - range.location; - [self getObjects: objects - inRange: range]; + [self getObjects: objects inRange: range]; if (range.location + range.length > ULONG_MAX) @throw [OFOutOfRangeException exception]; state->state = (unsigned long)(range.location + range.length); @@ -824,34 +792,30 @@ if (object == nil) @throw [OFInvalidArgumentException exception]; ret = [[self mutableCopy] autorelease]; - [ret addObject: object]; [ret makeImmutable]; return ret; } - (OFArray *)arrayByAddingObjectsFromArray: (OFArray *)array { OFMutableArray *ret = [[self mutableCopy] autorelease]; - [ret addObjectsFromArray: array]; [ret makeImmutable]; return ret; } - (OFArray *)arrayByRemovingObject: (id)object { OFMutableArray *ret = [[self mutableCopy] autorelease]; - [ret removeObject: object]; [ret makeImmutable]; - return ret; } #ifdef OF_HAVE_BLOCKS - (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block @@ -864,12 +828,11 @@ [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { tmp[idx] = block(object, idx); }]; - ret = [OFArray arrayWithObjects: tmp - count: count]; + ret = [OFArray arrayWithObjects: tmp count: count]; } @finally { free(tmp); } return ret; @@ -888,12 +851,11 @@ bool *stop) { if (block(object, idx)) tmp[i++] = object; }]; - ret = [OFArray arrayWithObjects: tmp - count: i]; + ret = [OFArray arrayWithObjects: tmp count: i]; } @finally { free(tmp); } return ret; @@ -905,11 +867,11 @@ __block id current; if (count == 0) return nil; if (count == 1) - return [[[self firstObject] retain] autorelease]; + return [[[self objectAtIndex: 0] retain] autorelease]; [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { id new; Index: src/OFBitSetCharacterSet.h ================================================================== --- src/OFBitSetCharacterSet.h +++ src/OFBitSetCharacterSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFBitSetCharacterSet.m ================================================================== --- src/OFBitSetCharacterSet.m +++ src/OFBitSetCharacterSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFBlock.h ================================================================== --- src/OFBlock.h +++ src/OFBlock.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFBytesValue.h ================================================================== --- src/OFBytesValue.h +++ src/OFBytesValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFBytesValue.m ================================================================== --- src/OFBytesValue.m +++ src/OFBytesValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -47,14 +45,13 @@ free(_bytes); [super dealloc]; } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != _size) @throw [OFOutOfRangeException exception]; memcpy(value, _bytes, _size); } @end Index: src/OFCharacterSet.h ================================================================== --- src/OFCharacterSet.h +++ src/OFCharacterSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFCharacterSet.m ================================================================== --- src/OFCharacterSet.m +++ src/OFCharacterSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFCollection.h ================================================================== --- src/OFCollection.h +++ src/OFCollection.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFColor.h ================================================================== --- src/OFColor.h +++ src/OFColor.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFColor.m ================================================================== --- src/OFColor.m +++ src/OFColor.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFCondition.h ================================================================== --- src/OFCondition.h +++ src/OFCondition.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -114,12 +112,11 @@ * @param date The date at which the timeout is reached * @param signalMask A pointer to a signal mask of Exec Signals to receive. * This is modified and set to the mask of signals received. * @return Whether the condition has been signaled or a signal received */ -- (bool)waitUntilDate: (OFDate *)date - orExecSignal: (ULONG *)signalMask; +- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask; #endif /** * @brief Signals the next waiting thread to continue. */ Index: src/OFCondition.m ================================================================== --- src/OFCondition.m +++ src/OFCondition.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -126,12 +124,11 @@ { return [self waitForTimeInterval: date.timeIntervalSinceNow]; } #ifdef OF_AMIGAOS -- (bool)waitUntilDate: (OFDate *)date - orExecSignal: (ULONG *)signalMask +- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask { return [self waitForTimeInterval: date.timeIntervalSinceNow orExecSignal: signalMask]; } #endif Index: src/OFConstantString.h ================================================================== --- src/OFConstantString.h +++ src/OFConstantString.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -168,239 +166,201 @@ /* From protocol OFCopying */ - (id)copy { [self finishInitialization]; - return [self copy]; } /* From protocol OFMutableCopying */ - (id)mutableCopy { [self finishInitialization]; - return [self mutableCopy]; } /* From protocol OFComparing */ - (of_comparison_result_t)compare: (id )object { [self finishInitialization]; - return [self compare: object]; } /* From OFObject, but reimplemented in OFString */ - (bool)isEqual: (id)object { [self finishInitialization]; - return [self isEqual: object]; } - (unsigned long)hash { [self finishInitialization]; - return self.hash; } - (OFString *)description { [self finishInitialization]; - return self.description; } /* From OFString */ - (const char *)UTF8String { [self finishInitialization]; - return self.UTF8String; } - (size_t)getCString: (char *)cString_ maxLength: (size_t)maxLength encoding: (of_string_encoding_t)encoding { [self finishInitialization]; - return [self getCString: cString_ maxLength: maxLength encoding: encoding]; } - (const char *)cStringWithEncoding: (of_string_encoding_t)encoding { [self finishInitialization]; - return [self cStringWithEncoding: encoding]; } - (size_t)length { [self finishInitialization]; - return self.length; } - (size_t)UTF8StringLength { [self finishInitialization]; - return self.UTF8StringLength; } - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding { [self finishInitialization]; - return [self cStringLengthWithEncoding: encoding]; } - (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString { [self finishInitialization]; - return [self caseInsensitiveCompare: otherString]; } - (of_unichar_t)characterAtIndex: (size_t)idx { [self finishInitialization]; - return [self characterAtIndex: idx]; } -- (void)getCharacters: (of_unichar_t *)buffer - inRange: (of_range_t)range +- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range { [self finishInitialization]; - - [self getCharacters: buffer - inRange: range]; + [self getCharacters: buffer inRange: range]; } - (of_range_t)rangeOfString: (OFString *)string { [self finishInitialization]; - return [self rangeOfString: string]; } -- (of_range_t)rangeOfString: (OFString *)string - options: (int)options +- (of_range_t)rangeOfString: (OFString *)string options: (int)options { [self finishInitialization]; - - return [self rangeOfString: string - options: options]; + return [self rangeOfString: string options: options]; } - (of_range_t)rangeOfString: (OFString *)string options: (int)options range: (of_range_t)range { [self finishInitialization]; - - return [self rangeOfString: string - options: options - range: range]; + return [self rangeOfString: string options: options range: range]; } - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet { [self finishInitialization]; - return [self indexOfCharacterFromSet: characterSet]; } - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (int)options { [self finishInitialization]; - - return [self indexOfCharacterFromSet: characterSet - options: options]; + return [self indexOfCharacterFromSet: characterSet options: options]; } - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (int)options range: (of_range_t)range { [self finishInitialization]; - return [self indexOfCharacterFromSet: characterSet options: options range: range]; } - (bool)containsString: (OFString *)string { [self finishInitialization]; - return [self containsString: string]; } - (OFString *)substringFromIndex: (size_t)idx { [self finishInitialization]; - return [self substringFromIndex: idx]; } - (OFString *)substringToIndex: (size_t)idx { [self finishInitialization]; - return [self substringToIndex: idx]; } - (OFString *)substringWithRange: (of_range_t)range { [self finishInitialization]; - return [self substringWithRange: range]; } - (OFString *)stringByAppendingString: (OFString *)string { [self finishInitialization]; - return [self stringByAppendingString: string]; } - (OFString *)stringByAppendingFormat: (OFConstantString *)format arguments: (va_list)arguments { [self finishInitialization]; - - return [self stringByAppendingFormat: format - arguments: arguments]; + return [self stringByAppendingFormat: format arguments: arguments]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { [self finishInitialization]; - return [self stringByAppendingPathComponent: component]; } - (OFString *)stringByPrependingString: (OFString *)string { [self finishInitialization]; - return [self stringByPrependingString: string]; } - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement { [self finishInitialization]; - return [self stringByReplacingOccurrencesOfString: string withString: replacement]; } - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string @@ -407,282 +367,240 @@ withString: (OFString *)replacement options: (int)options range: (of_range_t)range { [self finishInitialization]; - return [self stringByReplacingOccurrencesOfString: string withString: replacement options: options range: range]; } - (OFString *)uppercaseString { [self finishInitialization]; - return self.uppercaseString; } - (OFString *)lowercaseString { [self finishInitialization]; - return self.lowercaseString; } - (OFString *)capitalizedString { [self finishInitialization]; - return self.capitalizedString; } - (OFString *)stringByDeletingLeadingWhitespaces { [self finishInitialization]; - return self.stringByDeletingLeadingWhitespaces; } - (OFString *)stringByDeletingTrailingWhitespaces { [self finishInitialization]; - return self.stringByDeletingTrailingWhitespaces; } - (OFString *)stringByDeletingEnclosingWhitespaces { [self finishInitialization]; - return self.stringByDeletingEnclosingWhitespaces; } - (bool)hasPrefix: (OFString *)prefix { [self finishInitialization]; - return [self hasPrefix: prefix]; } - (bool)hasSuffix: (OFString *)suffix { [self finishInitialization]; - return [self hasSuffix: suffix]; } - (OFArray *)componentsSeparatedByString: (OFString *)delimiter { [self finishInitialization]; - return [self componentsSeparatedByString: delimiter]; } - (OFArray *)componentsSeparatedByString: (OFString *)delimiter options: (int)options { [self finishInitialization]; - - return [self componentsSeparatedByString: delimiter - options: options]; + return [self componentsSeparatedByString: delimiter options: options]; } - (OFArray *) componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet { [self finishInitialization]; - return [self componentsSeparatedByCharactersInSet: characterSet]; } - (OFArray *) componentsSeparatedByCharactersInSet: (OFCharacterSet *)characterSet options: (int)options { [self finishInitialization]; - return [self componentsSeparatedByCharactersInSet: characterSet options: options]; } - (OFArray *)pathComponents { [self finishInitialization]; - return self.pathComponents; } - (OFString *)lastPathComponent { [self finishInitialization]; - return self.lastPathComponent; } - (OFString *)stringByDeletingLastPathComponent { [self finishInitialization]; - return self.stringByDeletingLastPathComponent; } - (long long)longLongValue { [self finishInitialization]; - return self.longLongValue; } - (long long)longLongValueWithBase: (int)base { [self finishInitialization]; - return [self longLongValueWithBase: base]; } - (unsigned long long)unsignedLongLongValue { [self finishInitialization]; - return self.unsignedLongLongValue; } - (unsigned long long)unsignedLongLongValueWithBase: (int)base { [self finishInitialization]; - return [self unsignedLongLongValueWithBase: base]; } - (float)floatValue { [self finishInitialization]; - return self.floatValue; } - (double)doubleValue { [self finishInitialization]; - return self.doubleValue; } - (const of_unichar_t *)characters { [self finishInitialization]; - return self.characters; } - (const of_char16_t *)UTF16String { [self finishInitialization]; - return self.UTF16String; } - (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder { [self finishInitialization]; - return [self UTF16StringWithByteOrder: byteOrder]; } - (size_t)UTF16StringLength { [self finishInitialization]; - return self.UTF16StringLength; } - (const of_char32_t *)UTF32String { [self finishInitialization]; - return self.UTF32String; } - (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder { [self finishInitialization]; - return [self UTF32StringWithByteOrder: byteOrder]; } - (OFData *)dataWithEncoding: (of_string_encoding_t)encoding { [self finishInitialization]; - return [self dataWithEncoding: encoding]; } #ifdef OF_HAVE_UNICODE_TABLES - (OFString *)decomposedStringWithCanonicalMapping { [self finishInitialization]; - return self.decomposedStringWithCanonicalMapping; } - (OFString *)decomposedStringWithCompatibilityMapping { [self finishInitialization]; - return self.decomposedStringWithCompatibilityMapping; } #endif #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { [self finishInitialization]; - return self.stringByExpandingWindowsEnvironmentStrings; } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { [self finishInitialization]; - [self writeToFile: path]; } -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding +- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding { [self finishInitialization]; - - [self writeToFile: path - encoding: encoding]; + [self writeToFile: path encoding: encoding]; } #endif - (void)writeToURL: (OFURL *)URL { [self finishInitialization]; - [self writeToURL: URL]; } -- (void)writeToURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding +- (void)writeToURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding { [self finishInitialization]; - - [self writeToURL: URL - encoding: encoding]; + [self writeToURL: URL encoding: encoding]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { [self finishInitialization]; - [self enumerateLinesUsingBlock: block]; } #endif @end Index: src/OFCountedMapTableSet.h ================================================================== --- src/OFCountedMapTableSet.h +++ src/OFCountedMapTableSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFCountedMapTableSet.m ================================================================== --- src/OFCountedMapTableSet.m +++ src/OFCountedMapTableSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -83,12 +81,11 @@ } return self; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [self init]; @try { for (size_t i = 0; i < count; i++) @@ -99,12 +96,11 @@ } return self; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { self = [self init]; @try { id object; @@ -193,12 +189,11 @@ size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1) @throw [OFOutOfRangeException exception]; - [_mapTable setObject: (void *)(uintptr_t)(count + 1) - forKey: object]; + [_mapTable setObject: (void *)(uintptr_t)(count + 1) forKey: object]; } - (void)removeObject: (id)object { size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; @@ -207,12 +202,11 @@ return; count--; if (count > 0) - [_mapTable setObject: (void *)(uintptr_t)count - forKey: object]; + [_mapTable setObject: (void *)(uintptr_t)count forKey: object]; else [_mapTable removeObjectForKey: object]; } - (void)removeAllObjects Index: src/OFCountedSet.h ================================================================== --- src/OFCountedSet.h +++ src/OFCountedSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFCountedSet.m ================================================================== --- src/OFCountedSet.m +++ src/OFCountedSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,19 +57,17 @@ va_end(arguments); return ret; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFCountedMapTableSet alloc] initWithObjects: objects count: count]; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject arguments: arguments]; } @@ -160,14 +156,12 @@ if (++i < count) [ret appendString: @",\n"]; objc_autoreleasePoolPop(pool2); } - [ret replaceOccurrencesOfString: @"\n" - withString: @"\n\t"]; + [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)}"]; - [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; Index: src/OFCryptoHash.h ================================================================== --- src/OFCryptoHash.h +++ src/OFCryptoHash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -98,12 +96,11 @@ * @brief Adds a buffer to the cryptographic hash to be calculated. * * @param buffer The buffer which should be included into the calculation * @param length The length of the buffer */ -- (void)updateWithBuffer: (const void *)buffer - length: (size_t)length; +- (void)updateWithBuffer: (const void *)buffer length: (size_t)length; /** * @brief Resets all state so that a new hash can be calculated. * * @warning This invalidates any pointer previously returned by @ref digest. If Index: src/OFDNSQuery.h ================================================================== --- src/OFDNSQuery.h +++ src/OFDNSQuery.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSQuery.m ================================================================== --- src/OFDNSQuery.m +++ src/OFDNSQuery.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResolver.h ================================================================== --- src/OFDNSResolver.h +++ src/OFDNSResolver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -453,12 +451,11 @@ array = [ret objectForKey: name]; if (array == nil) { array = [OFMutableArray array]; - [ret setObject: array - forKey: name]; + [ret setObject: array forKey: name]; } [array addObject: record]; } @@ -492,23 +489,17 @@ queryData = [OFMutableData dataWithCapacity: 512]; /* Header */ tmp = OF_BSWAP16_IF_LE(_ID.unsignedShortValue); - [queryData addItems: &tmp - count: 2]; - + [queryData addItems: &tmp count: 2]; /* RD */ tmp = OF_BSWAP16_IF_LE(1u << 8); - [queryData addItems: &tmp - count: 2]; - + [queryData addItems: &tmp count: 2]; /* QDCOUNT */ tmp = OF_BSWAP16_IF_LE(1); - [queryData addItems: &tmp - count: 2]; - + [queryData addItems: &tmp count: 2]; /* ANCOUNT, NSCOUNT and ARCOUNT */ [queryData increaseCountBy: 6]; /* Question */ @@ -527,18 +518,14 @@ count: length]; } /* QTYPE */ tmp = OF_BSWAP16_IF_LE(_query.recordType); - [queryData addItems: &tmp - count: 2]; - + [queryData addItems: &tmp count: 2]; /* QCLASS */ tmp = OF_BSWAP16_IF_LE(_query.DNSClass); - [queryData addItems: &tmp - count: 2]; - + [queryData addItems: &tmp count: 2]; [queryData makeImmutable]; _queryData = [queryData copy]; objc_autoreleasePoolPop(pool); @@ -716,12 +703,11 @@ runLoopMode: (of_run_loop_mode_t)runLoopMode { OFUDPSocket *sock; OFString *nameServer; - [_queries setObject: context - forKey: context->_ID]; + [_queries setObject: context forKey: context->_ID]; [context->_cancelTimer invalidate]; [context->_cancelTimer release]; context->_cancelTimer = nil; context->_cancelTimer = [[OFTimer alloc] @@ -740,12 +726,11 @@ if (context->_settings->_usesTCP) { OF_ENSURE(context->_TCPSocket == nil); context->_TCPSocket = [[OFTCPSocket alloc] init]; - [_TCPQueries setObject: context - forKey: context->_TCPSocket]; + [_TCPQueries setObject: context forKey: context->_TCPSocket]; context->_TCPSocket.delegate = self; [context->_TCPSocket asyncConnectToHost: nameServer port: 53 runLoopMode: runLoopMode]; @@ -835,12 +820,11 @@ context = [[[OFDNSResolverContext alloc] initWithQuery: query ID: ID settings: _settings delegate: delegate] autorelease]; - [self of_sendQueryForContext: context - runLoopMode: runLoopMode]; + [self of_sendQueryForContext: context runLoopMode: runLoopMode]; objc_autoreleasePoolPop(pool); } - (void)of_contextTimedOut: (OFDNSResolverContext *)context @@ -859,19 +843,17 @@ } if (context->_nameServersIndex + 1 < context->_settings->_nameServers.count) { context->_nameServersIndex++; - [self of_sendQueryForContext: context - runLoopMode: runLoopMode]; + [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return; } if (++context->_attempt < context->_settings->_maxAttempts) { context->_nameServersIndex = 0; - [self of_sendQueryForContext: context - runLoopMode: runLoopMode]; + [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return; } context = [[context retain] autorelease]; [_queries removeObjectForKey: context->_ID]; @@ -879,16 +861,14 @@ /* * Cancel any pending queries, to avoid a send being still pending and * trying to access the query once it no longer exists. */ [_IPv4Socket cancelAsyncRequests]; - [_IPv4Socket asyncReceiveIntoBuffer: _buffer - length: BUFFER_LENGTH]; + [_IPv4Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; - [_IPv6Socket asyncReceiveIntoBuffer: _buffer - length: BUFFER_LENGTH]; + [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; #endif exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query error: OF_DNS_RESOLVER_ERROR_TIMEOUT]; @@ -1104,12 +1084,11 @@ context->_TCPQueryData = [[OFMutableData alloc] initWithCapacity: queryDataCount + 2]; tmp = OF_BSWAP16_IF_LE(queryDataCount); - [context->_TCPQueryData addItems: &tmp - count: sizeof(tmp)]; + [context->_TCPQueryData addItems: &tmp count: sizeof(tmp)]; [context->_TCPQueryData addItems: context->_queryData.items count: queryDataCount]; } [sock asyncWriteData: context->_TCPQueryData]; @@ -1138,12 +1117,11 @@ } if (context->_TCPBuffer == nil) context->_TCPBuffer = of_alloc(MAX_DNS_RESPONSE_LENGTH, 1); - [sock asyncReadIntoBuffer: context->_TCPBuffer - exactLength: 2]; + [sock asyncReadIntoBuffer: context->_TCPBuffer exactLength: 2]; return nil; } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer @@ -1186,13 +1164,11 @@ * The connection was closed before we received the entire * response. */ goto done; - [self of_handleResponseBuffer: buffer - length: length - sender: NULL]; + [self of_handleResponseBuffer: buffer length: length sender: NULL]; done: [_TCPQueries removeObjectForKey: context->_TCPSocket]; [context->_TCPSocket release]; context->_TCPSocket = nil; Index: src/OFDNSResolverSettings.h ================================================================== --- src/OFDNSResolverSettings.h +++ src/OFDNSResolverSettings.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResolverSettings.m ================================================================== --- src/OFDNSResolverSettings.m +++ src/OFDNSResolverSettings.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -68,10 +66,11 @@ #else # define HOSTS_PATH @"/etc/hosts" # define RESOLV_CONF_PATH @"/etc/resolv.conf" #endif +#ifndef OF_WII static OFString * domainFromHostname(OFString *hostname) { if (hostname == nil) return nil; @@ -92,10 +91,11 @@ return nil; return [hostname substringFromIndex: pos + 1]; } } +#endif #if !defined(OF_WII) && !defined(OF_MORPHOS) static OFString * obtainHostname(void) { @@ -251,12 +251,11 @@ OFMutableDictionary *staticHosts; OFFile *file; OFString *line; @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } @@ -286,12 +285,11 @@ OFMutableArray *addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; - [staticHosts setObject: addresses - forKey: host]; + [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } @@ -352,12 +350,11 @@ OFMutableArray *nameServers = [[_nameServers mutableCopy] autorelease]; OFFile *file; OFString *line; @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } @@ -391,11 +388,11 @@ if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } - [nameServers addObject: [arguments firstObject]]; + [nameServers addObject: arguments.firstObject]; } else if ([option isEqual: @"domain"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } @@ -490,12 +487,11 @@ OFMutableArray *addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; - [staticHosts setObject: addresses - forKey: host]; + [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } @@ -619,11 +615,11 @@ # ifdef OF_HAVE_FILES OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" securityAndAccessRights: KEY_QUERY_VALUE]; - path = [[[key stringForValue: @"DataBasePath"] + path = [[[key stringForValueNamed: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; if (path != nil) [self parseHosts: path]; Index: src/OFDNSResourceRecord.h ================================================================== --- src/OFDNSResourceRecord.h +++ src/OFDNSResourceRecord.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResourceRecord.m ================================================================== --- src/OFDNSResourceRecord.m +++ src/OFDNSResourceRecord.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResponse.h ================================================================== --- src/OFDNSResponse.h +++ src/OFDNSResponse.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDNSResponse.m ================================================================== --- src/OFDNSResponse.m +++ src/OFDNSResponse.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFData+CryptoHashing.h ================================================================== --- src/OFData+CryptoHashing.h +++ src/OFData+CryptoHashing.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFData+CryptoHashing.m ================================================================== --- src/OFData+CryptoHashing.m +++ src/OFData+CryptoHashing.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -38,12 +36,11 @@ [class cryptoHashWithAllowsSwappableMemory: true]; size_t digestSize = [class digestSize]; const unsigned char *digest; char cString[digestSize * 2]; - [hash updateWithBuffer: _items - length: _count * _itemSize]; + [hash updateWithBuffer: _items length: _count * _itemSize]; digest = hash.digest; for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; Index: src/OFData+MessagePackParsing.h ================================================================== --- src/OFData+MessagePackParsing.h +++ src/OFData+MessagePackParsing.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFData+MessagePackParsing.m ================================================================== --- src/OFData+MessagePackParsing.m +++ src/OFData+MessagePackParsing.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -118,12 +116,11 @@ pos += parseObject(buffer + pos, length - pos, &key, depthLimit); pos += parseObject(buffer + pos, length - pos, &value, depthLimit); - [*object setObject: value - forKey: key]; + [*object setObject: value forKey: key]; objc_autoreleasePoolPop(pool); } return pos; @@ -322,12 +319,11 @@ count = buffer[1]; if (length < count + 2) @throw [OFTruncatedDataException exception]; - *object = [OFData dataWithItems: buffer + 2 - count: count]; + *object = [OFData dataWithItems: buffer + 2 count: count]; return count + 2; case 0xC5: /* bin 16 */ if (length < 3) @throw [OFTruncatedDataException exception]; @@ -335,12 +331,11 @@ count = readUInt16(buffer + 1); if (length < count + 3) @throw [OFTruncatedDataException exception]; - *object = [OFData dataWithItems: buffer + 3 - count: count]; + *object = [OFData dataWithItems: buffer + 3 count: count]; return count + 3; case 0xC6: /* bin 32 */ if (length < 5) @throw [OFTruncatedDataException exception]; @@ -348,12 +343,11 @@ count = readUInt32(buffer + 1); if (length < count + 5) @throw [OFTruncatedDataException exception]; - *object = [OFData dataWithItems: buffer + 5 - count: count]; + *object = [OFData dataWithItems: buffer + 5 count: count]; return count + 5; /* Extensions */ case 0xC7: /* ext 8 */ if (length < 3) @@ -362,12 +356,11 @@ count = buffer[1]; if (length < count + 3) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 3 - count: count]; + data = [[OFData alloc] initWithItems: buffer + 3 count: count]; @try { *object = createExtension(buffer[2], data); } @finally { [data release]; } @@ -380,12 +373,11 @@ count = readUInt16(buffer + 1); if (length < count + 4) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 4 - count: count]; + data = [[OFData alloc] initWithItems: buffer + 4 count: count]; @try { *object = createExtension(buffer[3], data); } @finally { [data release]; } @@ -398,12 +390,11 @@ count = readUInt32(buffer + 1); if (length < count + 6) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 6 - count: count]; + data = [[OFData alloc] initWithItems: buffer + 6 count: count]; @try { *object = createExtension(buffer[5], data); } @finally { [data release]; } @@ -411,12 +402,11 @@ return count + 6; case 0xD4: /* fixext 1 */ if (length < 3) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 2 - count: 1]; + data = [[OFData alloc] initWithItems: buffer + 2 count: 1]; @try { *object = createExtension(buffer[1], data); } @finally { [data release]; } @@ -424,12 +414,11 @@ return 3; case 0xD5: /* fixext 2 */ if (length < 4) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 2 - count: 2]; + data = [[OFData alloc] initWithItems: buffer + 2 count: 2]; @try { *object = createExtension(buffer[1], data); } @finally { [data release]; } @@ -437,12 +426,11 @@ return 4; case 0xD6: /* fixext 4 */ if (length < 6) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 2 - count: 4]; + data = [[OFData alloc] initWithItems: buffer + 2 count: 4]; @try { *object = createExtension(buffer[1], data); } @finally { [data release]; } @@ -450,12 +438,11 @@ return 6; case 0xD7: /* fixext 8 */ if (length < 10) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 2 - count: 8]; + data = [[OFData alloc] initWithItems: buffer + 2 count: 8]; @try { *object = createExtension(buffer[1], data); } @finally { [data release]; } @@ -463,12 +450,11 @@ return 10; case 0xD8: /* fixext 16 */ if (length < 18) @throw [OFTruncatedDataException exception]; - data = [[OFData alloc] initWithItems: buffer + 2 - count: 16]; + data = [[OFData alloc] initWithItems: buffer + 2 count: 16]; @try { *object = createExtension(buffer[1], data); } @finally { [data release]; } Index: src/OFData.h ================================================================== --- src/OFData.h +++ src/OFData.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -94,12 +92,11 @@ * * @param items The items to store in the OFData * @param count The number of items * @return A new autoreleased OFData */ -+ (instancetype)dataWithItems: (const void *)items - count: (size_t)count; ++ (instancetype)dataWithItems: (const void *)items count: (size_t)count; /** * @brief Creates a new OFData with the specified `count` items of the * specified size. * @@ -186,12 +183,11 @@ * * @param items The items to store in the OFData * @param count The number of items * @return An initialized OFData */ -- (instancetype)initWithItems: (const void *)items - count: (size_t)count; +- (instancetype)initWithItems: (const void *)items count: (size_t)count; /** * @brief Initialized an already allocated OFData with the specified `count` * items of the specified size. * Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -53,15 +51,13 @@ } @implementation OFData @synthesize itemSize = _itemSize; -+ (instancetype)dataWithItems: (const void *)items - count: (size_t)count ++ (instancetype)dataWithItems: (const void *)items count: (size_t)count { - return [[[self alloc] initWithItems: items - count: count] autorelease]; + return [[[self alloc] initWithItems: items count: count] autorelease]; } + (instancetype)dataWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize @@ -112,16 +108,13 @@ + (instancetype)dataWithBase64EncodedString: (OFString *)string { return [[[self alloc] initWithBase64EncodedString: string] autorelease]; } -- (instancetype)initWithItems: (const void *)items - count: (size_t)count +- (instancetype)initWithItems: (const void *)items count: (size_t)count { - return [self initWithItems: items - count: count - itemSize: 1]; + return [self initWithItems: items count: count itemSize: 1]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize @@ -195,15 +188,13 @@ if (size > SIZE_MAX) @throw [OFOutOfRangeException exception]; # endif buffer = of_alloc((size_t)size, 1); - file = [[OFFile alloc] initWithPath: path - mode: @"r"]; + file = [[OFFile alloc] initWithPath: path mode: @"r"]; @try { - [file readIntoBuffer: buffer - exactLength: (size_t)size]; + [file readIntoBuffer: buffer exactLength: (size_t)size]; } @finally { [file release]; } } @catch (id e) { free(buffer); @@ -238,12 +229,11 @@ if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; - stream = [URLHandler openItemAtURL: URL - mode: @"r"]; + stream = [URLHandler openItemAtURL: URL mode: @"r"]; _count = 0; _itemSize = 1; _freeWhenDone = true; @@ -602,16 +592,13 @@ } #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { - OFFile *file = [[OFFile alloc] initWithPath: path - mode: @"w"]; - + OFFile *file = [[OFFile alloc] initWithPath: path mode: @"w"]; @try { - [file writeBuffer: _items - length: _count * _itemSize]; + [file writeBuffer: _items length: _count * _itemSize]; } @finally { [file release]; } } #endif @@ -618,18 +605,15 @@ - (void)writeToURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFURLHandler *URLHandler; - OFStream *stream; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; - stream = [URLHandler openItemAtURL: URL - mode: @"w"]; - [stream writeData: self]; + [[URLHandler openItemAtURL: URL mode: @"w"] writeData: self]; objc_autoreleasePoolPop(pool); } - (OFXMLElement *)XMLElementBySerializing @@ -662,41 +646,31 @@ if (_count <= UINT8_MAX) { uint8_t type = 0xC4; uint8_t tmp = (uint8_t)_count; - data = [OFMutableData dataWithItemSize: 1 - capacity: _count + 2]; - + data = [OFMutableData dataWithCapacity: _count + 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (_count <= UINT16_MAX) { uint8_t type = 0xC5; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)_count); - data = [OFMutableData dataWithItemSize: 1 - capacity: _count + 3]; - + data = [OFMutableData dataWithCapacity: _count + 3]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (_count <= UINT32_MAX) { uint8_t type = 0xC6; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)_count); - data = [OFMutableData dataWithItemSize: 1 - capacity: _count + 5]; - + data = [OFMutableData dataWithCapacity: _count + 5]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; - [data addItems: _items - count: _count]; - + [data addItems: _items count: _count]; [data makeImmutable]; return data; } @end Index: src/OFDatagramSocket.h ================================================================== --- src/OFDatagramSocket.h +++ src/OFDatagramSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -170,12 +168,11 @@ * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer */ -- (void)asyncReceiveIntoBuffer: (void *)buffer - length: (size_t)length; +- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * Index: src/OFDatagramSocket.m ================================================================== --- src/OFDatagramSocket.m +++ src/OFDatagramSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,10 +13,15 @@ * file. */ #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define _HPUX_ALT_XOPEN_SOCKET_API + #include #ifdef HAVE_FCNTL_H # include #endif @@ -212,12 +215,11 @@ } return ret; } -- (void)asyncReceiveIntoBuffer: (void *)buffer - length: (size_t)length +- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length { [self asyncReceiveIntoBuffer: buffer length: length runLoopMode: of_run_loop_mode_default]; } Index: src/OFDate.h ================================================================== --- src/OFDate.h +++ src/OFDate.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -643,17 +641,14 @@ data: data] messagePackRepresentation]; } } else { OFMutableData *data = [OFMutableData dataWithCapacity: 12]; - seconds = OF_BSWAP64_IF_LE(seconds); nanoseconds = OF_BSWAP32_IF_LE(nanoseconds); - - [data addItems: &nanoseconds - count: sizeof(nanoseconds)]; - [data addItems: &seconds - count: sizeof(seconds)]; + [data addItems: &nanoseconds count: sizeof(nanoseconds)]; + seconds = OF_BSWAP64_IF_LE(seconds); + [data addItems: &seconds count: sizeof(seconds)]; ret = [[OFMessagePackExtension extensionWithType: -1 data: data] messagePackRepresentation]; } Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -98,12 +96,11 @@ * * @param key The key * @param object The object * @return A new autoreleased OFDictionary */ -+ (instancetype)dictionaryWithObject: (ObjectType)object - forKey: (KeyType)key; ++ (instancetype)dictionaryWithObject: (ObjectType)object forKey: (KeyType)key; /** * @brief Creates a new OFDictionary with the specified keys and objects. * * @param keys An array of keys @@ -152,12 +149,11 @@ * * @param key The key * @param object The object * @return An initialized OFDictionary */ -- (instancetype)initWithObject: (ObjectType)object - forKey: (KeyType)key; +- (instancetype)initWithObject: (ObjectType)object forKey: (KeyType)key; /** * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * @@ -196,12 +192,11 @@ * * @param firstKey The first key * @param arguments A va_list of the other arguments * @return An initialized OFDictionary */ -- (instancetype)initWithKey: (KeyType)firstKey - arguments: (va_list)arguments; +- (instancetype)initWithKey: (KeyType)firstKey arguments: (va_list)arguments; /** * @brief Returns the object for the given key or `nil` if the key was not * found. * @@ -234,12 +229,11 @@ * dictionary is immutable, an @ref OFUndefinedKeyException is thrown. * * @param key The key to set * @param value The value to set the key to */ -- (void)setValue: (nullable id)value - forKey: (OFString *)key; +- (void)setValue: (nullable id)value forKey: (OFString *)key; /** * @brief Checks whether the dictionary contains an object equal to the * specified object. * Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -73,19 +71,17 @@ { return (id)[[OFMapTableDictionary alloc] initWithDictionary: dictionary]; } -- (instancetype)initWithObject: (id)object - forKey: (id)key +- (instancetype)initWithObject: (id)object forKey: (id)key { return (id)[[OFMapTableDictionary alloc] initWithObject: object forKey: key]; } -- (instancetype)initWithObjects: (OFArray *)objects - forKeys: (OFArray *)keys +- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { return (id)[[OFMapTableDictionary alloc] initWithObjects: objects forKeys: keys]; } @@ -228,15 +224,13 @@ { return [[(OFDictionary *)[self alloc] initWithDictionary: dictionary] autorelease]; } -+ (instancetype)dictionaryWithObject: (id)object - forKey: (id)key ++ (instancetype)dictionaryWithObject: (id)object forKey: (id)key { - return [[[self alloc] initWithObject: object - forKey: key] autorelease]; + return [[[self alloc] initWithObject: object forKey: key] autorelease]; } + (instancetype)dictionaryWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { @@ -244,11 +238,11 @@ forKeys: keys] autorelease]; } + (instancetype)dictionaryWithObjects: (id const *)objects forKeys: (id const *)keys - count: (size_t)count + count: (size_t)count { return [[[self alloc] initWithObjects: objects forKeys: keys count: count] autorelease]; } @@ -285,21 +279,19 @@ - (instancetype)initWithDictionary: (OFDictionary *)dictionary { OF_INVALID_INIT_METHOD } -- (instancetype)initWithObject: (id)object - forKey: (id)key +- (instancetype)initWithObject: (id)object forKey: (id)key { if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; return [self initWithKeysAndObjects: key, object, nil]; } -- (instancetype)initWithObjects: (OFArray *)objects_ - forKeys: (OFArray *)keys_ +- (instancetype)initWithObjects: (OFArray *)objects_ forKeys: (OFArray *)keys_ { id const *objects, *keys; size_t count; @try { @@ -313,13 +305,11 @@ } @catch (id e) { [self release]; @throw e; } - return [self initWithObjects: objects - forKeys: keys - count: count]; + return [self initWithObjects: objects forKeys: keys count: count]; } - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count @@ -331,19 +321,17 @@ { id ret; va_list arguments; va_start(arguments, firstKey); - ret = [self initWithKey: firstKey - arguments: arguments]; + ret = [self initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } -- (instancetype)initWithKey: (id)firstKey - arguments: (va_list)arguments +- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } - (instancetype)initWithSerialization: (OFXMLElement *)element @@ -367,20 +355,18 @@ return [super valueForKey: @"count"]; return [self objectForKey: key]; } -- (void)setValue: (id)value - forKey: (OFString *)key +- (void)setValue: (id)value forKey: (OFString *)key { if (![self isKindOfClass: [OFMutableDictionary class]]) @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; - [(OFMutableDictionary *)self setObject: value - forKey: key]; + [(OFMutableDictionary *)self setObject: value forKey: key]; } - (size_t)count { OF_UNRECOGNIZED_SELECTOR @@ -568,12 +554,11 @@ { OFMutableDictionary *new = [OFMutableDictionary dictionary]; [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { - [new setObject: block(key, object) - forKey: key]; + [new setObject: block(key, object) forKey: key]; }]; [new makeImmutable]; return new; @@ -585,12 +570,11 @@ OFMutableDictionary *new = [OFMutableDictionary dictionary]; [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { if (block(key, object)) - [new setObject: object - forKey: key]; + [new setObject: object forKey: key]; }]; [new makeImmutable]; return new; @@ -644,12 +628,11 @@ if (++i < count) [ret appendString: @";\n"]; objc_autoreleasePoolPop(pool2); } - [ret replaceOccurrencesOfString: @"\n" - withString: @"\n\t"]; + [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @";\n}"]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); @@ -733,18 +716,16 @@ return [element autorelease]; } - (OFString *)JSONRepresentation { - return [self of_JSONRepresentationWithOptions: 0 - depth: 0]; + return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { - return [self of_JSONRepresentationWithOptions: options - depth: 0]; + return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { @@ -843,19 +824,17 @@ } else if (count <= UINT16_MAX) { uint8_t type = 0xDE; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)count); [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (count <= UINT32_MAX) { uint8_t type = 0xDF; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count); [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); @@ -868,16 +847,14 @@ OFData *child; i++; child = key.messagePackRepresentation; - [data addItems: child.items - count: child.count]; + [data addItems: child.items count: child.count]; child = object.messagePackRepresentation; - [data addItems: child.items - count: child.count]; + [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } assert(i == count); Index: src/OFDimensionValue.h ================================================================== --- src/OFDimensionValue.h +++ src/OFDimensionValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFDimensionValue.m ================================================================== --- src/OFDimensionValue.m +++ src/OFDimensionValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -36,12 +34,11 @@ - (const char *)objCType { return @encode(of_dimension_t); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_dimension)) @throw [OFOutOfRangeException exception]; memcpy(value, &_dimension, sizeof(_dimension)); Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFEnumerator.m ================================================================== --- src/OFEnumerator.m +++ src/OFEnumerator.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFEpollKernelEventObserver.h ================================================================== --- src/OFEpollKernelEventObserver.h +++ src/OFEpollKernelEventObserver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFEpollKernelEventObserver.m ================================================================== --- src/OFEpollKernelEventObserver.m +++ src/OFEpollKernelEventObserver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -63,12 +61,11 @@ * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ -+ (instancetype)fileWithPath: (OFString *)path - mode: (OFString *)mode; ++ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode; /** * @brief Creates a new OFFile with the specified URL and mode. * * @param URL The URL to the file to open @@ -84,12 +81,11 @@ * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ -+ (instancetype)fileWithURL: (OFURL *)URL - mode: (OFString *)mode; ++ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode; /** * @brief Creates a new OFFile with the specified native file handle. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this @@ -121,12 +117,11 @@ * `ab` | write-only, create, append, binary * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode; +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; /** * @brief Initializes an already allocated OFFile. * * @param URL The URL to the file to open @@ -146,12 +141,11 @@ * `ab` | write-only, create, append, binary * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ -- (instancetype)initWithURL: (OFURL *)URL - mode: (OFString *)mode; +- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode; /** * @brief Initializes an already allocated OFFile. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -14,10 +12,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#define _LARGEFILE64_SOURCE #include #include #ifdef HAVE_FCNTL_H @@ -180,22 +180,18 @@ @throw [OFInitializationFailedException exceptionWithClass: self]; #endif } -+ (instancetype)fileWithPath: (OFString *)path - mode: (OFString *)mode ++ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode { - return [[[self alloc] initWithPath: path - mode: mode] autorelease]; + return [[[self alloc] initWithPath: path mode: mode] autorelease]; } -+ (instancetype)fileWithURL: (OFURL *)URL - mode: (OFString *)mode ++ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode { - return [[[self alloc] initWithURL: URL - mode: mode] autorelease]; + return [[[self alloc] initWithURL: URL mode: mode] autorelease]; } + (instancetype)fileWithHandle: (of_file_handle_t)handle { return [[[self alloc] initWithHandle: handle] autorelease]; @@ -204,12 +200,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode { of_file_handle_t handle; @try { void *pool = objc_autoreleasePoolPush(); @@ -324,12 +319,11 @@ } return self; } -- (instancetype)initWithURL: (OFURL *)URL - mode: (OFString *)mode +- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFString *fileSystemRepresentation; @try { @@ -337,12 +331,11 @@ } @catch (id e) { [self release]; @throw e; } - self = [self initWithPath: fileSystemRepresentation - mode: mode]; + self = [self initWithPath: fileSystemRepresentation mode: mode]; objc_autoreleasePoolPop(pool); return self; } @@ -362,12 +355,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; if (_handle == OF_INVALID_FILE_HANDLE) @throw [OFNotOpenException exceptionWithObject: self]; @@ -399,12 +391,11 @@ _atEndOfStream = true; return ret; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_handle == OF_INVALID_FILE_HANDLE) @throw [OFNotOpenException exceptionWithObject: self]; #if defined(OF_WINDOWS) @@ -458,12 +449,11 @@ #endif return (size_t)bytesWritten; } -- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset - whence: (int)whence +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence { of_offset_t ret; if (_handle == OF_INVALID_FILE_HANDLE) @throw [OFNotOpenException exceptionWithObject: self]; Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -376,12 +374,11 @@ * @brief Creates a directory at the specified URL. * * @param URL The URL of the directory to create * @param createParents Whether to create the parents of the directory */ -- (void)createDirectoryAtURL: (OFURL *)URL - createParents: (bool)createParents; +- (void)createDirectoryAtURL: (OFURL *)URL createParents: (bool)createParents; #ifdef OF_HAVE_FILES /** * @brief Returns an array with the items in the specified directory. * @@ -429,12 +426,11 @@ * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination path */ -- (void)copyItemAtPath: (OFString *)source - toPath: (OFString *)destination; +- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Copies a file, directory or symbolic link (if supported by the OS). * @@ -446,12 +442,11 @@ * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination URL */ -- (void)copyItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination; #ifdef OF_HAVE_FILES /** * @brief Moves an item. * @@ -463,12 +458,11 @@ * removed using @ref removeItemAtPath:. * * @param source The item to rename * @param destination The new name for the item */ -- (void)moveItemAtPath: (OFString *)source - toPath: (OFString *)destination; +- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Moves an item. * @@ -480,12 +474,11 @@ * @ref copyItemAtURL:toURL: and the source removed using @ref removeItemAtURL:. * * @param source The item to rename * @param destination The new name for the item */ -- (void)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (void)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination; #ifdef OF_HAVE_FILES /** * @brief Removes the item at the specified path. * @@ -515,12 +508,11 @@ * This method is not available on some systems. * * @param source The path to the item for which a link should be created * @param destination The path to the item which should link to the source */ -- (void)linkItemAtPath: (OFString *)source - toPath: (OFString *)destination; +- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Creates a hard link for the specified item. * @@ -530,12 +522,11 @@ * This method is not available for all URLs. * * @param source The URL to the item for which a link should be created * @param destination The URL to the item which should link to the source */ -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination; #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS /** * @brief Creates a symbolic link for an item. * Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -271,23 +269,20 @@ @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; - [URLHandler setAttributes: attributes - ofItemAtURL: URL]; + [URLHandler setAttributes: attributes ofItemAtURL: URL]; } #ifdef OF_HAVE_FILES - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); - [self setAttributes: attributes ofItemAtURL: [OFURL fileURLWithPath: path]]; - objc_autoreleasePoolPop(pool); } #endif - (bool)fileExistsAtURL: (OFURL *)URL @@ -552,12 +547,11 @@ [self changeCurrentDirectoryPath: URL.fileSystemRepresentation]; objc_autoreleasePoolPop(pool); } -- (void)copyItemAtPath: (OFString *)source - toPath: (OFString *)destination +- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); [self copyItemAtURL: [OFURL fileURLWithPath: source] toURL: [OFURL fileURLWithPath: destination]]; @@ -564,12 +558,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (void)copyItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; OFURLHandler *URLHandler; of_file_attributes_t attributes; of_file_type_t type; @@ -581,12 +574,11 @@ if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: source]; - if ([URLHandler copyItemAtURL: source - toURL: destination]) + if ([URLHandler copyItemAtURL: source toURL: destination]) return; if ([self fileExistsAtURL: destination]) @throw [OFCopyItemFailedException exceptionWithSourceURL: source @@ -652,12 +644,11 @@ sourceURL = [source URLByAppendingPathComponent: item]; destinationURL = [destination URLByAppendingPathComponent: item]; - [self copyItemAtURL: sourceURL - toURL: destinationURL]; + [self copyItemAtURL: sourceURL toURL: destinationURL]; objc_autoreleasePoolPop(pool2); } } else if ([type isEqual: of_file_type_regular]) { size_t pageSize = [OFSystemInfo pageSize]; @@ -750,24 +741,20 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_FILES -- (void)moveItemAtPath: (OFString *)source - toPath: (OFString *)destination +- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); - [self moveItemAtURL: [OFURL fileURLWithPath: source] toURL: [OFURL fileURLWithPath: destination]]; - objc_autoreleasePoolPop(pool); } #endif -- (void)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; OFURLHandler *URLHandler; if (source == nil || destination == nil) @@ -778,12 +765,11 @@ if ((URLHandler = [OFURLHandler handlerForURL: source]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: source]; @try { - if ([URLHandler moveItemAtURL: source - toURL: destination]) + if ([URLHandler moveItemAtURL: source toURL: destination]) return; } @catch (OFMoveItemFailedException *e) { if (e.errNo != EXDEV) @throw e; } @@ -793,12 +779,11 @@ exceptionWithSourceURL: source destinationURL: destination errNo: EEXIST]; @try { - [self copyItemAtURL: source - toURL: destination]; + [self copyItemAtURL: source toURL: destination]; } @catch (OFCopyItemFailedException *e) { [self removeItemAtURL: destination]; @throw [OFMoveItemFailedException exceptionWithSourceURL: source @@ -833,19 +818,16 @@ #ifdef OF_HAVE_FILES - (void)removeItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); - [self removeItemAtURL: [OFURL fileURLWithPath: path]]; - objc_autoreleasePoolPop(pool); } #endif -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool = objc_autoreleasePoolPush(); OFURLHandler *URLHandler; if (source == nil || destination == nil) @@ -858,25 +840,21 @@ if (URLHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: source]; - [URLHandler linkItemAtURL: source - toURL: destination]; + [URLHandler linkItemAtURL: source toURL: destination]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS -- (void)linkItemAtPath: (OFString *)source - toPath: (OFString *)destination +- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); - [self linkItemAtURL: [OFURL fileURLWithPath: source] toURL: [OFURL fileURLWithPath: destination]]; - objc_autoreleasePoolPop(pool); } #endif - (void)createSymbolicLinkAtURL: (OFURL *)URL @@ -891,25 +869,22 @@ URLHandler = [OFURLHandler handlerForURL: URL]; if (URLHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; - [URLHandler createSymbolicLinkAtURL: URL - withDestinationPath: target]; + [URLHandler createSymbolicLinkAtURL: URL withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)createSymbolicLinkAtPath: (OFString *)path withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); - [self createSymbolicLinkAtURL: [OFURL fileURLWithPath: path] withDestinationPath: target]; - objc_autoreleasePoolPop(pool); } #endif @end Index: src/OFFileURLHandler.h ================================================================== --- src/OFFileURLHandler.h +++ src/OFFileURLHandler.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -14,10 +12,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#define _LARGEFILE64_SOURCE #include #include #ifdef HAVE_DIRENT_H @@ -481,12 +481,11 @@ destination = [OFString stringWithCString: destinationC encoding: encoding length: length]; key = of_file_attribute_key_symbolic_link_destination; - [attributes setObject: destination - forKey: key]; + [attributes setObject: destination forKey: key]; # else HANDLE handle; OFString *destination; if (func_CreateSymbolicLinkW == NULL) @@ -530,12 +529,11 @@ sizeof(wchar_t)]; [attributes setObject: of_file_type_symbolic_link forKey: of_file_attribute_key_type]; key = of_file_attribute_key_symbolic_link_destination; - [attributes setObject: destination - forKey: key]; + [attributes setObject: destination forKey: key]; # undef slrb } @finally { CloseHandle(handle); } # endif @@ -592,12 +590,11 @@ return false; return S_ISDIR(s.st_mode); } -- (OFStream *)openItemAtURL: (OFURL *)URL - mode: (OFString *)mode +- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFFile *file = [[OFFile alloc] initWithPath: URL.fileSystemRepresentation mode: mode]; @@ -1158,11 +1155,10 @@ while (ExNext(lock, &fib)) { OFString *file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; - @try { [files addObject: file]; } @finally { [file release]; } @@ -1178,11 +1174,10 @@ UnLock(lock); } #else of_string_encoding_t encoding = [OFLocale encoding]; DIR *dir; - if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errno]; @@ -1343,12 +1338,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; if (source == nil || destination == nil) @@ -1425,12 +1419,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (bool)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; if (![source.scheme isEqual: _scheme] || ![destination.scheme isEqual: _scheme]) Index: src/OFGZIPStream.h ================================================================== --- src/OFGZIPStream.h +++ src/OFGZIPStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -105,12 +103,11 @@ * @param stream The underlying stream for the OFGZIPStream * @param mode The mode for the OFGZIPStream. Valid modes are "r" for reading * and "w" for writing. * @return A new, autoreleased OFGZIPStream */ -+ (instancetype)streamWithStream: (OFStream *)stream - mode: (OFString *)mode; ++ (instancetype)streamWithStream: (OFStream *)stream mode: (OFString *)mode; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFGZIPStream with the specified Index: src/OFGZIPStream.m ================================================================== --- src/OFGZIPStream.m +++ src/OFGZIPStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,24 +29,21 @@ @implementation OFGZIPStream @synthesize operatingSystemMadeOn = _operatingSystemMadeOn; @synthesize modificationDate = _modificationDate; -+ (instancetype)streamWithStream: (OFStream *)stream - mode: (OFString *)mode ++ (instancetype)streamWithStream: (OFStream *)stream mode: (OFString *)mode { - return [[[self alloc] initWithStream: stream - mode: mode] autorelease]; + return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OFStream *)stream - mode: (OFString *)mode +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { if (![mode isEqual: @"r"]) @@ -77,12 +72,11 @@ [_modificationDate release]; [super dealloc]; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; for (;;) { @@ -98,12 +92,11 @@ switch (_state) { case OF_GZIP_STREAM_ID1: case OF_GZIP_STREAM_ID2: case OF_GZIP_STREAM_COMPRESSION_METHOD: - if ([_stream readIntoBuffer: &byte - length: 1] < 1) + if ([_stream readIntoBuffer: &byte length: 1] < 1) return 0; if ((_state == OF_GZIP_STREAM_ID1 && byte != 0x1F) || (_state == OF_GZIP_STREAM_ID2 && byte != 0x8B) || (_state == OF_GZIP_STREAM_COMPRESSION_METHOD && @@ -111,12 +104,11 @@ @throw [OFInvalidFormatException exception]; _state++; break; case OF_GZIP_STREAM_FLAGS: - if ([_stream readIntoBuffer: &byte - length: 1] < 1) + if ([_stream readIntoBuffer: &byte length: 1] < 1) return 0; _flags = byte; _state++; break; @@ -138,20 +130,18 @@ _bytesRead = 0; _state++; break; case OF_GZIP_STREAM_EXTRA_FLAGS: - if ([_stream readIntoBuffer: &byte - length: 1] < 1) + if ([_stream readIntoBuffer: &byte length: 1] < 1) return 0; _extraFlags = byte; _state++; break; case OF_GZIP_STREAM_OPERATING_SYSTEM: - if ([_stream readIntoBuffer: &byte - length: 1] < 1) + if ([_stream readIntoBuffer: &byte length: 1] < 1) return 0; _operatingSystemMadeOn = byte; _state++; break; Index: src/OFHMAC.h ================================================================== --- src/OFHMAC.h +++ src/OFHMAC.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -93,21 +91,19 @@ * it yourself before calling @ref setKey:length:! * * @param key The key for the HMAC * @param length The length of the key for the HMAC */ -- (void)setKey: (const void *)key - length: (size_t)length; +- (void)setKey: (const void *)key length: (size_t)length; /** * @brief Adds a buffer to the HMAC to be calculated. * * @param buffer The buffer which should be included into the calculation * @param length The length of the buffer */ -- (void)updateWithBuffer: (const void *)buffer - length: (size_t)length; +- (void)updateWithBuffer: (const void *)buffer length: (size_t)length; /** * @brief Resets the HMAC so that it can be calculated for a new message. * * @note This does not reset the key so that a new HMAC with the same key can Index: src/OFHMAC.m ================================================================== --- src/OFHMAC.m +++ src/OFHMAC.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,12 +57,11 @@ [_innerHashCopy release]; [super dealloc]; } -- (void)setKey: (const void *)key - length: (size_t)length +- (void)setKey: (const void *)key length: (size_t)length { void *pool = objc_autoreleasePoolPush(); size_t blockSize = [_hashClass blockSize]; OFSecureData *outerKeyPad = [OFSecureData dataWithCount: blockSize @@ -84,13 +81,11 @@ @try { if (length > blockSize) { id hash = [_hashClass cryptoHashWithAllowsSwappableMemory: _allowsSwappableMemory]; - - [hash updateWithBuffer: key - length: length]; + [hash updateWithBuffer: key length: length]; length = hash.digestSize; if OF_UNLIKELY (length > blockSize) length = blockSize; @@ -131,22 +126,20 @@ _innerHashCopy = [_innerHash copy]; _calculated = false; } -- (void)updateWithBuffer: (const void *)buffer - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer length: (size_t)length { if (_innerHash == nil) @throw [OFInvalidArgumentException exception]; if (_calculated) @throw [OFHashAlreadyCalculatedException exceptionWithObject: self]; - [_innerHash updateWithBuffer: buffer - length: length]; + [_innerHash updateWithBuffer: buffer length: length]; } - (const unsigned char *)digest { if (_outerHash == nil || _innerHash == nil) Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -154,15 +152,13 @@ if (port != nil) { OFString *host = [OFString stringWithFormat: @"%@:%@", URL.URLEncodedHost, port]; - [headers setObject: host - forKey: @"Host"]; + [headers setObject: host forKey: @"Host"]; } else - [headers setObject: [URL URLEncodedHost] - forKey: @"Host"]; + [headers setObject: URL.URLEncodedHost forKey: @"Host"]; } if ((user.length > 0 || password.length > 0) && [headers objectForKey: @"Authorization"] == nil) { OFMutableData *authorizationData = [OFMutableData data]; @@ -175,12 +171,11 @@ count: password.UTF8StringLength]; authorization = [OFString stringWithFormat: @"Basic %@", authorizationData.stringByBase64Encoding]; - [headers setObject: authorization - forKey: @"Authorization"]; + [headers setObject: authorization forKey: @"Authorization"]; } if ([headers objectForKey: @"User-Agent"] == nil) [headers setObject: @"Something using ObjFW " @"" @@ -187,12 +182,11 @@ forKey: @"User-Agent"]; if (request.protocolVersion.major == 1 && request.protocolVersion.minor == 0 && [headers objectForKey: @"Connection"] == nil) - [headers setObject: @"keep-alive" - forKey: @"Connection"]; + [headers setObject: @"keep-alive" forKey: @"Connection"]; hasContentLength = ([headers objectForKey: @"Content-Length"] != nil); chunked = [[headers objectForKey: @"Transfer-Encoding"] isEqual: @"chunked"]; @@ -536,12 +530,11 @@ old = [_serverHeaders objectForKey: key]; if (old != nil) value = [old stringByAppendingFormat: @",%@", value]; - [_serverHeaders setObject: value - forKey: key]; + [_serverHeaders setObject: value forKey: key]; return true; } - (bool)stream: (OFStream *)sock @@ -723,12 +716,11 @@ URLPort = URL.port; if (URLPort != nil) port = URLPort.unsignedShortValue; sock.delegate = self; - [sock asyncConnectToHost: URL.host - port: port]; + [sock asyncConnectToHost: URL.host port: port]; } @catch (id e) { [self raiseException: e]; } } @end @@ -805,12 +797,11 @@ if (_chunked) [_socket writeFormat: @"%zX\r\n", length]; else if (length > _toWrite) length = (size_t)_toWrite; - ret = [_socket writeBuffer: buffer - length: length]; + ret = [_socket writeBuffer: buffer length: length]; if (_chunked) [_socket writeString: @"\r\n"]; if (ret > length) @throw [OFOutOfRangeException exception]; @@ -910,22 +901,20 @@ @throw [OFInvalidServerReplyException exception]; } } } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; if (!_hasContentLength && !_chunked) - return [_socket readIntoBuffer: buffer - length: length]; + return [_socket readIntoBuffer: buffer length: length]; if (_socket.atEndOfStream) @throw [OFTruncatedDataException exception]; /* Content-Length */ @@ -933,13 +922,11 @@ size_t ret; if (length > (unsigned long long)_toRead) length = (size_t)_toRead; - ret = [_socket readIntoBuffer: buffer - length: length]; - + ret = [_socket readIntoBuffer: buffer length: length]; if (ret > length) @throw [OFOutOfRangeException exception]; _toRead -= ret; @@ -951,12 +938,11 @@ /* Chunked */ if (_toRead == -2) { char tmp[2]; - switch ([_socket readIntoBuffer: tmp - length: 2]) { + switch ([_socket readIntoBuffer: tmp length: 2]) { case 2: _toRead++; if (tmp[1] != '\n') @throw [OFInvalidServerReplyException exception]; @@ -972,12 +958,11 @@ return 0; } else if (_toRead == -1) { char tmp; - if ([_socket readIntoBuffer: &tmp - length: 1] == 1) { + if ([_socket readIntoBuffer: &tmp length: 1] == 1) { _toRead++; if (tmp != '\n') @throw [OFInvalidServerReplyException exception]; } @@ -988,15 +973,13 @@ return 0; } else if (_toRead > 0) { if (length > (unsigned long long)_toRead) length = (size_t)_toRead; - length = [_socket readIntoBuffer: buffer - length: length]; + length = [_socket readIntoBuffer: buffer length: length]; _toRead -= length; - if (_toRead == 0) _toRead = -2; return length; } else { @@ -1120,15 +1103,12 @@ } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { - [_client asyncPerformRequest: request - redirects: redirects]; - + [_client asyncPerformRequest: request redirects: redirects]; [[OFRunLoop currentRunLoop] run]; - return _response; } - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request @@ -1226,12 +1206,11 @@ [super dealloc]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request { - return [self performRequest: request - redirects: REDIRECTS_DEFAULT]; + return [self performRequest: request redirects: REDIRECTS_DEFAULT]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { @@ -1249,12 +1228,11 @@ return [response autorelease]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request { - [self asyncPerformRequest: request - redirects: REDIRECTS_DEFAULT]; + [self asyncPerformRequest: request redirects: REDIRECTS_DEFAULT]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { Index: src/OFHTTPCookie.h ================================================================== --- src/OFHTTPCookie.h +++ src/OFHTTPCookie.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPCookie.m ================================================================== --- src/OFHTTPCookie.m +++ src/OFHTTPCookie.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPCookieManager.h ================================================================== --- src/OFHTTPCookieManager.h +++ src/OFHTTPCookieManager.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -54,12 +52,11 @@ * If you do not want this, pass a copy! * * @param cookie The cookie to add to the manager * @param URL The URL for which the cookie should be added */ -- (void)addCookie: (OFHTTPCookie *)cookie - forURL: (OFURL *)URL; +- (void)addCookie: (OFHTTPCookie *)cookie forURL: (OFURL *)URL; /** * @brief Adds the specified cookies for the specified URL. * * @warning This modifies the cookies (e.g. it sets the domain if it is unset)! Index: src/OFHTTPCookieManager.m ================================================================== --- src/OFHTTPCookieManager.m +++ src/OFHTTPCookieManager.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -53,12 +51,11 @@ - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies { return [[_cookies copy] autorelease]; } -- (void)addCookie: (OFHTTPCookie *)cookie - forURL: (OFURL *)URL +- (void)addCookie: (OFHTTPCookie *)cookie forURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFString *cookieDomain, *URLHost; size_t i; @@ -87,13 +84,11 @@ i = 0; for (OFHTTPCookie *iter in _cookies) { if ([iter.name isEqual: cookie.name] && [iter.domain isEqual: cookie.domain] && [iter.path isEqual: cookie.path]) { - [_cookies replaceObjectAtIndex: i - withObject: cookie]; - + [_cookies replaceObjectAtIndex: i withObject: cookie]; objc_autoreleasePoolPop(pool); return; } i++; @@ -106,12 +101,11 @@ - (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies forURL: (OFURL *)URL { for (OFHTTPCookie *cookie in cookies) - [self addCookie: cookie - forURL: URL]; + [self addCookie: cookie forURL: URL]; } - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURL: (OFURL *)URL { OFMutableArray *ret = [OFMutableArray array]; Index: src/OFHTTPRequest.h ================================================================== --- src/OFHTTPRequest.h +++ src/OFHTTPRequest.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPResponse.h ================================================================== --- src/OFHTTPResponse.h +++ src/OFHTTPResponse.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPResponse.m ================================================================== --- src/OFHTTPResponse.m +++ src/OFHTTPResponse.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPServer.h ================================================================== --- src/OFHTTPServer.h +++ src/OFHTTPServer.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -196,21 +194,18 @@ headers = [[_headers mutableCopy] autorelease]; if ([headers objectForKey: @"Date"] == nil) { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; - - [headers setObject: date - forKey: @"Date"]; + [headers setObject: date forKey: @"Date"]; } if ([headers objectForKey: @"Server"] == nil) { OFString *name = _server.name; if (name != nil) - [headers setObject: name - forKey: @"Server"]; + [headers setObject: name forKey: @"Server"]; } keyEnumerator = [headers keyEnumerator]; valueEnumerator = [headers objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && @@ -224,12 +219,11 @@ isEqual: @"chunked"]; objc_autoreleasePoolPop(pool); } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { /* TODO: Use non-blocking writes */ void *pool; @@ -238,19 +232,17 @@ if (!_headersSent) [self of_sendHeaders]; if (!_chunked) - return [_socket writeBuffer: buffer - length: length]; + return [_socket writeBuffer: buffer length: length]; pool = objc_autoreleasePoolPush(); [_socket writeString: [OFString stringWithFormat: @"%zX\r\n", length]]; objc_autoreleasePoolPop(pool); - [_socket writeBuffer: buffer - length: length]; + [_socket writeBuffer: buffer length: length]; [_socket writeString: @"\r\n"]; return length; } @@ -465,12 +457,11 @@ old = [_headers objectForKey: key]; if (old != nil) value = [old stringByAppendingFormat: @",%@", value]; - [_headers setObject: value - forKey: key]; + [_headers setObject: value forKey: key]; if ([key isEqual: @"Host"]) { pos = [value rangeOfString: @":" options: OF_STRING_SEARCH_BACKWARDS].location; @@ -503,19 +494,17 @@ - (bool)sendErrorAndClose: (short)statusCode { OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; - [_socket writeFormat: @"HTTP/1.1 %hd %@\r\n" @"Date: %@\r\n" @"Server: %@\r\n" @"\r\n", statusCode, of_http_status_code_to_string(statusCode), date, _server.name]; - return false; } - (void)createResponse { @@ -616,12 +605,11 @@ - (bool)lowlevelIsAtEndOfStream { return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) @@ -635,12 +623,11 @@ size_t ret; if (length > (unsigned long long)_toRead) length = (size_t)_toRead; - ret = [_socket readIntoBuffer: buffer - length: length]; + ret = [_socket readIntoBuffer: buffer length: length]; _toRead -= ret; if (_toRead == 0) _atEndOfStream = true; @@ -650,12 +637,11 @@ /* Chunked */ if (_toRead == -2) { char tmp[2]; - switch ([_socket readIntoBuffer: tmp - length: 2]) { + switch ([_socket readIntoBuffer: tmp length: 2]) { case 2: _toRead++; if (tmp[1] != '\n') @throw [OFInvalidFormatException exception]; case 1: @@ -669,12 +655,11 @@ return 0; } else if (_toRead == -1) { char tmp; - if ([_socket readIntoBuffer: &tmp - length: 1] == 1) { + if ([_socket readIntoBuffer: &tmp length: 1] == 1) { _toRead++; if (tmp != '\n') @throw [OFInvalidFormatException exception]; } @@ -684,15 +669,13 @@ return 0; } else if (_toRead > 0) { if (length > (unsigned long long)_toRead) length = (size_t)_toRead; - length = [_socket readIntoBuffer: buffer - length: length]; + length = [_socket readIntoBuffer: buffer length: length]; _toRead -= length; - if (_toRead == 0) _toRead = -2; return length; } else { @@ -936,12 +919,11 @@ TLSSocket.privateKeyFile = _privateKeyFile; TLSSocket.privateKeyPassphrase = _privateKeyPassphrase; } else _listeningSocket = [[OFTCPSocket alloc] init]; - _port = [_listeningSocket bindToHost: _host - port: _port]; + _port = [_listeningSocket bindToHost: _host port: _port]; [_listeningSocket listen]; #ifdef OF_HAVE_THREADS if (_numberOfThreads > 1) { OFMutableArray *threads = @@ -999,11 +981,11 @@ if (exception != nil) { if (![_delegate respondsToSelector: @selector(server:didReceiveExceptionOnListeningSocket:)]) return false; - return [_delegate server: self + return [_delegate server: self didReceiveExceptionOnListeningSocket: exception]; } #ifdef OF_HAVE_THREADS if (_numberOfThreads > 1) { Index: src/OFHTTPURLHandler.h ================================================================== --- src/OFHTTPURLHandler.h +++ src/OFHTTPURLHandler.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHTTPURLHandler.m ================================================================== --- src/OFHTTPURLHandler.m +++ src/OFHTTPURLHandler.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHostAddressResolver.h ================================================================== --- src/OFHostAddressResolver.h +++ src/OFHostAddressResolver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFHostAddressResolver.m ================================================================== --- src/OFHostAddressResolver.m +++ src/OFHostAddressResolver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -351,24 +349,20 @@ _delegate = [delegate retain]; [self asyncResolve]; while (!delegate->_done) - [runLoop runMode: resolveRunLoopMode - beforeDate: nil]; + [runLoop runMode: resolveRunLoopMode beforeDate: nil]; /* Cleanup */ - [runLoop runMode: resolveRunLoopMode - beforeDate: [OFDate date]]; + [runLoop runMode: resolveRunLoopMode beforeDate: [OFDate date]]; if (delegate->_exception != nil) @throw delegate->_exception; ret = [delegate->_addresses copy]; - objc_autoreleasePoolPop(pool); - return [ret autorelease]; } @end @implementation OFHostAddressResolverDelegate Index: src/OFINICategory+Private.h ================================================================== --- src/OFINICategory+Private.h +++ src/OFINICategory+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFINICategory.h ================================================================== --- src/OFINICategory.h +++ src/OFINICategory.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -41,191 +39,183 @@ @property (copy, nonatomic) OFString *name; - (instancetype)init OF_UNAVAILABLE; /** - * @brief Returns the string value for the specified key, or `nil` if it does - * not exist. - * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. - * - * @param key The key for which the string value should be returned - * @return The string value for the specified key, or `nil` if it does not exist + * @brief Returns the string for the specified key, or `nil` if it does not + * exist. + * + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. + * + * @param key The key for which the string should be returned + * @return The string for the specified key, or `nil` if it does not exist */ - (nullable OFString *)stringForKey: (OFString *)key; /** - * @brief Returns the string value for the specified key or the specified - * default value if it does not exist. + * @brief Returns the string for the specified key or the specified default + * value if it does not exist. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. * - * @param key The key for which the string value should be returned + * @param key The key for which the string should be returned * @param defaultValue The value to return if the key does not exist - * @return The string value for the specified key or the specified default - * value if it does not exist + * @return The string for the specified key or the specified default value if + * it does not exist */ - (nullable OFString *)stringForKey: (OFString *)key defaultValue: (nullable OFString *)defaultValue; /** - * @brief Returns the integer value for the specified key or the specified - * default value if it does not exist. - * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. - * - * @param key The key for which the integer value should be returned - * @param defaultValue The value to return if the key does not exist - * @return The integer value for the specified key or the specified default - * value if it does not exist - */ -- (long long)integerForKey: (OFString *)key - defaultValue: (long long)defaultValue; - -/** - * @brief Returns the bool value for the specified key or the specified default - * value if it does not exist. - * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. - * - * @param key The key for which the bool value should be returned - * @param defaultValue The value to return if the key does not exist - * @return The bool value for the specified key or the specified default value - * if it does not exist - */ -- (bool)boolForKey: (OFString *)key - defaultValue: (bool)defaultValue; - -/** - * @brief Returns the float value for the specified key or the specified - * default value if it does not exist. - * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. - * - * @param key The key for which the float value should be returned - * @param defaultValue The value to return if the key does not exist - * @return The float value for the specified key or the specified default value - * if it does not exist - */ -- (float)floatForKey: (OFString *)key - defaultValue: (float)defaultValue; - -/** - * @brief Returns the double value for the specified key or the specified - * default value if it does not exist. - * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is returned. - * - * @param key The key for which the double value should be returned - * @param defaultValue The value to return if the key does not exist - * @return The double value for the specified key or the specified default - * value if it does not exist - */ -- (double)doubleForKey: (OFString *)key - defaultValue: (double)defaultValue; - -/** - * @brief Returns an array of string values for the specified multi-key, or an - * empty array if the key does not exist. + * @brief Returns the long long for the specified key or the specified default + * value if it does not exist. + * + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. + * + * @param key The key for which the long long should be returned + * @param defaultValue The value to return if the key does not exist + * @return The long long for the specified key or the specified default value + * if it does not exist + */ +- (long long)longLongForKey: (OFString *)key + defaultValue: (long long)defaultValue; + +/** + * @brief Returns the bool for the specified key or the specified default value + * if it does not exist. + * + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. + * + * @param key The key for which the bool should be returned + * @param defaultValue The value to return if the key does not exist + * @return The bool for the specified key or the specified default value if it + * does not exist + */ +- (bool)boolForKey: (OFString *)key defaultValue: (bool)defaultValue; + +/** + * @brief Returns the float for the specified key or the specified default + * value if it does not exist. + * + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. + * + * @param key The key for which the float should be returned + * @param defaultValue The value to return if the key does not exist + * @return The float for the specified key or the specified default value if it + * does not exist + */ +- (float)floatForKey: (OFString *)key defaultValue: (float)defaultValue; + +/** + * @brief Returns the double for the specified key or the specified default + * value if it does not exist. + * + * If the specified key is a multi-key (see @ref stringArrayForKey:), the value + * of the first key/value pair found is returned. + * + * @param key The key for which the double should be returned + * @param defaultValue The value to return if the key does not exist + * @return The double for the specified key or the specified default value if + * it does not exist + */ +- (double)doubleForKey: (OFString *)key defaultValue: (double)defaultValue; + +/** + * @brief Returns an array of strings for the specified multi-key, or an empty + * array if the key does not exist. * * A multi-key is a key which exists several times in the same category. Each * occurrence of the key/value pair adds the respective value to the array. * * @param key The multi-key for which the array should be returned * @return The array for the specified key, or an empty array if it does not * exist */ -- (OFArray OF_GENERIC(OFString *) *)arrayForKey: (OFString *)key; +- (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified string. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is changed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), the + * value of the first key/value pair found is changed. * - * @param string The string to which the value of the key should be set + * @param string The string to which the key should be set * @param key The key for which the new value should be set */ -- (void)setString: (OFString *)string - forKey: (OFString *)key; +- (void)setString: (OFString *)string forKey: (OFString *)key; /** - * @brief Sets the value of the specified key to the specified integer. + * @brief Sets the value of the specified key to the specified long long. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is changed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), the value + * of the first key/value pair found is changed. * - * @param integer The integer to which the value of the key should be set + * @param longLong The long long to which the key should be set * @param key The key for which the new value should be set */ -- (void)setInteger: (long long)integer - forKey: (OFString *)key; +- (void)setLongLong: (long long)longLong forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified bool. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is changed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), the + * value of the first key/value pair found is changed. * - * @param bool_ The bool to which the value of the key should be set + * @param bool_ The bool to which the key should be set * @param key The key for which the new value should be set */ -- (void)setBool: (bool)bool_ - forKey: (OFString *)key; +- (void)setBool: (bool)bool_ forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified float. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is changed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), the + * value of the first key/value pair found is changed. * - * @param float_ The float to which the value of the key should be set + * @param float_ The float to which the key should be set * @param key The key for which the new value should be set */ -- (void)setFloat: (float)float_ - forKey: (OFString *)key; +- (void)setFloat: (float)float_ forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified double. * - * If the specified key is a multi-key (see @ref arrayForKey:), the value of - * the first key/value pair found is changed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), the value + * of the first key/value pair found is changed. * - * @param double_ The double to which the value of the key should be set + * @param double_ The double to which the key should be set * @param key The key for which the new value should be set */ -- (void)setDouble: (double)double_ - forKey: (OFString *)key; +- (void)setDouble: (double)double_ forKey: (OFString *)key; /** * @brief Sets the specified multi-key to the specified array of strings. * * It replaces the first occurrence of the multi-key with several key/value * pairs and removes all following occurrences. If the multi-key does not exist * yet, it is appended to the section. * - * See also @ref arrayForKey: for more information about multi-keys. + * See also @ref stringArrayForKey: for more information about multi-keys. * * @param array The array of strings to which the multi-key should be set * @param key The multi-key for which the new values should be set */ -- (void)setArray: (OFArray OF_GENERIC(OFString *) *)array - forKey: (OFString *)key; +- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array + forKey: (OFString *)key; /** * @brief Removes the value for the specified key * - * If the specified key is a multi-key (see @ref arrayForKey:), all key/value - * pairs matching the specified key are removed. + * If the specified key is a multi-key (see @ref stringValuesForKey:), all + * key/value pairs matching the specified key are removed. * * @param key The key of the value to remove */ - (void)removeValueForKey: (OFString *)key; @end OF_ASSUME_NONNULL_END Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -52,20 +50,15 @@ ![string containsString: @"\""]) return string; mutableString = [[string mutableCopy] autorelease]; - [mutableString replaceOccurrencesOfString: @"\\" - withString: @"\\\\"]; - [mutableString replaceOccurrencesOfString: @"\f" - withString: @"\\f"]; - [mutableString replaceOccurrencesOfString: @"\r" - withString: @"\\r"]; - [mutableString replaceOccurrencesOfString: @"\n" - withString: @"\\n"]; - [mutableString replaceOccurrencesOfString: @"\"" - withString: @"\\\""]; + [mutableString replaceOccurrencesOfString: @"\\" withString: @"\\\\"]; + [mutableString replaceOccurrencesOfString: @"\f" withString: @"\\f"]; + [mutableString replaceOccurrencesOfString: @"\r" withString: @"\\r"]; + [mutableString replaceOccurrencesOfString: @"\n" withString: @"\\n"]; + [mutableString replaceOccurrencesOfString: @"\"" withString: @"\\\""]; [mutableString prependString: @"\""]; [mutableString appendString: @"\""]; [mutableString makeImmutable]; @@ -82,20 +75,15 @@ return string; string = [string substringWithRange: of_range(1, string.length - 2)]; mutableString = [[string mutableCopy] autorelease]; - [mutableString replaceOccurrencesOfString: @"\\f" - withString: @"\f"]; - [mutableString replaceOccurrencesOfString: @"\\r" - withString: @"\r"]; - [mutableString replaceOccurrencesOfString: @"\\n" - withString: @"\n"]; - [mutableString replaceOccurrencesOfString: @"\\\"" - withString: @"\""]; - [mutableString replaceOccurrencesOfString: @"\\\\" - withString: @"\\"]; + [mutableString replaceOccurrencesOfString: @"\\f" withString: @"\f"]; + [mutableString replaceOccurrencesOfString: @"\\r" withString: @"\r"]; + [mutableString replaceOccurrencesOfString: @"\\n" withString: @"\n"]; + [mutableString replaceOccurrencesOfString: @"\\\"" withString: @"\""]; + [mutableString replaceOccurrencesOfString: @"\\\\" withString: @"\\"]; [mutableString makeImmutable]; return mutableString; } @@ -106,19 +94,29 @@ [_key release]; [_value release]; [super dealloc]; } + +- (OFString *)description +{ + return [OFString stringWithFormat: @"%@ = %@", _key, _value]; +} @end @implementation OFINICategoryComment - (void)dealloc { [_comment release]; [super dealloc]; } + +- (OFString *)description +{ + return [[_comment copy] autorelease]; +} @end @implementation OFINICategory @synthesize name = _name; @@ -180,12 +178,11 @@ } } - (OFString *)stringForKey: (OFString *)key { - return [self stringForKey: key - defaultValue: nil]; + return [self stringForKey: key defaultValue: nil]; } - (OFString *)stringForKey: (OFString *)key defaultValue: (OFString *)defaultValue { @@ -202,16 +199,15 @@ } return defaultValue; } -- (long long)integerForKey: (OFString *)key - defaultValue: (long long)defaultValue +- (long long)longLongForKey: (OFString *)key + defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringForKey: key defaultValue: nil]; long long ret; if (value != nil) ret = [value longLongValueWithBase: 0]; else @@ -220,16 +216,14 @@ objc_autoreleasePoolPop(pool); return ret; } -- (bool)boolForKey: (OFString *)key - defaultValue: (bool)defaultValue +- (bool)boolForKey: (OFString *)key defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringForKey: key defaultValue: nil]; bool ret; if (value != nil) { if ([value isEqual: @"true"]) ret = true; @@ -243,16 +237,14 @@ objc_autoreleasePoolPop(pool); return ret; } -- (float)floatForKey: (OFString *)key - defaultValue: (float)defaultValue +- (float)floatForKey: (OFString *)key defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringForKey: key defaultValue: nil]; float ret; if (value != nil) ret = value.floatValue; else @@ -261,16 +253,14 @@ objc_autoreleasePoolPop(pool); return ret; } -- (double)doubleForKey: (OFString *)key - defaultValue: (double)defaultValue +- (double)doubleForKey: (OFString *)key defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); - OFString *value = [self stringForKey: key - defaultValue: nil]; + OFString *value = [self stringForKey: key defaultValue: nil]; double ret; if (value != nil) ret = value.doubleValue; else @@ -279,11 +269,11 @@ objc_autoreleasePoolPop(pool); return ret; } -- (OFArray *)arrayForKey: (OFString *)key +- (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { @@ -303,12 +293,11 @@ [ret makeImmutable]; return ret; } -- (void)setString: (OFString *)string - forKey: (OFString *)key +- (void)setString: (OFString *)string forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); OFINICategoryPair *pair; for (id line in _lines) { @@ -344,52 +333,47 @@ } objc_autoreleasePoolPop(pool); } -- (void)setInteger: (long long)integer - forKey: (OFString *)key +- (void)setLongLong: (long long)longLong forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); - [self setString: [OFString stringWithFormat: @"%lld", integer] + [self setString: [OFString stringWithFormat: @"%lld", longLong] forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setBool: (bool)bool_ - forKey: (OFString *)key +- (void)setBool: (bool)bool_ forKey: (OFString *)key { - [self setString: (bool_ ? @"true" : @"false") - forKey: key]; + [self setString: (bool_ ? @"true" : @"false") forKey: key]; } -- (void)setFloat: (float)float_ - forKey: (OFString *)key +- (void)setFloat: (float)float_ forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setString: [OFString stringWithFormat: @"%g", float_] forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setDouble: (double)double_ - forKey: (OFString *)key +- (void)setDouble: (double)double_ forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setString: [OFString stringWithFormat: @"%g", double_] forKey: key]; objc_autoreleasePoolPop(pool); } -- (void)setArray: (OFArray *)array - forKey: (OFString *)key +- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array + forKey: (OFString *)key { void *pool; OFMutableArray *pairs; id const *lines; size_t count; @@ -402,19 +386,19 @@ pool = objc_autoreleasePoolPush(); pairs = [OFMutableArray arrayWithCapacity: array.count]; - for (id object in array) { + for (OFString *string in array) { OFINICategoryPair *pair; - if (![object isKindOfClass: [OFString class]]) + if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategoryPair alloc] init] autorelease]; pair->_key = [key copy]; - pair->_value = [object copy]; + pair->_value = [string copy]; [pairs addObject: pair]; } lines = _lines.objects; @@ -503,15 +487,19 @@ OFINICategoryPair *pair = line; OFString *key = escapeString(pair->_key); OFString *value = escapeString(pair->_value); OFString *tmp = [OFString stringWithFormat: @"%@=%@\r\n", key, value]; - - [stream writeString: tmp - encoding: encoding]; + [stream writeString: tmp encoding: encoding]; } else @throw [OFInvalidArgumentException exception]; } return true; } + +- (OFString *)description +{ + return [OFString stringWithFormat: @"<%@ \"%@\": %@>", + self.class, _name, _lines]; +} @end Index: src/OFINIFile.h ================================================================== --- src/OFINIFile.h +++ src/OFINIFile.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -32,10 +30,15 @@ @interface OFINIFile: OFObject { OFMutableArray OF_GENERIC(OFINICategory *) *_categories; } +/** + * @brief All categories in the INI file. + */ +@property (readonly, nonatomic) OFArray OF_GENERIC(OFINICategory *) *categories; + /** * @brief Creates a new OFINIFile with the contents of the specified file. * * @param path The path to the file whose contents the OFINIFile should contain * @@ -103,10 +106,9 @@ * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use */ -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; +- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding; @end OF_ASSUME_NONNULL_END Index: src/OFINIFile.m ================================================================== --- src/OFINIFile.m +++ src/OFINIFile.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -29,12 +27,11 @@ #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" OF_DIRECT_MEMBERS @interface OFINIFile () -- (void)of_parseFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; +- (void)of_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding; @end static bool isWhitespaceLine(OFString *line) { @@ -47,10 +44,12 @@ return true; } @implementation OFINIFile +@synthesize categories = _categories; + + (instancetype)fileWithPath: (OFString *)path { return [[[self alloc] initWithPath: path] autorelease]; } @@ -66,12 +65,11 @@ OF_INVALID_INIT_METHOD } - (instancetype)initWithPath: (OFString *)path { - return [self initWithPath: path - encoding: OF_STRING_ENCODING_UTF_8]; + return [self initWithPath: path encoding: OF_STRING_ENCODING_UTF_8]; } - (instancetype)initWithPath: (OFString *)path encoding: (of_string_encoding_t)encoding { @@ -78,12 +76,11 @@ self = [super init]; @try { _categories = [[OFMutableArray alloc] init]; - [self of_parseFile: path - encoding: encoding]; + [self of_parseFile: path encoding: encoding]; } @catch (id e) { [self release]; @throw e; } @@ -112,21 +109,19 @@ objc_autoreleasePoolPop(pool); return category; } -- (void)of_parseFile: (OFString *)path - encoding: (of_string_encoding_t)encoding +- (void)of_parseFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file; OFINICategory *category = nil; OFString *line; @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { /* Handle missing file like an empty file */ if (e.errNo == ENOENT) return; @@ -143,11 +138,10 @@ if (![line hasSuffix: @"]"]) @throw [OFInvalidFormatException exception]; categoryName = [line substringWithRange: of_range(1, line.length - 2)]; - category = [[[OFINICategory alloc] of_initWithName: categoryName] autorelease]; [_categories addObject: category]; } else { if (category == nil) @@ -160,20 +154,17 @@ objc_autoreleasePoolPop(pool); } - (void)writeToFile: (OFString *)path { - [self writeToFile: path - encoding: OF_STRING_ENCODING_UTF_8]; + [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding +- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); - OFFile *file = [OFFile fileWithPath: path - mode: @"w"]; + OFFile *file = [OFFile fileWithPath: path mode: @"w"]; bool first = true; for (OFINICategory *category in _categories) if ([category of_writeToStream: file encoding: encoding @@ -180,6 +171,12 @@ first: first]) first = false; objc_autoreleasePoolPop(pool); } + +- (OFString *)description +{ + return [OFString stringWithFormat: @"<%@: %@>", + self.class, _categories]; +} @end Index: src/OFINIFileSettings.h ================================================================== --- src/OFINIFileSettings.h +++ src/OFINIFileSettings.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFINIFileSettings.m ================================================================== --- src/OFINIFileSettings.m +++ src/OFINIFileSettings.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -69,102 +67,75 @@ *category = [path substringToIndex: pos]; *key = [path substringFromIndex: pos + 1]; } -- (void)setString: (OFString *)string - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setString: string - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (void)setInteger: (long long)integer - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setInteger: integer - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (void)setBool: (bool)bool_ - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setBool: bool_ - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (void)setFloat: (float)float_ - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setFloat: float_ - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (void)setDouble: (double)double_ - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setDouble: double_ - forKey: key]; - - objc_autoreleasePoolPop(pool); -} - -- (void)setArray: (OFArray *)array - forPath: (OFString *)path -{ - void *pool = objc_autoreleasePoolPush(); - OFString *category, *key; - - [self of_getCategory: &category - andKey: &key - forPath: path]; - - [[_INIFile categoryForName: category] setArray: array - forKey: key]; +- (void)setString: (OFString *)string forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setString: string forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setLongLong: (long long)longLong forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setLongLong: longLong + forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setBool: (bool)bool_ forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setBool: bool_ forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setFloat: (float)float_ forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setFloat: float_ forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setDouble: (double)double_ forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setDouble: double_ forKey: key]; + + objc_autoreleasePoolPop(pool); +} + +- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array + forPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFString *category, *key; + + [self of_getCategory: &category andKey: &key forPath: path]; + [[_INIFile categoryForName: category] setStringArray: array + forKey: key]; objc_autoreleasePoolPop(pool); } - (OFString *)stringForPath: (OFString *)path @@ -171,110 +142,89 @@ defaultValue: (OFString *)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key, *ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] stringForKey: key defaultValue: defaultValue]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } -- (long long)integerForPath: (OFString *)path - defaultValue: (long long)defaultValue +- (long long)longLongForPath: (OFString *)path + defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; long long ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] - integerForKey: key - defaultValue: defaultValue]; + longLongForKey: key + defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (bool)boolForPath: (OFString *)path - defaultValue: (bool)defaultValue +- (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; bool ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] boolForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (float)floatForPath: (OFString *)path - defaultValue: (float)defaultValue +- (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; float ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] floatForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (double)doubleForPath: (OFString *)path - defaultValue: (double)defaultValue +- (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; double ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] doubleForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } -- (OFArray *)arrayForPath: (OFString *)path +- (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; OFArray *ret; - [self of_getCategory: &category - andKey: &key - forPath: path]; - - ret = [[_INIFile categoryForName: category] arrayForKey: key]; + [self of_getCategory: &category andKey: &key forPath: path]; + ret = [[_INIFile categoryForName: category] stringArrayForKey: key]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -282,14 +232,11 @@ - (void)removeValueForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; - [self of_getCategory: &category - andKey: &key - forPath: path]; - + [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] removeValueForKey: key]; objc_autoreleasePoolPop(pool); } Index: src/OFIPSocketAsyncConnector.h ================================================================== --- src/OFIPSocketAsyncConnector.h +++ src/OFIPSocketAsyncConnector.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFIPSocketAsyncConnector.m ================================================================== --- src/OFIPSocketAsyncConnector.m +++ src/OFIPSocketAsyncConnector.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -77,21 +75,20 @@ OF_ENSURE(0); } else { #endif if ([_delegate respondsToSelector: @selector(socket:didConnectToHost:port:exception:)]) - [_delegate socket: _socket + [_delegate socket: _socket didConnectToHost: _host port: _port exception: _exception]; #ifdef OF_HAVE_BLOCKS } #endif } -- (void)of_socketDidConnect: (id)sock - exception: (id)exception +- (void)of_socketDidConnect: (id)sock exception: (id)exception { if (exception != nil) { /* * self might be retained only by the pending async requests, * which we're about to cancel. @@ -117,12 +114,11 @@ timerWithTimeInterval: 0 target: self selector: selector object: runLoop.currentMode repeats: false]; - [runLoop addTimer: timer - forMode: runLoop.currentMode]; + [runLoop addTimer: timer forMode: runLoop.currentMode]; } return; } @@ -143,12 +139,11 @@ [_socketAddresses itemAtIndex: _socketAddressesIndex++]; int errNo; of_socket_address_set_port(&address, _port); - if (![_socket of_createSocketForAddress: &address - errNo: &errNo]) { + if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket @@ -175,12 +170,11 @@ [_socket setCanBlock: true]; #else [_socket setCanBlock: false]; #endif - if (![_socket of_connectSocketToAddress: &address - errNo: &errNo]) { + if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket mode: runLoopMode delegate: self]; Index: src/OFIPXSocket.h ================================================================== --- src/OFIPXSocket.h +++ src/OFIPXSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFIPXSocket.m ================================================================== --- src/OFIPXSocket.m +++ src/OFIPXSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -123,11 +121,9 @@ /* If it's not IPX, no fix-up needed - it will fail anyway. */ if (fixedReceiver.family == OF_SOCKET_ADDRESS_FAMILY_IPX) fixedReceiver.sockaddr.ipx.sipx_type = _packetType; - [super sendBuffer: buffer - length: length - receiver: &fixedReceiver]; + [super sendBuffer: buffer length: length receiver: &fixedReceiver]; } #endif @end Index: src/OFInflate64Stream.h ================================================================== --- src/OFInflate64Stream.h +++ src/OFInflate64Stream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInflate64Stream.m ================================================================== --- src/OFInflate64Stream.m +++ src/OFInflate64Stream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInflateStream.h ================================================================== --- src/OFInflateStream.h +++ src/OFInflateStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInvertedCharacterSet.h ================================================================== --- src/OFInvertedCharacterSet.h +++ src/OFInvertedCharacterSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInvertedCharacterSet.m ================================================================== --- src/OFInvertedCharacterSet.m +++ src/OFInvertedCharacterSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFInvocation.h ================================================================== --- src/OFInvocation.h +++ src/OFInvocation.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -62,21 +60,19 @@ * @brief Sets the argument for the specified index. * * @param buffer The buffer in which the argument is stored * @param index The index of the argument to set */ -- (void)setArgument: (const void *)buffer - atIndex: (size_t)index; +- (void)setArgument: (const void *)buffer atIndex: (size_t)index; /** * @brief Gets the argument for the specified index. * * @param buffer The buffer in which the argument is stored * @param index The index of the argument to get */ -- (void)getArgument: (void *)buffer - atIndex: (size_t)index; +- (void)getArgument: (void *)buffer atIndex: (size_t)index; /** * @brief Sets the return value. * * @param buffer The buffer in which the return value is stored Index: src/OFInvocation.m ================================================================== --- src/OFInvocation.m +++ src/OFInvocation.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -84,23 +82,19 @@ [_returnValue release]; [super dealloc]; } -- (void)setArgument: (const void *)buffer - atIndex: (size_t)idx +- (void)setArgument: (const void *)buffer atIndex: (size_t)idx { OFMutableData *data = [_arguments objectAtIndex: idx]; - memcpy(data.mutableItems, buffer, data.itemSize); } -- (void)getArgument: (void *)buffer - atIndex: (size_t)idx +- (void)getArgument: (void *)buffer atIndex: (size_t)idx { OFData *data = [_arguments objectAtIndex: idx]; - memcpy(buffer, data.items, data.itemSize); } - (void)setReturnValue: (const void *)buffer { Index: src/OFJSONRepresentation.h ================================================================== --- src/OFJSONRepresentation.h +++ src/OFJSONRepresentation.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFKernelEventObserver.h ================================================================== --- src/OFKernelEventObserver.h +++ src/OFKernelEventObserver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFKernelEventObserver.m ================================================================== --- src/OFKernelEventObserver.m +++ src/OFKernelEventObserver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFKeyValueCoding.h ================================================================== --- src/OFKeyValueCoding.h +++ src/OFKeyValueCoding.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -61,21 +59,19 @@ * @brief Set the value for the specified key. * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value - forKey: (OFString *)key; +- (void)setValue: (nullable id)value forKey: (OFString *)key; /** * @brief Set the value for the specified key path. * * @param value The value for the specified key path * @param keyPath The key path of the value to set */ -- (void)setValue: (nullable id)value - forKeyPath: (OFString *)keyPath; +- (void)setValue: (nullable id)value forKeyPath: (OFString *)keyPath; /** * @brief This is called by @ref setValue:forKey: if the specified key does not * exist. * @@ -82,12 +78,11 @@ * By default, this throws an @ref OFUndefinedKeyException. * * @param value The value for the specified undefined key * @param key The undefined key of the value to set */ -- (void)setValue: (nullable id)value - forUndefinedKey: (OFString *)key; +- (void)setValue: (nullable id)value forUndefinedKey: (OFString *)key; /** * @brief This is called by @ref setValue:forKey: if the specified key is a * scalar, but the value specified is `nil`. * Index: src/OFKqueueKernelEventObserver.h ================================================================== --- src/OFKqueueKernelEventObserver.h +++ src/OFKqueueKernelEventObserver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFKqueueKernelEventObserver.m ================================================================== --- src/OFKqueueKernelEventObserver.m +++ src/OFKqueueKernelEventObserver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -87,15 +85,15 @@ memset(&event, 0, sizeof(event)); event.ident = object.fileDescriptorForReading; event.filter = EVFILT_READ; event.flags = EV_ADD; -#ifndef OF_NETBSD - event.udata = object; -#else - event.udata = (intptr_t)object; -#endif + /* + * Ugly hack required for NetBSD: NetBSD used `intptr_t` for udata, but + * switched this to `void *` in NetBSD 10. + */ + event.udata = (__typeof__(event.udata))object; if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; @@ -108,15 +106,15 @@ memset(&event, 0, sizeof(event)); event.ident = object.fileDescriptorForWriting; event.filter = EVFILT_WRITE; event.flags = EV_ADD; -#ifndef OF_NETBSD - event.udata = object; -#else - event.udata = (intptr_t)object; -#endif + /* + * Ugly hack required for NetBSD: NetBSD used `intptr_t` for udata, but + * switched this to `void *` in NetBSD 10. + */ + event.udata = (__typeof__(event.udata))object; if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; Index: src/OFLHAArchive.h ================================================================== --- src/OFLHAArchive.h +++ src/OFLHAArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -65,12 +63,11 @@ * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFLHAArchive */ -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode; ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /** * @brief Creates a new OFLHAArchive object with the specified file. * @@ -78,12 +75,11 @@ * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFLHAArchive */ -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode; ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode; #endif - (instancetype)init OF_UNAVAILABLE; /** @@ -109,12 +105,11 @@ * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFLHAArchive */ -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode; +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; #endif /** * @brief Returns the next entry from the LHA archive or `nil` if all entries * have been read. Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -70,33 +68,28 @@ @end @implementation OFLHAArchive @synthesize encoding = _encoding; -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { - return [[[self alloc] initWithStream: stream - mode: mode] autorelease]; + return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } #ifdef OF_HAVE_FILES -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode { - return [[[self alloc] initWithPath: path - mode: mode] autorelease]; + return [[[self alloc] initWithPath: path mode: mode] autorelease]; } #endif - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OFStream *)stream - mode: (OFString *)mode +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { _stream = [stream retain]; @@ -127,25 +120,21 @@ return self; } #ifdef OF_HAVE_FILES -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode { OFFile *file; if ([mode isEqual: @"a"]) - file = [[OFFile alloc] initWithPath: path - mode: @"r+"]; + file = [[OFFile alloc] initWithPath: path mode: @"r+"]; else - file = [[OFFile alloc] initWithPath: path - mode: mode]; + file = [[OFFile alloc] initWithPath: path mode: mode]; @try { - self = [self initWithStream: file - mode: mode]; + self = [self initWithStream: file mode: mode]; } @finally { [file release]; } return self; @@ -325,12 +314,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @@ -342,12 +330,11 @@ @throw [OFTruncatedDataException exception]; if (length > _toRead) length = _toRead; - ret = [_decompressedStream readIntoBuffer: buffer - length: length]; + ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; _CRC16 = of_crc16(_CRC16, buffer, ret); if (_toRead == 0) { @@ -417,12 +404,11 @@ size_t min = toRead; if (min > 512) min = 512; - toRead -= [stream readIntoBuffer: buffer - length: min]; + toRead -= [stream readIntoBuffer: buffer length: min]; } } _toRead = 0; _skipped = true; @@ -454,14 +440,12 @@ @try { _entry = [entry mutableCopy]; _encoding = encoding; - _headerOffset = [stream seekToOffset: 0 - whence: SEEK_CUR]; - [_entry of_writeToStream: stream - encoding: _encoding]; + _headerOffset = [stream seekToOffset: 0 whence: SEEK_CUR]; + [_entry of_writeToStream: stream encoding: _encoding]; /* * Retain stream last, so that -[close] called by -[dealloc] * doesn't write in case of an error. */ @@ -482,12 +466,11 @@ [_entry release]; [super dealloc]; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { uint32_t bytesWritten; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @@ -534,20 +517,16 @@ _entry.uncompressedSize = _bytesWritten; _entry.compressedSize = _bytesWritten; _entry.CRC16 = _CRC16; - offset = [_stream seekToOffset: 0 - whence:SEEK_CUR]; - [_stream seekToOffset: _headerOffset - whence: SEEK_SET]; - [_entry of_writeToStream: _stream - encoding: _encoding]; - [_stream seekToOffset: offset - whence: SEEK_SET]; + offset = [_stream seekToOffset: 0 whence: SEEK_CUR]; + [_stream seekToOffset: _headerOffset whence: SEEK_SET]; + [_entry of_writeToStream: _stream encoding: _encoding]; + [_stream seekToOffset: offset whence: SEEK_SET]; [_stream release]; _stream = nil; [super close]; } @end Index: src/OFLHAArchiveEntry+Private.h ================================================================== --- src/OFLHAArchiveEntry+Private.h +++ src/OFLHAArchiveEntry+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFLHAArchiveEntry.h ================================================================== --- src/OFLHAArchiveEntry.h +++ src/OFLHAArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFLHAArchiveEntry.m ================================================================== --- src/OFLHAArchiveEntry.m +++ src/OFLHAArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -584,56 +582,47 @@ [data addItems: [_compressionMethod cStringWithEncoding: OF_STRING_ENCODING_ASCII] count: 5]; tmp32 = OF_BSWAP32_IF_BE(_compressedSize); - [data addItems: &tmp32 - count: sizeof(tmp32)]; + [data addItems: &tmp32 count: sizeof(tmp32)]; tmp32 = OF_BSWAP32_IF_BE(_uncompressedSize); - [data addItems: &tmp32 - count: sizeof(tmp32)]; + [data addItems: &tmp32 count: sizeof(tmp32)]; tmp32 = OF_BSWAP32_IF_BE((uint32_t)_date.timeIntervalSince1970); - [data addItems: &tmp32 - count: sizeof(tmp32)]; + [data addItems: &tmp32 count: sizeof(tmp32)]; /* Reserved */ [data increaseCountBy: 1]; /* Header level */ [data addItem: "\x02"]; /* CRC16 */ tmp16 = OF_BSWAP16_IF_BE(_CRC16); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; /* Operating system identifier */ [data addItem: "U"]; /* Common header. Contains CRC16, which is written at the end. */ tmp16 = OF_BSWAP16_IF_BE(5); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x00"]; [data increaseCountBy: 2]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)fileNameLength + 3); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x01"]; - [data addItems: fileName - count: fileNameLength]; + [data addItems: fileName count: fileNameLength]; if (directoryNameLength > 0) { tmp16 = OF_BSWAP16_IF_BE((uint16_t)directoryNameLength + 3); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x02"]; - [data addItems: directoryName - count: directoryNameLength]; + [data addItems: directoryName count: directoryNameLength]; } if (_fileComment != nil) { size_t fileCommentLength = [_fileComment cStringLengthWithEncoding: encoding]; @@ -640,44 +629,38 @@ if (fileCommentLength > UINT16_MAX - 3) @throw [OFOutOfRangeException exception]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)fileCommentLength + 3); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x3F"]; [data addItems: [_fileComment cStringWithEncoding: encoding] count: fileCommentLength]; } if (_mode != nil) { tmp16 = OF_BSWAP16_IF_BE(5); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x50"]; tmp16 = OF_BSWAP16_IF_BE(_mode.unsignedShortValue); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; } if (_UID != nil || _GID != nil) { if (_UID == nil || _GID == nil) @throw [OFInvalidArgumentException exception]; tmp16 = OF_BSWAP16_IF_BE(7); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x51"]; tmp16 = OF_BSWAP16_IF_BE(_GID.unsignedShortValue); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; tmp16 = OF_BSWAP16_IF_BE(_UID.unsignedShortValue); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; } if (_group != nil) { size_t groupLength = [_group cStringLengthWithEncoding: encoding]; @@ -684,12 +667,11 @@ if (groupLength > UINT16_MAX - 3) @throw [OFOutOfRangeException exception]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)groupLength + 3); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x52"]; [data addItems: [_group cStringWithEncoding: encoding] count: groupLength]; } @@ -699,27 +681,24 @@ if (ownerLength > UINT16_MAX - 3) @throw [OFOutOfRangeException exception]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)ownerLength + 3); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x53"]; [data addItems: [_owner cStringWithEncoding: encoding] count: ownerLength]; } if (_modificationDate != nil) { tmp16 = OF_BSWAP16_IF_BE(7); - [data addItems: &tmp16 - count: sizeof(tmp16)]; + [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x54"]; tmp32 = OF_BSWAP32_IF_BE( (uint32_t)_modificationDate.timeIntervalSince1970); - [data addItems: &tmp32 - count: sizeof(tmp32)]; + [data addItems: &tmp32 count: sizeof(tmp32)]; } for (OFData *extension in _extensions) { size_t extensionLength = extension.count; @@ -728,14 +707,12 @@ if (extensionLength > UINT16_MAX - 2) @throw [OFOutOfRangeException exception]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)extensionLength + 2); - [data addItems: &tmp16 - count: sizeof(tmp16)]; - [data addItems: extension.items - count: extension.count]; + [data addItems: &tmp16 count: sizeof(tmp16)]; + [data addItems: extension.items count: extension.count]; } /* Zero-length extension to terminate */ [data increaseCountBy: 2]; Index: src/OFLHADecompressingStream.h ================================================================== --- src/OFLHADecompressingStream.h +++ src/OFLHADecompressingStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFLHADecompressingStream.m ================================================================== --- src/OFLHADecompressingStream.m +++ src/OFLHADecompressingStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -358,12 +356,11 @@ if (iter->next != NULL) [ret appendString: @",\n"]; objc_autoreleasePoolPop(pool); } - [ret replaceOccurrencesOfString: @"\n" - withString: @"\n\t"]; + [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n]"]; [ret makeImmutable]; return ret; @@ -416,13 +413,13 @@ return count; } - (OFEnumerator *)objectEnumerator { - return [[[OFListEnumerator alloc] - initWithList: self - mutationsPointer: &_mutations] autorelease]; + return [[[OFListEnumerator alloc] initWithList: self + mutationsPointer: &_mutations] + autorelease]; } @end @implementation OFListEnumerator - (instancetype)initWithList: (OFList *)list Index: src/OFLocale.h ================================================================== --- src/OFLocale.h +++ src/OFLocale.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -85,12 +83,13 @@ } } #endif static bool -evaluateCondition(OFString *condition, OFDictionary *variables) +evaluateCondition(OFString *condition_, OFDictionary *variables) { + OFMutableString *condition = [[condition_ mutableCopy] autorelease]; OFMutableArray *tokens, *operators, *stack; /* Empty condition is the fallback that's always true */ if (condition.length == 0) return true; @@ -98,16 +97,13 @@ /* * Dirty hack to allow not needing spaces after "!" or "(" and spaces * before ")". * TODO: Replace with a proper tokenizer. */ - condition = [condition stringByReplacingOccurrencesOfString: @"!" - withString: @"! "]; - condition = [condition stringByReplacingOccurrencesOfString: @"(" - withString: @"( "]; - condition = [condition stringByReplacingOccurrencesOfString: @")" - withString: @" )"]; + [condition replaceOccurrencesOfString: @"!" withString: @"! "]; + [condition replaceOccurrencesOfString: @"(" withString: @"( "]; + [condition replaceOccurrencesOfString: @")" withString: @" )"]; /* Substitute variables and convert to RPN first */ tokens = [OFMutableArray array]; operators = [OFMutableArray array]; for (OFString *token in [condition @@ -571,12 +567,11 @@ size_t last, UTF8StringLength; int state = 0; variables = [OFMutableDictionary dictionary]; while ((name = va_arg(arguments, OFConstantString *)) != nil) - [variables setObject: va_arg(arguments, id) - forKey: name]; + [variables setObject: va_arg(arguments, id) forKey: name]; for (OFDictionary *strings in _localizedStrings) { id string = [strings objectForKey: ID]; if (string == nil) Index: src/OFLocking.h ================================================================== --- src/OFLocking.h +++ src/OFLocking.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -208,12 +206,11 @@ _iVars->state[1] = 0xEFCDAB89; _iVars->state[2] = 0x98BADCFE; _iVars->state[3] = 0x10325476; } -- (void)updateWithBuffer: (const void *)buffer_ - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length { const unsigned char *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException Index: src/OFMapTable+Private.h ================================================================== --- src/OFMapTable+Private.h +++ src/OFMapTable+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMapTable.h ================================================================== --- src/OFMapTable.h +++ src/OFMapTable.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -162,12 +160,11 @@ * @brief Sets an object for a key. * * @param key The key to set * @param object The object to set the key to */ -- (void)setObject: (nullable void *)object - forKey: (nullable void *)key; +- (void)setObject: (nullable void *)object forKey: (nullable void *)key; /** * @brief Removes the object for the specified key from the map table. * * @param key The key whose object should be removed Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,17 +57,10 @@ defaultEqual(void *object1, void *object2) { return (object1 == object2); } -OF_DIRECT_MEMBERS -@interface OFMapTable () -- (void)of_setObject: (void *)object - forKey: (void *)key - hash: (unsigned long)hash; -@end - OF_DIRECT_MEMBERS @interface OFMapTableEnumerator () - (instancetype)of_initWithMapTable: (OFMapTable *)mapTable buckets: (struct of_map_table_bucket **)buckets capacity: (unsigned long)capacity @@ -188,10 +179,164 @@ free(_buckets); [super dealloc]; } + +static void +resizeForCount(OFMapTable *self, unsigned long count) +{ + unsigned long fullness, capacity; + struct of_map_table_bucket **buckets; + + if (count > ULONG_MAX / sizeof(*self->_buckets) || + count > ULONG_MAX / 8) + @throw [OFOutOfRangeException exception]; + + fullness = count * 8 / self->_capacity; + + if (fullness >= 6) { + if (self->_capacity > ULONG_MAX / 2) + return; + + capacity = self->_capacity * 2; + } else if (fullness <= 1) + capacity = self->_capacity / 2; + else + return; + + /* + * Don't downsize if we have an initial capacity or if we would fall + * below the minimum capacity. + */ + if ((capacity < self->_capacity && count > self->_count) || + capacity < MIN_CAPACITY) + return; + + buckets = of_alloc_zeroed(capacity, sizeof(*buckets)); + + for (unsigned long i = 0; i < self->_capacity; i++) { + if (self->_buckets[i] != NULL && + self->_buckets[i] != &deleted) { + unsigned long j, last; + + last = capacity; + + for (j = self->_buckets[i]->hash & (capacity - 1); + j < last && buckets[j] != NULL; j++); + + /* In case the last bucket is already used */ + if (j >= last) { + last = self->_buckets[i]->hash & (capacity - 1); + + for (j = 0; j < last && + buckets[j] != NULL; j++); + } + + if (j >= last) + @throw [OFOutOfRangeException exception]; + + buckets[j] = self->_buckets[i]; + } + } + + free(self->_buckets); + self->_buckets = buckets; + self->_capacity = capacity; +} + +static void +setObject(OFMapTable *restrict self, void *key, void *object, + unsigned long hash) +{ + unsigned long i, last; + void *old; + + if (key == NULL || object == NULL) + @throw [OFInvalidArgumentException exception]; + + hash = OF_ROL(hash, self->_rotate); + last = self->_capacity; + + for (i = hash & (self->_capacity - 1); + i < last && self->_buckets[i] != NULL; i++) { + if (self->_buckets[i] == &deleted) + continue; + + if (self->_keyFunctions.equal(self->_buckets[i]->key, key)) + break; + } + + /* In case the last bucket is already used */ + if (i >= last) { + last = hash & (self->_capacity - 1); + + for (i = 0; i < last && self->_buckets[i] != NULL; i++) { + if (self->_buckets[i] == &deleted) + continue; + + if (self->_keyFunctions.equal( + self->_buckets[i]->key, key)) + break; + } + } + + /* Key not in map table */ + if (i >= last || self->_buckets[i] == NULL || + self->_buckets[i] == &deleted || + !self->_keyFunctions.equal(self->_buckets[i]->key, key)) { + struct of_map_table_bucket *bucket; + + resizeForCount(self, self->_count + 1); + + self->_mutations++; + last = self->_capacity; + + for (i = hash & (self->_capacity - 1); i < last && + self->_buckets[i] != NULL && self->_buckets[i] != &deleted; + i++); + + /* In case the last bucket is already used */ + if (i >= last) { + last = hash & (self->_capacity - 1); + + for (i = 0; i < last && self->_buckets[i] != NULL && + self->_buckets[i] != &deleted; i++); + } + + if (i >= last) + @throw [OFOutOfRangeException exception]; + + bucket = of_alloc(1, sizeof(*bucket)); + + @try { + bucket->key = self->_keyFunctions.retain(key); + } @catch (id e) { + free(bucket); + @throw e; + } + + @try { + bucket->object = self->_objectFunctions.retain(object); + } @catch (id e) { + self->_keyFunctions.release(bucket->key); + free(bucket); + @throw e; + } + + bucket->hash = hash; + + self->_buckets[i] = bucket; + self->_count++; + + return; + } + + old = self->_buckets[i]->object; + self->_buckets[i]->object = self->_objectFunctions.retain(object); + self->_objectFunctions.release(old); +} - (bool)isEqual: (id)object { OFMapTable *mapTable; @@ -244,14 +389,13 @@ capacity: _capacity]; @try { for (unsigned long i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) - [copy of_setObject: _buckets[i]->object - forKey: _buckets[i]->key - hash: OF_ROR(_buckets[i]->hash, - _rotate)]; + setObject(copy, _buckets[i]->key, + _buckets[i]->object, + OF_ROR(_buckets[i]->hash, _rotate)); } @catch (id e) { [copy release]; @throw e; } @@ -296,162 +440,13 @@ } return NULL; } -- (void)of_resizeForCount: (unsigned long)count OF_DIRECT -{ - unsigned long fullness, capacity; - struct of_map_table_bucket **buckets; - - if (count > ULONG_MAX / sizeof(*_buckets) || count > ULONG_MAX / 8) - @throw [OFOutOfRangeException exception]; - - fullness = count * 8 / _capacity; - - if (fullness >= 6) { - if (_capacity > ULONG_MAX / 2) - return; - - capacity = _capacity * 2; - } else if (fullness <= 1) - capacity = _capacity / 2; - else - return; - - /* - * Don't downsize if we have an initial capacity or if we would fall - * below the minimum capacity. - */ - if ((capacity < _capacity && count > _count) || capacity < MIN_CAPACITY) - return; - - buckets = of_alloc_zeroed(capacity, sizeof(*buckets)); - - for (unsigned long i = 0; i < _capacity; i++) { - if (_buckets[i] != NULL && _buckets[i] != &deleted) { - unsigned long j, last; - - last = capacity; - - for (j = _buckets[i]->hash & (capacity - 1); - j < last && buckets[j] != NULL; j++); - - /* In case the last bucket is already used */ - if (j >= last) { - last = _buckets[i]->hash & (capacity - 1); - - for (j = 0; j < last && - buckets[j] != NULL; j++); - } - - if (j >= last) - @throw [OFOutOfRangeException exception]; - - buckets[j] = _buckets[i]; - } - } - - free(_buckets); - _buckets = buckets; - _capacity = capacity; -} - -- (void)of_setObject: (void *)object - forKey: (void *)key - hash: (unsigned long)hash -{ - unsigned long i, last; - void *old; - - if (key == NULL || object == NULL) - @throw [OFInvalidArgumentException exception]; - - hash = OF_ROL(hash, _rotate); - last = _capacity; - - for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { - if (_buckets[i] == &deleted) - continue; - - if (_keyFunctions.equal(_buckets[i]->key, key)) - break; - } - - /* In case the last bucket is already used */ - if (i >= last) { - last = hash & (_capacity - 1); - - for (i = 0; i < last && _buckets[i] != NULL; i++) { - if (_buckets[i] == &deleted) - continue; - - if (_keyFunctions.equal(_buckets[i]->key, key)) - break; - } - } - - /* Key not in map table */ - if (i >= last || _buckets[i] == NULL || _buckets[i] == &deleted || - !_keyFunctions.equal(_buckets[i]->key, key)) { - struct of_map_table_bucket *bucket; - - [self of_resizeForCount: _count + 1]; - - _mutations++; - last = _capacity; - - for (i = hash & (_capacity - 1); i < last && - _buckets[i] != NULL && _buckets[i] != &deleted; i++); - - /* In case the last bucket is already used */ - if (i >= last) { - last = hash & (_capacity - 1); - - for (i = 0; i < last && _buckets[i] != NULL && - _buckets[i] != &deleted; i++); - } - - if (i >= last) - @throw [OFOutOfRangeException exception]; - - bucket = of_alloc(1, sizeof(*bucket)); - - @try { - bucket->key = _keyFunctions.retain(key); - } @catch (id e) { - free(bucket); - @throw e; - } - - @try { - bucket->object = _objectFunctions.retain(object); - } @catch (id e) { - _keyFunctions.release(bucket->key); - free(bucket); - @throw e; - } - - bucket->hash = hash; - - _buckets[i] = bucket; - _count++; - - return; - } - - old = _buckets[i]->object; - _buckets[i]->object = _objectFunctions.retain(object); - _objectFunctions.release(old); -} - -- (void)setObject: (void *)object - forKey: (void *)key -{ - [self of_setObject: object - forKey: key - hash: _keyFunctions.hash(key)]; +- (void)setObject: (void *)object forKey: (void *)key +{ + setObject(self, key, object,_keyFunctions.hash(key)); } - (void)removeObjectForKey: (void *)key { unsigned long i, hash, last; @@ -474,11 +469,11 @@ free(_buckets[i]); _buckets[i] = &deleted; _count--; - [self of_resizeForCount: _count]; + resizeForCount(self, _count); return; } } @@ -499,11 +494,11 @@ free(_buckets[i]); _buckets[i] = &deleted; _count--; _mutations++; - [self of_resizeForCount: _count]; + resizeForCount(self, _count); return; } } } Index: src/OFMapTableDictionary.h ================================================================== --- src/OFMapTableDictionary.h +++ src/OFMapTableDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMapTableDictionary.m ================================================================== --- src/OFMapTableDictionary.m +++ src/OFMapTableDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -137,12 +135,11 @@ keyEnumerator = [dictionary keyEnumerator]; objectEnumerator = [dictionary objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [_mapTable setObject: object - forKey: key]; + [_mapTable setObject: object forKey: key]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -149,18 +146,16 @@ } return self; } -- (instancetype)initWithObject: (id)object - forKey: (id)key +- (instancetype)initWithObject: (id)object forKey: (id)key { self = [self initWithCapacity: 1]; @try { - [_mapTable setObject: object - forKey: key]; + [_mapTable setObject: object forKey: key]; } @catch (id e) { [self release]; @throw e; } @@ -175,22 +170,20 @@ @try { size_t i; for (i = 0; i < count; i++) - [_mapTable setObject: objects[i] - forKey: keys[i]]; + [_mapTable setObject: objects[i] forKey: keys[i]]; } @catch (id e) { [self release]; @throw e; } return self; } -- (instancetype)initWithKey: (id)firstKey - arguments: (va_list)arguments +- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { self = [super init]; @try { va_list argumentsCopy; @@ -218,22 +211,20 @@ _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions objectFunctions: objectFunctions capacity: count]; - [_mapTable setObject: object - forKey: key]; + [_mapTable setObject: object forKey: key]; for (i = 1; i < count; i++) { key = va_arg(arguments, id); object = va_arg(arguments, id); if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; - [_mapTable setObject: object - forKey: key]; + [_mapTable setObject: object forKey: key]; } } @catch (id e) { [self release]; @throw e; } @@ -360,12 +351,11 @@ keys[i++] = (id)*keyPtr; } objc_autoreleasePoolPop(pool); - ret = [OFArray arrayWithObjects: keys - count: count]; + ret = [OFArray arrayWithObjects: keys count: count]; } @finally { free(keys); } return ret; @@ -394,12 +384,11 @@ objects[i++] = (id)*objectPtr; } objc_autoreleasePoolPop(pool); - ret = [OFArray arrayWithObjects: objects - count: count]; + ret = [OFArray arrayWithObjects: objects count: count]; } @finally { free(objects); } return ret; Index: src/OFMapTableSet.h ================================================================== --- src/OFMapTableSet.h +++ src/OFMapTableSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMapTableSet.m ================================================================== --- src/OFMapTableSet.m +++ src/OFMapTableSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -100,12 +98,11 @@ self = [self initWithCapacity: count]; @try { for (id object in set) - [_mapTable setObject: (void *)1 - forKey: object]; + [_mapTable setObject: (void *)1 forKey: object]; } @catch (id e) { [self release]; @throw e; } @@ -128,39 +125,35 @@ self = [self initWithCapacity: count]; @try { for (id object in array) - [_mapTable setObject: (void *)1 - forKey: object]; + [_mapTable setObject: (void *)1 forKey: object]; } @catch (id e) { [self release]; @throw e; } return self; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [self initWithCapacity: count]; @try { for (size_t i = 0; i < count; i++) - [_mapTable setObject: (void *)1 - forKey: objects[i]]; + [_mapTable setObject: (void *)1 forKey: objects[i]]; } @catch (id e) { [self release]; @throw e; } return self; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { self = [super init]; @try { id object; @@ -174,16 +167,14 @@ _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions objectFunctions: objectFunctions capacity: count]; - [_mapTable setObject: (void *)1 - forKey: firstObject]; + [_mapTable setObject: (void *)1 forKey: firstObject]; while ((object = va_arg(arguments, id)) != nil) - [_mapTable setObject: (void *)1 - forKey: object]; + [_mapTable setObject: (void *)1 forKey: object]; } @catch (id e) { [self release]; @throw e; } Index: src/OFMessagePackExtension.h ================================================================== --- src/OFMessagePackExtension.h +++ src/OFMessagePackExtension.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -52,12 +50,11 @@ * * @param type The MessagePack extension type * @param data The data for the extension * @return A new, autoreleased OFMessagePackRepresentation */ -+ (instancetype)extensionWithType: (int8_t)type - data: (OFData *)data; ++ (instancetype)extensionWithType: (int8_t)type data: (OFData *)data; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFMessagePackRepresentation with the Index: src/OFMessagePackExtension.m ================================================================== --- src/OFMessagePackExtension.m +++ src/OFMessagePackExtension.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -24,24 +22,21 @@ #import "OFInvalidArgumentException.h" @implementation OFMessagePackExtension @synthesize type = _type, data = _data; -+ (instancetype)extensionWithType: (int8_t)type - data: (OFData *)data ++ (instancetype)extensionWithType: (int8_t)type data: (OFData *)data { - return [[[self alloc] initWithType: type - data: data] autorelease]; + return [[[self alloc] initWithType: type data: data] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithType: (int8_t)type - data: (OFData *)data +- (instancetype)initWithType: (int8_t)type data: (OFData *)data { self = [super init]; @try { if (data == nil || data.itemSize != 1) @@ -124,12 +119,11 @@ prefix = 0xC8; [ret addItem: &prefix]; length = OF_BSWAP16_IF_LE((uint16_t)count); - [ret addItems: &length - count: 2]; + [ret addItems: &length count: 2]; [ret addItem: &_type]; } else { uint32_t length; @@ -137,19 +131,16 @@ prefix = 0xC9; [ret addItem: &prefix]; length = OF_BSWAP32_IF_LE((uint32_t)count); - [ret addItems: &length - count: 4]; + [ret addItems: &length count: 4]; [ret addItem: &_type]; } - [ret addItems: _data.items - count: _data.count]; - + [ret addItems: _data.items count: _data.count]; [ret makeImmutable]; return ret; } Index: src/OFMessagePackRepresentation.h ================================================================== --- src/OFMessagePackRepresentation.h +++ src/OFMessagePackRepresentation.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMethodSignature.h ================================================================== --- src/OFMethodSignature.h +++ src/OFMethodSignature.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMethodSignature.m ================================================================== --- src/OFMethodSignature.m +++ src/OFMethodSignature.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableAdjacentArray.h ================================================================== --- src/OFMutableAdjacentArray.h +++ src/OFMutableAdjacentArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableAdjacentArray.m ================================================================== --- src/OFMutableAdjacentArray.m +++ src/OFMutableAdjacentArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,37 +57,32 @@ [object retain]; _mutations++; } -- (void)insertObject: (id)object - atIndex: (size_t)idx +- (void)insertObject: (id)object atIndex: (size_t)idx { if (object == nil) @throw [OFInvalidArgumentException exception]; @try { - [_array insertItem: &object - atIndex: idx]; + [_array insertItem: &object atIndex: idx]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } [object retain]; _mutations++; } -- (void)insertObjectsFromArray: (OFArray *)array - atIndex: (size_t)idx +- (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx { id const *objects = array.objects; size_t count = array.count; @try { - [_array insertItems: objects - atIndex: idx - count: count]; + [_array insertItems: objects atIndex: idx count: count]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } for (size_t i = 0; i < count; i++) @@ -96,12 +89,11 @@ [objects[i] retain]; _mutations++; } -- (void)replaceObject: (id)oldObject - withObject: (id)newObject +- (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects; size_t count; if (oldObject == nil || newObject == nil) @@ -119,12 +111,11 @@ return; } } } -- (void)replaceObjectAtIndex: (size_t)idx - withObject: (id)object +- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object { id *objects; id oldObject; if (object == nil) @@ -138,12 +129,11 @@ oldObject = objects[idx]; objects[idx] = [object retain]; [oldObject release]; } -- (void)replaceObjectIdenticalTo: (id)oldObject - withObject: (id)newObject +- (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { id *objects; size_t count; if (oldObject == nil || newObject == nil) @@ -272,12 +262,11 @@ _mutations++; #endif } -- (void)exchangeObjectAtIndex: (size_t)idx1 - withObjectAtIndex: (size_t)idx2 +- (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2 { id *objects = _array.mutableItems; size_t count = _array.count; id tmp; Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -82,12 +80,11 @@ * @brief Inserts an object to the OFArray at the specified index. * * @param object An object to add * @param index The index where the object should be inserted */ -- (void)insertObject: (ObjectType)object - atIndex: (size_t)index; +- (void)insertObject: (ObjectType)object atIndex: (size_t)index; /** * @brief Inserts the objects from the specified OFArray at the specified index. * * @param array An array of objects @@ -101,21 +98,19 @@ * other specified object. * * @param oldObject The object to replace * @param newObject The replacement object */ -- (void)replaceObject: (ObjectType)oldObject - withObject: (ObjectType)newObject; +- (void)replaceObject: (ObjectType)oldObject withObject: (ObjectType)newObject; /** * @brief Replaces the object at the specified index with the specified object. * * @param index The index of the object to replace * @param object The replacement object */ -- (void)replaceObjectAtIndex: (size_t)index - withObject: (ObjectType)object; +- (void)replaceObjectAtIndex: (size_t)index withObject: (ObjectType)object; /** * @brief Replaces the object at the specified index with the specified object. * * This method is the same as @ref replaceObjectAtIndex:withObject:. @@ -123,12 +118,11 @@ * This method is also used by the subscripting syntax. * * @param index The index of the object to replace * @param object The replacement object */ -- (void)setObject: (ObjectType)object - atIndexedSubscript: (size_t)index; +- (void)setObject: (ObjectType)object atIndexedSubscript: (size_t)index; /** * @brief Replaces the first object that has the same address as the specified * object with the other specified object. * @@ -190,12 +184,11 @@ * @brief Exchange the objects at the specified indices. * * @param index1 The index of the first object to exchange * @param index2 The index of the second object to exchange */ -- (void)exchangeObjectAtIndex: (size_t)index1 - withObjectAtIndex: (size_t)index2; +- (void)exchangeObjectAtIndex: (size_t)index1 withObjectAtIndex: (size_t)index2; /** * @brief Sorts the array in ascending order. */ - (void)sort; @@ -209,12 +202,11 @@ * Possible values are: * Value | Description * ---------------------------|------------------------- * `OF_ARRAY_SORT_DESCENDING` | Sort in descending order */ -- (void)sortUsingSelector: (SEL)selector - options: (int)options; +- (void)sortUsingSelector: (SEL)selector options: (int)options; #ifdef OF_HAVE_BLOCKS /** * @brief Sorts the array using the specified comparator and options. * @@ -223,12 +215,11 @@ * Possible values are: * Value | Description * ---------------------------|------------------------- * `OF_ARRAY_SORT_DESCENDING` | Sort in descending order */ -- (void)sortUsingComparator: (of_comparator_t)comparator - options: (int)options; +- (void)sortUsingComparator: (of_comparator_t)comparator options: (int)options; #endif /** * @brief Reverts the order of the objects in the array. */ Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -165,12 +163,11 @@ va_end(arguments); return ret; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFMutableAdjacentArray alloc] initWithObject: firstObject arguments: arguments]; } @@ -177,12 +174,11 @@ - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFMutableAdjacentArray alloc] initWithArray: array]; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFMutableAdjacentArray alloc] initWithObjects: objects count: count]; } @@ -257,51 +253,42 @@ return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object { - [self insertObject: object - atIndex: self.count]; + [self insertObject: object atIndex: self.count]; } - (void)addObjectsFromArray: (OFArray *)array { - [self insertObjectsFromArray: array - atIndex: self.count]; + [self insertObjectsFromArray: array atIndex: self.count]; } -- (void)insertObject: (id)object - atIndex: (size_t)idx +- (void)insertObject: (id)object atIndex: (size_t)idx { OF_UNRECOGNIZED_SELECTOR } -- (void)insertObjectsFromArray: (OFArray *)array - atIndex: (size_t)idx +- (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx { size_t i = 0; for (id object in array) - [self insertObject: object - atIndex: idx + i++]; + [self insertObject: object atIndex: idx + i++]; } -- (void)replaceObjectAtIndex: (size_t)idx - withObject: (id)object +- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object { OF_UNRECOGNIZED_SELECTOR } -- (void)setObject: (id)object - atIndexedSubscript: (size_t)idx +- (void)setObject: (id)object atIndexedSubscript: (size_t)idx { - [self replaceObjectAtIndex: idx - withObject: object]; + [self replaceObjectAtIndex: idx withObject: object]; } -- (void)replaceObject: (id)oldObject - withObject: (id)newObject +- (void)replaceObject: (id)oldObject withObject: (id)newObject { size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; @@ -308,19 +295,17 @@ count = self.count; for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: oldObject]) { - [self replaceObjectAtIndex: i - withObject: newObject]; + [self replaceObjectAtIndex: i withObject: newObject]; return; } } } -- (void)replaceObjectIdenticalTo: (id)oldObject - withObject: (id)newObject +- (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; @@ -327,12 +312,11 @@ count = self.count; for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == oldObject) { - [self replaceObjectAtIndex: i - withObject: newObject]; + [self replaceObjectAtIndex: i withObject: newObject]; return; } } } @@ -405,37 +389,32 @@ [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { id new = block(object, idx); if (new != object) - [self replaceObjectAtIndex: idx - withObject: new]; + [self replaceObjectAtIndex: idx withObject: new]; }]; } #endif -- (void)exchangeObjectAtIndex: (size_t)idx1 - withObjectAtIndex: (size_t)idx2 +- (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2 { id object1 = [self objectAtIndex: idx1]; id object2 = [self objectAtIndex: idx2]; [object1 retain]; @try { - [self replaceObjectAtIndex: idx1 - withObject: object2]; - [self replaceObjectAtIndex: idx2 - withObject: object1]; + [self replaceObjectAtIndex: idx1 withObject: object2]; + [self replaceObjectAtIndex: idx2 withObject: object1]; } @finally { [object1 release]; } } - (void)sort { - [self sortUsingSelector: @selector(compare:) - options: 0]; + [self sortUsingSelector: @selector(compare:) options: 0]; } - (void)sortUsingSelector: (SEL)selector options: (int)options { @@ -446,12 +425,11 @@ quicksort(self, 0, count - 1, selector, options); } #ifdef OF_HAVE_BLOCKS -- (void)sortUsingComparator: (of_comparator_t)comparator - options: (int)options +- (void)sortUsingComparator: (of_comparator_t)comparator options: (int)options { size_t count = self.count; if (count == 0 || count == 1) return; @@ -466,13 +444,12 @@ if (count == 0 || count == 1) return; for (i = 0, j = count - 1; i < j; i++, j--) - [self exchangeObjectAtIndex: i - withObjectAtIndex: j]; + [self exchangeObjectAtIndex: i withObjectAtIndex: j]; } - (void)makeImmutable { } @end Index: src/OFMutableData.h ================================================================== --- src/OFMutableData.h +++ src/OFMutableData.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -86,12 +84,11 @@ * * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ -+ (instancetype)dataWithItemSize: (size_t)itemSize - capacity: (size_t)capacity; ++ (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableData with an item size of 1. * * @return An initialized OFMutableData @@ -124,12 +121,11 @@ * * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData */ -- (instancetype)initWithItemSize: (size_t)itemSize - capacity: (size_t)capacity; +- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /** * @brief Returns a specific item of the OFMutableData. * * Modifying the returned item directly is allowed and will change the contents @@ -151,21 +147,19 @@ * @brief Adds an item to the OFMutableData at the specified index. * * @param item A pointer to an arbitrary item * @param index The index where the item should be added */ -- (void)insertItem: (const void *)item - atIndex: (size_t)index; +- (void)insertItem: (const void *)item atIndex: (size_t)index; /** * @brief Adds items from a C array to the OFMutableData. * * @param items A C array containing the items to add * @param count The number of items to add */ -- (void)addItems: (const void *)items - count: (size_t)count; +- (void)addItems: (const void *)items count: (size_t)count; /** * @brief Adds items from a C array to the OFMutableData at the specified index. * * @param items A C array containing the items to add Index: src/OFMutableData.m ================================================================== --- src/OFMutableData.m +++ src/OFMutableData.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -42,12 +40,11 @@ + (instancetype)dataWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } -+ (instancetype)dataWithItemSize: (size_t)itemSize - capacity: (size_t)capacity ++ (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } @@ -83,12 +80,11 @@ { return [self initWithItemSize: 1 capacity: capacity]; } -- (instancetype)initWithItemSize: (size_t)itemSize - capacity: (size_t)capacity +- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity { self = [super init]; @try { if (itemSize == 0) @@ -108,13 +104,11 @@ - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { - self = [super initWithItems: items - count: count - itemSize: itemSize]; + self = [super initWithItems: items count: count itemSize: itemSize]; _capacity = _count; return self; } @@ -122,13 +116,11 @@ - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { - self = [self initWithItems: items - count: count - itemSize: itemSize]; + self = [self initWithItems: items count: count itemSize: itemSize]; if (freeWhenDone) free(items); return self; @@ -196,20 +188,16 @@ memcpy(_items + _count * _itemSize, item, _itemSize); _count++; } -- (void)insertItem: (const void *)item - atIndex: (size_t)idx +- (void)insertItem: (const void *)item atIndex: (size_t)idx { - [self insertItems: item - atIndex: idx - count: 1]; + [self insertItems: item atIndex: idx count: 1]; } -- (void)addItems: (const void *)items - count: (size_t)count +- (void)addItems: (const void *)items count: (size_t)count { if (count > SIZE_MAX - _count) @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -71,12 +69,11 @@ * A key can be any object that conforms to the OFCopying protocol. * * @param key The key to set * @param object The object to set the key to */ -- (void)setObject: (ObjectType)object - forKey: (KeyType)key; +- (void)setObject: (ObjectType)object forKey: (KeyType)key; /** * @brief Sets an object for a key. * * A key can be any object that conforms to the OFCopying protocol. @@ -85,12 +82,11 @@ * * @param key The key to set * @param object The object to set the key to. If it is nil, this is equal to * calling @ref removeObjectForKey:. */ -- (void)setObject: (nullable ObjectType)object - forKeyedSubscript: (KeyType)key; +- (void)setObject: (nullable ObjectType)object forKeyedSubscript: (KeyType)key; /** * @brief Removes the object for the specified key from the dictionary. * * @param key The key whose object should be removed Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -40,19 +38,17 @@ { return (id)[[OFMutableMapTableDictionary alloc] initWithDictionary: dictionary]; } -- (instancetype)initWithObject: (id)object - forKey: (id)key +- (instancetype)initWithObject: (id)object forKey: (id)key { return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object forKey: key]; } -- (instancetype)initWithObjects: (OFArray *)objects - forKeys: (OFArray *)keys +- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects forKeys: keys]; } @@ -76,12 +72,11 @@ va_end(arguments); return ret; } -- (instancetype)initWithKey: (id)firstKey - arguments: (va_list)arguments +- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey arguments: arguments]; } @@ -156,22 +151,19 @@ - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } -- (void)setObject: (id)object - forKey: (id)key +- (void)setObject: (id)object forKey: (id)key { OF_UNRECOGNIZED_SELECTOR } -- (void)setObject: (id)object - forKeyedSubscript: (id)key +- (void)setObject: (id)object forKeyedSubscript: (id)key { if (object != nil) - [self setObject: object - forKey: key]; + [self setObject: object forKey: key]; else [self removeObjectForKey: key]; } - (void)removeObjectForKey: (id)key @@ -201,12 +193,11 @@ OFEnumerator *objectEnumerator = [dictionary objectEnumerator]; id key, object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [self setObject: object - forKey: key]; + [self setObject: object forKey: key]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS @@ -215,16 +206,15 @@ [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { id new = block(key, object); if (new != object) { - [self setObject: block(key, object) - forKey: key]; + [self setObject: block(key, object) forKey: key]; } }]; } #endif - (void)makeImmutable { } @end Index: src/OFMutableLHAArchiveEntry.h ================================================================== --- src/OFMutableLHAArchiveEntry.h +++ src/OFMutableLHAArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableLHAArchiveEntry.m ================================================================== --- src/OFMutableLHAArchiveEntry.m +++ src/OFMutableLHAArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableMapTableDictionary.h ================================================================== --- src/OFMutableMapTableDictionary.h +++ src/OFMutableMapTableDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableMapTableDictionary.m ================================================================== --- src/OFMutableMapTableDictionary.m +++ src/OFMutableMapTableDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,15 +29,13 @@ { if (self == [OFMutableMapTableDictionary class]) [self inheritMethodsFromClass: [OFMapTableDictionary class]]; } -- (void)setObject: (id)object - forKey: (id)key +- (void)setObject: (id)object forKey: (id)key { - [_mapTable setObject: object - forKey: key]; + [_mapTable setObject: object forKey: key]; } - (void)removeObjectForKey: (id)key { [_mapTable removeObjectForKey: key]; Index: src/OFMutableMapTableSet.h ================================================================== --- src/OFMutableMapTableSet.h +++ src/OFMutableMapTableSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableMapTableSet.m ================================================================== --- src/OFMutableMapTableSet.m +++ src/OFMutableMapTableSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -28,12 +26,11 @@ [self inheritMethodsFromClass: [OFMapTableSet class]]; } - (void)addObject: (id)object { - [_mapTable setObject: (void *)1 - forKey: object]; + [_mapTable setObject: (void *)1 forKey: object]; } - (void)removeObject: (id)object { [_mapTable removeObjectForKey: object]; Index: src/OFMutablePair.h ================================================================== --- src/OFMutablePair.h +++ src/OFMutablePair.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutablePair.m ================================================================== --- src/OFMutablePair.m +++ src/OFMutablePair.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -37,16 +35,14 @@ } - (id)copy { OFMutablePair *copy = [self mutableCopy]; - [copy makeImmutable]; - return copy; } - (void)makeImmutable { object_setClass(self, [OFPair class]); } @end Index: src/OFMutableSet.h ================================================================== --- src/OFMutableSet.h +++ src/OFMutableSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -58,19 +56,17 @@ va_end(arguments); return ret; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFMutableMapTableSet alloc] initWithObjects: objects count: count]; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFMutableMapTableSet alloc] initWithObject: firstObject arguments: arguments]; } @@ -182,11 +178,11 @@ cArray[i++] = object; } for (i = 0; i < count; i++) if (![set containsObject: cArray[i]]) - [self removeObject: cArray[i]]; + [self removeObject: cArray[i]]; } @finally { free(cArray); } objc_autoreleasePoolPop(pool); Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -33,12 +31,11 @@ * @brief Sets the character at the specified index. * * @param character The character to set * @param index The index where to set the character */ -- (void)setCharacter: (of_unichar_t)character - atIndex: (size_t)index; +- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)index; /** * @brief Appends another OFString to the OFMutableString. * * @param string An OFString to append @@ -111,12 +108,11 @@ * `const of_unichar_t *`. * * @param format A format string which generates the string to append * @param arguments The arguments used in the format string */ -- (void)appendFormat: (OFConstantString *)format - arguments: (va_list)arguments; +- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments; /** * @brief Prepends another OFString to the OFMutableString. * * @param string An OFString to prepend @@ -151,12 +147,11 @@ * @brief Inserts a string at the specified index. * * @param string The string to insert * @param index The index */ -- (void)insertString: (OFString *)string - atIndex: (size_t)index; +- (void)insertString: (OFString *)string atIndex: (size_t)index; /** * @brief Deletes the characters at the specified range. * * @param range The range of the characters which should be removed Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -174,11 +172,10 @@ initWithContentsOfFile: path encoding: encoding]; } #endif -#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - (instancetype)initWithContentsOfURL: (OFURL *)URL { return (id)[[OFMutableUTF8String alloc] initWithContentsOfURL: URL]; } @@ -187,11 +184,10 @@ { return (id)[[OFMutableUTF8String alloc] initWithContentsOfURL: URL encoding: encoding]; } -#endif - (instancetype)initWithSerialization: (OFXMLElement *)element { return (id)[[OFMutableUTF8String alloc] initWithSerialization: element]; } @@ -233,11 +229,11 @@ #ifdef OF_HAVE_UNICODE_TABLES - (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable wordMiddleTable: (const of_unichar_t *const [])middleTable wordStartTableSize: (size_t)startTableSize - wordMiddleTableSize: (size_t)middleTableSize OF_DIRECT + wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = self.characters; size_t length = self.length; bool isStart = true; @@ -254,22 +250,21 @@ table = middleTable; tableSize = middleTableSize; } if (c >> 8 < tableSize && table[c >> 8][c & 0xFF]) - [self setCharacter: table[c >> 8][c & 0xFF] - atIndex: i]; + [self setCharacter: table[c >> 8][c & 0xFF] atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #else -- (void)of_convertWithWordStartFunction: (char (*)(char))startFunction - wordMiddleFunction: (char (*)(char))middleFunction - OF_DIRECT +static void +convert(OFMutableString *self, char (*startFunction)(char), + char (*middleFunction)(char)) { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = self.characters; size_t length = self.length; bool isStart = true; @@ -278,93 +273,75 @@ char (*function)(char) = (isStart ? startFunction : middleFunction); of_unichar_t c = characters[i]; if (c <= 0x7F) - [self setCharacter: (int)function(c) - atIndex: i]; + [self setCharacter: (int)function(c) atIndex: i]; isStart = of_ascii_isspace(c); } objc_autoreleasePoolPop(pool); } #endif -- (void)setCharacter: (of_unichar_t)character - atIndex: (size_t)idx +- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx { void *pool = objc_autoreleasePoolPush(); - OFString *string; - - string = [OFString stringWithCharacters: &character - length: 1]; - - [self replaceCharactersInRange: of_range(idx, 1) - withString: string]; - + OFString *string = + [OFString stringWithCharacters: &character length: 1]; + [self replaceCharactersInRange: of_range(idx, 1) withString: string]; objc_autoreleasePoolPop(pool); } - (void)appendString: (OFString *)string { - [self insertString: string - atIndex: self.length]; + [self insertString: string atIndex: self.length]; } - (void)appendCharacters: (const of_unichar_t *)characters length: (size_t)length { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCharacters: characters length: length]]; - objc_autoreleasePoolPop(pool); } - (void)appendUTF8String: (const char *)UTF8String { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithUTF8String: UTF8String]]; - objc_autoreleasePoolPop(pool); } - (void)appendUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithUTF8String: UTF8String length: UTF8StringLength]]; - objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char *)cString encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCString: cString encoding: encoding]]; - objc_autoreleasePoolPop(pool); } - (void)appendCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { void *pool = objc_autoreleasePoolPush(); - [self appendString: [OFString stringWithCString: cString encoding: encoding length: cStringLength]]; - objc_autoreleasePoolPop(pool); } - (void)appendFormat: (OFConstantString *)format, ... { @@ -374,12 +351,11 @@ [self appendFormat: format arguments: arguments]; va_end(arguments); } -- (void)appendFormat: (OFConstantString *)format - arguments: (va_list)arguments +- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments { char *UTF8String; int UTF8StringLength; if (format == nil) @@ -388,33 +364,29 @@ if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { - [self appendUTF8String: UTF8String - length: UTF8StringLength]; + [self appendUTF8String: UTF8String length: UTF8StringLength]; } @finally { free(UTF8String); } } - (void)prependString: (OFString *)string { - [self insertString: string - atIndex: 0]; + [self insertString: string atIndex: 0]; } - (void)reverse { size_t i, j, length = self.length; for (i = 0, j = length - 1; i < length / 2; i++, j--) { of_unichar_t tmp = [self characterAtIndex: j]; - [self setCharacter: [self characterAtIndex: i] - atIndex: j]; - [self setCharacter: tmp - atIndex: i]; + [self setCharacter: [self characterAtIndex: i] atIndex: j]; + [self setCharacter: tmp atIndex: i]; } } #ifdef OF_HAVE_UNICODE_TABLES - (void)uppercase @@ -441,38 +413,32 @@ wordMiddleTableSize: OF_UNICODE_LOWERCASE_TABLE_SIZE]; } #else - (void)uppercase { - [self of_convertWithWordStartFunction: of_ascii_toupper - wordMiddleFunction: of_ascii_toupper]; + convert(self, of_ascii_toupper, of_ascii_toupper); } - (void)lowercase { - [self of_convertWithWordStartFunction: of_ascii_tolower - wordMiddleFunction: of_ascii_tolower]; + convert(self, of_ascii_tolower, of_ascii_tolower); } - (void)capitalize { - [self of_convertWithWordStartFunction: of_ascii_toupper - wordMiddleFunction: of_ascii_tolower]; + convert(self, of_ascii_toupper, of_ascii_tolower); } #endif -- (void)insertString: (OFString *)string - atIndex: (size_t)idx +- (void)insertString: (OFString *)string atIndex: (size_t)idx { - [self replaceCharactersInRange: of_range(idx, 0) - withString: string]; + [self replaceCharactersInRange: of_range(idx, 0) withString: string]; } - (void)deleteCharactersInRange: (of_range_t)range { - [self replaceCharactersInRange: range - withString: @""]; + [self replaceCharactersInRange: range withString: @""]; } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString *)replacement { Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableTarArchiveEntry.m ================================================================== --- src/OFMutableTarArchiveEntry.m +++ src/OFMutableTarArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableTriple.h ================================================================== --- src/OFMutableTriple.h +++ src/OFMutableTriple.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableTriple.m ================================================================== --- src/OFMutableTriple.m +++ src/OFMutableTriple.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableURL.h ================================================================== --- src/OFMutableURL.h +++ src/OFMutableURL.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableURL.m ================================================================== --- src/OFMutableURL.m +++ src/OFMutableURL.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -312,12 +310,11 @@ return copy; } - (void)appendPathComponent: (OFString *)component { - [self appendPathComponent: component - isDirectory: false]; + [self appendPathComponent: component isDirectory: false]; #ifdef OF_HAVE_FILES if ([_URLEncodedScheme isEqual: @"file"] && ![_URLEncodedPath hasSuffix: @"/"] && [[OFFileManager defaultManager] directoryExistsAtURL: self]) { @@ -413,12 +410,11 @@ break; } } } - [array insertObject: @"" - atIndex: 0]; + [array insertObject: @"" atIndex: 0]; if (endsWithEmpty) [array addObject: @""]; path = [array componentsJoinedByString: @"/"]; if (path.length == 0) Index: src/OFMutableUTF8String.h ================================================================== --- src/OFMutableUTF8String.h +++ src/OFMutableUTF8String.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableUTF8String.m ================================================================== --- src/OFMutableUTF8String.m +++ src/OFMutableUTF8String.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -55,23 +53,23 @@ - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String length: (size_t)UTF8StringLength freeWhenDone: (bool)freeWhenDone { - self = [self initWithUTF8String: UTF8String - length: UTF8StringLength]; + self = [self initWithUTF8String: UTF8String length: UTF8StringLength]; if (freeWhenDone) free(UTF8String); return self; } -- (void)of_convertWithWordStartTable: (const of_unichar_t *const[])startTable - wordMiddleTable: (const of_unichar_t *const[])middleTable +#ifdef OF_HAVE_UNICODE_TABLES +- (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable + wordMiddleTable: (const of_unichar_t *const [])middleTable wordStartTableSize: (size_t)startTableSize - wordMiddleTableSize: (size_t)middleTableSize OF_DIRECT + wordMiddleTableSize: (size_t)middleTableSize { of_unichar_t *unicodeString; size_t unicodeLen, newCStringLength; size_t i, j; char *newCString; @@ -187,13 +185,13 @@ /* * Even though cStringLength can change, length cannot, therefore no * need to change it. */ } +#endif -- (void)setCharacter: (of_unichar_t)character - atIndex: (size_t)idx +- (void)setCharacter: (of_unichar_t)character atIndex: (size_t)idx { char buffer[4]; of_unichar_t c; size_t lenNew; ssize_t lenOld; @@ -328,12 +326,11 @@ - (void)appendCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { if (encoding == OF_STRING_ENCODING_UTF_8) - [self appendUTF8String: cString - length: cStringLength]; + [self appendUTF8String: cString length: cStringLength]; else { void *pool = objc_autoreleasePoolPush(); [self appendString: [OFString stringWithCString: cString @@ -409,12 +406,11 @@ } @finally { free(tmp); } } -- (void)appendFormat: (OFConstantString *)format - arguments: (va_list)arguments +- (void)appendFormat: (OFConstantString *)format arguments: (va_list)arguments { char *UTF8String; int UTF8StringLength; if (format == nil) @@ -423,12 +419,11 @@ if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { - [self appendUTF8String: UTF8String - length: UTF8StringLength]; + [self appendUTF8String: UTF8String length: UTF8StringLength]; } @finally { free(UTF8String); } } @@ -510,12 +505,11 @@ /* UTF-8 does not allow more than 4 bytes per character */ @throw [OFInvalidEncodingException exception]; } } -- (void)insertString: (OFString *)string - atIndex: (size_t)idx +- (void)insertString: (OFString *)string atIndex: (size_t)idx { size_t newCStringLength; if (idx > _s->length) @throw [OFOutOfRangeException exception]; Index: src/OFMutableZIPArchiveEntry.h ================================================================== --- src/OFMutableZIPArchiveEntry.h +++ src/OFMutableZIPArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutableZIPArchiveEntry.m ================================================================== --- src/OFMutableZIPArchiveEntry.m +++ src/OFMutableZIPArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -33,13 +31,11 @@ @dynamic of_localFileHeaderOffset; - (id)copy { OFMutableZIPArchiveEntry *copy = [self mutableCopy]; - [copy makeImmutable]; - return copy; } - (void)setFileName: (OFString *)fileName { Index: src/OFMutex.h ================================================================== --- src/OFMutex.h +++ src/OFMutex.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFMutex.m ================================================================== --- src/OFMutex.m +++ src/OFMutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFNonretainedObjectValue.h ================================================================== --- src/OFNonretainedObjectValue.h +++ src/OFNonretainedObjectValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFNonretainedObjectValue.m ================================================================== --- src/OFNonretainedObjectValue.m +++ src/OFNonretainedObjectValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -35,12 +33,11 @@ - (const char *)objCType { return @encode(id); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_object)) @throw [OFOutOfRangeException exception]; memcpy(value, &_object, sizeof(_object)); Index: src/OFNull.h ================================================================== --- src/OFNull.h +++ src/OFNull.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFNull.m ================================================================== --- src/OFNull.m +++ src/OFNull.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -84,18 +82,16 @@ return [element autorelease]; } - (OFString *)JSONRepresentation { - return [self of_JSONRepresentationWithOptions: 0 - depth: 0]; + return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { - return [self of_JSONRepresentationWithOptions: options - depth: 0]; + return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { @@ -103,13 +99,11 @@ } - (OFData *)messagePackRepresentation { uint8_t type = 0xC0; - - return [OFData dataWithItems: &type - count: 1]; + return [OFData dataWithItems: &type count: 1]; } - (instancetype)autorelease { return self; Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -794,12 +792,11 @@ - (const char *)objCType { return _typeEncoding; } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { switch (*self.objCType) { #define CASE(enc, type, property) \ case enc: { \ type tmp = (type)self.property; \ @@ -1051,22 +1048,19 @@ element = [OFXMLElement elementWithName: @"OFNumber" namespace: OF_SERIALIZATION_NS stringValue: self.description]; if (*self.objCType == 'B') - [element addAttributeWithName: @"type" - stringValue: @"bool"]; + [element addAttributeWithName: @"type" stringValue: @"bool"]; else if (isFloat(self)) { - [element addAttributeWithName: @"type" - stringValue: @"float"]; + [element addAttributeWithName: @"type" stringValue: @"float"]; element.stringValue = [OFString stringWithFormat: @"%016" PRIx64, OF_BSWAP64_IF_LE(OF_DOUBLE_TO_INT_RAW(OF_BSWAP_DOUBLE_IF_LE( self.doubleValue)))]; } else if (isSigned(self)) - [element addAttributeWithName: @"type" - stringValue: @"signed"]; + [element addAttributeWithName: @"type" stringValue: @"signed"]; else if (isUnsigned(self)) [element addAttributeWithName: @"type" stringValue: @"unsigned"]; else @throw [OFInvalidFormatException exception]; @@ -1078,18 +1072,16 @@ return [element autorelease]; } - (OFString *)JSONRepresentation { - return [self of_JSONRepresentationWithOptions: 0 - depth: 0]; + return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { - return [self of_JSONRepresentationWithOptions: options - depth: 0]; + return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { @@ -1117,129 +1109,96 @@ OFMutableData *data; const char *typeEncoding = self.objCType; if (*typeEncoding == 'B') { uint8_t type = (self.boolValue ? 0xC3 : 0xC2); - - data = [OFMutableData dataWithItems: &type - count: 1]; + data = [OFMutableData dataWithItems: &type count: 1]; } else if (*typeEncoding == 'f') { uint8_t type = 0xCA; float tmp = OF_BSWAP_FLOAT_IF_LE(self.floatValue); - data = [OFMutableData dataWithItemSize: 1 - capacity: 5]; - + data = [OFMutableData dataWithCapacity: 5]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (*typeEncoding == 'd') { uint8_t type = 0xCB; double tmp = OF_BSWAP_DOUBLE_IF_LE(self.doubleValue); - data = [OFMutableData dataWithItemSize: 1 - capacity: 9]; - + data = [OFMutableData dataWithCapacity: 9]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (isSigned(self)) { long long value = self.longLongValue; if (value >= -32 && value < 0) { uint8_t tmp = 0xE0 | ((uint8_t)(value - 32) & 0x1F); - data = [OFMutableData dataWithItems: &tmp - count: 1]; + data = [OFMutableData dataWithItems: &tmp count: 1]; } else if (value >= INT8_MIN && value <= INT8_MAX) { uint8_t type = 0xD0; int8_t tmp = (int8_t)value; - data = [OFMutableData dataWithItemSize: 1 - capacity: 2]; - + data = [OFMutableData dataWithCapacity: 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (value >= INT16_MIN && value <= INT16_MAX) { uint8_t type = 0xD1; int16_t tmp = OF_BSWAP16_IF_LE((int16_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 3]; - + data = [OFMutableData dataWithCapacity: 3]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (value >= INT32_MIN && value <= INT32_MAX) { uint8_t type = 0xD2; int32_t tmp = OF_BSWAP32_IF_LE((int32_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 5]; - + data = [OFMutableData dataWithCapacity: 5]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (value >= INT64_MIN && value <= INT64_MAX) { uint8_t type = 0xD3; int64_t tmp = OF_BSWAP64_IF_LE((int64_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 9]; - + data = [OFMutableData dataWithCapacity: 9]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; } else if (isUnsigned(self)) { unsigned long long value = self.unsignedLongLongValue; if (value <= 127) { uint8_t tmp = ((uint8_t)value & 0x7F); - - data = [OFMutableData dataWithItems: &tmp - count: 1]; + data = [OFMutableData dataWithItems: &tmp count: 1]; } else if (value <= UINT8_MAX) { uint8_t type = 0xCC; uint8_t tmp = (uint8_t)value; - data = [OFMutableData dataWithItemSize: 1 - capacity: 2]; - + data = [OFMutableData dataWithCapacity: 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (value <= UINT16_MAX) { uint8_t type = 0xCD; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 3]; - + data = [OFMutableData dataWithCapacity: 3]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (value <= UINT32_MAX) { uint8_t type = 0xCE; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 5]; - + data = [OFMutableData dataWithCapacity: 5]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (value <= UINT64_MAX) { uint8_t type = 0xCF; uint64_t tmp = OF_BSWAP64_IF_LE((uint64_t)value); - data = [OFMutableData dataWithItemSize: 1 - capacity: 9]; - + data = [OFMutableData dataWithCapacity: 9]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; } else @throw [OFInvalidFormatException exception]; Index: src/OFObject+KeyValueCoding.h ================================================================== --- src/OFObject+KeyValueCoding.h +++ src/OFObject+KeyValueCoding.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFObject+KeyValueCoding.m ================================================================== --- src/OFObject+KeyValueCoding.m +++ src/OFObject+KeyValueCoding.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -139,16 +137,14 @@ return [ret autorelease]; } - (id)valueForUndefinedKey: (OFString *)key { - @throw [OFUndefinedKeyException exceptionWithObject: self - key: key]; + @throw [OFUndefinedKeyException exceptionWithObject: self key: key]; } -- (void)setValue: (id)value - forKey: (OFString *)key +- (void)setValue: (id)value forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); size_t keyLength; char *name; SEL selector; @@ -155,12 +151,11 @@ OFMethodSignature *methodSignature; const char *valueType; if ((keyLength = key.UTF8StringLength) < 1) { objc_autoreleasePoolPop(pool); - [self setValue: value - forUndefinedKey: key]; + [self setValue: value forUndefinedKey: key]; return; } name = of_alloc(keyLength + 5, 1); @try { @@ -181,12 +176,11 @@ methodSignature.numberOfArguments != 3 || *methodSignature.methodReturnType != 'v' || *[methodSignature argumentTypeAtIndex: 0] != '@' || *[methodSignature argumentTypeAtIndex: 1] != ':') { objc_autoreleasePoolPop(pool); - [self setValue: value - forUndefinedKey: key]; + [self setValue: value forUndefinedKey: key]; return; } valueType = [methodSignature argumentTypeAtIndex: 2]; @@ -228,40 +222,36 @@ CASE('f', float, floatValue) CASE('d', double, doubleValue) #undef CASE default: objc_autoreleasePoolPop(pool); - [self setValue: value - forUndefinedKey: key]; + [self setValue: value forUndefinedKey: key]; return; } objc_autoreleasePoolPop(pool); } -- (void)setValue: (id)value - forKeyPath: (OFString *)keyPath +- (void)setValue: (id)value forKeyPath: (OFString *)keyPath { void *pool = objc_autoreleasePoolPush(); OFArray *keys = [keyPath componentsSeparatedByString: @"."]; size_t keysCount = keys.count; id object = self; size_t i = 0; for (OFString *key in keys) { if (++i == keysCount) - [object setValue: value - forKey: key]; + [object setValue: value forKey: key]; else object = [object valueForKey: key]; } objc_autoreleasePoolPop(pool); } -- (void)setValue: (id)value - forUndefinedKey: (OFString *)key +- (void)setValue: (id)value forUndefinedKey: (OFString *)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; } Index: src/OFObject+Serialization.h ================================================================== --- src/OFObject+Serialization.h +++ src/OFObject+Serialization.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFObject+Serialization.m ================================================================== --- src/OFObject+Serialization.m +++ src/OFObject+Serialization.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -43,12 +41,11 @@ pool = objc_autoreleasePoolPush(); element = ((id )self).XMLElementBySerializing; root = [OFXMLElement elementWithName: @"serialization" namespace: OF_SERIALIZATION_NS]; - [root addAttributeWithName: @"version" - stringValue: @"1"]; + [root addAttributeWithName: @"version" stringValue: @"1"]; [root addChild: element]; ret = [@"\n" stringByAppendingString: [root XMLStringWithIndentation: 2]]; Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -401,12 +399,11 @@ * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @return The object returned by the method specified by the selector */ -- (nullable id)performSelector: (SEL)selector - withObject: (nullable id)object; +- (nullable id)performSelector: (SEL)selector withObject: (nullable id)object; /** * @brief Performs the specified selector with the specified objects. * * @param selector The selector to perform @@ -537,11 +534,11 @@ @property (class, readonly, nonatomic) OFString *className; @property (class, readonly, nullable, nonatomic) Class superclass; @property (class, readonly, nonatomic) OFString *description; # endif -# ifdef __cplusplus +# ifndef __cplusplus @property (readonly, nonatomic) Class class; # else @property (readonly, nonatomic, getter=class) Class class_; #endif @property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass; @@ -819,12 +816,11 @@ * @brief Performs the specified selector after the specified delay. * * @param selector The selector to perform * @param delay The delay after which the selector will be performed */ -- (void)performSelector: (SEL)selector - afterDelay: (of_time_interval_t)delay; +- (void)performSelector: (SEL)selector afterDelay: (of_time_interval_t)delay; /** * @brief Performs the specified selector with the specified object after the * specified delay. * Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -460,12 +458,11 @@ + (OFString *)description { return [self className]; } -+ (IMP)replaceClassMethod: (SEL)selector - withMethodFromClass: (Class)class ++ (IMP)replaceClassMethod: (SEL)selector withMethodFromClass: (Class)class { IMP method = [class methodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; @@ -472,12 +469,11 @@ return class_replaceMethod(object_getClass(self), selector, method, typeEncodingForSelector(object_getClass(class), selector)); } -+ (IMP)replaceInstanceMethod: (SEL)selector - withMethodFromClass: (Class)class ++ (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class { IMP method = [class instanceMethodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; @@ -608,12 +604,11 @@ #endif return imp(self, selector); } -- (id)performSelector: (SEL)selector - withObject: (id)object +- (id)performSelector: (SEL)selector withObject: (id)object { #if defined(OF_OBJFW_RUNTIME) id (*imp)(id, SEL, id) = (id (*)(id, SEL, id))objc_msg_lookup(self, selector); #elif defined(OF_APPLE_RUNTIME) @@ -668,12 +663,11 @@ #endif return imp(self, selector, object1, object2, object3, object4); } -- (void)performSelector: (SEL)selector - afterDelay: (of_time_interval_t)delay +- (void)performSelector: (SEL)selector afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); [OFTimer scheduledTimerWithTimeInterval: delay target: self Index: src/OFOptionsParser.h ================================================================== --- src/OFOptionsParser.h +++ src/OFOptionsParser.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPair.h ================================================================== --- src/OFPair.h +++ src/OFPair.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPair.m ================================================================== --- src/OFPair.m +++ src/OFPair.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPlugin.h ================================================================== --- src/OFPlugin.h +++ src/OFPlugin.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPointValue.h ================================================================== --- src/OFPointValue.h +++ src/OFPointValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPointValue.m ================================================================== --- src/OFPointValue.m +++ src/OFPointValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -36,12 +34,11 @@ - (const char *)objCType { return @encode(of_point_t); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_point)) @throw [OFOutOfRangeException exception]; memcpy(value, &_point, sizeof(_point)); Index: src/OFPointerValue.h ================================================================== --- src/OFPointerValue.h +++ src/OFPointerValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPointerValue.m ================================================================== --- src/OFPointerValue.m +++ src/OFPointerValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -35,12 +33,11 @@ - (const char *)objCType { return @encode(void *); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_pointer)) @throw [OFOutOfRangeException exception]; memcpy(value, &_pointer, sizeof(_pointer)); Index: src/OFPollKernelEventObserver.h ================================================================== --- src/OFPollKernelEventObserver.h +++ src/OFPollKernelEventObserver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFPollKernelEventObserver.m ================================================================== --- src/OFPollKernelEventObserver.m +++ src/OFPollKernelEventObserver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -67,24 +65,23 @@ free(_FDToObject); [super dealloc]; } -- (void)of_addObject: (id)object - fileDescriptor: (int)fd - events: (short)events OF_DIRECT +static void +addObject(OFPollKernelEventObserver *self, id object, int fd, short events) { struct pollfd *FDs; size_t count; bool found; if (fd < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: EBADF]; - FDs = _FDs.mutableItems; - count = _FDs.count; + FDs = self->_FDs.mutableItems; + count = self->_FDs.count; found = false; for (size_t i = 0; i < count; i++) { if (FDs[i].fd == fd) { FDs[i].events |= events; @@ -94,34 +91,33 @@ } if (!found) { struct pollfd p = { fd, events, 0 }; - if (fd > _maxFD) { - _maxFD = fd; - _FDToObject = of_realloc(_FDToObject, - (size_t)_maxFD + 1, sizeof(id)); + if (fd > self->_maxFD) { + self->_maxFD = fd; + self->_FDToObject = of_realloc(self->_FDToObject, + (size_t)self->_maxFD + 1, sizeof(id)); } - _FDToObject[fd] = object; - [_FDs addItem: &p]; + self->_FDToObject[fd] = object; + [self->_FDs addItem: &p]; } } -- (void)of_removeObject: (id)object - fileDescriptor: (int)fd - events: (short)events OF_DIRECT +static void +removeObject(OFPollKernelEventObserver *self, id object, int fd, short events) { struct pollfd *FDs; size_t nFDs; if (fd < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: EBADF]; - FDs = _FDs.mutableItems; - nFDs = _FDs.count; + FDs = self->_FDs.mutableItems; + nFDs = self->_FDs.count; for (size_t i = 0; i < nFDs; i++) { if (FDs[i].fd == fd) { FDs[i].events &= ~events; @@ -128,50 +124,42 @@ if (FDs[i].events == 0) { /* * TODO: Remove from and resize _FDToObject, * adjust _maxFD. */ - [_FDs removeItemAtIndex: i]; + [self->_FDs removeItemAtIndex: i]; } break; } } } - (void)addObjectForReading: (id )object { - [self of_addObject: object - fileDescriptor: object.fileDescriptorForReading - events: POLLIN]; + addObject(self, object, object.fileDescriptorForReading, POLLIN); [super addObjectForReading: object]; } - (void)addObjectForWriting: (id )object { - [self of_addObject: object - fileDescriptor: object.fileDescriptorForWriting - events: POLLOUT]; + addObject(self, object, object.fileDescriptorForWriting, POLLOUT); [super addObjectForWriting: object]; } - (void)removeObjectForReading: (id )object { - [self of_removeObject: object - fileDescriptor: object.fileDescriptorForReading - events: POLLIN]; + removeObject(self, object, object.fileDescriptorForReading, POLLIN); [super removeObjectForReading: object]; } - (void)removeObjectForWriting: (id )object { - [self of_removeObject: object - fileDescriptor: object.fileDescriptorForWriting - events: POLLOUT]; + removeObject(self, object, object.fileDescriptorForWriting, POLLOUT); [super removeObjectForWriting: object]; } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval DELETED src/OFProcess.h Index: src/OFProcess.h ================================================================== --- src/OFProcess.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS -#endif -#ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS -#endif - -#include "objfw-defs.h" - -#ifdef OF_HAVE_SYS_TYPES_H -# include -#endif - -#import "OFStream.h" -#import "OFKernelEventObserver.h" -#import "OFString.h" - -#ifdef OF_WINDOWS -# include -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFArray OF_GENERIC(ObjectType); -@class OFDictionary OF_GENERIC(KeyType, ObjectType); - -/** - * @class OFProcess OFProcess.h ObjFW/OFProcess.h - * - * @brief A class for stream-like communication with a newly created process. - */ -OF_SUBCLASSING_RESTRICTED -@interface OFProcess: OFStream -#ifndef OF_WINDOWS - -#endif -{ -#ifndef OF_WINDOWS - pid_t _pid; - int _readPipe[2], _writePipe[2]; -#else - HANDLE _process, _readPipe[2], _writePipe[2]; -#endif - int _status; - bool _atEndOfStream; -} - -/** - * @brief Creates a new OFProcess with the specified program and invokes the - * program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @return A new, autoreleased OFProcess. - */ -+ (instancetype)processWithProgram: (OFString *)program; - -/** - * @brief Creates a new OFProcess with the specified program and arguments and - * invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param arguments The arguments to pass to the program, or `nil` - * @return A new, autoreleased OFProcess. - */ -+ (instancetype) - processWithProgram: (OFString *)program - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; - -/** - * @brief Creates a new OFProcess with the specified program, program name and - * arguments and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param programName The program name for the program to invoke (argv[0]). - * Usually, this is equal to program. - * @param arguments The arguments to pass to the program, or `nil` - * @return A new, autoreleased OFProcess. - */ -+ (instancetype) - processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; - -/** - * @brief Creates a new OFProcess with the specified program, program name, - * arguments and environment and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param programName The program name for the program to invoke (argv[0]). - * Usually, this is equal to program. - * @param arguments The arguments to pass to the program, or `nil` - * @param environment The environment to pass to the program, or `nil`. If it - * is not `nil`, the passed dictionary will be used to - * override the environment. If you want to add to the - * existing environment, you need to get the existing - * environment first, copy it, modify it and then pass it. - * @return A new, autoreleased OFProcess. - */ -+ (instancetype) - processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments - environment: (nullable OFDictionary - OF_GENERIC(OFString *, OFString *) *)environment; - -- (instancetype)init OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated OFProcess with the specified program - * and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @return An initialized OFProcess. - */ -- (instancetype)initWithProgram: (OFString *)program; - -/** - * @brief Initializes an already allocated OFProcess with the specified program - * and arguments and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param arguments The arguments to pass to the program, or `nil` - * @return An initialized OFProcess. - */ -- (instancetype) - initWithProgram: (OFString *)program - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; - -/** - * @brief Initializes an already allocated OFProcess with the specified program, - * program name and arguments and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param programName The program name for the program to invoke (argv[0]). - * Usually, this is equal to program. - * @param arguments The arguments to pass to the program, or `nil` - * @return An initialized OFProcess. - */ -- (instancetype) - initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; - -/** - * @brief Initializes an already allocated OFProcess with the specified program, - * program name, arguments and environment and invokes the program. - * - * @param program The program to execute. If it does not start with a slash, the - * search path specified in PATH is used. - * @param programName The program name for the program to invoke (argv[0]). - * Usually, this is equal to program. - * @param arguments The arguments to pass to the program, or `nil` - * @param environment The environment to pass to the program, or `nil`. If it - * is not `nil`, the passed dictionary will be used to - * override the environment. If you want to add to the - * existing environment, you need to get the existing - * environment first, copy it, modify it and then pass it. - * @return An initialized OFProcess. - */ -- (instancetype) - initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments - environment: (nullable OFDictionary - OF_GENERIC(OFString *, OFString *) *)environment - OF_DESIGNATED_INITIALIZER; - -/** - * @brief Closes the write direction of the process. - * - * This method needs to be called for some programs before data can be read, - * since some programs don't start processing before the write direction is - * closed. - */ -- (void)closeForWriting; - -/** - * @brief Waits for the process to terminate and returns the exit status. - * - * If the process has already exited, this returns the exit status immediately. - */ -- (int)waitForTermination; -@end - -OF_ASSUME_NONNULL_END DELETED src/OFProcess.m Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#include "platform.h" - -#ifdef OF_WINDOWS -# include "platform/windows/OFProcess.m" -#else -# include "platform/posix/OFProcess.m" -#endif Index: src/OFRIPEMD160Hash.h ================================================================== --- src/OFRIPEMD160Hash.h +++ src/OFRIPEMD160Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRIPEMD160Hash.m ================================================================== --- src/OFRIPEMD160Hash.m +++ src/OFRIPEMD160Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -223,12 +221,11 @@ _iVars->state[2] = 0x98BADCFE; _iVars->state[3] = 0x10325476; _iVars->state[4] = 0xC3D2E1F0; } -- (void)updateWithBuffer: (const void *)buffer_ - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length { const unsigned char *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException Index: src/OFRangeCharacterSet.h ================================================================== --- src/OFRangeCharacterSet.h +++ src/OFRangeCharacterSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRangeCharacterSet.m ================================================================== --- src/OFRangeCharacterSet.m +++ src/OFRangeCharacterSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRangeValue.h ================================================================== --- src/OFRangeValue.h +++ src/OFRangeValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRangeValue.m ================================================================== --- src/OFRangeValue.m +++ src/OFRangeValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -36,12 +34,11 @@ - (const char *)objCType { return @encode(of_range_t); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_range)) @throw [OFOutOfRangeException exception]; memcpy(value, &_range, sizeof(_range)); Index: src/OFRectangleValue.h ================================================================== --- src/OFRectangleValue.h +++ src/OFRectangleValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRectangleValue.m ================================================================== --- src/OFRectangleValue.m +++ src/OFRectangleValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -36,12 +34,11 @@ - (const char *)objCType { return @encode(of_rectangle_t); } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { if (size != sizeof(_rectangle)) @throw [OFOutOfRangeException exception]; memcpy(value, &_rectangle, sizeof(_rectangle)); Index: src/OFRecursiveMutex.h ================================================================== --- src/OFRecursiveMutex.h +++ src/OFRecursiveMutex.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRecursiveMutex.m ================================================================== --- src/OFRecursiveMutex.m +++ src/OFRecursiveMutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFRunLoop+Private.h ================================================================== --- src/OFRunLoop+Private.h +++ src/OFRunLoop+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -128,10 +126,9 @@ # endif delegate: (nullable id )delegate; + (void)of_cancelAsyncRequestsForObject: (id)object mode: (of_run_loop_mode_t)mode; #endif -- (void)of_removeTimer: (OFTimer *)timer - forMode: (of_run_loop_mode_t)mode; +- (void)of_removeTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode; @end OF_ASSUME_NONNULL_END Index: src/OFRunLoop.h ================================================================== --- src/OFRunLoop.h +++ src/OFRunLoop.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -102,12 +100,11 @@ * @brief Adds an OFTimer to the run loop for the specified mode. * * @param timer The timer to add * @param mode The run loop mode in which to run the timer */ -- (void)addTimer: (OFTimer *)timer - forMode: (of_run_loop_mode_t)mode; +- (void)addTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode; #ifdef OF_AMIGAOS /** * @brief Adds an Exec Signal to the run loop. * @@ -120,13 +117,11 @@ * @param target The target to call when the signal was received * @param selector The selector to call on the target when the signal was * received. The selector must have one parameter for the ULONG * of the signal that was received. */ -- (void)addExecSignal: (ULONG)signal - target: (id)target - selector: (SEL)selector; +- (void)addExecSignal: (ULONG)signal target: (id)target selector: (SEL)selector; /** * @brief Adds an Exec Signal to the run loop for the specified mode. * * If a signal is added multiple times, the specified methods will be performed Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -76,16 +74,10 @@ # endif #endif } @end -OF_DIRECT_MEMBERS -@interface OFRunLoop () -- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode - create: (bool)create; -@end - #ifdef OF_HAVE_SOCKETS @interface OFRunLoopQueueItem: OFObject { @public id _delegate; @@ -429,12 +421,11 @@ { size_t length; id exception = nil; @try { - length = [object readIntoBuffer: _buffer - length: _length]; + length = [object readIntoBuffer: _buffer length: _length]; } @catch (id e) { length = 0; exception = e; } @@ -738,13 +729,11 @@ selector: @selector(of_socketDidConnect: exception:) object: object object: exception repeats: false]; - - [runLoop addTimer: timer - forMode: runLoop.currentMode]; + [runLoop addTimer: timer forMode: runLoop.currentMode]; } return false; } @end @@ -909,12 +898,11 @@ { size_t length; id exception = nil; @try { - length = [object receiveIntoBuffer: _buffer - length: _length]; + length = [object receiveIntoBuffer: _buffer length: _length]; } @catch (id e) { length = 0; exception = e; } @@ -1025,24 +1013,50 @@ + (void)of_setMainRunLoop: (OFRunLoop *)runLoop { mainRunLoop = [runLoop retain]; } + +static OFRunLoopState * +stateForMode(OFRunLoop *self, of_run_loop_mode_t mode, bool create) +{ + OFRunLoopState *state; + +#ifdef OF_HAVE_THREADS + [self->_statesMutex lock]; + @try { +#endif + state = [self->_states objectForKey: mode]; + + if (create && state == nil) { + state = [[OFRunLoopState alloc] init]; + @try { + [self->_states setObject: state forKey: mode]; + } @finally { + [state release]; + } + } +#ifdef OF_HAVE_THREADS + } @finally { + [self->_statesMutex unlock]; + } +#endif + + return state; +} #ifdef OF_HAVE_SOCKETS # define NEW_READ(type, object, mode) \ void *pool = objc_autoreleasePoolPush(); \ OFRunLoop *runLoop = [self currentRunLoop]; \ - OFRunLoopState *state = [runLoop of_stateForMode: mode \ - create: true]; \ + OFRunLoopState *state = stateForMode(runLoop, mode, true); \ OFList *queue = [state->_readQueues objectForKey: object]; \ type *queueItem; \ \ if (queue == nil) { \ queue = [OFList list]; \ - [state->_readQueues setObject: queue \ - forKey: object]; \ + [state->_readQueues setObject: queue forKey: object]; \ } \ \ if (queue.count == 0) \ [state->_kernelEventObserver \ addObjectForReading: object]; \ @@ -1049,19 +1063,17 @@ \ queueItem = [[[type alloc] init] autorelease]; # define NEW_WRITE(type, object, mode) \ void *pool = objc_autoreleasePoolPush(); \ OFRunLoop *runLoop = [self currentRunLoop]; \ - OFRunLoopState *state = [runLoop of_stateForMode: mode \ - create: true]; \ + OFRunLoopState *state = stateForMode(runLoop, mode, true); \ OFList *queue = [state->_writeQueues objectForKey: object]; \ type *queueItem; \ \ if (queue == nil) { \ queue = [OFList list]; \ - [state->_writeQueues setObject: queue \ - forKey: object]; \ + [state->_writeQueues setObject: queue forKey: object]; \ } \ \ if (queue.count == 0) \ [state->_kernelEventObserver \ addObjectForWriting: object]; \ @@ -1295,12 +1307,11 @@ + (void)of_cancelAsyncRequestsForObject: (id)object mode: (of_run_loop_mode_t)mode { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop = [self currentRunLoop]; - OFRunLoopState *state = [runLoop of_stateForMode: mode - create: false]; + OFRunLoopState *state = stateForMode(runLoop, mode, false); OFList *queue; if (state == nil) return; @@ -1370,50 +1381,18 @@ #endif [super dealloc]; } -- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode - create: (bool)create -{ - OFRunLoopState *state; - -#ifdef OF_HAVE_THREADS - [_statesMutex lock]; - @try { -#endif - state = [_states objectForKey: mode]; - - if (create && state == nil) { - state = [[OFRunLoopState alloc] init]; - @try { - [_states setObject: state - forKey: mode]; - } @finally { - [state release]; - } - } -#ifdef OF_HAVE_THREADS - } @finally { - [_statesMutex unlock]; - } -#endif - - return state; -} - -- (void)addTimer: (OFTimer *)timer -{ - [self addTimer: timer - forMode: of_run_loop_mode_default]; -} - -- (void)addTimer: (OFTimer *)timer - forMode: (of_run_loop_mode_t)mode -{ - OFRunLoopState *state = [self of_stateForMode: mode - create: true]; +- (void)addTimer: (OFTimer *)timer +{ + [self addTimer: timer forMode: of_run_loop_mode_default]; +} + +- (void)addTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode +{ + OFRunLoopState *state = stateForMode(self, mode, true); #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; @try { #endif @@ -1422,25 +1401,22 @@ } @finally { [state->_timersQueueMutex unlock]; } #endif - [timer of_setInRunLoop: self - mode: mode]; + [timer of_setInRunLoop: self mode: mode]; #if defined(OF_HAVE_SOCKETS) [state->_kernelEventObserver cancel]; #elif defined(OF_HAVE_THREADS) [state->_condition signal]; #endif } -- (void)of_removeTimer: (OFTimer *)timer - forMode: (of_run_loop_mode_t)mode +- (void)of_removeTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode { - OFRunLoopState *state = [self of_stateForMode: mode - create: false]; + OFRunLoopState *state = stateForMode(self, mode, false); if (state == nil) return; #ifdef OF_HAVE_THREADS @@ -1462,13 +1438,11 @@ } #endif } #ifdef OF_AMIGAOS -- (void)addExecSignal: (ULONG)signal - target: (id)target - selector: (SEL)selector +- (void)addExecSignal: (ULONG)signal target: (id)target selector: (SEL)selector { [self addExecSignal: signal forMode: of_run_loop_mode_default target: target selector: selector]; @@ -1477,12 +1451,11 @@ - (void)addExecSignal: (ULONG)signal forMode: (of_run_loop_mode_t)mode target: (id)target selector: (SEL)selector { - OFRunLoopState *state = [self of_stateForMode: mode - create: true]; + OFRunLoopState *state = stateForMode(self, mode, true); # ifdef OF_HAVE_THREADS [state->_execSignalsMutex lock]; @try { # endif @@ -1521,12 +1494,11 @@ - (void)removeExecSignal: (ULONG)signal forMode: (of_run_loop_mode_t)mode target: (id)target selector: (SEL)selector { - OFRunLoopState *state = [self of_stateForMode: mode - create: false]; + OFRunLoopState *state = stateForMode(self, mode, false); if (state == nil) return; # ifdef OF_HAVE_THREADS @@ -1582,21 +1554,18 @@ { _stop = false; while (!_stop && (deadline == nil || deadline.timeIntervalSinceNow >= 0)) - [self runMode: of_run_loop_mode_default - beforeDate: deadline]; + [self runMode: of_run_loop_mode_default beforeDate: deadline]; } -- (void)runMode: (of_run_loop_mode_t)mode - beforeDate: (OFDate *)deadline +- (void)runMode: (of_run_loop_mode_t)mode beforeDate: (OFDate *)deadline { void *pool = objc_autoreleasePoolPush(); of_run_loop_mode_t previousMode = _currentMode; - OFRunLoopState *state = [self of_stateForMode: mode - create: false]; + OFRunLoopState *state = stateForMode(self, mode, false); if (state == nil) return; _currentMode = mode; @@ -1622,12 +1591,11 @@ retain] autorelease]; [state->_timersQueue removeListObject: listObject]; - [timer of_setInRunLoop: nil - mode: nil]; + [timer of_setInRunLoop: nil mode: nil]; } else break; #ifdef OF_HAVE_THREADS } @finally { [state->_timersQueueMutex unlock]; @@ -1726,12 +1694,12 @@ } } - (void)stop { - OFRunLoopState *state = [self of_stateForMode: of_run_loop_mode_default - create: false]; + OFRunLoopState *state = + stateForMode(self, of_run_loop_mode_default, false); _stop = true; if (state == nil) return; Index: src/OFSHA1Hash.h ================================================================== --- src/OFSHA1Hash.h +++ src/OFSHA1Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -183,12 +181,11 @@ _iVars->state[2] = 0x98BADCFE; _iVars->state[3] = 0x10325476; _iVars->state[4] = 0xC3D2E1F0; } -- (void)updateWithBuffer: (const void *)buffer_ - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length { const unsigned char *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException Index: src/OFSHA224Hash.h ================================================================== --- src/OFSHA224Hash.h +++ src/OFSHA224Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA224Hash.m ================================================================== --- src/OFSHA224Hash.m +++ src/OFSHA224Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA224Or256Hash.h ================================================================== --- src/OFSHA224Or256Hash.h +++ src/OFSHA224Or256Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA224Or256Hash.m ================================================================== --- src/OFSHA224Or256Hash.m +++ src/OFSHA224Or256Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -199,12 +197,11 @@ copy->_calculated = _calculated; return copy; } -- (void)updateWithBuffer: (const void *)buffer_ - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length { const unsigned char *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException Index: src/OFSHA256Hash.h ================================================================== --- src/OFSHA256Hash.h +++ src/OFSHA256Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA256Hash.m ================================================================== --- src/OFSHA256Hash.m +++ src/OFSHA256Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA384Hash.h ================================================================== --- src/OFSHA384Hash.h +++ src/OFSHA384Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA384Hash.m ================================================================== --- src/OFSHA384Hash.m +++ src/OFSHA384Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA384Or512Hash.h ================================================================== --- src/OFSHA384Or512Hash.h +++ src/OFSHA384Or512Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA384Or512Hash.m ================================================================== --- src/OFSHA384Or512Hash.m +++ src/OFSHA384Or512Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -210,12 +208,11 @@ copy->_calculated = _calculated; return copy; } -- (void)updateWithBuffer: (const void *)buffer_ - length: (size_t)length +- (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length { const unsigned char *buffer = buffer_; if (_calculated) @throw [OFHashAlreadyCalculatedException Index: src/OFSHA512Hash.h ================================================================== --- src/OFSHA512Hash.h +++ src/OFSHA512Hash.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSHA512Hash.m ================================================================== --- src/OFSHA512Hash.m +++ src/OFSHA512Hash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSPXSocket.h ================================================================== --- src/OFSPXSocket.h +++ src/OFSPXSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSPXSocket.m ================================================================== --- src/OFSPXSocket.m +++ src/OFSPXSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -110,20 +108,18 @@ of_socket_address_t address = of_socket_address_ipx(_node, _network, _port); id exception = nil; int errNo; - if (![_socket of_createSocketForAddress: &address - errNo: &errNo]) { + if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } _socket.canBlock = false; - if (![_socket of_connectSocketToAddress: &address - errNo: &errNo]) { + if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket mode: runLoopMode delegate: self]; return; @@ -139,12 +135,11 @@ withObject: _socket withObject: exception afterDelay: 0]; } -- (void)of_socketDidConnect: (id)sock - exception: (id)exception +- (void)of_socketDidConnect: (id)sock exception: (id)exception { id delegate = ((OFSPXSocket *)sock).delegate; if (exception == nil) ((OFSPXSocket *)sock).canBlock = true; @@ -230,21 +225,19 @@ { of_socket_address_t address = of_socket_address_ipx(node, network, port); int errNo; - if (![self of_createSocketForAddress: &address - errNo: &errNo]) + if (![self of_createSocketForAddress: &address errNo: &errNo]) @throw [OFConnectionFailedException exceptionWithNode: node network: network port: port socket: self errNo: errNo]; - if (![self of_connectSocketToAddress: &address - errNo: &errNo]) { + if (![self of_connectSocketToAddress: &address errNo: &errNo]) { [self of_closeSocket]; @throw [OFConnectionFailedException exceptionWithNode: node network: network Index: src/OFSPXStreamSocket.h ================================================================== --- src/OFSPXStreamSocket.h +++ src/OFSPXStreamSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSPXStreamSocket.m ================================================================== --- src/OFSPXStreamSocket.m +++ src/OFSPXStreamSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -113,20 +111,18 @@ of_socket_address_t address = of_socket_address_ipx(_node, _network, _port); id exception = nil; int errNo; - if (![_socket of_createSocketForAddress: &address - errNo: &errNo]) { + if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { exception = [self of_connectionFailedExceptionForErrNo: errNo]; goto inform_delegate; } _socket.canBlock = false; - if (![_socket of_connectSocketToAddress: &address - errNo: &errNo]) { + if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { if (errNo == EINPROGRESS) { [OFRunLoop of_addAsyncConnectForSocket: _socket mode: runLoopMode delegate: self]; return; @@ -142,12 +138,11 @@ withObject: _socket withObject: exception afterDelay: 0]; } -- (void)of_socketDidConnect: (id)sock - exception: (id)exception +- (void)of_socketDidConnect: (id)sock exception: (id)exception { id delegate = ((OFSPXStreamSocket *)sock).delegate; if (exception == nil) @@ -234,21 +229,19 @@ { of_socket_address_t address = of_socket_address_ipx(node, network, port); int errNo; - if (![self of_createSocketForAddress: &address - errNo: &errNo]) + if (![self of_createSocketForAddress: &address errNo: &errNo]) @throw [OFConnectionFailedException exceptionWithNode: node network: network port: port socket: self errNo: errNo]; - if (![self of_connectSocketToAddress: &address - errNo: &errNo]) { + if (![self of_connectSocketToAddress: &address errNo: &errNo]) { [self of_closeSocket]; @throw [OFConnectionFailedException exceptionWithNode: node network: network Index: src/OFSandbox.h ================================================================== --- src/OFSandbox.h +++ src/OFSandbox.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -98,10 +96,9 @@ #endif @property (readonly, nonatomic) OFArray OF_GENERIC(of_sandbox_unveil_path_t) *unveiledPaths; + (instancetype)sandbox; -- (void)unveilPath: (OFString *)path - permissions: (OFString *)permissions; +- (void)unveilPath: (OFString *)path permissions: (OFString *)permissions; @end OF_ASSUME_NONNULL_END Index: src/OFSandbox.m ================================================================== --- src/OFSandbox.m +++ src/OFSandbox.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -587,12 +585,11 @@ return [ret autorelease]; } #endif -- (void)unveilPath: (OFString *)path - permissions: (OFString *)permissions +- (void)unveilPath: (OFString *)path permissions: (OFString *)permissions { void *pool = objc_autoreleasePoolPush(); [_unveiledPaths addObject: [OFPair pairWithFirstObject: path secondObject: permissions]]; Index: src/OFSecureData.h ================================================================== --- src/OFSecureData.h +++ src/OFSecureData.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -334,11 +332,11 @@ autorelease]; } + (instancetype)dataWithCount: (size_t)count itemSize: (size_t)itemSize - allowsSwappableMemory: (bool)allowsSwappableMemory + allowsSwappableMemory: (bool)allowsSwappableMemory { return [[[self alloc] initWithCount: count itemSize: itemSize allowsSwappableMemory: allowsSwappableMemory] autorelease]; @@ -467,12 +465,11 @@ } return self; } -- (instancetype)initWithItems: (const void *)items - count: (size_t)count +- (instancetype)initWithItems: (const void *)items count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithItems: (const void *)items Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -71,12 +69,11 @@ * `SEEK_SET` | Seek to the specified byte * `SEEK_CUR` | Seek to the current location + offset * `SEEK_END` | Seek to the end of the stream + offset * @return The new offset form the start of the file */ -- (of_offset_t)seekToOffset: (of_offset_t)offset - whence: (int)whence; +- (of_offset_t)seekToOffset: (of_offset_t)offset whence: (int)whence; /** * @brief Seek the stream on the lowlevel. * * @warning Do not call this directly! @@ -92,10 +89,9 @@ * `SEEK_SET` | Seek to the specified byte * `SEEK_CUR` | Seek to the current location + offset * `SEEK_END` | Seek to the end of the stream + offset * @return The new offset from the start of the file */ -- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset - whence: (int)whence; +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence; @end OF_ASSUME_NONNULL_END Index: src/OFSeekableStream.m ================================================================== --- src/OFSeekableStream.m +++ src/OFSeekableStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -38,27 +36,24 @@ } return [super init]; } -- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset - whence: (int)whence +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence { OF_UNRECOGNIZED_SELECTOR } -- (of_offset_t)seekToOffset: (of_offset_t)offset - whence: (int)whence +- (of_offset_t)seekToOffset: (of_offset_t)offset whence: (int)whence { if (whence == SEEK_CUR) offset -= _readBufferLength; - offset = [self lowlevelSeekToOffset: offset - whence: whence]; + offset = [self lowlevelSeekToOffset: offset whence: whence]; free(_readBufferMemory); _readBuffer = _readBufferMemory = NULL; _readBufferLength = 0; return offset; } @end Index: src/OFSelectKernelEventObserver.h ================================================================== --- src/OFSelectKernelEventObserver.h +++ src/OFSelectKernelEventObserver.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSelectKernelEventObserver.m ================================================================== --- src/OFSelectKernelEventObserver.m +++ src/OFSelectKernelEventObserver.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -13,13 +11,13 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#define __NO_EXT_QNX - #include "config.h" + +#define __NO_EXT_QNX #include "platform.h" #ifdef OF_WINDOWS /* Win32 has a ridiculous default of 64, even though it supports much more. */ @@ -41,10 +39,15 @@ #import "socket_helpers.h" #ifdef OF_AMIGAOS # include #endif + +#ifdef OF_HPUX +/* FD_SET causes warnings on HP-UX/IA64. */ +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif @implementation OFSelectKernelEventObserver - (instancetype)init { self = [super init]; Index: src/OFSequencedPacketSocket+Private.h ================================================================== --- src/OFSequencedPacketSocket+Private.h +++ src/OFSequencedPacketSocket+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSequencedPacketSocket.h ================================================================== --- src/OFSequencedPacketSocket.h +++ src/OFSequencedPacketSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -178,12 +176,11 @@ * * @param buffer The buffer to write the packet to * @param length The length of the buffer * @return The length of the received packet */ -- (size_t)receiveIntoBuffer: (void *)buffer - length: (size_t)length; +- (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Asynchronously receives a packet and stores it into the specified * buffer. * @@ -190,12 +187,11 @@ * If the buffer is too small, the receive operation fails. * * @param buffer The buffer to write the packet to * @param length The length of the buffer */ -- (void)asyncReceiveIntoBuffer: (void *)buffer - length: (size_t)length; +- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Asynchronously receives a packet and stores it into the specified * buffer. * @@ -257,12 +253,11 @@ * @brief Sends the specified packet. * * @param buffer The buffer to send as a packet * @param length The length of the buffer */ -- (void)sendBuffer: (const void *)buffer - length: (size_t)length; +- (void)sendBuffer: (const void *)buffer length: (size_t)length; /** * @brief Asynchronously sends the specified packet. * * @param data The data to send as a packet Index: src/OFSequencedPacketSocket.m ================================================================== --- src/OFSequencedPacketSocket.m +++ src/OFSequencedPacketSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,10 +13,15 @@ * file. */ #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define _HPUX_ALT_XOPEN_SOCKET_API + #include #include #ifdef HAVE_FCNTL_H # include @@ -144,12 +147,11 @@ #else OF_UNRECOGNIZED_SELECTOR #endif } -- (size_t)receiveIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; @@ -172,12 +174,11 @@ #endif return ret; } -- (void)asyncReceiveIntoBuffer: (void *)buffer - length: (size_t)length +- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length { [self asyncReceiveIntoBuffer: buffer length: length runLoopMode: of_run_loop_mode_default]; } @@ -223,12 +224,11 @@ block: block delegate: nil]; } #endif -- (void)sendBuffer: (const void *)buffer - length: (size_t)length +- (void)sendBuffer: (const void *)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS @@ -264,12 +264,11 @@ errNo: 0]; } - (void)asyncSendData: (OFData *)data { - [self asyncSendData: data - runLoopMode: of_run_loop_mode_default]; + [self asyncSendData: data runLoopMode: of_run_loop_mode_default]; } - (void)asyncSendData: (OFData *)data runLoopMode: (of_run_loop_mode_t)runLoopMode { Index: src/OFSerialization.h ================================================================== --- src/OFSerialization.h +++ src/OFSerialization.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -239,12 +237,11 @@ * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value - forKey: (OFString *)key; +- (void)setValue: (nullable id)value forKey: (OFString *)key; #ifdef OF_HAVE_BLOCKS /** * @brief Executes a block for each object in the set. * Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -60,19 +58,17 @@ va_end(arguments); return ret; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFMapTableSet alloc] initWithObjects: objects count: count]; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFMapTableSet alloc] initWithObject: firstObject arguments: arguments]; } @@ -142,12 +138,11 @@ va_end(arguments); return ret; } -+ (instancetype)setWithObjects: (id const *)objects - count: (size_t)count ++ (instancetype)setWithObjects: (id const *)objects count: (size_t)count { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } @@ -175,12 +170,11 @@ - (instancetype)initWithArray: (OFArray *)array { OF_INVALID_INIT_METHOD } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithObjects: (id)firstObject, ... @@ -187,19 +181,17 @@ { id ret; va_list arguments; va_start(arguments, firstObject); - ret = [self initWithObject: firstObject - arguments: arguments]; + ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } - (instancetype)initWithSerialization: (OFXMLElement *)element @@ -231,16 +223,14 @@ [ret makeImmutable]; return ret; } -- (void)setValue: (id)value - forKey: (OFString *)key +- (void)setValue: (id)value forKey: (OFString *)key { for (id object in self) - [object setValue: value - forKey: key]; + [object setValue: value forKey: key]; } - (bool)containsObject: (id)object { OF_UNRECOGNIZED_SELECTOR @@ -333,14 +323,12 @@ if (++i < count) [ret appendString: @",\n"]; objc_autoreleasePoolPop(pool2); } - [ret replaceOccurrencesOfString: @"\n" - withString: @"\n\t"]; + [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)}"]; - [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; @@ -386,13 +374,11 @@ element = [OFXMLElement elementWithName: @"OFSet" namespace: OF_SERIALIZATION_NS]; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); - [element addChild: object.XMLElementBySerializing]; - objc_autoreleasePoolPop(pool2); } [element retain]; @@ -401,59 +387,45 @@ return [element autorelease]; } - (OFSet *)setBySubtractingSet: (OFSet *)set { - OFMutableSet *new; - - new = [[self mutableCopy] autorelease]; + OFMutableSet *new = [[self mutableCopy] autorelease]; [new minusSet: set]; - [new makeImmutable]; - return new; } - (OFSet *)setByIntersectingWithSet: (OFSet *)set { - OFMutableSet *new; - - new = [[self mutableCopy] autorelease]; + OFMutableSet *new = [[self mutableCopy] autorelease]; [new intersectSet: set]; - [new makeImmutable]; - return new; } - (OFSet *)setByAddingSet: (OFSet *)set { - OFMutableSet *new; - - new = [[self mutableCopy] autorelease]; + OFMutableSet *new = [[self mutableCopy] autorelease]; [new unionSet: set]; - [new makeImmutable]; - return new; } - (OFArray *)allObjects { void *pool = objc_autoreleasePoolPush(); OFArray *ret = [[[self objectEnumerator] allObjects] retain]; objc_autoreleasePoolPop(pool); - return [ret autorelease]; } - (id)anyObject { void *pool = objc_autoreleasePoolPush(); id ret = [[[self objectEnumerator] nextObject] retain]; objc_autoreleasePoolPop(pool); - return [ret autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block Index: src/OFSettings.h ================================================================== --- src/OFSettings.h +++ src/OFSettings.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -72,130 +70,122 @@ * @brief Sets the specified path to the specified string. * * @param string The string to set * @param path The path to store the string at */ -- (void)setString: (OFString *)string - forPath: (OFString *)path; +- (void)setString: (OFString *)string forPath: (OFString *)path; /** - * @brief Sets the specified path to the specified integer. + * @brief Sets the specified path to the specified long long. * - * @param integer The integer to set - * @param path The path to store the integer at + * @param longLong The long long to set + * @param path The path to store the long long at */ -- (void)setInteger: (long long)integer - forPath: (OFString *)path; +- (void)setLongLong: (long long)longLong forPath: (OFString *)path; /** * @brief Sets the specified path to the specified bool. * * @param bool_ The bool to set * @param path The path to store the bool at */ -- (void)setBool: (bool)bool_ - forPath: (OFString *)path; +- (void)setBool: (bool)bool_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified float. * * @param float_ The float to set * @param path The path to store the float at */ -- (void)setFloat: (float)float_ - forPath: (OFString *)path; +- (void)setFloat: (float)float_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified double. * * @param double_ The double to set * @param path The path to store the double at */ -- (void)setDouble: (double)double_ - forPath: (OFString *)path; +- (void)setDouble: (double)double_ forPath: (OFString *)path; /** * @brief Sets the specified path to the specified array of strings. * * @param array The array of strings to set - * @param path The path to store the array of strings at + * @param path The path to store the array of string at */ -- (void)setArray: (OFArray OF_GENERIC(OFString *) *)array - forPath: (OFString *)path; +- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array + forPath: (OFString *)path; /** * @brief Returns the string for the specified path, or `nil` if the path does * not exist. * - * @param path The path for which the string value should be returned - * @return The string value of the specified path + * @param path The path for which the string should be returned + * @return The string of the specified path */ - (nullable OFString *)stringForPath: (OFString *)path; /** * @brief Returns the string for the specified path, or the default value if * the path does not exist. * - * @param path The path for which the string value should be returned + * @param path The path for which the string should be returned * @param defaultValue The default value to return if the path does not exist - * @return The string value of the specified path + * @return The string of the specified path */ - (nullable OFString *)stringForPath: (OFString *)path defaultValue: (nullable OFString *)defaultValue; /** - * @brief Returns the integer for the specified path, or the default value if + * @brief Returns the long long for the specified path, or the default value if * the path does not exist. * - * @param path The path for which the integer value should be returned + * @param path The path for which the long long should be returned * @param defaultValue The default value to return if the path does not exist - * @return The integer value of the specified path + * @return The long long of the specified path */ -- (long long)integerForPath: (OFString *)path - defaultValue: (long long)defaultValue; +- (long long)longLongForPath: (OFString *)path + defaultValue: (long long)defaultValue; /** * @brief Returns the bool for the specified path, or the default value if the * path does not exist. * - * @param path The path for which the bool value should be returned + * @param path The path for which the bool should be returned * @param defaultValue The default value to return if the path does not exist - * @return The bool value of the specified path + * @return The bool of the specified path */ -- (bool)boolForPath: (OFString *)path - defaultValue: (bool)defaultValue; +- (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue; /** * @brief Returns the float for the specified path, or the default value if the * path does not exist. * - * @param path The path for which the float value should be returned + * @param path The path for which the float should be returned * @param defaultValue The default value to return if the path does not exist - * @return The float value of the specified path + * @return The float of the specified path */ -- (float)floatForPath: (OFString *)path - defaultValue: (float)defaultValue; +- (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue; /** * @brief Returns the double for the specified path, or the default value if * the path does not exist. * - * @param path The path for which the double value should be returned + * @param path The path for which the double should be returned * @param defaultValue The default value to return if the path does not exist - * @return The double value of the specified path + * @return The double of the specified path */ -- (double)doubleForPath: (OFString *)path - defaultValue: (double)defaultValue; +- (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue; /** * @brief Returns the array of strings for the specified path, or an empty * array if the path does not exist. * * @param path The path for which the array of strings should be returned - * @return The array of strings of the specified path + * @return The array of string values of the specified path */ -- (OFArray OF_GENERIC(OFString *) *)arrayForPath: (OFString *)path; +- (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path; /** * @brief Removes the value for the specified path. * * @param path The path for which the value should be removed Index: src/OFSettings.m ================================================================== --- src/OFSettings.m +++ src/OFSettings.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -62,83 +60,74 @@ [_applicationName release]; [super dealloc]; } -- (void)setString: (OFString *)string - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setInteger: (long long)integer - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setBool: (bool)bool_ - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setFloat: (float)float_ - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setDouble: (double)double_ - forPath: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (void)setArray: (OFArray *)array - forPath: (OFString *)path +- (void)setString: (OFString *)string forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setLongLong: (long long)longLong forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setBool: (bool)bool_ forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setFloat: (float)float_ forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setDouble: (double)double_ forPath: (OFString *)path +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array + forPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (OFString *)stringForPath: (OFString *)path { - return [self stringForPath: path - defaultValue: nil]; + return [self stringForPath: path defaultValue: nil]; } - (OFString *)stringForPath: (OFString *)path defaultValue: (OFString *)defaultValue { OF_UNRECOGNIZED_SELECTOR } -- (long long)integerForPath: (OFString *)path - defaultValue: (long long)defaultValue +- (long long)longLongForPath: (OFString *)path + defaultValue: (long long)defaultValue +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue { OF_UNRECOGNIZED_SELECTOR } -- (bool)boolForPath: (OFString *)path - defaultValue: (bool)defaultValue +- (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue { OF_UNRECOGNIZED_SELECTOR } -- (float)floatForPath: (OFString *)path - defaultValue: (float)defaultValue +- (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue { OF_UNRECOGNIZED_SELECTOR } -- (double)doubleForPath: (OFString *)path - defaultValue: (double)defaultValue -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (OFArray *)arrayForPath: (OFString *)path +- (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } - (void)removeValueForPath: (OFString *)path Index: src/OFSortedList.h ================================================================== --- src/OFSortedList.h +++ src/OFSortedList.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSortedList.m ================================================================== --- src/OFSortedList.m +++ src/OFSortedList.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStdIOStream+Private.h ================================================================== --- src/OFStdIOStream+Private.h +++ src/OFStdIOStream+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -210,12 +208,11 @@ _fd = fd; return self; } #else -- (instancetype)of_initWithHandle: (BPTR)handle - closable: (bool)closable +- (instancetype)of_initWithHandle: (BPTR)handle closable: (bool)closable { self = [super init]; _handle = handle; _closable = closable; @@ -246,12 +243,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; #ifndef OF_AMIGAOS if (_fd == -1) @@ -288,12 +284,11 @@ _atEndOfStream = true; return ret; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #ifndef OF_AMIGAOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; Index: src/OFStream+Private.h ================================================================== --- src/OFStream+Private.h +++ src/OFStream+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -248,12 +246,11 @@ * @param buffer The buffer into which the data is read * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! * @return The number of bytes read */ -- (size_t)readIntoBuffer: (void *)buffer - length: (size_t)length; +- (size_t)readIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Reads exactly the specified length bytes from the stream into a * buffer. * @@ -266,12 +263,11 @@ * * @param buffer The buffer into which the data is read * @param length The length of the data that should be read. * The buffer *must* be *at least* this big! */ - - (void)readIntoBuffer: (void *)buffer - exactLength: (size_t)length; + - (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length; #ifdef OF_HAVE_SOCKETS /** * @brief Asynchronously reads *at most* size bytes from the stream into a * buffer. @@ -290,12 +286,11 @@ * @param buffer The buffer into which the data is read. * The buffer must not be freed before the async read completed! * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! */ -- (void)asyncReadIntoBuffer: (void *)buffer - length: (size_t)length; +- (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Asynchronously reads *at most* size bytes from the stream into a * buffer. * @@ -334,12 +329,11 @@ * * @param buffer The buffer into which the data is read * @param length The length of the data that should be read. * The buffer *must* be *at least* this big! */ -- (void)asyncReadIntoBuffer: (void *)buffer - exactLength: (size_t)length; +- (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length; /** * @brief Asynchronously reads exactly the specified length bytes from the * stream into a buffer. * @@ -590,12 +584,11 @@ * @param buffer A buffer of sufficient size to store the specified number of * floats * @param count The number of floats to read * @return The number of bytes read */ -- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer - count: (size_t)count; +- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer count: (size_t)count; /** * @brief Reads the specified number of doubles from the stream which are * encoded in big endian. * @@ -605,12 +598,11 @@ * @param buffer A buffer of sufficient size to store the specified number of * doubles * @param count The number of doubles to read * @return The number of bytes read */ -- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer - count: (size_t)count; +- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer count: (size_t)count; /** * @brief Reads a uint16_t from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! @@ -756,12 +748,11 @@ * * @param itemSize The size of each item * @param count The number of items to read * @return OFData with count items. */ -- (OFData *)readDataWithItemSize: (size_t)itemSize - count: (size_t)count; +- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count; /** * @brief Returns OFData with all the remaining data of the stream. * * @return OFData with an item size of 1 with all the data of the stream until @@ -986,12 +977,11 @@ * @param buffer The buffer from which the data is written into the stream * @param length The length of the data that should be written * @return The number of bytes written. This can only differ from the specified * length in non-blocking mode. */ -- (size_t)writeBuffer: (const void *)buffer - length: (size_t)length; +- (size_t)writeBuffer: (const void *)buffer length: (size_t)length; #ifdef OF_HAVE_SOCKETS /** * @brief Asynchronously writes data into the stream. * @@ -1188,12 +1178,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint16_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of uint32_ts into the stream, encoded in * big endian. * @@ -1200,12 +1189,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint32_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of uint64_ts into the stream, encoded in * big endian. * @@ -1212,12 +1200,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint64_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of floats into the stream, encoded in big * endian. * @@ -1224,12 +1211,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of floats to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianFloats: (const float *)buffer - count: (size_t)count; +- (size_t)writeBigEndianFloats: (const float *)buffer count: (size_t)count; /** * @brief Writes the specified number of doubles into the stream, encoded in * big endian. * @@ -1236,12 +1222,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of doubles to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianDoubles: (const double *)buffer - count: (size_t)count; +- (size_t)writeBigEndianDoubles: (const double *)buffer count: (size_t)count; /** * @brief Writes a uint16_t into the stream, encoded in little endian. * * @param int16 A uint16_t @@ -1319,12 +1304,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of floats to write * @return The number of bytes written to the stream */ -- (size_t)writeLittleEndianFloats: (const float *)buffer - count: (size_t)count; +- (size_t)writeLittleEndianFloats: (const float *)buffer count: (size_t)count; /** * @brief Writes the specified number of doubles into the stream, encoded in * little endian. * @@ -1331,12 +1315,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of doubles to write * @return The number of bytes written to the stream */ -- (size_t)writeLittleEndianDoubles: (const double *)buffer - count: (size_t)count; +- (size_t)writeLittleEndianDoubles: (const double *)buffer count: (size_t)count; /** * @brief Writes OFData into the stream. * * @param data The OFData to write into the stream @@ -1403,12 +1386,11 @@ * * @param format A string used as format * @param arguments The arguments used in the format string * @return The number of bytes written */ -- (size_t)writeFormat: (OFConstantString *)format - arguments: (va_list)arguments; +- (size_t)writeFormat: (OFConstantString *)format arguments: (va_list)arguments; #ifdef OF_HAVE_SOCKETS /** * @brief Cancels all pending asynchronous requests on the stream. */ @@ -1434,12 +1416,11 @@ * unread. * * @param buffer The buffer to unread * @param length The length of the buffer to unread */ -- (void)unreadFromBuffer: (const void *)buffer - length: (size_t)length; +- (void)unreadFromBuffer: (const void *)buffer length: (size_t)length; /** * @brief Closes the stream. * * @note If you override this, make sure to call `[super close]`! @@ -1456,12 +1437,11 @@ * * @param buffer The buffer for the data to read * @param length The length of the buffer * @return The number of bytes read */ -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length; +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Performs a lowlevel write. * * @warning Do not call this directly! @@ -1471,12 +1451,11 @@ * * @param buffer The buffer with the data to write * @param length The length of the data to write * @return The number of bytes written */ -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length; +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length; /** * @brief Returns whether the lowlevel is at the end of the stream. * * @warning Do not call this directly! Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -104,18 +102,16 @@ - (bool)lowlevelIsAtEndOfStream { OF_UNRECOGNIZED_SELECTOR } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } - (id)copy @@ -129,12 +125,11 @@ return false; return [self lowlevelIsAtEndOfStream]; } -- (size_t)readIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)readIntoBuffer: (void *)buffer length: (size_t)length { if (_readBufferLength == 0) { /* * For small sizes, it is cheaper to read more and cache the * remainder - even if that means more copying of data - than @@ -163,12 +158,11 @@ memcpy(buffer, tmp, bytesRead); return bytesRead; } } - return [self lowlevelReadIntoBuffer: buffer - length: length]; + return [self lowlevelReadIntoBuffer: buffer length: length]; } if (length >= _readBufferLength) { size_t ret = _readBufferLength; memcpy(buffer, _readBuffer, _readBufferLength); @@ -186,12 +180,11 @@ return length; } } -- (void)readIntoBuffer: (void *)buffer - exactLength: (size_t)length +- (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length { size_t readLength = 0; while (readLength < length) { if (self.atEndOfStream) @@ -201,12 +194,11 @@ length: length - readLength]; } } #ifdef OF_HAVE_SOCKETS -- (void)asyncReadIntoBuffer: (void *)buffer - length: (size_t)length +- (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length { [self asyncReadIntoBuffer: buffer length: length runLoopMode: of_run_loop_mode_default]; } @@ -226,12 +218,11 @@ block: NULL # endif delegate: _delegate]; } -- (void)asyncReadIntoBuffer: (void *)buffer - exactLength: (size_t)length +- (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length { [self asyncReadIntoBuffer: buffer exactLength: length runLoopMode: of_run_loop_mode_default]; } @@ -309,163 +300,135 @@ #endif - (uint8_t)readInt8 { uint8_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 1]; - + [self readIntoBuffer: (char *)&ret exactLength: 1]; return ret; } - (uint16_t)readBigEndianInt16 { uint16_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 2]; - + [self readIntoBuffer: (char *)&ret exactLength: 2]; return OF_BSWAP16_IF_LE(ret); } - (uint32_t)readBigEndianInt32 { uint32_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP32_IF_LE(ret); } - (uint64_t)readBigEndianInt64 { uint64_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP64_IF_LE(ret); } - (float)readBigEndianFloat { float ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_LE(ret); } - (double)readBigEndianDouble { double ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_LE(ret); } -- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt16sIntoBuffer: (uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif return size; } -- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt32sIntoBuffer: (uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif return size; } -- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer - count: (size_t)count +- (size_t)readBigEndianInt64sIntoBuffer: (uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif return size; } -- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer - count: (size_t)count +- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif return size; } -- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer - count: (size_t)count +- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifndef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif @@ -474,54 +437,39 @@ } - (uint16_t)readLittleEndianInt16 { uint16_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 2]; - + [self readIntoBuffer: (char *)&ret exactLength: 2]; return OF_BSWAP16_IF_BE(ret); } - (uint32_t)readLittleEndianInt32 { uint32_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP32_IF_BE(ret); } - (uint64_t)readLittleEndianInt64 { uint64_t ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP64_IF_BE(ret); } - (float)readLittleEndianFloat { float ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 4]; - + [self readIntoBuffer: (char *)&ret exactLength: 4]; return OF_BSWAP_FLOAT_IF_BE(ret); } - (double)readLittleEndianDouble { double ret; - - [self readIntoBuffer: (char *)&ret - exactLength: 8]; - + [self readIntoBuffer: (char *)&ret exactLength: 8]; return OF_BSWAP_DOUBLE_IF_BE(ret); } - (size_t)readLittleEndianInt16sIntoBuffer: (uint16_t *)buffer count: (size_t)count @@ -531,12 +479,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP16(buffer[i]); #endif @@ -552,12 +499,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP32(buffer[i]); #endif @@ -573,12 +519,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP64(buffer[i]); #endif @@ -594,12 +539,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_FLOAT(buffer[i]); #endif @@ -615,12 +559,11 @@ if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); - [self readIntoBuffer: buffer - exactLength: size]; + [self readIntoBuffer: buffer exactLength: size]; #ifdef OF_FLOAT_BIG_ENDIAN for (size_t i = 0; i < count; i++) buffer[i] = OF_BSWAP_DOUBLE(buffer[i]); #endif @@ -628,28 +571,24 @@ return size; } - (OFData *)readDataWithCount: (size_t)count { - return [self readDataWithItemSize: 1 - count: count]; + return [self readDataWithItemSize: 1 count: count]; } -- (OFData *)readDataWithItemSize: (size_t)itemSize - count: (size_t)count +- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count { OFData *ret; char *buffer; if OF_UNLIKELY (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; buffer = of_alloc(count, itemSize); @try { - [self readIntoBuffer: buffer - exactLength: count * itemSize]; - + [self readIntoBuffer: buffer exactLength: count * itemSize]; ret = [OFData dataWithItemsNoCopy: buffer count: count itemSize: itemSize freeWhenDone: true]; } @catch (id e) { @@ -666,23 +605,19 @@ size_t pageSize = [OFSystemInfo pageSize]; char *buffer = of_alloc(1, pageSize); @try { while (!self.atEndOfStream) { - size_t length; - - length = [self readIntoBuffer: buffer - length: pageSize]; - [data addItems: buffer - count: length]; + size_t length = + [self readIntoBuffer: buffer length: pageSize]; + [data addItems: buffer count: length]; } } @finally { free(buffer); } [data makeImmutable]; - return data; } - (OFString *)readStringWithLength: (size_t)length { @@ -696,15 +631,12 @@ OFString *ret; char *buffer = of_alloc(length + 1, 1); buffer[length] = 0; @try { - [self readIntoBuffer: buffer - exactLength: length]; - - ret = [OFString stringWithCString: buffer - encoding: encoding]; + [self readIntoBuffer: buffer exactLength: length]; + ret = [OFString stringWithCString: buffer encoding: encoding]; } @finally { free(buffer); } return ret; @@ -1127,12 +1059,11 @@ - (void)flushWriteBuffer { if (_writeBuffer == NULL) return; - [self lowlevelWriteBuffer: _writeBuffer - length: _writeBufferLength]; + [self lowlevelWriteBuffer: _writeBuffer length: _writeBufferLength]; free(_writeBuffer); _writeBuffer = NULL; _writeBufferLength = 0; } @@ -1163,12 +1094,11 @@ } #ifdef OF_HAVE_SOCKETS - (void)asyncWriteData: (OFData *)data { - [self asyncWriteData: data - runLoopMode: of_run_loop_mode_default]; + [self asyncWriteData: data runLoopMode: of_run_loop_mode_default]; } - (void)asyncWriteData: (OFData *)data runLoopMode: (of_run_loop_mode_t)runLoopMode { @@ -1276,196 +1206,170 @@ # endif #endif - (void)writeInt8: (uint8_t)int8 { - [self writeBuffer: (char *)&int8 - length: 1]; + [self writeBuffer: (char *)&int8 length: 1]; } - (void)writeBigEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_LE(int16); - - [self writeBuffer: (char *)&int16 - length: 2]; + [self writeBuffer: (char *)&int16 length: 2]; } - (void)writeBigEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_LE(int32); - - [self writeBuffer: (char *)&int32 - length: 4]; + [self writeBuffer: (char *)&int32 length: 4]; } - (void)writeBigEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_LE(int64); - - [self writeBuffer: (char *)&int64 - length: 8]; + [self writeBuffer: (char *)&int64 length: 8]; } - (void)writeBigEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_LE(float_); - - [self writeBuffer: (char *)&float_ - length: 4]; + [self writeBuffer: (char *)&float_ length: 4]; } - (void)writeBigEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_LE(double_); - - [self writeBuffer: (char *)&double_ - length: 8]; + [self writeBuffer: (char *)&double_ length: 8]; } -- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer - count: (size_t)count +- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); #ifdef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianFloats: (const float *)buffer - count: (size_t)count +- (size_t)writeBigEndianFloats: (const float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeBigEndianDoubles: (const double *)buffer - count: (size_t)count +- (size_t)writeBigEndianDoubles: (const double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); #ifdef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif @@ -1473,189 +1377,164 @@ } - (void)writeLittleEndianInt16: (uint16_t)int16 { int16 = OF_BSWAP16_IF_BE(int16); - - [self writeBuffer: (char *)&int16 - length: 2]; + [self writeBuffer: (char *)&int16 length: 2]; } - (void)writeLittleEndianInt32: (uint32_t)int32 { int32 = OF_BSWAP32_IF_BE(int32); - - [self writeBuffer: (char *)&int32 - length: 4]; + [self writeBuffer: (char *)&int32 length: 4]; } - (void)writeLittleEndianInt64: (uint64_t)int64 { int64 = OF_BSWAP64_IF_BE(int64); - - [self writeBuffer: (char *)&int64 - length: 8]; + [self writeBuffer: (char *)&int64 length: 8]; } - (void)writeLittleEndianFloat: (float)float_ { float_ = OF_BSWAP_FLOAT_IF_BE(float_); - - [self writeBuffer: (char *)&float_ - length: 4]; + [self writeBuffer: (char *)&float_ length: 4]; } - (void)writeLittleEndianDouble: (double)double_ { double_ = OF_BSWAP_DOUBLE_IF_BE(double_); - - [self writeBuffer: (char *)&double_ - length: 8]; + [self writeBuffer: (char *)&double_ length: 8]; } -- (size_t)writeLittleEndianInt16s: (const uint16_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt16s: (const uint16_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint16_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint16_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianInt32s: (const uint32_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt32s: (const uint32_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint32_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint32_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianInt64s: (const uint64_t *)buffer - count: (size_t)count +- (size_t)writeLittleEndianInt64s: (const uint64_t *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(uint64_t)) @throw [OFOutOfRangeException exception]; size = count * sizeof(uint64_t); #ifndef OF_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianFloats: (const float *)buffer - count: (size_t)count +- (size_t)writeLittleEndianFloats: (const float *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(float)) @throw [OFOutOfRangeException exception]; size = count * sizeof(float); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif return size; } -- (size_t)writeLittleEndianDoubles: (const double *)buffer - count: (size_t)count +- (size_t)writeLittleEndianDoubles: (const double *)buffer count: (size_t)count { size_t size; if OF_UNLIKELY (count > SIZE_MAX / sizeof(double)) @throw [OFOutOfRangeException exception]; size = count * sizeof(double); #ifndef OF_FLOAT_BIG_ENDIAN - [self writeBuffer: buffer - length: size]; + [self writeBuffer: buffer length: size]; #else double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); - [self writeBuffer: tmp - length: size]; + [self writeBuffer: tmp length: size]; } @finally { free(tmp); } #endif @@ -1669,24 +1548,22 @@ if (data == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); + length = data.count * data.itemSize; - - [self writeBuffer: data.items - length: length]; + [self writeBuffer: data.items length: length]; objc_autoreleasePoolPop(pool); return length; } - (size_t)writeString: (OFString *)string { - return [self writeString: string - encoding: OF_STRING_ENCODING_UTF_8]; + return [self writeString: string encoding: OF_STRING_ENCODING_UTF_8]; } - (size_t)writeString: (OFString *)string encoding: (of_string_encoding_t)encoding { @@ -1707,16 +1584,14 @@ return length; } - (size_t)writeLine: (OFString *)string { - return [self writeLine: string - encoding: OF_STRING_ENCODING_UTF_8]; + return [self writeLine: string encoding: OF_STRING_ENCODING_UTF_8]; } -- (size_t)writeLine: (OFString *)string - encoding: (of_string_encoding_t)encoding +- (size_t)writeLine: (OFString *)string encoding: (of_string_encoding_t)encoding { size_t stringLength = [string cStringLengthWithEncoding: encoding]; char *buffer; buffer = of_alloc(stringLength + 1, 1); @@ -1724,12 +1599,11 @@ @try { memcpy(buffer, [string cStringWithEncoding: encoding], stringLength); buffer[stringLength] = '\n'; - [self writeBuffer: buffer - length: stringLength + 1]; + [self writeBuffer: buffer length: stringLength + 1]; } @finally { free(buffer); } return stringLength + 1; @@ -1739,19 +1613,17 @@ { va_list arguments; size_t ret; va_start(arguments, format); - ret = [self writeFormat: format - arguments: arguments]; + ret = [self writeFormat: format arguments: arguments]; va_end(arguments); return ret; } -- (size_t)writeFormat: (OFConstantString *)format - arguments: (va_list)arguments +- (size_t)writeFormat: (OFConstantString *)format arguments: (va_list)arguments { char *UTF8String; int length; if (format == nil) @@ -1760,12 +1632,11 @@ if ((length = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { - [self writeBuffer: UTF8String - length: length]; + [self writeBuffer: UTF8String length: length]; } @finally { free(UTF8String); } return length; @@ -1864,12 +1735,11 @@ [OFRunLoop of_cancelAsyncRequestsForObject: self mode: of_run_loop_mode_default]; } #endif -- (void)unreadFromBuffer: (const void *)buffer - length: (size_t)length +- (void)unreadFromBuffer: (const void *)buffer length: (size_t)length { char *readBuffer; if (length > SIZE_MAX - _readBufferLength) @throw [OFOutOfRangeException exception]; Index: src/OFStreamSocket+Private.h ================================================================== --- src/OFStreamSocket+Private.h +++ src/OFStreamSocket+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStreamSocket.h ================================================================== --- src/OFStreamSocket.h +++ src/OFStreamSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -13,14 +11,18 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#define __NO_EXT_QNX - #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define __NO_EXT_QNX +#define _HPUX_ALT_XOPEN_SOCKET_API + #include #include #include #import "OFStreamSocket.h" @@ -93,12 +95,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; @@ -124,12 +125,11 @@ _atEndOfStream = true; return ret; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS Index: src/OFString+CryptoHashing.h ================================================================== --- src/OFString+CryptoHashing.h +++ src/OFString+CryptoHashing.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+CryptoHashing.m ================================================================== --- src/OFString+CryptoHashing.m +++ src/OFString+CryptoHashing.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -37,12 +35,11 @@ cryptoHashWithAllowsSwappableMemory: true]; size_t digestSize = [class digestSize]; const unsigned char *digest; char cString[digestSize * 2]; - [hash updateWithBuffer: self.UTF8String - length: self.UTF8StringLength]; + [hash updateWithBuffer: self.UTF8String length: self.UTF8StringLength]; digest = hash.digest; for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; Index: src/OFString+JSONParsing.h ================================================================== --- src/OFString+JSONParsing.h +++ src/OFString+JSONParsing.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+JSONParsing.m ================================================================== --- src/OFString+JSONParsing.m +++ src/OFString+JSONParsing.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -504,12 +502,11 @@ object = nextObject(pointer, stop, line, depthLimit); if (object == nil) return nil; - [dictionary setObject: object - forKey: key]; + [dictionary setObject: object forKey: key]; skipWhitespacesAndComments(pointer, stop, line); if (*pointer >= stop) return nil; @@ -550,12 +547,11 @@ break; } } - string = [[OFString alloc] initWithUTF8String: *pointer - length: i]; + string = [[OFString alloc] initWithUTF8String: *pointer length: i]; *pointer += i; @try { if (hasDecimal) number = [OFNumber numberWithDouble: Index: src/OFString+PathAdditions.h ================================================================== --- src/OFString+PathAdditions.h +++ src/OFString+PathAdditions.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+PathAdditions.m ================================================================== --- src/OFString+PathAdditions.m +++ src/OFString+PathAdditions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+PropertyListParsing.h ================================================================== --- src/OFString+PropertyListParsing.h +++ src/OFString+PropertyListParsing.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+PropertyListParsing.m ================================================================== --- src/OFString+PropertyListParsing.m +++ src/OFString+PropertyListParsing.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -66,12 +64,11 @@ (object = [enumerator nextObject])) { if (key.namespace != nil || key.attributes.count != 0 || ![key.name isEqual: @"key"]) @throw [OFInvalidFormatException exception]; - [ret setObject: parseElement(object) - forKey: key.stringValue]; + [ret setObject: parseElement(object) forKey: key.stringValue]; } [ret makeImmutable]; objc_autoreleasePoolPop(pool); Index: src/OFString+Serialization.h ================================================================== --- src/OFString+Serialization.h +++ src/OFString+Serialization.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+Serialization.m ================================================================== --- src/OFString+Serialization.m +++ src/OFString+Serialization.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+URLEncoding.h ================================================================== --- src/OFString+URLEncoding.h +++ src/OFString+URLEncoding.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+URLEncoding.m ================================================================== --- src/OFString+URLEncoding.m +++ src/OFString+URLEncoding.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -45,12 +43,11 @@ for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (characterIsMember(allowedCharacters, @selector(characterIsMember:), c)) - [ret appendCharacters: &c - length: 1]; + [ret appendCharacters: &c length: 1]; else { char buffer[4]; size_t bufferLen; if ((bufferLen = of_string_utf8_encode(c, buffer)) == 0) @@ -66,12 +63,11 @@ escaped[1] = (high > 9 ? high - 10 + 'A' : high + '0'); escaped[2] = (low > 9 ? low - 10 + 'A' : low + '0'); - [ret appendUTF8String: escaped - length: 3]; + [ret appendUTF8String: escaped length: 3]; } } } objc_autoreleasePoolPop(pool); Index: src/OFString+XMLEscaping.h ================================================================== --- src/OFString+XMLEscaping.h +++ src/OFString+XMLEscaping.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+XMLEscaping.m ================================================================== --- src/OFString+XMLEscaping.m +++ src/OFString+XMLEscaping.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+XMLUnescaping.h ================================================================== --- src/OFString+XMLUnescaping.h +++ src/OFString+XMLUnescaping.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -68,12 +66,11 @@ if ((i = of_string_utf8_encode(c, buffer)) == 0) return nil; buffer[i] = 0; - return [OFString stringWithUTF8String: buffer - length: i]; + return [OFString stringWithUTF8String: buffer length: i]; } static OFString * parseEntities(OFString *self, id (*lookup)(void *, OFString *, OFString *), void *context) @@ -94,13 +91,11 @@ last = 0; inEntity = false; for (i = 0; i < length; i++) { if (!inEntity && string[i] == '&') { - [ret appendUTF8String: string + last - length: i - last]; - + [ret appendUTF8String: string + last length: i - last]; last = i + 1; inEntity = true; } else if (inEntity && string[i] == ';') { const char *entity = string + last; size_t entityLength = i - last; @@ -170,13 +165,11 @@ } if (inEntity) @throw [OFInvalidFormatException exception]; - [ret appendUTF8String: string + last - length: i - last]; - + [ret appendUTF8String: string + last length: i - last]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; @@ -188,12 +181,11 @@ id delegate = context; if (delegate == nil) return nil; - return [delegate string: self - containsUnknownEntityNamed: entity]; + return [delegate string: self containsUnknownEntityNamed: entity]; } #ifdef OF_HAVE_BLOCKS static id lookupUsingBlock(void *context, OFString *self, OFString *entity) Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -517,11 +515,10 @@ */ + (instancetype)stringWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding; # endif -# if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) /** * @brief Creates a new OFString with the contents of the specified URL. * * If the URL's scheme is file, it tries UTF-8 encoding. * @@ -542,11 +539,10 @@ * @param encoding The encoding to assume * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding; -# endif /** * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * @@ -909,12 +905,11 @@ * buffer. * * @param buffer The buffer to store the Unicode characters * @param range The range of the Unicode characters to copy */ -- (void)getCharacters: (of_unichar_t *)buffer - inRange: (of_range_t)range; +- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range; /** * @brief Returns the range of the first occurrence of the string. * * @param string The string to search @@ -933,12 +928,11 @@ * -----------------------------|------------------------------- * `OF_STRING_SEARCH_BACKWARDS` | Search backwards in the string * @return The range of the first occurrence of the string or a range with * `OF_NOT_FOUND` as start position if it was not found */ -- (of_range_t)rangeOfString: (OFString *)string - options: (int)options; +- (of_range_t)rangeOfString: (OFString *)string options: (int)options; /** * @brief Returns the range of the string in the specified range. * * @param string The string to search @@ -1244,12 +1238,11 @@ * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use to write the string into the file */ -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding; +- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding; # endif /** * @brief Writes the string to the specified URL using UTF-8 encoding. * @@ -1261,12 +1254,11 @@ * @brief Writes the string to the specified URL using the specified encoding. * * @param URL The URL to write to * @param encoding The encoding to use to write the string to the URL */ -- (void)writeToURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding; +- (void)writeToURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding; # ifdef OF_HAVE_BLOCKS /** * Enumerates all lines in the receiver using the specified block. * Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -70,12 +68,11 @@ */ #ifdef __MINGW32__ # define strtod __strtod #endif -#ifdef OF_AMIGAOS_M68K -/* libnix has strtod, but not strtof */ +#ifndef HAVE_STRTOF # define strtof strtod #endif #ifndef INFINITY # define INFINITY __builtin_inf() @@ -352,21 +349,19 @@ for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; const char *const *page; if (c >= size) { - [ret appendCharacters: &c - length: 1]; + [ret appendCharacters: &c length: 1]; continue; } page = table[c >> 8]; if (page != NULL && page[c & 0xFF] != NULL) [ret appendUTF8String: page[c & 0xFF]]; else - [ret appendCharacters: &c - length: 1]; + [ret appendCharacters: &c length: 1]; } objc_autoreleasePoolPop(pool); return ret; @@ -574,11 +569,10 @@ return (id)[[OFUTF8String alloc] initWithContentsOfFile: path encoding: encoding]; } #endif -#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) - (instancetype)initWithContentsOfURL: (OFURL *)URL { return (id)[[OFUTF8String alloc] initWithContentsOfURL: URL]; } @@ -586,11 +580,10 @@ encoding: (of_string_encoding_t)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfURL: URL encoding: encoding]; } -#endif - (instancetype)initWithSerialization: (OFXMLElement *)element { return (id)[[OFUTF8String alloc] initWithSerialization: element]; } @@ -790,11 +783,10 @@ return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } #endif -#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS) + (instancetype)stringWithContentsOfURL: (OFURL *)URL { return [[[self alloc] initWithContentsOfURL: URL] autorelease]; } @@ -802,11 +794,10 @@ encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithContentsOfURL: URL encoding: encoding] autorelease]; } -#endif - (instancetype)init { if ([self isMemberOfClass: [OFString class]]) { @try { @@ -850,12 +841,11 @@ - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String length: (size_t)UTF8StringLength freeWhenDone: (bool)freeWhenDone { - id ret = [self initWithUTF8String: UTF8String - length: UTF8StringLength]; + id ret = [self initWithUTF8String: UTF8String length: UTF8StringLength]; if (freeWhenDone) free(UTF8String); return ret; @@ -969,12 +959,11 @@ { id ret; va_list arguments; va_start(arguments, format); - ret = [self initWithFormat: format - arguments: arguments]; + ret = [self initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } @@ -1025,13 +1014,11 @@ if (SIZE_MAX - (size_t)fileSize < 1) @throw [OFOutOfRangeException exception]; tmp = of_alloc((size_t)fileSize + 1, 1); @try { - file = [[OFFile alloc] initWithPath: path - mode: @"r"]; - + file = [[OFFile alloc] initWithPath: path mode: @"r"]; [file readIntoBuffer: tmp exactLength: (size_t)fileSize]; } @catch (id e) { free(tmp); @throw e; @@ -1446,18 +1433,16 @@ } } - (const char *)cStringWithEncoding: (of_string_encoding_t)encoding { - return [self of_cStringWithEncoding: encoding - lossy: false]; + return [self of_cStringWithEncoding: encoding lossy: false]; } - (const char *)lossyCStringWithEncoding: (of_string_encoding_t)encoding { - return [self of_cStringWithEncoding: encoding - lossy: true]; + return [self of_cStringWithEncoding: encoding lossy: true]; } - (const char *)UTF8String { return [self cStringWithEncoding: OF_STRING_ENCODING_UTF_8]; @@ -1723,42 +1708,33 @@ return [element autorelease]; } - (OFString *)JSONRepresentation { - return [self of_JSONRepresentationWithOptions: 0 - depth: 0]; + return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (int)options { - return [self of_JSONRepresentationWithOptions: options - depth: 0]; + return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { OFMutableString *JSON = [[self mutableCopy] autorelease]; /* FIXME: This is slow! Write it in pure C! */ - [JSON replaceOccurrencesOfString: @"\\" - withString: @"\\\\"]; - [JSON replaceOccurrencesOfString: @"\"" - withString: @"\\\""]; - [JSON replaceOccurrencesOfString: @"\b" - withString: @"\\b"]; - [JSON replaceOccurrencesOfString: @"\f" - withString: @"\\f"]; - [JSON replaceOccurrencesOfString: @"\r" - withString: @"\\r"]; - [JSON replaceOccurrencesOfString: @"\t" - withString: @"\\t"]; + [JSON replaceOccurrencesOfString: @"\\" withString: @"\\\\"]; + [JSON replaceOccurrencesOfString: @"\"" withString: @"\\\""]; + [JSON replaceOccurrencesOfString: @"\b" withString: @"\\b"]; + [JSON replaceOccurrencesOfString: @"\f" withString: @"\\f"]; + [JSON replaceOccurrencesOfString: @"\r" withString: @"\\r"]; + [JSON replaceOccurrencesOfString: @"\t" withString: @"\\t"]; if (options & OF_JSON_REPRESENTATION_JSON5) { - [JSON replaceOccurrencesOfString: @"\n" - withString: @"\\\n"]; + [JSON replaceOccurrencesOfString: @"\n" withString: @"\\\n"]; if (options & OF_JSON_REPRESENTATION_IDENTIFIER) { const char *cString = self.UTF8String; if ((!of_ascii_isalpha(cString[0]) && @@ -1770,12 +1746,11 @@ } else { [JSON prependString: @"\""]; [JSON appendString: @"\""]; } } else { - [JSON replaceOccurrencesOfString: @"\n" - withString: @"\\n"]; + [JSON replaceOccurrencesOfString: @"\n" withString: @"\\n"]; [JSON prependString: @"\""]; [JSON appendString: @"\""]; } @@ -1792,48 +1767,37 @@ length = self.UTF8StringLength; if (length <= 31) { uint8_t tmp = 0xA0 | ((uint8_t)length & 0x1F); - data = [OFMutableData dataWithItemSize: 1 - capacity: length + 1]; - + data = [OFMutableData dataWithCapacity: length + 1]; [data addItem: &tmp]; } else if (length <= UINT8_MAX) { uint8_t type = 0xD9; uint8_t tmp = (uint8_t)length; - data = [OFMutableData dataWithItemSize: 1 - capacity: length + 2]; - + data = [OFMutableData dataWithCapacity: length + 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (length <= UINT16_MAX) { uint8_t type = 0xDA; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)length); - data = [OFMutableData dataWithItemSize: 1 - capacity: length + 3]; - + data = [OFMutableData dataWithCapacity: length + 3]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else if (length <= UINT32_MAX) { uint8_t type = 0xDB; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)length); - data = [OFMutableData dataWithItemSize: 1 - capacity: length + 5]; - + data = [OFMutableData dataWithCapacity: length + 5]; [data addItem: &type]; - [data addItems: &tmp - count: sizeof(tmp)]; + [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; - [data addItems: self.UTF8String - count: length]; + [data addItems: self.UTF8String count: length]; return data; } - (of_range_t)rangeOfString: (OFString *)string @@ -1841,12 +1805,11 @@ return [self rangeOfString: string options: 0 range: of_range(0, self.length)]; } -- (of_range_t)rangeOfString: (OFString *)string - options: (int)options +- (of_range_t)rangeOfString: (OFString *)string options: (int)options { return [self rangeOfString: string options: options range: of_range(0, self.length)]; } @@ -1873,12 +1836,11 @@ searchCharacters = string.characters; characters = of_alloc(range.length, sizeof(of_unichar_t)); @try { - [self getCharacters: characters - inRange: range]; + [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - searchLength;; i--) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) == 0) { @@ -1941,12 +1903,11 @@ if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; characters = of_alloc(range.length, sizeof(of_unichar_t)); @try { - [self getCharacters: characters - inRange: range]; + [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - 1;; i--) { if (characterIsMember(characterSet, @selector(characterIsMember:), @@ -2045,135 +2006,101 @@ { OFString *ret; va_list arguments; va_start(arguments, format); - ret = [self stringByAppendingFormat: format - arguments: arguments]; + ret = [self stringByAppendingFormat: format arguments: arguments]; va_end(arguments); return ret; } - (OFString *)stringByAppendingFormat: (OFConstantString *)format arguments: (va_list)arguments { - OFMutableString *new; - - new = [OFMutableString stringWithString: self]; - [new appendFormat: format - arguments: arguments]; - + OFMutableString *new = [OFMutableString stringWithString: self]; + [new appendFormat: format arguments: arguments]; [new makeImmutable]; - return new; } - (OFString *)stringByPrependingString: (OFString *)string { OFMutableString *new = [[string mutableCopy] autorelease]; - [new appendString: self]; - [new makeImmutable]; - return new; } - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement { OFMutableString *new = [[self mutableCopy] autorelease]; - - [new replaceOccurrencesOfString: string - withString: replacement]; - + [new replaceOccurrencesOfString: string withString: replacement]; [new makeImmutable]; - return new; } - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options range: (of_range_t)range { OFMutableString *new = [[self mutableCopy] autorelease]; - [new replaceOccurrencesOfString: string withString: replacement options: options range: range]; - [new makeImmutable]; - return new; } - (OFString *)uppercaseString { OFMutableString *new = [[self mutableCopy] autorelease]; - [new uppercase]; - [new makeImmutable]; - return new; } - (OFString *)lowercaseString { OFMutableString *new = [[self mutableCopy] autorelease]; - [new lowercase]; - [new makeImmutable]; - return new; } - (OFString *)capitalizedString { OFMutableString *new = [[self mutableCopy] autorelease]; - [new capitalize]; - [new makeImmutable]; - return new; } - (OFString *)stringByDeletingLeadingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; - [new deleteLeadingWhitespaces]; - [new makeImmutable]; - return new; } - (OFString *)stringByDeletingTrailingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; - [new deleteTrailingWhitespaces]; - [new makeImmutable]; - return new; } - (OFString *)stringByDeletingEnclosingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; - [new deleteEnclosingWhitespaces]; - [new makeImmutable]; - return new; } - (bool)hasPrefix: (OFString *)prefix { @@ -2186,12 +2113,11 @@ tmp = of_alloc(prefixLength, sizeof(of_unichar_t)); @try { void *pool = objc_autoreleasePoolPush(); - [self getCharacters: tmp - inRange: of_range(0, prefixLength)]; + [self getCharacters: tmp inRange: of_range(0, prefixLength)]; hasPrefix = (memcmp(tmp, prefix.characters, prefixLength * sizeof(of_unichar_t)) == 0); objc_autoreleasePoolPop(pool); @@ -2234,12 +2160,11 @@ return hasSuffix; } - (OFArray *)componentsSeparatedByString: (OFString *)delimiter { - return [self componentsSeparatedByString: delimiter - options: 0]; + return [self componentsSeparatedByString: delimiter options: 0]; } - (OFArray *)componentsSeparatedByString: (OFString *)delimiter options: (int)options { @@ -2380,10 +2305,13 @@ base = 8; UTF8String++; } } + + if (base == 0) + base = 10; while (*UTF8String != '\0') { unsigned char c = of_ascii_toupper(*UTF8String++); if (c >= '0' && c <= '9') @@ -2452,10 +2380,13 @@ base = 8; UTF8String++; } } + + if (base == 0) + base = 10; while (*UTF8String != '\0') { unsigned char c = of_ascii_toupper(*UTF8String++); if (c >= '0' && c <= '9') @@ -2496,10 +2427,14 @@ [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME) return -INFINITY; + if ([stripped caseInsensitiveCompare: @"NAN"] == OF_ORDERED_SAME) + return NAN; + if ([stripped caseInsensitiveCompare: @"-NAN"] == OF_ORDERED_SAME) + return -NAN; #ifdef HAVE_STRTOF_L const char *UTF8String = self.UTF8String; #else /* @@ -2545,10 +2480,14 @@ [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME) return -INFINITY; + if ([stripped caseInsensitiveCompare: @"NAN"] == OF_ORDERED_SAME) + return NAN; + if ([stripped caseInsensitiveCompare: @"-NAN"] == OF_ORDERED_SAME) + return -NAN; #ifdef HAVE_STRTOD_L const char *UTF8String = self.UTF8String; #else /* @@ -2590,12 +2529,11 @@ size_t length = self.length; of_unichar_t *buffer; buffer = of_alloc(length, sizeof(of_unichar_t)); @try { - [self getCharacters: buffer - inRange: of_range(0, length)]; + [self getCharacters: buffer inRange: of_range(0, length)]; return [[OFData dataWithItemsNoCopy: buffer count: length itemSize: sizeof(of_unichar_t) freeWhenDone: true] items]; @@ -2692,12 +2630,11 @@ size_t length = self.length; of_char32_t *buffer; buffer = of_alloc(length + 1, sizeof(of_char32_t)); @try { - [self getCharacters: buffer - inRange: of_range(0, length)]; + [self getCharacters: buffer inRange: of_range(0, length)]; buffer[length] = 0; if (byteOrder != OF_BYTE_ORDER_NATIVE) for (size_t i = 0; i < length; i++) buffer[i] = OF_BSWAP32(buffer[i]); @@ -2771,49 +2708,38 @@ #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { - [self writeToFile: path - encoding: OF_STRING_ENCODING_UTF_8]; + [self writeToFile: path encoding: OF_STRING_ENCODING_UTF_8]; } -- (void)writeToFile: (OFString *)path - encoding: (of_string_encoding_t)encoding +- (void)writeToFile: (OFString *)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); - OFFile *file; - - file = [OFFile fileWithPath: path - mode: @"w"]; - [file writeString: self - encoding: encoding]; - + OFFile *file = [OFFile fileWithPath: path mode: @"w"]; + [file writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } #endif - (void)writeToURL: (OFURL *)URL { - [self writeToURL: URL - encoding: OF_STRING_ENCODING_UTF_8]; + [self writeToURL: URL encoding: OF_STRING_ENCODING_UTF_8]; } -- (void)writeToURL: (OFURL *)URL - encoding: (of_string_encoding_t)encoding +- (void)writeToURL: (OFURL *)URL encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFURLHandler *URLHandler; OFStream *stream; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; - stream = [URLHandler openItemAtURL: URL - mode: @"w"]; - [stream writeString: self - encoding: encoding]; + stream = [URLHandler openItemAtURL: URL mode: @"w"]; + [stream writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS Index: src/OFSubarray.h ================================================================== --- src/OFSubarray.h +++ src/OFSubarray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -23,12 +21,10 @@ { OFArray *_array; of_range_t _range; } -+ (instancetype)arrayWithArray: (OFArray *)array - range: (of_range_t)range; -- (instancetype)initWithArray: (OFArray *)array - range: (of_range_t)range; ++ (instancetype)arrayWithArray: (OFArray *)array range: (of_range_t)range; +- (instancetype)initWithArray: (OFArray *)array range: (of_range_t)range; @end OF_ASSUME_NONNULL_END Index: src/OFSubarray.m ================================================================== --- src/OFSubarray.m +++ src/OFSubarray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -20,19 +18,16 @@ #import "OFSubarray.h" #import "OFOutOfRangeException.h" @implementation OFSubarray -+ (instancetype)arrayWithArray: (OFArray *)array - range: (of_range_t)range ++ (instancetype)arrayWithArray: (OFArray *)array range: (of_range_t)range { - return [[[self alloc] initWithArray: array - range: range] autorelease]; + return [[[self alloc] initWithArray: array range: range] autorelease]; } -- (instancetype)initWithArray: (OFArray *)array - range: (of_range_t)range +- (instancetype)initWithArray: (OFArray *)array range: (of_range_t)range { self = [super init]; @try { /* Should usually be retain, as it's useless with a copy */ @@ -64,21 +59,19 @@ @throw [OFOutOfRangeException exception]; return [_array objectAtIndex: idx + _range.location]; } -- (void)getObjects: (id *)buffer - inRange: (of_range_t)range +- (void)getObjects: (id *)buffer inRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _range.length) @throw [OFOutOfRangeException exception]; range.location += _range.location; - [_array getObjects: buffer - inRange: range]; + [_array getObjects: buffer inRange: range]; } - (size_t)indexOfObject: (id)object { size_t idx = [_array indexOfObject: object]; ADDED src/OFSubprocess.h Index: src/OFSubprocess.h ================================================================== --- /dev/null +++ src/OFSubprocess.h @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif + +#include "objfw-defs.h" + +#ifdef OF_HAVE_SYS_TYPES_H +# include +#endif + +#import "OFStream.h" +#import "OFKernelEventObserver.h" +#import "OFString.h" + +#ifdef OF_WINDOWS +# include +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFArray OF_GENERIC(ObjectType); +@class OFDictionary OF_GENERIC(KeyType, ObjectType); + +/** + * @class OFSubprocess OFSubprocess.h ObjFW/OFSubprocess.h + * + * @brief A class for stream-like communication with a newly created subprocess. + */ +OF_SUBCLASSING_RESTRICTED +@interface OFSubprocess: OFStream +#ifndef OF_WINDOWS + +#endif +{ +#ifndef OF_WINDOWS + pid_t _pid; + int _readPipe[2], _writePipe[2]; +#else + HANDLE _handle, _readPipe[2], _writePipe[2]; +#endif + int _status; + bool _atEndOfStream; +} + +/** + * @brief Creates a new OFSubprocess with the specified program and invokes the + * program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @return A new, autoreleased OFSubprocess. + */ ++ (instancetype)subprocessWithProgram: (OFString *)program; + +/** + * @brief Creates a new OFSubprocess with the specified program and arguments + * and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param arguments The arguments to pass to the program, or `nil` + * @return A new, autoreleased OFSubprocess. + */ ++ (instancetype) + subProcessWithProgram: (OFString *)program + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; + +/** + * @brief Creates a new OFSubprocess with the specified program, program name + * and arguments and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param programName The program name for the program to invoke (argv[0]). + * Usually, this is equal to program. + * @param arguments The arguments to pass to the program, or `nil` + * @return A new, autoreleased OFSubprocess. + */ ++ (instancetype) + subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; + +/** + * @brief Creates a new OFSubprocess with the specified program, program name, + * arguments and environment and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param programName The program name for the program to invoke (argv[0]). + * Usually, this is equal to program. + * @param arguments The arguments to pass to the program, or `nil` + * @param environment The environment to pass to the program, or `nil`. If it + * is not `nil`, the passed dictionary will be used to + * override the environment. If you want to add to the + * existing environment, you need to get the existing + * environment first, copy it, modify it and then pass it. + * @return A new, autoreleased OFSubprocess. + */ ++ (instancetype) + subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments + environment: (nullable OFDictionary + OF_GENERIC(OFString *, OFString *) *)environment; + +- (instancetype)init OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated OFSubprocess with the specified + * program and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @return An initialized OFSubprocess. + */ +- (instancetype)initWithProgram: (OFString *)program; + +/** + * @brief Initializes an already allocated OFSubprocess with the specified + * program and arguments and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param arguments The arguments to pass to the program, or `nil` + * @return An initialized OFSubprocess. + */ +- (instancetype) + initWithProgram: (OFString *)program + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; + +/** + * @brief Initializes an already allocated OFSubprocess with the specified + * program, program name and arguments and invokes the program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param programName The program name for the program to invoke (argv[0]). + * Usually, this is equal to program. + * @param arguments The arguments to pass to the program, or `nil` + * @return An initialized OFSubprocess. + */ +- (instancetype) + initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments; + +/** + * @brief Initializes an already allocated OFSubprocess with the specified + * program, program name, arguments and environment and invokes the + * program. + * + * @param program The program to execute. If it does not start with a slash, the + * search path specified in PATH is used. + * @param programName The program name for the program to invoke (argv[0]). + * Usually, this is equal to program. + * @param arguments The arguments to pass to the program, or `nil` + * @param environment The environment to pass to the program, or `nil`. If it + * is not `nil`, the passed dictionary will be used to + * override the environment. If you want to add to the + * existing environment, you need to get the existing + * environment first, copy it, modify it and then pass it. + * @return An initialized OFSubprocess. + */ +- (instancetype) + initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments + environment: (nullable OFDictionary + OF_GENERIC(OFString *, OFString *) *)environment + OF_DESIGNATED_INITIALIZER; + +/** + * @brief Closes the write direction of the subprocess. + * + * This method needs to be called for some programs before data can be read, + * since some programs don't start processing before the write direction is + * closed. + */ +- (void)closeForWriting; + +/** + * @brief Waits for the subprocess to terminate and returns the exit status. + * + * If the subprocess has already exited, this returns the exit status + * immediately. + */ +- (int)waitForTermination; +@end + +OF_ASSUME_NONNULL_END ADDED src/OFSubprocess.m Index: src/OFSubprocess.m ================================================================== --- /dev/null +++ src/OFSubprocess.m @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#include "platform.h" + +#ifdef OF_WINDOWS +# include "platform/windows/OFSubprocess.m" +#else +# include "platform/posix/OFSubprocess.m" +#endif Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -487,11 +485,10 @@ [path deleteCharactersInRange: of_range(0, 1)]; [path prependString: home]; } [path appendString: @"/Preferences"]; - [path makeImmutable]; return path; # elif defined(OF_WINDOWS) OFDictionary *env = [OFApplication environment]; Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -151,21 +149,19 @@ * @brief Connect the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to */ -- (void)connectToHost: (OFString *)host - port: (uint16_t)port; +- (void)connectToHost: (OFString *)host port: (uint16_t)port; /** * @brief Asynchronously connect the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to */ -- (void)asyncConnectToHost: (OFString *)host - port: (uint16_t)port; +- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port; /** * @brief Asynchronously connect the OFTCPSocket to the specified destination. * * @param host The host to connect to @@ -209,12 +205,11 @@ * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. * @return The port the socket was bound to */ -- (uint16_t)bindToHost: (OFString *)host - port: (uint16_t)port; +- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port; @end #ifdef __cplusplus extern "C" { #endif Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -13,14 +11,18 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#define __NO_EXT_QNX - #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define __NO_EXT_QNX +#define _HPUX_ALT_XOPEN_SOCKET_API + #include #include #include #include @@ -178,12 +180,11 @@ { closesocket(_socket); _socket = INVALID_SOCKET; } -- (void)connectToHost: (OFString *)host - port: (uint16_t)port +- (void)connectToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); id delegate = _delegate; OFTCPSocketConnectDelegate *connectDelegate = [[[OFTCPSocketConnectDelegate alloc] init] autorelease]; @@ -193,27 +194,24 @@ [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode]; while (!connectDelegate->_done) - [runLoop runMode: connectRunLoopMode - beforeDate: nil]; + [runLoop runMode: connectRunLoopMode beforeDate: nil]; /* Cleanup */ - [runLoop runMode: connectRunLoopMode - beforeDate: [OFDate date]]; + [runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]]; if (connectDelegate->_exception != nil) @throw connectDelegate->_exception; self.delegate = delegate; objc_autoreleasePoolPop(pool); } -- (void)asyncConnectToHost: (OFString *)host - port: (uint16_t)port +- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port { [self asyncConnectToHost: host port: port runLoopMode: of_run_loop_mode_default]; } @@ -297,12 +295,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (uint16_t)bindToHost: (OFString *)host - port: (uint16_t)port +- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { const int one = 1; void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; of_socket_address_t address; @@ -340,11 +337,11 @@ #endif setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&one, (socklen_t)sizeof(one)); -#if defined(OF_WII) || defined(OF_NINTENDO_3DS) +#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) if (port != 0) { #endif if (bind(_socket, &address.sockaddr.sockaddr, address.length) != 0) { int errNo = of_socket_errno(); @@ -355,11 +352,11 @@ @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } -#if defined(OF_WII) || defined(OF_NINTENDO_3DS) +#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) } else { for (;;) { uint16_t rnd = 0; int ret; @@ -393,11 +390,11 @@ objc_autoreleasePoolPop(pool); if (port > 0) return port; -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) memset(&address, 0, sizeof(address)); address.length = (socklen_t)sizeof(address.sockaddr); if (of_getsockname(_socket, &address.sockaddr.sockaddr, &address.length) != 0) { Index: src/OFTCPSocketSOCKS5Connector.h ================================================================== --- src/OFTCPSocketSOCKS5Connector.h +++ src/OFTCPSocketSOCKS5Connector.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTCPSocketSOCKS5Connector.m ================================================================== --- src/OFTCPSocketSOCKS5Connector.m +++ src/OFTCPSocketSOCKS5Connector.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -82,11 +80,11 @@ _block(_exception); else { #endif if ([_delegate respondsToSelector: @selector(socket:didConnectToHost:port:exception:)]) - [_delegate socket: _socket + [_delegate socket: _socket didConnectToHost: _host port: _port exception: _exception]; #ifdef OF_HAVE_BLOCKS } @@ -104,12 +102,11 @@ _exception = [exception retain]; [self didConnect]; return; } - data = [OFData dataWithItems: "\x05\x01\x00" - count: 3]; + data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; _SOCKS5State = OF_SOCKS5_STATE_SEND_AUTHENTICATION; [_socket asyncWriteData: data runLoopMode: [OFRunLoop currentRunLoop].currentMode]; } @@ -148,26 +145,22 @@ } [_request release]; _request = [[OFMutableData alloc] init]; - [_request addItems: "\x05\x01\x00\x03" - count: 4]; + [_request addItems: "\x05\x01\x00\x03" count: 4]; hostLength = (uint8_t)_host.UTF8StringLength; [_request addItem: &hostLength]; - [_request addItems: _host.UTF8String - count: hostLength]; + [_request addItems: _host.UTF8String count: hostLength]; port[0] = _port >> 8; port[1] = _port & 0xFF; - [_request addItems: port - count: 2]; + [_request addItems: port count: 2]; _SOCKS5State = OF_SOCKS5_STATE_SEND_REQUEST; - [_socket asyncWriteData: _request - runLoopMode: runLoopMode]; + [_socket asyncWriteData: _request runLoopMode: runLoopMode]; return false; case OF_SOCKS5_STATE_READ_RESPONSE: response = buffer; if (response[0] != 5 || response[2] != 0) { Index: src/OFTLSSocket.h ================================================================== --- src/OFTLSSocket.h +++ src/OFTLSSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTarArchive.h ================================================================== --- src/OFTarArchive.h +++ src/OFTarArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -65,12 +63,11 @@ * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive */ -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode; ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /** * @brief Creates a new OFTarArchive object with the specified file. * @@ -78,12 +75,11 @@ * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive */ -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode; ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode; #endif - (instancetype)init OF_UNAVAILABLE; /** @@ -109,12 +105,11 @@ * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFTarArchive */ -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode; +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; #endif /** * @brief Returns the next entry from the tar archive or `nil` if all entries * have been read. Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -61,33 +59,28 @@ @end @implementation OFTarArchive: OFObject @synthesize encoding = _encoding; -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { - return [[[self alloc] initWithStream: stream - mode: mode] autorelease]; + return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } #ifdef OF_HAVE_FILES -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode { - return [[[self alloc] initWithPath: path - mode: mode] autorelease]; + return [[[self alloc] initWithPath: path mode: mode] autorelease]; } #endif - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OFStream *)stream - mode: (OFString *)mode +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { _stream = [stream retain]; @@ -108,12 +101,11 @@ if (![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; [(OFSeekableStream *)_stream seekToOffset: -1024 whence: SEEK_END]; - [_stream readIntoBuffer: buffer - exactLength: 1024]; + [_stream readIntoBuffer: buffer exactLength: 1024]; for (size_t i = 0; i < 1024 / sizeof(uint32_t); i++) if (buffer[i] != 0) empty = false; @@ -132,25 +124,21 @@ return self; } #ifdef OF_HAVE_FILES -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode { OFFile *file; if ([mode isEqual: @"a"]) - file = [[OFFile alloc] initWithPath: path - mode: @"r+"]; + file = [[OFFile alloc] initWithPath: path mode: @"r+"]; else - file = [[OFFile alloc] initWithPath: path - mode: mode]; + file = [[OFFile alloc] initWithPath: path mode: mode]; @try { - self = [self initWithStream: file - mode: mode]; + self = [self initWithStream: file mode: mode]; } @finally { [file release]; } return self; @@ -183,20 +171,18 @@ _lastReturnedStream = nil; if (_stream.atEndOfStream) return nil; - [_stream readIntoBuffer: buffer - exactLength: 512]; + [_stream readIntoBuffer: buffer exactLength: 512]; for (size_t i = 0; i < 512 / sizeof(uint32_t); i++) if (buffer[i] != 0) empty = false; if (empty) { - [_stream readIntoBuffer: buffer - exactLength: 512]; + [_stream readIntoBuffer: buffer exactLength: 512]; for (size_t i = 0; i < 512 / sizeof(uint32_t); i++) if (buffer[i] != 0) @throw [OFInvalidFormatException exception]; @@ -242,12 +228,11 @@ /* Might have already been closed by the user - that's fine. */ } [_lastReturnedStream release]; _lastReturnedStream = nil; - [entry of_writeToStream: _stream - encoding: _encoding]; + [entry of_writeToStream: _stream encoding: _encoding]; _lastReturnedStream = [[OFTarArchiveFileWriteStream alloc] of_initWithStream: _stream entry: entry]; @@ -328,13 +313,11 @@ #endif if ((uint64_t)length > _toRead) length = (size_t)_toRead; - ret = [_stream readIntoBuffer: buffer - length: length]; - + ret = [_stream readIntoBuffer: buffer length: length]; if (ret == 0) _atEndOfStream = true; _toRead -= ret; @@ -396,12 +379,11 @@ } else { char buffer[512]; uint64_t size; while (_toRead >= 512) { - [_stream readIntoBuffer: buffer - exactLength: 512]; + [_stream readIntoBuffer: buffer exactLength: 512]; _toRead -= 512; } if (_toRead > 0) { [_stream readIntoBuffer: buffer @@ -446,12 +428,11 @@ [_entry release]; [super dealloc]; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { size_t bytesWritten; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; Index: src/OFTarArchiveEntry+Private.h ================================================================== --- src/OFTarArchiveEntry+Private.h +++ src/OFTarArchiveEntry+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -342,9 +340,8 @@ checksum += buffer[i]; stringToBuffer(buffer + 148, [OFString stringWithFormat: @"%06" PRIo16, checksum], 7, OF_STRING_ENCODING_ASCII); - [stream writeBuffer: buffer - length: sizeof(buffer)]; + [stream writeBuffer: buffer length: sizeof(buffer)]; } @end Index: src/OFThread+Private.h ================================================================== --- src/OFThread+Private.h +++ src/OFThread+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -250,10 +248,21 @@ #elif defined(OF_NINTENDO_3DS) if (timeInterval * 1000000000 > INT64_MAX) @throw [OFOutOfRangeException exception]; svcSleepThread((int64_t)(timeInterval * 1000000000)); +#elif defined(OF_AMIGAOS) + struct timerequest request = *DOSBase->dl_TimeReq; + + request.tr_node.io_Message.mn_ReplyPort = + &((struct Process *)FindTask(NULL))->pr_MsgPort; + request.tr_node.io_Command = TR_ADDREQUEST; + request.tr_time.tv_secs = (ULONG)timeInterval; + request.tr_time.tv_micro = (ULONG) + ((timeInterval - (unsigned int)timeInterval) * 1000000); + + DoIO((struct IORequest *)&request); #elif defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)timeInterval; rqtp.tv_nsec = (long)((timeInterval - rqtp.tv_sec) * 1000000000); @@ -260,15 +269,10 @@ if (rqtp.tv_sec != trunc(timeInterval)) @throw [OFOutOfRangeException exception]; nanosleep(&rqtp, NULL); -#elif defined(OF_AMIGAOS) - if (timeInterval * 50 > ULONG_MAX) - @throw [OFOutOfRangeException exception]; - - Delay(timeInterval * 50); #elif defined(OF_NINTENDO_DS) uint64_t counter; if (timeInterval > UINT64_MAX / 60) @throw [OFOutOfRangeException exception]; @@ -280,11 +284,11 @@ if (timeInterval > UINT_MAX) @throw [OFOutOfRangeException exception]; sleep((unsigned int)timeInterval); usleep((unsigned int) - (timeInterval - (unsigned int)timeInterval) * 1000000); + ((timeInterval - (unsigned int)timeInterval) * 1000000)); #endif } + (void)sleepUntilDate: (OFDate *)date { Index: src/OFTimer+Private.h ================================================================== --- src/OFTimer+Private.h +++ src/OFTimer+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTimer.h ================================================================== --- src/OFTimer.h +++ src/OFTimer.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -518,12 +516,11 @@ timer = (OFTimer *)object; return [_fireDate compare: timer->_fireDate]; } -- (void)of_setInRunLoop: (OFRunLoop *)runLoop - mode: (of_run_loop_mode_t)mode +- (void)of_setInRunLoop: (OFRunLoop *)runLoop mode: (of_run_loop_mode_t)mode { OFRunLoop *oldInRunLoop = _inRunLoop; of_run_loop_mode_t oldInRunLoopMode = _inRunLoopMode; _inRunLoop = [runLoop retain]; @@ -560,12 +557,11 @@ [_fireDate release]; _fireDate = [[OFDate alloc] initWithTimeIntervalSince1970: newFireDate]; runLoop = [OFRunLoop currentRunLoop]; - [runLoop addTimer: self - forMode: runLoop.currentMode]; + [runLoop addTimer: self forMode: runLoop.currentMode]; } else [self invalidate]; #ifdef OF_HAVE_BLOCKS if (_block != NULL) @@ -575,12 +571,11 @@ switch (_arguments) { case 0: [target performSelector: _selector]; break; case 1: - [target performSelector: _selector - withObject: object1]; + [target performSelector: _selector withObject: object1]; break; case 2: [target performSelector: _selector withObject: object1 withObject: object2]; @@ -633,12 +628,11 @@ old = _fireDate; _fireDate = [fireDate copy]; [old release]; - [_inRunLoop addTimer: self - forMode: _inRunLoopMode]; + [_inRunLoop addTimer: self forMode: _inRunLoopMode]; } } @finally { [self release]; } } Index: src/OFTriple.h ================================================================== --- src/OFTriple.h +++ src/OFTriple.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFTriple.m ================================================================== --- src/OFTriple.m +++ src/OFTriple.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFUDPSocket+Private.h ================================================================== --- src/OFUDPSocket+Private.h +++ src/OFUDPSocket+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -72,10 +70,9 @@ * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. * @return The port the socket was bound to */ -- (uint16_t)bindToHost: (OFString *)host - port: (uint16_t)port; +- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port; @end OF_ASSUME_NONNULL_END Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,10 +13,15 @@ * file. */ #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define _HPUX_ALT_XOPEN_SOCKET_API + #include #ifdef HAVE_FCNTL_H # include #endif @@ -65,11 +68,11 @@ if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) { fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); } #endif -#if defined(OF_WII) || defined(OF_NINTENDO_3DS) +#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) if (of_socket_address_get_port(address) != 0) { #endif if (bind(_socket, &address->sockaddr.sockaddr, address->length) != 0) { int errNo = of_socket_errno(); @@ -81,11 +84,11 @@ @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } -#if defined(OF_WII) || defined(OF_NINTENDO_3DS) +#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS) } else { for (;;) { uint16_t rnd = 0; int ret; @@ -121,11 +124,11 @@ objc_autoreleasePoolPop(pool); if ((port = of_socket_address_get_port(address)) > 0) return port; -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) memset(address, 0, sizeof(*address)); address->length = (socklen_t)sizeof(address->sockaddr); if (of_getsockname(_socket, &address->sockaddr.sockaddr, &address->length) != 0) { @@ -167,12 +170,11 @@ socket: self errNo: EADDRNOTAVAIL]; #endif } -- (uint16_t)bindToHost: (OFString *)host - port: (uint16_t)port +- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; of_socket_address_t address; @@ -184,13 +186,12 @@ addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY]; address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0]; of_socket_address_set_port(&address, port); - port = [self of_bindToAddress: &address - extraType: 0]; + port = [self of_bindToAddress: &address extraType: 0]; objc_autoreleasePoolPop(pool); return port; } @end Index: src/OFURL.h ================================================================== --- src/OFURL.h +++ src/OFURL.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -189,12 +187,11 @@ * * @param string A string describing a URL * @param URL An URL to which the string is relative * @return A new, autoreleased OFURL */ -+ (instancetype)URLWithString: (OFString *)string - relativeToURL: (OFURL *)URL; ++ (instancetype)URLWithString: (OFString *)string relativeToURL: (OFURL *)URL; #ifdef OF_HAVE_FILES /** * @brief Creates a new URL with the specified local file path. * @@ -232,12 +229,11 @@ * * @param string A string describing a URL * @param URL A URL to which the string is relative * @return An initialized OFURL */ -- (instancetype)initWithString: (OFString *)string - relativeToURL: (OFURL *)URL; +- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL; #ifdef OF_HAVE_FILES /** * @brief Initializes an already allocated OFURL with the specified local file * path. Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -615,12 +613,11 @@ } return self; } -- (instancetype)initWithString: (OFString *)string - relativeToURL: (OFURL *)URL +- (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL { char *UTF8String, *UTF8String2 = NULL; if ([string containsString: @"://"]) return [self initWithString: string]; @@ -717,21 +714,18 @@ { bool isDirectory; @try { void *pool = objc_autoreleasePoolPush(); - isDirectory = [path of_isDirectoryPath]; - objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } - self = [self initFileURLWithPath: path - isDirectory: isDirectory]; + self = [self initFileURLWithPath: path isDirectory: isDirectory]; return self; } - (instancetype)initFileURLWithPath: (OFString *)path @@ -950,22 +944,20 @@ OFString *path = [_URLEncodedPath of_URLPathToPathWithURLEncodedHost: nil]; ret = [[path.pathComponents mutableCopy] autorelease]; if (![ret.firstObject isEqual: @"/"]) - [ret insertObject: @"/" - atIndex: 0]; + [ret insertObject: @"/" atIndex: 0]; } else #endif ret = [[[_URLEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; count = ret.count; if (count > 0 && [ret.firstObject length] == 0) - [ret replaceObjectAtIndex: 0 - withObject: @"/"]; + [ret replaceObjectAtIndex: 0 withObject: @"/"]; for (size_t i = 0; i < count; i++) { OFString *component = [ret objectAtIndex: i]; #ifdef OF_HAVE_FILES @@ -1162,36 +1154,29 @@ #endif - (OFURL *)URLByAppendingPathComponent: (OFString *)component { OFMutableURL *URL = [[self mutableCopy] autorelease]; - [URL appendPathComponent: component]; [URL makeImmutable]; - return URL; } - (OFURL *)URLByAppendingPathComponent: (OFString *)component isDirectory: (bool)isDirectory { OFMutableURL *URL = [[self mutableCopy] autorelease]; - - [URL appendPathComponent: component - isDirectory: isDirectory]; + [URL appendPathComponent: component isDirectory: isDirectory]; [URL makeImmutable]; - return URL; } - (OFURL *)URLByStandardizingPath { OFMutableURL *URL = [[self mutableCopy] autorelease]; - [URL standardizePath]; [URL makeImmutable]; - return URL; } - (OFString *)description { Index: src/OFURLHandler.h ================================================================== --- src/OFURLHandler.h +++ src/OFURLHandler.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -51,12 +49,11 @@ * @param class_ The class to register as the handler for the specified scheme * @param scheme The scheme for which to register the handler * @return Whether the class was successfully registered. If a handler for the * same scheme is already registered, registration fails. */ -+ (bool)registerClass: (Class)class_ - forScheme: (OFString *)scheme; ++ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme; /** * @brief Returns the handler for the specified URL. * * @return The handler for the specified URL. @@ -92,12 +89,11 @@ * `a+` | Read-write, create or append * @n * The handler is allowed to not implement all modes and is also * allowed to implement additional, scheme-specific modes. */ -- (OFStream *)openItemAtURL: (OFURL *)URL - mode: (OFString *)mode; +- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode; /** * @brief Returns the attributes for the item at the specified URL. * * @param URL The URL to return the attributes for @@ -168,12 +164,11 @@ * This method is not available for all URLs. * * @param source The URL to the item for which a link should be created * @param destination The URL to the item which should link to the source */ -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination; /** * @brief Creates a symbolic link for an item. * * The destination uRL must have a full path, which means it must include the @@ -205,12 +200,11 @@ * @param destination The destination URL * @return True if an efficient copy was performed, false if an efficient copy * was not possible. Note that errors while performing a copy are * reported via exceptions and not by returning false! */ -- (bool)copyItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (bool)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination; /** * @brief Tries to efficiently move an item. If a move would only be possible * by copying the source and deleting it, it returns false. * @@ -224,10 +218,9 @@ * @param destination The new name for the item * @return True if an efficient move was performed, false if an efficient move * was not possible. Note that errors while performing a move are * reported via exceptions and not by returning false! */ -- (bool)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination; +- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination; @end OF_ASSUME_NONNULL_END Index: src/OFURLHandler.m ================================================================== --- src/OFURLHandler.m +++ src/OFURLHandler.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -57,23 +55,19 @@ mutex = [[OFMutex alloc] init]; atexit(releaseMutex); #endif #ifdef OF_HAVE_FILES - [self registerClass: [OFFileURLHandler class] - forScheme: @"file"]; + [self registerClass: [OFFileURLHandler class] forScheme: @"file"]; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) - [self registerClass: [OFHTTPURLHandler class] - forScheme: @"http"]; - [self registerClass: [OFHTTPURLHandler class] - forScheme: @"https"]; + [self registerClass: [OFHTTPURLHandler class] forScheme: @"http"]; + [self registerClass: [OFHTTPURLHandler class] forScheme: @"https"]; #endif } -+ (bool)registerClass: (Class)class - forScheme: (OFString *)scheme ++ (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; @try { #endif @@ -82,12 +76,11 @@ if ([handlers objectForKey: scheme] != nil) return false; handler = [[class alloc] initWithScheme: scheme]; @try { - [handlers setObject: handler - forKey: scheme]; + [handlers setObject: handler forKey: scheme]; } @finally { [handler release]; } #ifdef OF_HAVE_THREADS } @finally { @@ -140,12 +133,11 @@ [_scheme release]; [super dealloc]; } -- (OFStream *)openItemAtURL: (OFURL *)URL - mode: (OFString *)mode +- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode { OF_UNRECOGNIZED_SELECTOR } - (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL @@ -182,12 +174,11 @@ - (void)removeItemAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { OF_UNRECOGNIZED_SELECTOR } - (void)createSymbolicLinkAtURL: (OFURL *)destination @@ -194,17 +185,15 @@ withDestinationPath: (OFString *)source { OF_UNRECOGNIZED_SELECTOR } -- (bool)copyItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (bool)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination { return false; } -- (bool)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination { return false; } @end Index: src/OFUTF8String+Private.h ================================================================== --- src/OFUTF8String+Private.h +++ src/OFUTF8String+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFUTF8String.h ================================================================== --- src/OFUTF8String.h +++ src/OFUTF8String.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFUTF8String.m ================================================================== --- src/OFUTF8String.m +++ src/OFUTF8String.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -971,12 +969,11 @@ @throw [OFInvalidEncodingException exception]; return character; } -- (void)getCharacters: (of_unichar_t *)buffer - inRange: (of_range_t)range +- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range { /* TODO: Could be slightly optimized */ void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = self.characters; @@ -1239,13 +1236,13 @@ } if (*cString == '\n' || *cString == '\r') { pool = objc_autoreleasePoolPush(); - block([OFString - stringWithUTF8String: last - length: cString - last], &stop); + block([OFString stringWithUTF8String: last + length: cString - last], + &stop); last = cString + 1; objc_autoreleasePoolPop(pool); } Index: src/OFValue.h ================================================================== --- src/OFValue.h +++ src/OFValue.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -220,15 +218,14 @@ * @ref OFOutOfRangeException. * * @param value The buffer to copy the value into * @param size The size of the value */ -- (void)getValue: (void *)value - size: (size_t)size; +- (void)getValue: (void *)value size: (size_t)size; @end OF_ASSUME_NONNULL_END #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* Required for array literals to work */ @compatibility_alias NSValue OFValue; #endif Index: src/OFValue.m ================================================================== --- src/OFValue.m +++ src/OFValue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -190,15 +188,12 @@ free(value); @throw e; } @try { - [self getValue: value - size: size]; - [object getValue: otherValue - size: size]; - + [self getValue: value size: size]; + [object getValue: otherValue size: size]; ret = (memcmp(value, otherValue, size) == 0); } @finally { free(value); free(otherValue); } @@ -212,12 +207,11 @@ unsigned char *value; uint32_t hash; value = of_alloc(1, size); @try { - [self getValue: value - size: size]; + [self getValue: value size: size]; OF_HASH_INIT(hash); for (size_t i = 0; i < size; i++) OF_HASH_ADD(hash, value[i]); @@ -238,73 +232,54 @@ - (const char *)objCType { OF_UNRECOGNIZED_SELECTOR } -- (void)getValue: (void *)value - size: (size_t)size +- (void)getValue: (void *)value size: (size_t)size { OF_UNRECOGNIZED_SELECTOR } - (void *)pointerValue { void *ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (id)nonretainedObjectValue { id ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_range_t)rangeValue { of_range_t ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_point_t)pointValue { of_point_t ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_dimension_t)dimensionValue { of_dimension_t ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (of_rectangle_t)rectangleValue { of_rectangle_t ret; - - [self getValue: &ret - size: sizeof(ret)]; - + [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { @@ -313,12 +288,11 @@ size_t size = of_sizeof_type_encoding(self.objCType); unsigned char *value; value = of_alloc(1, size); @try { - [self getValue: value - size: size]; + [self getValue: value size: size]; for (size_t i = 0; i < size; i++) { if (i > 0) [ret appendString: @" "]; Index: src/OFWin32ConsoleStdIOStream.h ================================================================== --- src/OFWin32ConsoleStdIOStream.h +++ src/OFWin32ConsoleStdIOStream.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFWin32ConsoleStdIOStream.m ================================================================== --- src/OFWin32ConsoleStdIOStream.m +++ src/OFWin32ConsoleStdIOStream.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -124,12 +122,11 @@ } return self; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer_ - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer_ length: (size_t)length { void *pool = objc_autoreleasePoolPush(); char *buffer = buffer_; of_char16_t *UTF16; size_t j = 0; @@ -190,12 +187,11 @@ j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; - [rest addItems: UTF8 - count: UTF8Len]; + [rest addItems: UTF8 count: UTF8Len]; } _incompleteUTF16Surrogate = 0; i++; } @@ -248,29 +244,26 @@ j += UTF8Len; } else { if (rest == nil) rest = [OFMutableData data]; - [rest addItems: UTF8 - count: UTF8Len]; + [rest addItems: UTF8 count: UTF8Len]; } } if (rest != nil) - [self unreadFromBuffer: rest.items - length: rest.count]; + [self unreadFromBuffer: rest.items length: rest.count]; } @finally { free(UTF16); } objc_autoreleasePoolPop(pool); return j; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer_ - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer_ length: (size_t)length { const char *buffer = buffer_; of_char16_t *tmp; size_t i = 0, j = 0; @@ -491,14 +484,11 @@ return; csbi.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); - [color getRed: &red - green: &green - blue: &blue - alpha: NULL]; + [color getRed: &red green: &green blue: &blue alpha: NULL]; if (red >= 0.25) csbi.wAttributes |= FOREGROUND_RED; if (green >= 0.25) csbi.wAttributes |= FOREGROUND_GREEN; @@ -520,14 +510,11 @@ return; csbi.wAttributes &= ~(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY); - [color getRed: &red - green: &green - blue: &blue - alpha: NULL]; + [color getRed: &red green: &green blue: &blue alpha: NULL]; if (red >= 0.25) csbi.wAttributes |= BACKGROUND_RED; if (green >= 0.25) csbi.wAttributes |= BACKGROUND_GREEN; Index: src/OFWindowsRegistryKey.h ================================================================== --- src/OFWindowsRegistryKey.h +++ src/OFWindowsRegistryKey.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -136,72 +134,72 @@ disposition: (nullable DWORD *)disposition; /** * @brief Returns the data for the specified value at the specified path. * - * @param value The name of the value to return - * @param type A pointer to store the type of the value, or NULL - * @return The data for the specified value - */ -- (nullable OFData *)dataForValue: (nullable OFString *)value - type: (nullable DWORD *)type; - -/** - * @brief Sets the data for the specified value. - * - * @param data The data to set the value to - * @param value The name of the value to set - * @param type The type for the value - */ -- (void)setData: (nullable OFData *)data - forValue: (nullable OFString *)value - type: (DWORD)type; - -/** - * @brief Returns the string for the specified value at the specified path. - * - * @param value The name of the value to return - * @return The string for the specified value - */ -- (nullable OFString *)stringForValue: (nullable OFString *)value; - -/** - * @brief Returns the string for the specified value at the specified path. - * - * @param value The name of the value to return - * @param type A pointer to store the type of the value, or NULL - * @return The string for the specified value - */ -- (nullable OFString *)stringForValue: (nullable OFString *)value - type: (nullable DWORD *)type; - -/** - * @brief Sets the string for the specified value. - * - * @param string The string to set the value to - * @param value The name of the value to set - */ -- (void)setString: (nullable OFString *)string - forValue: (nullable OFString *)value; - -/** - * @brief Sets the string for the specified value. - * - * @param string The string to set the value to - * @param value The name of the value to set - * @param type The type for the value - */ -- (void)setString: (nullable OFString *)string - forValue: (nullable OFString *)value - type: (DWORD)type; - -/** - * @brief Deletes the specified value. - * - * @param value The value to delete - */ -- (void)deleteValue: (nullable OFString *)value; + * @param name The name of the value to return + * @param type A pointer to store the type of the value, or NULL + * @return The data for the specified value + */ +- (nullable OFData *)dataForValueNamed: (nullable OFString *)name + type: (nullable DWORD *)type; + +/** + * @brief Sets the data for the specified value. + * + * @param data The data to set the value to + * @param name The name of the value to set + * @param type The type for the value + */ +- (void)setData: (nullable OFData *)data + forValueNamed: (nullable OFString *)name + type: (DWORD)type; + +/** + * @brief Returns the string for the specified value at the specified path. + * + * @param name The name of the value to return + * @return The string for the specified value + */ +- (nullable OFString *)stringForValueNamed: (nullable OFString *)name; + +/** + * @brief Returns the string for the specified value at the specified path. + * + * @param name The name of the value to return + * @param type A pointer to store the type of the value, or NULL + * @return The string for the specified value + */ +- (nullable OFString *)stringForValueNamed: (nullable OFString *)name + type: (nullable DWORD *)type; + +/** + * @brief Sets the string for the specified value. + * + * @param string The string to set the value to + * @param name The name of the value to set + */ +- (void)setString: (nullable OFString *)string + forValueNamed: (nullable OFString *)name; + +/** + * @brief Sets the string for the specified value. + * + * @param string The string to set the value to + * @param name The name of the value to set + * @param type The type for the value + */ +- (void)setString: (nullable OFString *)string + forValueNamed: (nullable OFString *)name + type: (DWORD)type; + +/** + * @brief Deletes the specified value. + * + * @param name The value to delete + */ +- (void)deleteValueNamed: (nullable OFString *)name; /** * @brief Deletes the specified subkey. * * @param subkeyPath The path of the subkey to delete Index: src/OFWindowsRegistryKey.m ================================================================== --- src/OFWindowsRegistryKey.m +++ src/OFWindowsRegistryKey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -34,12 +32,11 @@ #import "OFOutOfRangeException.h" #import "OFSetWindowsRegistryValueFailedException.h" OF_DIRECT_MEMBERS @interface OFWindowsRegistryKey () -- (instancetype)of_initWithHKey: (HKEY)hKey - close: (bool)close; +- (instancetype)of_initWithHKey: (HKEY)hKey close: (bool)close; @end @implementation OFWindowsRegistryKey + (instancetype)classesRootKey { @@ -69,12 +66,11 @@ { return [[[self alloc] of_initWithHKey: HKEY_USERS close: false] autorelease]; } -- (instancetype)of_initWithHKey: (HKEY)hKey - close: (bool)close +- (instancetype)of_initWithHKey: (HKEY)hKey close: (bool)close { self = [super init]; _hKey = hKey; _close = close; @@ -185,12 +181,11 @@ return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } -- (OFData *)dataForValue: (OFString *)value - type: (DWORD *)type +- (OFData *)dataForValueNamed: (OFString *)name type: (DWORD *)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; @@ -197,15 +192,15 @@ bool winNT = [OFSystemInfo isWindowsNT]; LSTATUS status; for (;;) { if (winNT) - status = RegQueryValueExW(_hKey, value.UTF16String, + status = RegQueryValueExW(_hKey, name.UTF16String, NULL, type, buffer, &length); else status = RegQueryValueExA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]], + [name cStringWithEncoding: [OFLocale encoding]], NULL, type, buffer, &length); switch (status) { case ERROR_SUCCESS: if (buffer == stackBuffer) { @@ -235,56 +230,53 @@ continue; default: @throw [OFGetWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name status: status]; } } } - (void)setData: (OFData *)data - forValue: (OFString *)value + forValueNamed: (OFString *)name type: (DWORD)type { size_t length = data.count * data.itemSize; LSTATUS status; if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; if ([OFSystemInfo isWindowsNT]) - status = RegSetValueExW(_hKey, value.UTF16String, 0, type, + status = RegSetValueExW(_hKey, name.UTF16String, 0, type, data.items, (DWORD)length); else status = RegSetValueExA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]], 0, type, + [name cStringWithEncoding: [OFLocale encoding]], 0, type, data.items, (DWORD)length); if (status != ERROR_SUCCESS) @throw [OFSetWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name data: data type: type status: status]; } -- (OFString *)stringForValue: (OFString *)value +- (OFString *)stringForValueNamed: (OFString *)name { - return [self stringForValue: value - type: NULL]; + return [self stringForValueNamed: name type: NULL]; } -- (OFString *)stringForValue: (OFString *)value - type: (DWORD *)typeOut +- (OFString *)stringForValueNamed: (OFString *)name type: (DWORD *)typeOut { void *pool = objc_autoreleasePoolPush(); DWORD type; - OFData *data = [self dataForValue: value - type: &type]; + OFData *data = [self dataForValueNamed: name type: &type]; OFString *ret; if (data == nil) return nil; @@ -342,20 +334,17 @@ objc_autoreleasePoolPop(pool); return [ret autorelease]; } -- (void)setString: (OFString *)string - forValue: (OFString *)value +- (void)setString: (OFString *)string forValueNamed: (OFString *)name { - [self setString: string - forValue: value - type: REG_SZ]; + [self setString: string forValueNamed: name type: REG_SZ]; } - (void)setString: (OFString *)string - forValue: (OFString *)value + forValueNamed: (OFString *)name type: (DWORD)type { void *pool = objc_autoreleasePoolPush(); OFData *data; @@ -366,36 +355,33 @@ else { of_string_encoding_t encoding = [OFLocale encoding]; const char *cString = [string cStringWithEncoding: encoding]; size_t length = [string cStringLengthWithEncoding: encoding]; - data = [OFData dataWithItems: cString - count: length + 1]; + data = [OFData dataWithItems: cString count: length + 1]; } - [self setData: data - forValue: value - type: type]; + [self setData: data forValueNamed: name type: type]; objc_autoreleasePoolPop(pool); } -- (void)deleteValue: (OFString *)value +- (void)deleteValueNamed: (OFString *)name { void *pool = objc_autoreleasePoolPush(); LSTATUS status; if ([OFSystemInfo isWindowsNT]) - status = RegDeleteValueW(_hKey, value.UTF16String); + status = RegDeleteValueW(_hKey, name.UTF16String); else status = RegDeleteValueA(_hKey, - [value cStringWithEncoding: [OFLocale encoding]]); + [name cStringWithEncoding: [OFLocale encoding]]); if (status != ERROR_SUCCESS) @throw [OFDeleteWindowsRegistryValueFailedException exceptionWithRegistryKey: self - value: value + valueName: name status: status]; objc_autoreleasePoolPop(pool); } Index: src/OFXMLAttribute.h ================================================================== --- src/OFXMLAttribute.h +++ src/OFXMLAttribute.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -160,13 +158,11 @@ void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; - - [element addAttributeWithName: @"name" - stringValue: _name]; + [element addAttributeWithName: @"name" stringValue: _name]; if (_namespace != nil) [element addAttributeWithName: @"namespace" stringValue: _namespace]; Index: src/OFXMLCDATA.h ================================================================== --- src/OFXMLCDATA.h +++ src/OFXMLCDATA.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLCDATA.m ================================================================== --- src/OFXMLCDATA.m +++ src/OFXMLCDATA.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -122,11 +120,11 @@ { return self.XMLString; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation - level: (unsigned int)level + level: (unsigned int)level { return self.XMLString; } - (OFString *)description Index: src/OFXMLCharacters.h ================================================================== --- src/OFXMLCharacters.h +++ src/OFXMLCharacters.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLCharacters.m ================================================================== --- src/OFXMLCharacters.m +++ src/OFXMLCharacters.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLComment.h ================================================================== --- src/OFXMLComment.h +++ src/OFXMLComment.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLElement+Serialization.h ================================================================== --- src/OFXMLElement+Serialization.h +++ src/OFXMLElement+Serialization.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLElement+Serialization.m ================================================================== --- src/OFXMLElement+Serialization.m +++ src/OFXMLElement+Serialization.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -21,10 +19,11 @@ @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableString; +@class OFStream; @class OFString; @class OFXMLAttribute; /** * @class OFXMLElement OFXMLElement.h ObjFW/OFXMLElement.h @@ -138,20 +137,18 @@ * @param string The string to parse * @return A new autoreleased OFXMLElement with the contents of the string */ + (instancetype)elementWithXMLString: (OFString *)string; -#ifdef OF_HAVE_FILES /** - * @brief Parses the specified file and returns an OFXMLElement for it. + * @brief Parses the specified stream and returns an OFXMLElement for it. * - * @param path The path to the file + * @param stream The stream to parse * @return A new autoreleased OFXMLElement with the contents of the specified - * file + * stream */ -+ (instancetype)elementWithFile: (OFString *)path; -#endif ++ (instancetype)elementWithStream: (OFStream *)stream; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFXMLElement with the specified name. @@ -216,40 +213,36 @@ * @param string The string to parse * @return An initialized OFXMLElement with the contents of the string */ - (instancetype)initWithXMLString: (OFString *)string; -#ifdef OF_HAVE_FILES /** - * @brief Parses the specified file and initializes an already allocated + * @brief Parses the specified stream and initializes an already allocated * OFXMLElement with it. * - * @param path The path to the file - * @return An initialized OFXMLElement with the contents of the specified file + * @param stream The stream to parse + * @return An initialized OFXMLElement with the contents of the specified stream */ -- (instancetype)initWithFile: (OFString *)path; -#endif +- (instancetype)initWithStream: (OFStream *)stream; - (instancetype)initWithSerialization: (OFXMLElement *)element; /** * @brief Sets a prefix for a namespace. * * @param prefix The prefix for the namespace * @param namespace_ The namespace for which the prefix is set */ -- (void)setPrefix: (OFString *)prefix - forNamespace: (OFString *)namespace_; +- (void)setPrefix: (OFString *)prefix forNamespace: (OFString *)namespace_; /** * @brief Binds a prefix for a namespace. * * @param prefix The prefix for the namespace * @param namespace_ The namespace for which the prefix is bound */ -- (void)bindPrefix: (OFString *)prefix - forNamespace: (OFString *)namespace_; +- (void)bindPrefix: (OFString *)prefix forNamespace: (OFString *)namespace_; /** * @brief Adds the specified attribute. * * If an attribute with the same name and namespace already exists, it is not @@ -331,12 +324,11 @@ * @brief Inserts a child at the specified index. * * @param child An OFXMLNode which is added as a child * @param index The index where the child is added */ -- (void)insertChild: (OFXMLNode *)child - atIndex: (size_t)index; +- (void)insertChild: (OFXMLNode *)child atIndex: (size_t)index; /** * @brief Inserts the specified children at the specified index. * * @param children An array of OFXMLNodes which are added as children @@ -364,21 +356,19 @@ * with the specified node. * * @param child The child to replace * @param node The node to replace the child with */ -- (void)replaceChild: (OFXMLNode *)child - withNode: (OFXMLNode *)node; +- (void)replaceChild: (OFXMLNode *)child withNode: (OFXMLNode *)node; /** * @brief Replaces the child at the specified index with the specified node. * * @param index The index of the child to replace * @param node The node to replace the child with */ -- (void)replaceChildAtIndex: (size_t)index - withNode: (OFXMLNode *)node; +- (void)replaceChildAtIndex: (size_t)index withNode: (OFXMLNode *)node; /** * @brief Returns all children that have the specified namespace. * * @return All children that have the specified namespace Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -23,20 +21,21 @@ #include #include #import "OFXMLElement.h" -#import "OFXMLNode+Private.h" -#import "OFString.h" #import "OFArray.h" -#import "OFDictionary.h" #import "OFData.h" +#import "OFDictionary.h" +#import "OFStream.h" +#import "OFString.h" #import "OFXMLAttribute.h" -#import "OFXMLCharacters.h" #import "OFXMLCDATA.h" -#import "OFXMLParser.h" +#import "OFXMLCharacters.h" #import "OFXMLElementBuilder.h" +#import "OFXMLNode+Private.h" +#import "OFXMLParser.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" @@ -112,27 +111,23 @@ + (instancetype)elementWithXMLString: (OFString *)string { return [[[self alloc] initWithXMLString: string] autorelease]; } -#ifdef OF_HAVE_FILES -+ (instancetype)elementWithFile: (OFString *)path ++ (instancetype)elementWithStream: (OFStream *)stream { - return [[[self alloc] initWithFile: path] autorelease]; + return [[[self alloc] initWithStream: stream] autorelease]; } -#endif - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name { - return [self initWithName: name - namespace: nil - stringValue: nil]; + return [self initWithName: name namespace: nil stringValue: nil]; } - (instancetype)initWithName: (OFString *)name stringValue: (OFString *)stringValue { @@ -142,13 +137,11 @@ } - (instancetype)initWithName: (OFString *)name namespace: (OFString *)namespace { - return [self initWithName: name - namespace: namespace - stringValue: nil]; + return [self initWithName: name namespace: namespace stringValue: nil]; } - (instancetype)initWithName: (OFString *)name namespace: (OFString *)namespace stringValue: (OFString *)stringValue @@ -232,12 +225,11 @@ objc_autoreleasePoolPop(pool); return self; } -#ifdef OF_HAVE_FILES -- (instancetype)initWithFile: (OFString *)path +- (instancetype)initWithStream: (OFStream *)stream { void *pool; OFXMLParser *parser; OFXMLElementBuilder *builder; OFXMLElementElementBuilderDelegate *delegate; @@ -252,11 +244,11 @@ autorelease]; parser.delegate = builder; builder.delegate = delegate; - [parser parseFile: path]; + [parser parseStream: stream]; if (!parser.hasFinishedParsing) @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; @@ -263,11 +255,10 @@ objc_autoreleasePoolPop(pool); return self; } -#endif - (instancetype)initWithSerialization: (OFXMLElement *)element { self = [super of_init]; @@ -441,12 +432,11 @@ tmp = [[allNS mutableCopy] autorelease]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [tmp setObject: object - forKey: key]; + [tmp setObject: object forKey: key]; allNS = tmp; } else allNS = _namespaces; @@ -666,12 +656,11 @@ element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; if (_name != nil) - [element addAttributeWithName: @"name" - stringValue: _name]; + [element addAttributeWithName: @"name" stringValue: _name]; if (_namespace != nil) [element addAttributeWithName: @"namespace" stringValue: _namespace]; @@ -821,27 +810,23 @@ return; } } } -- (void)setPrefix: (OFString *)prefix - forNamespace: (OFString *)namespace +- (void)setPrefix: (OFString *)prefix forNamespace: (OFString *)namespace { if (prefix.length == 0) @throw [OFInvalidArgumentException exception]; if (namespace == nil) namespace = @""; - [_namespaces setObject: prefix - forKey: namespace]; + [_namespaces setObject: prefix forKey: namespace]; } -- (void)bindPrefix: (OFString *)prefix - forNamespace: (OFString *)namespace +- (void)bindPrefix: (OFString *)prefix forNamespace: (OFString *)namespace { - [self setPrefix: prefix - forNamespace: namespace]; + [self setPrefix: prefix forNamespace: namespace]; [self addAttributeWithName: prefix namespace: @"http://www.w3.org/2000/xmlns/" stringValue: namespace]; } @@ -854,32 +839,28 @@ _children = [[OFMutableArray alloc] init]; [_children addObject: child]; } -- (void)insertChild: (OFXMLNode *)child - atIndex: (size_t)idx +- (void)insertChild: (OFXMLNode *)child atIndex: (size_t)idx { if ([child isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; if (_children == nil) _children = [[OFMutableArray alloc] init]; - [_children insertObject: child - atIndex: idx]; + [_children insertObject: child atIndex: idx]; } -- (void)insertChildren: (OFArray *)children - atIndex: (size_t)idx +- (void)insertChildren: (OFArray *)children atIndex: (size_t)idx { for (OFXMLNode *node in children) if ([node isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; - [_children insertObjectsFromArray: children - atIndex: idx]; + [_children insertObjectsFromArray: children atIndex: idx]; } - (void)removeChild: (OFXMLNode *)child { if ([child isKindOfClass: [OFXMLAttribute class]]) @@ -891,29 +872,25 @@ - (void)removeChildAtIndex: (size_t)idx { [_children removeObjectAtIndex: idx]; } -- (void)replaceChild: (OFXMLNode *)child - withNode: (OFXMLNode *)node +- (void)replaceChild: (OFXMLNode *)child withNode: (OFXMLNode *)node { if ([node isKindOfClass: [OFXMLAttribute class]] || [child isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; - [_children replaceObject: child - withObject: node]; + [_children replaceObject: child withObject: node]; } -- (void)replaceChildAtIndex: (size_t)idx - withNode: (OFXMLNode *)node +- (void)replaceChildAtIndex: (size_t)idx withNode: (OFXMLNode *)node { if ([node isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; - [_children replaceObjectAtIndex: idx - withObject: node]; + [_children replaceObjectAtIndex: idx withObject: node]; } - (OFXMLElement *)elementForName: (OFString *)elementName { return [self elementsForName: elementName].firstObject; Index: src/OFXMLElementBuilder.h ================================================================== --- src/OFXMLElementBuilder.h +++ src/OFXMLElementBuilder.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -67,12 +65,11 @@ if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) - [_delegate elementBuilder: self - didBuildParentlessNode: node]; + [_delegate elementBuilder: self didBuildParentlessNode: node]; } - (void)parser: (OFXMLParser *)parser didStartElement: (OFString *)name prefix: (OFString *)prefix @@ -136,12 +133,11 @@ if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) - [_delegate elementBuilder: self - didBuildParentlessNode: node]; + [_delegate elementBuilder: self didBuildParentlessNode: node]; } - (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)CDATA { @@ -150,12 +146,11 @@ if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) - [_delegate elementBuilder: self - didBuildParentlessNode: node]; + [_delegate elementBuilder: self didBuildParentlessNode: node]; } - (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment { @@ -164,12 +159,11 @@ if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) - [_delegate elementBuilder: self - didBuildParentlessNode: node]; + [_delegate elementBuilder: self didBuildParentlessNode: node]; } - (OFString *)parser: (OFXMLParser *)parser foundUnknownEntityNamed: (OFString *)entity { Index: src/OFXMLNode+Private.h ================================================================== --- src/OFXMLNode+Private.h +++ src/OFXMLNode+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLNode.h ================================================================== --- src/OFXMLNode.h +++ src/OFXMLNode.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLNode.m ================================================================== --- src/OFXMLNode.m +++ src/OFXMLNode.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -76,18 +74,16 @@ return self.stringValue.doubleValue; } - (OFString *)XMLString { - return [self XMLStringWithIndentation: 0 - level: 0]; + return [self XMLStringWithIndentation: 0 level: 0]; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation { - return [self XMLStringWithIndentation: 0 - level: 0]; + return [self XMLStringWithIndentation: 0 level: 0]; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation level: (unsigned int)level { @@ -94,11 +90,11 @@ OF_UNRECOGNIZED_SELECTOR } - (OFString *)description { - return [self XMLStringWithIndentation: 2]; + return [self XMLStringWithIndentation: 2 level: 0]; } - (OFXMLElement *)XMLElementBySerializing { OF_UNRECOGNIZED_SELECTOR Index: src/OFXMLParser.h ================================================================== --- src/OFXMLParser.h +++ src/OFXMLParser.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -82,30 +80,27 @@ * called multiple times in a row. * * @param parser The parser which found a string * @param characters The characters the XML parser found */ -- (void)parser: (OFXMLParser *)parser - foundCharacters: (OFString *)characters; +- (void)parser: (OFXMLParser *)parser foundCharacters: (OFString *)characters; /** * @brief This callback is called when the XML parser found CDATA. * * @param parser The parser which found a string * @param CDATA The CDATA the XML parser found */ -- (void)parser: (OFXMLParser *)parser - foundCDATA: (OFString *)CDATA; +- (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)CDATA; /** * @brief This callback is called when the XML parser found a comment. * * @param parser The parser which found a comment * @param comment The comment the XML parser found */ -- (void)parser: (OFXMLParser *)parser - foundComment: (OFString *)comment; +- (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment; /** * @brief This callback is called when the XML parser found an entity it * doesn't know. * @@ -210,12 +205,11 @@ * @brief Parses the specified buffer with the specified size. * * @param buffer The buffer to parse * @param length The length of the buffer */ -- (void)parseBuffer: (const char *)buffer - length: (size_t)length; +- (void)parseBuffer: (const char *)buffer length: (size_t)length; /** * @brief Parses the specified string. * * @param string The string to parse @@ -226,17 +220,8 @@ * @brief Parses the specified stream. * * @param stream The stream to parse */ - (void)parseStream: (OFStream *)stream; - -#ifdef OF_HAVE_FILES -/** - * @brief Parses the specified file. - * - * @param path The path to the file to parse -*/ -- (void)parseFile: (OFString *)path; -#endif @end OF_ASSUME_NONNULL_END Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -93,20 +91,18 @@ static OF_INLINE void appendToBuffer(OFMutableData *buffer, const char *string, of_string_encoding_t encoding, size_t length) { - if (OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8)) - [buffer addItems: string - count: length]; + if OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8) + [buffer addItems: string count: length]; else { void *pool = objc_autoreleasePoolPush(); OFString *tmp = [OFString stringWithCString: string encoding: encoding length: length]; - [buffer addItems: tmp.UTF8String - count: tmp.UTF8StringLength]; + [buffer addItems: tmp.UTF8String count: tmp.UTF8StringLength]; objc_autoreleasePoolPop(pool); } } static OFString * @@ -130,12 +126,11 @@ items[i] = '\n'; } else if (items[i] == '&') hasEntities = true; } - ret = [OFString stringWithUTF8String: items - length: length]; + ret = [OFString stringWithUTF8String: items length: length]; if (unescape && hasEntities) { @try { return [ret stringByXMLUnescapingWithDelegate: parser]; } @catch (OFInvalidFormatException *e) { @@ -240,12 +235,11 @@ [_previous release]; [super dealloc]; } -- (void)parseBuffer: (const char *)buffer - length: (size_t)length +- (void)parseBuffer: (const char *)buffer length: (size_t)length { _data = buffer; for (_i = _last = 0; _i < length; _i++) { size_t j = _i; @@ -269,12 +263,11 @@ length - _last); } - (void)parseString: (OFString *)string { - [self parseBuffer: string.UTF8String - length: string.UTF8StringLength]; + [self parseBuffer: string.UTF8String length: string.UTF8StringLength]; } - (void)parseStream: (OFStream *)stream { size_t pageSize = [OFSystemInfo pageSize]; @@ -282,32 +275,17 @@ @try { while (!stream.atEndOfStream) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; - - [self parseBuffer: buffer - length: length]; + [self parseBuffer: buffer length: length]; } } @finally { free(buffer); } } -#ifdef OF_HAVE_FILES -- (void)parseFile: (OFString *)path -{ - OFFile *file = [[OFFile alloc] initWithPath: path - mode: @"r"]; - @try { - [self parseStream: file]; - } @finally { - [file release]; - } -} -#endif - static void inByteOrderMarkState(OFXMLParser *self) { if (self->_data[self->_i] != "\xEF\xBB\xBF"[self->_level]) { if (self->_level == 0) { @@ -516,11 +494,11 @@ @throw [OFMalformedXMLException exceptionWithParser: self]; if ([self->_delegate respondsToSelector: @selector(parser:foundProcessingInstructions:)]) - [self->_delegate parser: self + [self->_delegate parser: self foundProcessingInstructions: PI]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; @@ -970,12 +948,11 @@ self->_encoding, self->_i - self->_last); CDATA = transformString(self, self->_buffer, 2, false); if ([self->_delegate respondsToSelector: @selector(parser:foundCDATA:)]) - [self->_delegate parser: self - foundCDATA: CDATA]; + [self->_delegate parser: self foundCDATA: CDATA]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; @@ -1024,12 +1001,11 @@ self->_encoding, self->_i - self->_last); comment = transformString(self, self->_buffer, 2, false); if ([self->_delegate respondsToSelector: @selector(parser:foundComment:)]) - [self->_delegate parser: self - foundComment: comment]; + [self->_delegate parser: self foundComment: comment]; objc_autoreleasePoolPop(pool); [self->_buffer removeAllItems]; @@ -1069,11 +1045,10 @@ - (OFString *)string: (OFString *)string containsUnknownEntityNamed: (OFString *)entity { if ([_delegate respondsToSelector: @selector(parser:foundUnknownEntityNamed:)]) - return [_delegate parser: self - foundUnknownEntityNamed: entity]; + return [_delegate parser: self foundUnknownEntityNamed: entity]; return nil; } @end Index: src/OFXMLProcessingInstructions.h ================================================================== --- src/OFXMLProcessingInstructions.h +++ src/OFXMLProcessingInstructions.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFXMLProcessingInstructions.m ================================================================== --- src/OFXMLProcessingInstructions.m +++ src/OFXMLProcessingInstructions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -76,12 +74,11 @@ * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFZIPArchive */ -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode; ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /** * @brief Creates a new OFZIPArchive object with the specified file. * @@ -89,12 +86,11 @@ * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFZIPArchive */ -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode; ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode; #endif - (instancetype)init OF_UNAVAILABLE; /** @@ -120,12 +116,11 @@ * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFZIPArchive */ -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode; +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; #endif /** * @brief Returns a stream for reading the specified file from the archive. * Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -141,12 +139,11 @@ static void seekOrThrowInvalidFormat(OFSeekableStream *stream, of_offset_t offset, int whence) { @try { - [stream seekToOffset: offset - whence: whence]; + [stream seekToOffset: offset whence: whence]; } @catch (OFSeekFailedException *e) { if (e.errNo == EINVAL) @throw [OFInvalidFormatException exception]; @throw e; @@ -154,33 +151,28 @@ } @implementation OFZIPArchive @synthesize archiveComment = _archiveComment; -+ (instancetype)archiveWithStream: (OFStream *)stream - mode: (OFString *)mode ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { - return [[[self alloc] initWithStream: stream - mode: mode] autorelease]; + return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } #ifdef OF_HAVE_FILES -+ (instancetype)archiveWithPath: (OFString *)path - mode: (OFString *)mode ++ (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode { - return [[[self alloc] initWithPath: path - mode: mode] autorelease]; + return [[[self alloc] initWithPath: path mode: mode] autorelease]; } #endif - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OFStream *)stream - mode: (OFString *)mode +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { if ([mode isEqual: @"r"]) @@ -225,25 +217,21 @@ return self; } #ifdef OF_HAVE_FILES -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode { OFFile *file; if ([mode isEqual: @"a"]) - file = [[OFFile alloc] initWithPath: path - mode: @"r+"]; + file = [[OFFile alloc] initWithPath: path mode: @"r+"]; else - file = [[OFFile alloc] initWithPath: path - mode: mode]; + file = [[OFFile alloc] initWithPath: path mode: mode]; @try { - self = [self initWithStream: file - mode: mode]; + self = [self initWithStream: file mode: mode]; } @finally { [file release]; } return self; @@ -372,12 +360,11 @@ if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFInvalidFormatException exception]; [_entries addObject: entry]; - [_pathToEntryMap setObject: entry - forKey: entry.fileName]; + [_pathToEntryMap setObject: entry forKey: entry.fileName]; } objc_autoreleasePoolPop(pool); } @@ -793,12 +780,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @@ -815,12 +801,11 @@ #endif if ((uint64_t)length > _toRead) length = (size_t)_toRead; - ret = [_decompressedStream readIntoBuffer: buffer - length: length]; + ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; _CRC32 = of_crc32(_CRC32, buffer, ret); if (_toRead == 0) { @@ -889,12 +874,11 @@ [_entry release]; [super dealloc]; } -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { size_t bytesWritten; #if SIZE_MAX >= INT64_MAX if (length > INT64_MAX) @@ -902,12 +886,11 @@ #endif if (INT64_MAX - _bytesWritten < (int64_t)length) @throw [OFOutOfRangeException exception]; - bytesWritten = [_stream writeBuffer: buffer - length: length]; + bytesWritten = [_stream writeBuffer: buffer length: length]; _bytesWritten += (int64_t)bytesWritten; _CRC32 = of_crc32(_CRC32, buffer, length); return bytesWritten; Index: src/OFZIPArchiveEntry+Private.h ================================================================== --- src/OFZIPArchiveEntry+Private.h +++ src/OFZIPArchiveEntry+Private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFZIPArchiveEntry.h ================================================================== --- src/OFZIPArchiveEntry.h +++ src/OFZIPArchiveEntry.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -95,12 +93,12 @@ # import "OFHTTPRequest.h" # import "OFHTTPResponse.h" # import "OFHTTPServer.h" #endif -#ifdef OF_HAVE_PROCESSES -# import "OFProcess.h" +#ifdef OF_HAVE_SUBPROCESSES +# import "OFSubprocess.h" #endif #import "OFCryptoHash.h" #import "OFMD5Hash.h" #import "OFRIPEMD160Hash.h" Index: src/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_builtins.h ================================================================== --- src/atomic_builtins.h +++ src/atomic_builtins.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_no_threads.h ================================================================== --- src/atomic_no_threads.h +++ src/atomic_no_threads.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_osatomic.h ================================================================== --- src/atomic_osatomic.h +++ src/atomic_osatomic.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_powerpc.h ================================================================== --- src/atomic_powerpc.h +++ src/atomic_powerpc.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_sync_builtins.h ================================================================== --- src/atomic_sync_builtins.h +++ src/atomic_sync_builtins.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/atomic_x86.h ================================================================== --- src/atomic_x86.h +++ src/atomic_x86.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/base64.h ================================================================== --- src/base64.h +++ src/base64.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/base64.m ================================================================== --- src/base64.m +++ src/base64.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -149,11 +147,10 @@ db[0] = (sb & 0xFF0000) >> 16; db[1] = (sb & 0x00FF00) >> 8; db[2] = sb & 0x0000FF; - [data addItems: db - count: count]; + [data addItems: db count: count]; } return true; } Index: src/block.h ================================================================== --- src/block.h +++ src/block.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSArray+OFObject.h ================================================================== --- src/bridge/NSArray+OFObject.h +++ src/bridge/NSArray+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSArray+OFObject.m ================================================================== --- src/bridge/NSArray+OFObject.m +++ src/bridge/NSArray+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSBridging.h ================================================================== --- src/bridge/NSBridging.h +++ src/bridge/NSBridging.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSDictionary+OFObject.h ================================================================== --- src/bridge/NSDictionary+OFObject.h +++ src/bridge/NSDictionary+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSDictionary+OFObject.m ================================================================== --- src/bridge/NSDictionary+OFObject.m +++ src/bridge/NSDictionary+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSEnumerator+OFObject.h ================================================================== --- src/bridge/NSEnumerator+OFObject.h +++ src/bridge/NSEnumerator+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSEnumerator+OFObject.m ================================================================== --- src/bridge/NSEnumerator+OFObject.m +++ src/bridge/NSEnumerator+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSNumber+OFObject.h ================================================================== --- src/bridge/NSNumber+OFObject.h +++ src/bridge/NSNumber+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSNumber+OFObject.m ================================================================== --- src/bridge/NSNumber+OFObject.m +++ src/bridge/NSNumber+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFArray.h ================================================================== --- src/bridge/NSOFArray.h +++ src/bridge/NSOFArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFArray.m ================================================================== --- src/bridge/NSOFArray.m +++ src/bridge/NSOFArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFDictionary.h ================================================================== --- src/bridge/NSOFDictionary.h +++ src/bridge/NSOFDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFDictionary.m ================================================================== --- src/bridge/NSOFDictionary.m +++ src/bridge/NSOFDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFEnumerator.h ================================================================== --- src/bridge/NSOFEnumerator.h +++ src/bridge/NSOFEnumerator.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFEnumerator.m ================================================================== --- src/bridge/NSOFEnumerator.m +++ src/bridge/NSOFEnumerator.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFSet.h ================================================================== --- src/bridge/NSOFSet.h +++ src/bridge/NSOFSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSOFSet.m ================================================================== --- src/bridge/NSOFSet.m +++ src/bridge/NSOFSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSSet+OFObject.h ================================================================== --- src/bridge/NSSet+OFObject.h +++ src/bridge/NSSet+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSSet+OFObject.m ================================================================== --- src/bridge/NSSet+OFObject.m +++ src/bridge/NSSet+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSString+OFObject.h ================================================================== --- src/bridge/NSString+OFObject.h +++ src/bridge/NSString+OFObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/NSString+OFObject.m ================================================================== --- src/bridge/NSString+OFObject.m +++ src/bridge/NSString+OFObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFArray+NSObject.h ================================================================== --- src/bridge/OFArray+NSObject.h +++ src/bridge/OFArray+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFArray+NSObject.m ================================================================== --- src/bridge/OFArray+NSObject.m +++ src/bridge/OFArray+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFBridging.h ================================================================== --- src/bridge/OFBridging.h +++ src/bridge/OFBridging.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFDictionary+NSObject.h ================================================================== --- src/bridge/OFDictionary+NSObject.h +++ src/bridge/OFDictionary+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFDictionary+NSObject.m ================================================================== --- src/bridge/OFDictionary+NSObject.m +++ src/bridge/OFDictionary+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFEnumerator+NSObject.h ================================================================== --- src/bridge/OFEnumerator+NSObject.h +++ src/bridge/OFEnumerator+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFEnumerator+NSObject.m ================================================================== --- src/bridge/OFEnumerator+NSObject.m +++ src/bridge/OFEnumerator+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFException+Swift.h ================================================================== --- src/bridge/OFException+Swift.h +++ src/bridge/OFException+Swift.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -47,12 +45,11 @@ * @note This is only useful for Swift. * * @param try The try block to execute * @param finally The finally block to call at the end */ -+ (void)try: (void (^)(void))try - finally: (void (^)(void))finally; ++ (void)try: (void (^)(void))try finally: (void (^)(void))finally; /** * @brief Execute the specified try block and call the catch block if an * OFException occurred and finally call the finally block. * Index: src/bridge/OFException+Swift.m ================================================================== --- src/bridge/OFException+Swift.m +++ src/bridge/OFException+Swift.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSArray.h ================================================================== --- src/bridge/OFNSArray.h +++ src/bridge/OFNSArray.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSArray.m ================================================================== --- src/bridge/OFNSArray.m +++ src/bridge/OFNSArray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSDictionary.h ================================================================== --- src/bridge/OFNSDictionary.h +++ src/bridge/OFNSDictionary.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSDictionary.m ================================================================== --- src/bridge/OFNSDictionary.m +++ src/bridge/OFNSDictionary.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSEnumerator.h ================================================================== --- src/bridge/OFNSEnumerator.h +++ src/bridge/OFNSEnumerator.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSEnumerator.m ================================================================== --- src/bridge/OFNSEnumerator.m +++ src/bridge/OFNSEnumerator.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSSet.h ================================================================== --- src/bridge/OFNSSet.h +++ src/bridge/OFNSSet.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNSSet.m ================================================================== --- src/bridge/OFNSSet.m +++ src/bridge/OFNSSet.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNumber+NSObject.h ================================================================== --- src/bridge/OFNumber+NSObject.h +++ src/bridge/OFNumber+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFNumber+NSObject.m ================================================================== --- src/bridge/OFNumber+NSObject.m +++ src/bridge/OFNumber+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFSet+NSObject.h ================================================================== --- src/bridge/OFSet+NSObject.h +++ src/bridge/OFSet+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFSet+NSObject.m ================================================================== --- src/bridge/OFSet+NSObject.m +++ src/bridge/OFSet+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFString+NSObject.h ================================================================== --- src/bridge/OFString+NSObject.h +++ src/bridge/OFString+NSObject.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/OFString+NSObject.m ================================================================== --- src/bridge/OFString+NSObject.m +++ src/bridge/OFString+NSObject.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/bridge/ObjFWBridge.h ================================================================== --- src/bridge/ObjFWBridge.h +++ src/bridge/ObjFWBridge.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/condition.h ================================================================== --- src/condition.h +++ src/condition.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/condition.m ================================================================== --- src/condition.m +++ src/condition.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/crc16.h ================================================================== --- src/crc16.h +++ src/crc16.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/crc16.m ================================================================== --- src/crc16.m +++ src/crc16.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/crc32.h ================================================================== --- src/crc32.h +++ src/crc32.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/crc32.m ================================================================== --- src/crc32.m +++ src/crc32.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/codepage-437.m ================================================================== --- src/encodings/codepage-437.m +++ src/encodings/codepage-437.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/codepage-850.m ================================================================== --- src/encodings/codepage-850.m +++ src/encodings/codepage-850.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/codepage-858.m ================================================================== --- src/encodings/codepage-858.m +++ src/encodings/codepage-858.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/common.h ================================================================== --- src/encodings/common.h +++ src/encodings/common.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/iso-8859-15.m ================================================================== --- src/encodings/iso-8859-15.m +++ src/encodings/iso-8859-15.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/iso-8859-2.m ================================================================== --- src/encodings/iso-8859-2.m +++ src/encodings/iso-8859-2.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/iso-8859-3.m ================================================================== --- src/encodings/iso-8859-3.m +++ src/encodings/iso-8859-3.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/koi8-r.m ================================================================== --- src/encodings/koi8-r.m +++ src/encodings/koi8-r.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/koi8-u.m ================================================================== --- src/encodings/koi8-u.m +++ src/encodings/koi8-u.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/mac-roman.m ================================================================== --- src/encodings/mac-roman.m +++ src/encodings/mac-roman.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/windows-1251.m ================================================================== --- src/encodings/windows-1251.m +++ src/encodings/windows-1251.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/encodings/windows-1252.m ================================================================== --- src/encodings/windows-1252.m +++ src/encodings/windows-1252.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFAcceptFailedException.h ================================================================== --- src/exceptions/OFAcceptFailedException.h +++ src/exceptions/OFAcceptFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -52,12 +50,11 @@ * * @param socket The socket which could not accept a connection * @param errNo The errno for the error * @return A new, autoreleased accept failed exception */ -+ (instancetype)exceptionWithSocket: (id)socket - errNo: (int)errNo; ++ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated accept failed exception. Index: src/exceptions/OFAcceptFailedException.m ================================================================== --- src/exceptions/OFAcceptFailedException.m +++ src/exceptions/OFAcceptFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithSocket: (id)socket - errNo: (int)errNo ++ (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo { - return [[[self alloc] initWithSocket: socket - errNo: errNo] autorelease]; + return [[[self alloc] initWithSocket: socket errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithSocket: (id)socket - errNo: (int)errNo +- (instancetype)initWithSocket: (id)socket errNo: (int)errNo { self = [super init]; _socket = [socket retain]; _errNo = errNo; Index: src/exceptions/OFAllocFailedException.h ================================================================== --- src/exceptions/OFAllocFailedException.h +++ src/exceptions/OFAllocFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFAllocFailedException.m ================================================================== --- src/exceptions/OFAllocFailedException.m +++ src/exceptions/OFAllocFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFAlreadyConnectedException.h ================================================================== --- src/exceptions/OFAlreadyConnectedException.h +++ src/exceptions/OFAlreadyConnectedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFAlreadyConnectedException.m ================================================================== --- src/exceptions/OFAlreadyConnectedException.m +++ src/exceptions/OFAlreadyConnectedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFBindFailedException.h ================================================================== --- src/exceptions/OFBindFailedException.h +++ src/exceptions/OFBindFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFBindFailedException.m ================================================================== --- src/exceptions/OFBindFailedException.m +++ src/exceptions/OFBindFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFChangeCurrentDirectoryPathFailedException.h ================================================================== --- src/exceptions/OFChangeCurrentDirectoryPathFailedException.h +++ src/exceptions/OFChangeCurrentDirectoryPathFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -53,12 +51,11 @@ * @param path The path of the directory to which the current path could not be * changed * @param errNo The errno of the error that occurred * @return A new, autoreleased change current directory path failed exception */ -+ (instancetype)exceptionWithPath: (OFString *)path - errNo: (int)errNo; ++ (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated change directory failed exception. Index: src/exceptions/OFChangeCurrentDirectoryPathFailedException.m ================================================================== --- src/exceptions/OFChangeCurrentDirectoryPathFailedException.m +++ src/exceptions/OFChangeCurrentDirectoryPathFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithPath: (OFString *)path - errNo: (int)errNo ++ (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo { - return [[[self alloc] initWithPath: path - errNo: errNo] autorelease]; + return [[[self alloc] initWithPath: path errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithPath: (OFString *)path - errNo: (int)errNo +- (instancetype)initWithPath: (OFString *)path errNo: (int)errNo { self = [super init]; @try { _path = [path copy]; Index: src/exceptions/OFChecksumMismatchException.h ================================================================== --- src/exceptions/OFChecksumMismatchException.h +++ src/exceptions/OFChecksumMismatchException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFChecksumMismatchException.m ================================================================== --- src/exceptions/OFChecksumMismatchException.m +++ src/exceptions/OFChecksumMismatchException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionBroadcastFailedException.h ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.h +++ src/exceptions/OFConditionBroadcastFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,12 +29,11 @@ { return [[[self alloc] initWithCondition: condition errNo: errNo] autorelease]; } -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo { self = [super init]; _condition = [condition retain]; _errNo = errNo; Index: src/exceptions/OFConditionSignalFailedException.h ================================================================== --- src/exceptions/OFConditionSignalFailedException.h +++ src/exceptions/OFConditionSignalFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,12 +29,11 @@ { return [[[self alloc] initWithCondition: condition errNo: errNo] autorelease]; } -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo { self = [super init]; _condition = [condition retain]; _errNo = errNo; Index: src/exceptions/OFConditionStillWaitingException.h ================================================================== --- src/exceptions/OFConditionStillWaitingException.h +++ src/exceptions/OFConditionStillWaitingException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionWaitFailedException.h ================================================================== --- src/exceptions/OFConditionWaitFailedException.h +++ src/exceptions/OFConditionWaitFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,12 +29,11 @@ { return [[[self alloc] initWithCondition: condition errNo: errNo] autorelease]; } -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo { self = [super init]; _condition = [condition retain]; _errNo = errNo; Index: src/exceptions/OFConnectionFailedException.h ================================================================== --- src/exceptions/OFConnectionFailedException.h +++ src/exceptions/OFConnectionFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFConnectionFailedException.m ================================================================== --- src/exceptions/OFConnectionFailedException.m +++ src/exceptions/OFConnectionFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCopyItemFailedException.h ================================================================== --- src/exceptions/OFCopyItemFailedException.h +++ src/exceptions/OFCopyItemFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCopyItemFailedException.m ================================================================== --- src/exceptions/OFCopyItemFailedException.m +++ src/exceptions/OFCopyItemFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCreateDirectoryFailedException.h ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.h +++ src/exceptions/OFCreateDirectoryFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -51,12 +49,11 @@ * * @param URL The URL of the directory which could not be created * @param errNo The errno of the error that occurred * @return A new, autoreleased create directory failed exception */ -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo; ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated create directory failed exception. Index: src/exceptions/OFCreateDirectoryFailedException.m ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.m +++ src/exceptions/OFCreateDirectoryFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -27,24 +25,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { - return [[[self alloc] initWithURL: URL - errNo: errNo] autorelease]; + return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithURL: (OFURL *)URL - errNo: (int)errNo +- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; Index: src/exceptions/OFCreateSymbolicLinkFailedException.h ================================================================== --- src/exceptions/OFCreateSymbolicLinkFailedException.h +++ src/exceptions/OFCreateSymbolicLinkFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCreateSymbolicLinkFailedException.m ================================================================== --- src/exceptions/OFCreateSymbolicLinkFailedException.m +++ src/exceptions/OFCreateSymbolicLinkFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCreateWindowsRegistryKeyFailedException.h ================================================================== --- src/exceptions/OFCreateWindowsRegistryKeyFailedException.h +++ src/exceptions/OFCreateWindowsRegistryKeyFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFCreateWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFCreateWindowsRegistryKeyFailedException.m +++ src/exceptions/OFCreateWindowsRegistryKeyFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFDNSQueryFailedException.h ================================================================== --- src/exceptions/OFDNSQueryFailedException.h +++ src/exceptions/OFDNSQueryFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFDNSQueryFailedException.m ================================================================== --- src/exceptions/OFDNSQueryFailedException.m +++ src/exceptions/OFDNSQueryFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -55,12 +53,11 @@ @synthesize query = _query, error = _error; + (instancetype)exceptionWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error { - return [[[self alloc] initWithQuery: query - error: error] autorelease]; + return [[[self alloc] initWithQuery: query error: error] autorelease]; } - (instancetype)initWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error { Index: src/exceptions/OFDeleteWindowsRegistryKeyFailedException.h ================================================================== --- src/exceptions/OFDeleteWindowsRegistryKeyFailedException.h +++ src/exceptions/OFDeleteWindowsRegistryKeyFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m +++ src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFDeleteWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFDeleteWindowsRegistryValueFailedException.h +++ src/exceptions/OFDeleteWindowsRegistryValueFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,23 +28,23 @@ * @brief An exception indicating that deleting a Windows registry value failed. */ @interface OFDeleteWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; LSTATUS _status; } /** * @brief The registry key on which deleting the value failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /** - * @brief The value which could not be deleted. + * @brief The name of the value which could not be deleted. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The status returned by RegDeleteValueEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -54,30 +52,30 @@ /** * @brief Creates a new, autoreleased delete Windows registry value failed * exception. * * @param registryKey The registry key on which deleting the value failed - * @param value The value which could not be deleted + * @param valueName The name of the value which could not be deleted * @param status The status returned by RegDeleteValueEx() * @return A new, autoreleased delete Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated delete Windows registry value failed * exception. * * @param registryKey The registry key on which deleting the value failed - * @param value The value which could not be deleted + * @param valueName The name of the value which could not be deleted * @param status The status returned by RegDeleteValueEx() * @return An initialized delete Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFDeleteWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFDeleteWindowsRegistryValueFailedException.m +++ src/exceptions/OFDeleteWindowsRegistryValueFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -20,35 +18,36 @@ #import "OFDeleteWindowsRegistryValueFailedException.h" #import "OFData.h" @implementation OFDeleteWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, status = _status; +@synthesize registryKey = _registryKey, valueName = _valueName; +@synthesize status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _status = status; } @catch (id e) { [self release]; @throw e; } @@ -57,17 +56,17 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to delete value %@: %@", - _value, of_windows_status_to_string(_status)]; + @"Failed to delete value named %@: %@", + _valueName, of_windows_status_to_string(_status)]; } @end Index: src/exceptions/OFEnumerationMutationException.h ================================================================== --- src/exceptions/OFEnumerationMutationException.h +++ src/exceptions/OFEnumerationMutationException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFEnumerationMutationException.m ================================================================== --- src/exceptions/OFEnumerationMutationException.m +++ src/exceptions/OFEnumerationMutationException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFException.h ================================================================== --- src/exceptions/OFException.h +++ src/exceptions/OFException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFGetCurrentDirectoryPathFailedException.h ================================================================== --- src/exceptions/OFGetCurrentDirectoryPathFailedException.h +++ src/exceptions/OFGetCurrentDirectoryPathFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFGetCurrentDirectoryPathFailedException.m ================================================================== --- src/exceptions/OFGetCurrentDirectoryPathFailedException.m +++ src/exceptions/OFGetCurrentDirectoryPathFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFGetOptionFailedException.h ================================================================== --- src/exceptions/OFGetOptionFailedException.h +++ src/exceptions/OFGetOptionFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -48,12 +46,11 @@ * * @param object The object for which the option could not be retrieved * @param errNo The errno of the error that occurred * @return A new, autoreleased get option failed exception */ -+ (instancetype)exceptionWithObject: (id)object - errNo: (int)errNo; ++ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated get option failed exception. Index: src/exceptions/OFGetOptionFailedException.m ================================================================== --- src/exceptions/OFGetOptionFailedException.m +++ src/exceptions/OFGetOptionFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithObject: (id)object - errNo: (int)errNo ++ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo { - return [[[self alloc] initWithObject: object - errNo: errNo] autorelease]; + return [[[self alloc] initWithObject: object errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithObject: (id)object - errNo: (int)errNo +- (instancetype)initWithObject: (id)object errNo: (int)errNo { self = [super init]; _object = [object retain]; _errNo = errNo; Index: src/exceptions/OFGetWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.h +++ src/exceptions/OFGetWindowsRegistryValueFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,11 +28,11 @@ * @brief An exception indicating that getting a Windows registry value failed. */ @interface OFGetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; DWORD _flags; LSTATUS _status; } /** @@ -41,13 +39,13 @@ * @brief The registry key on which getting the value at the key path failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /** - * @brief The value which could not be retrieved. + * @brief The name of the value which could not be retrieved. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The status returned by RegGetValueEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -56,16 +54,16 @@ * @brief Creates a new, autoreleased get Windows registry value failed * exception. * * @param registryKey The registry key on which getting the value at the sub * key path failed - * @param value The value which could not be retrieved + * @param valueName The name of the value which could not be retrieved * @param status The status returned by RegGetValueEx() * @return A new, autoreleased get Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /** @@ -72,15 +70,15 @@ * @brief Initializes an already allocated get Windows registry value failed * exception. * * @param registryKey The registry key on which getting the value at the sub * key path failed - * @param value The value which could not be retrieved + * @param valueName The name of the value which could not be retrieved * @param status The status returned by RegGetValueEx() * @return An initialized get Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFGetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.m +++ src/exceptions/OFGetWindowsRegistryValueFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -18,35 +16,36 @@ #include "config.h" #import "OFGetWindowsRegistryValueFailedException.h" @implementation OFGetWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, status = _status; +@synthesize registryKey = _registryKey, valueName = _valueName; +@synthesize status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _status = status; } @catch (id e) { [self release]; @throw e; } @@ -55,17 +54,17 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to get value %@: %@", - _value, of_windows_status_to_string(_status)]; + @"Failed to get value named %@: %@", + _valueName, of_windows_status_to_string(_status)]; } @end Index: src/exceptions/OFHTTPRequestFailedException.h ================================================================== --- src/exceptions/OFHTTPRequestFailedException.h +++ src/exceptions/OFHTTPRequestFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFHTTPRequestFailedException.m ================================================================== --- src/exceptions/OFHTTPRequestFailedException.m +++ src/exceptions/OFHTTPRequestFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFHashAlreadyCalculatedException.h ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.h +++ src/exceptions/OFHashAlreadyCalculatedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFHashAlreadyCalculatedException.m ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.m +++ src/exceptions/OFHashAlreadyCalculatedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInitializationFailedException.h ================================================================== --- src/exceptions/OFInitializationFailedException.h +++ src/exceptions/OFInitializationFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInitializationFailedException.m ================================================================== --- src/exceptions/OFInitializationFailedException.m +++ src/exceptions/OFInitializationFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidArgumentException.h ================================================================== --- src/exceptions/OFInvalidArgumentException.h +++ src/exceptions/OFInvalidArgumentException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidArgumentException.m ================================================================== --- src/exceptions/OFInvalidArgumentException.m +++ src/exceptions/OFInvalidArgumentException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidEncodingException.h ================================================================== --- src/exceptions/OFInvalidEncodingException.h +++ src/exceptions/OFInvalidEncodingException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidEncodingException.m ================================================================== --- src/exceptions/OFInvalidEncodingException.m +++ src/exceptions/OFInvalidEncodingException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidFormatException.h ================================================================== --- src/exceptions/OFInvalidFormatException.h +++ src/exceptions/OFInvalidFormatException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidFormatException.m ================================================================== --- src/exceptions/OFInvalidFormatException.m +++ src/exceptions/OFInvalidFormatException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidJSONException.h ================================================================== --- src/exceptions/OFInvalidJSONException.h +++ src/exceptions/OFInvalidJSONException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidJSONException.m ================================================================== --- src/exceptions/OFInvalidJSONException.m +++ src/exceptions/OFInvalidJSONException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithString: (OFString *)string - line: (size_t)line ++ (instancetype)exceptionWithString: (OFString *)string line: (size_t)line { - return [[[self alloc] initWithString: string - line: line] autorelease]; + return [[[self alloc] initWithString: string line: line] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithString: (OFString *)string - line: (size_t)line +- (instancetype)initWithString: (OFString *)string line: (size_t)line { self = [super init]; @try { _string = [string copy]; Index: src/exceptions/OFInvalidServerReplyException.h ================================================================== --- src/exceptions/OFInvalidServerReplyException.h +++ src/exceptions/OFInvalidServerReplyException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFInvalidServerReplyException.m ================================================================== --- src/exceptions/OFInvalidServerReplyException.m +++ src/exceptions/OFInvalidServerReplyException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFLinkFailedException.h ================================================================== --- src/exceptions/OFLinkFailedException.h +++ src/exceptions/OFLinkFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFLinkFailedException.m ================================================================== --- src/exceptions/OFLinkFailedException.m +++ src/exceptions/OFLinkFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFListenFailedException.h ================================================================== --- src/exceptions/OFListenFailedException.h +++ src/exceptions/OFListenFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFListenFailedException.m ================================================================== --- src/exceptions/OFListenFailedException.m +++ src/exceptions/OFListenFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFLoadPluginFailedException.h ================================================================== --- src/exceptions/OFLoadPluginFailedException.h +++ src/exceptions/OFLoadPluginFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFLoadPluginFailedException.m ================================================================== --- src/exceptions/OFLoadPluginFailedException.m +++ src/exceptions/OFLoadPluginFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithPath: (OFString *)path - error: (OFString *)error ++ (instancetype)exceptionWithPath: (OFString *)path error: (OFString *)error { - return [[[self alloc] initWithPath: path - error: error] autorelease]; + return [[[self alloc] initWithPath: path error: error] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithPath: (OFString *)path - error: (OFString *)error +- (instancetype)initWithPath: (OFString *)path error: (OFString *)error { self = [super init]; @try { _path = [path copy]; Index: src/exceptions/OFLockFailedException.h ================================================================== --- src/exceptions/OFLockFailedException.h +++ src/exceptions/OFLockFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFLockFailedException.m ================================================================== --- src/exceptions/OFLockFailedException.m +++ src/exceptions/OFLockFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -23,19 +21,16 @@ #import "OFString.h" @implementation OFLockFailedException @synthesize lock = _lock, errNo = _errNo; -+ (instancetype)exceptionWithLock: (id )lock - errNo: (int)errNo ++ (instancetype)exceptionWithLock: (id )lock errNo: (int)errNo { - return [[[self alloc] initWithLock: lock - errNo: errNo] autorelease]; + return [[[self alloc] initWithLock: lock errNo: errNo] autorelease]; } -- (instancetype)initWithLock: (id )lock - errNo: (int)errNo +- (instancetype)initWithLock: (id )lock errNo: (int)errNo { self = [super init]; _lock = [lock retain]; _errNo = errNo; Index: src/exceptions/OFMalformedXMLException.h ================================================================== --- src/exceptions/OFMalformedXMLException.h +++ src/exceptions/OFMalformedXMLException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFMalformedXMLException.m ================================================================== --- src/exceptions/OFMalformedXMLException.m +++ src/exceptions/OFMalformedXMLException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFMemoryNotPartOfObjectException.h ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.h +++ src/exceptions/OFMemoryNotPartOfObjectException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFMemoryNotPartOfObjectException.m ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.m +++ src/exceptions/OFMemoryNotPartOfObjectException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,12 +24,11 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithPointer: (void *)pointer - object: (id)object ++ (instancetype)exceptionWithPointer: (void *)pointer object: (id)object { return [[[self alloc] initWithPointer: pointer object: object] autorelease]; } @@ -38,12 +35,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithPointer: (void *)pointer - object: (id)object +- (instancetype)initWithPointer: (void *)pointer object: (id)object { self = [super init]; _pointer = pointer; _object = [object retain]; Index: src/exceptions/OFMoveItemFailedException.h ================================================================== --- src/exceptions/OFMoveItemFailedException.h +++ src/exceptions/OFMoveItemFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFMoveItemFailedException.m ================================================================== --- src/exceptions/OFMoveItemFailedException.m +++ src/exceptions/OFMoveItemFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,11 +28,11 @@ OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL destinationURL: (OFURL *)destinationURL - errNo: (int)errNo + errNo: (int)errNo { return [[[self alloc] initWithSourceURL: sourceURL destinationURL: destinationURL errNo: errNo] autorelease]; } Index: src/exceptions/OFNotImplementedException.h ================================================================== --- src/exceptions/OFNotImplementedException.h +++ src/exceptions/OFNotImplementedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFNotImplementedException.m ================================================================== --- src/exceptions/OFNotImplementedException.m +++ src/exceptions/OFNotImplementedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,12 +24,11 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithSelector: (SEL)selector - object: (id)object ++ (instancetype)exceptionWithSelector: (SEL)selector object: (id)object { return [[[self alloc] initWithSelector: selector object: object] autorelease]; } @@ -38,12 +35,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithSelector: (SEL)selector - object: (id)object +- (instancetype)initWithSelector: (SEL)selector object: (id)object { self = [super init]; _selector = selector; _object = [object retain]; Index: src/exceptions/OFNotOpenException.h ================================================================== --- src/exceptions/OFNotOpenException.h +++ src/exceptions/OFNotOpenException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFNotOpenException.m ================================================================== --- src/exceptions/OFNotOpenException.m +++ src/exceptions/OFNotOpenException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFObserveFailedException.h ================================================================== --- src/exceptions/OFObserveFailedException.h +++ src/exceptions/OFObserveFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFObserveFailedException.m ================================================================== --- src/exceptions/OFObserveFailedException.m +++ src/exceptions/OFObserveFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOpenItemFailedException.h ================================================================== --- src/exceptions/OFOpenItemFailedException.h +++ src/exceptions/OFOpenItemFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOpenItemFailedException.m ================================================================== --- src/exceptions/OFOpenItemFailedException.m +++ src/exceptions/OFOpenItemFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOpenWindowsRegistryKeyFailedException.h ================================================================== --- src/exceptions/OFOpenWindowsRegistryKeyFailedException.h +++ src/exceptions/OFOpenWindowsRegistryKeyFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOpenWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFOpenWindowsRegistryKeyFailedException.m +++ src/exceptions/OFOpenWindowsRegistryKeyFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOutOfMemoryException.h ================================================================== --- src/exceptions/OFOutOfMemoryException.h +++ src/exceptions/OFOutOfMemoryException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOutOfMemoryException.m ================================================================== --- src/exceptions/OFOutOfMemoryException.m +++ src/exceptions/OFOutOfMemoryException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOutOfRangeException.h ================================================================== --- src/exceptions/OFOutOfRangeException.h +++ src/exceptions/OFOutOfRangeException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFOutOfRangeException.m ================================================================== --- src/exceptions/OFOutOfRangeException.m +++ src/exceptions/OFOutOfRangeException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFReadFailedException.h ================================================================== --- src/exceptions/OFReadFailedException.h +++ src/exceptions/OFReadFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFReadFailedException.m ================================================================== --- src/exceptions/OFReadFailedException.m +++ src/exceptions/OFReadFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFReadOrWriteFailedException.h ================================================================== --- src/exceptions/OFReadOrWriteFailedException.h +++ src/exceptions/OFReadOrWriteFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFReadOrWriteFailedException.m ================================================================== --- src/exceptions/OFReadOrWriteFailedException.m +++ src/exceptions/OFReadOrWriteFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFRemoveItemFailedException.h ================================================================== --- src/exceptions/OFRemoveItemFailedException.h +++ src/exceptions/OFRemoveItemFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -50,12 +48,11 @@ * * @param URL The URL of the item which could not be removed * @param errNo The errno of the error that occurred * @return A new, autoreleased remove item failed exception */ -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo; ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated remove failed exception. Index: src/exceptions/OFRemoveItemFailedException.m ================================================================== --- src/exceptions/OFRemoveItemFailedException.m +++ src/exceptions/OFRemoveItemFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -27,24 +25,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { - return [[[self alloc] initWithURL: URL - errNo: errNo] autorelease]; + return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithURL: (OFURL *)URL - errNo: (int)errNo +- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; Index: src/exceptions/OFResolveHostFailedException.h ================================================================== --- src/exceptions/OFResolveHostFailedException.h +++ src/exceptions/OFResolveHostFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFResolveHostFailedException.m ================================================================== --- src/exceptions/OFResolveHostFailedException.m +++ src/exceptions/OFResolveHostFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFRetrieveItemAttributesFailedException.h ================================================================== --- src/exceptions/OFRetrieveItemAttributesFailedException.h +++ src/exceptions/OFRetrieveItemAttributesFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -51,12 +49,11 @@ * * @param URL The URL of the item whose attributes could not be retrieved * @param errNo The errno of the error that occurred * @return A new, autoreleased retrieve item attributes failed exception */ -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo; ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated retrieve item attributes failed Index: src/exceptions/OFRetrieveItemAttributesFailedException.m ================================================================== --- src/exceptions/OFRetrieveItemAttributesFailedException.m +++ src/exceptions/OFRetrieveItemAttributesFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -27,24 +25,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithURL: (OFURL *)URL - errNo: (int)errNo ++ (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { - return [[[self alloc] initWithURL: URL - errNo: errNo] autorelease]; + return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithURL: (OFURL *)URL - errNo: (int)errNo +- (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; Index: src/exceptions/OFSandboxActivationFailedException.h ================================================================== --- src/exceptions/OFSandboxActivationFailedException.h +++ src/exceptions/OFSandboxActivationFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -29,13 +27,12 @@ @property (readonly, nonatomic) OFSandbox *sandbox; @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; -+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox - errNo: (int)errNo; ++ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; - (instancetype)initWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFSandboxActivationFailedException.m ================================================================== --- src/exceptions/OFSandboxActivationFailedException.m +++ src/exceptions/OFSandboxActivationFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -27,12 +25,11 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox - errNo: (int)errNo ++ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo { return [[[self alloc] initWithSandbox: sandbox errNo: errNo] autorelease]; } @@ -39,12 +36,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithSandbox: (OFSandbox *)sandbox - errNo: (int)errNo +- (instancetype)initWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo { self = [super init]; _sandbox = [sandbox retain]; _errNo = errNo; Index: src/exceptions/OFSeekFailedException.h ================================================================== --- src/exceptions/OFSeekFailedException.h +++ src/exceptions/OFSeekFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFSetItemAttributesFailedException.h ================================================================== --- src/exceptions/OFSetItemAttributesFailedException.h +++ src/exceptions/OFSetItemAttributesFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFSetItemAttributesFailedException.m ================================================================== --- src/exceptions/OFSetItemAttributesFailedException.m +++ src/exceptions/OFSetItemAttributesFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFSetOptionFailedException.h ================================================================== --- src/exceptions/OFSetOptionFailedException.h +++ src/exceptions/OFSetOptionFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -48,12 +46,11 @@ * * @param object The object for which the option could not be set * @param errNo The errno of the error that occurred * @return A new, autoreleased set option failed exception */ -+ (instancetype)exceptionWithObject: (id)object - errNo: (int)errNo; ++ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated set option failed exception. Index: src/exceptions/OFSetOptionFailedException.m ================================================================== --- src/exceptions/OFSetOptionFailedException.m +++ src/exceptions/OFSetOptionFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,24 +24,21 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithObject: (id)object - errNo: (int)errNo ++ (instancetype)exceptionWithObject: (id)object errNo: (int)errNo { - return [[[self alloc] initWithObject: object - errNo: errNo] autorelease]; + return [[[self alloc] initWithObject: object errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithObject: (id)object - errNo: (int)errNo +- (instancetype)initWithObject: (id)object errNo: (int)errNo { self = [super init]; _object = [object retain]; _errNo = errNo; Index: src/exceptions/OFSetWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFSetWindowsRegistryValueFailedException.h +++ src/exceptions/OFSetWindowsRegistryValueFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,11 +28,11 @@ * @brief An exception indicating that setting a Windows registry value failed. */ @interface OFSetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; - OFString *_Nullable _value; + OFString *_Nullable _valueName; OFData *_Nullable _data; DWORD _type; LSTATUS _status; } @@ -42,13 +40,13 @@ * @brief The registry key on which setting the value failed. */ @property (readonly, nonatomic) OFWindowsRegistryKey *registryKey; /** - * @brief The value which could not be set. + * @brief The name of the value which could not be set. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *value; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *valueName; /** * @brief The data to which the value could not be set. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFData *data; @@ -66,18 +64,18 @@ /** * @brief Creates a new, autoreleased set Windows registry value failed * exception. * * @param registryKey The registry key on which setting the value failed - * @param value The value which could not be set + * @param valueName The name of the value which could not be set * @param data The data to which the value could not be set * @param type The type for the value that could not be set * @param status The status returned by RegSetValueEx() * @return A new, autoreleased set Windows registry value failed exception */ + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName data: (nullable OFData *)data type: (DWORD)type status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; @@ -85,19 +83,19 @@ /** * @brief Initializes an already allocated set Windows registry value failed * exception. * * @param registryKey The registry key on which setting the value failed - * @param value The value which could not be set + * @param valueName The name of the value which could not be set * @param data The data to which the value could not be set * @param type The type for the value that could not be set * @param status The status returned by RegSetValueEx() * @return An initialized set Windows registry value failed exception */ - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (nullable OFString *)value + valueName: (nullable OFString *)valueName data: (nullable OFData *)data type: (DWORD)type status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFSetWindowsRegistryValueFailedException.m ================================================================== --- src/exceptions/OFSetWindowsRegistryValueFailedException.m +++ src/exceptions/OFSetWindowsRegistryValueFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -20,21 +18,21 @@ #import "OFSetWindowsRegistryValueFailedException.h" #import "OFData.h" @implementation OFSetWindowsRegistryValueFailedException -@synthesize registryKey = _registryKey, value = _value, data = _data; +@synthesize registryKey = _registryKey, valueName = _valueName, data = _data; @synthesize type = _type, status = _status; + (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName data: (OFData *)data type: (DWORD)type status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey - value: value + valueName: valueName data: data type: type status: status] autorelease]; } @@ -42,20 +40,20 @@ { OF_INVALID_INIT_METHOD } - (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - value: (OFString *)value + valueName: (OFString *)valueName data: (OFData *)data type: (DWORD)type status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; - _value = [value copy]; + _valueName = [valueName copy]; _data = [data copy]; _type = type; _status = status; } @catch (id e) { [self release]; @@ -66,18 +64,18 @@ } - (void)dealloc { [_registryKey release]; - [_value release]; + [_valueName release]; [_data release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: - @"Failed to set value %@ of type %u: %@", - _value, _type, of_windows_status_to_string(_status)]; + @"Failed to set value named %@ of type %u: %@", + _valueName, _type, of_windows_status_to_string(_status)]; } @end Index: src/exceptions/OFStillLockedException.h ================================================================== --- src/exceptions/OFStillLockedException.h +++ src/exceptions/OFStillLockedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFStillLockedException.m ================================================================== --- src/exceptions/OFStillLockedException.m +++ src/exceptions/OFStillLockedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFThreadJoinFailedException.h ================================================================== --- src/exceptions/OFThreadJoinFailedException.h +++ src/exceptions/OFThreadJoinFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -24,19 +22,16 @@ #import "OFThread.h" @implementation OFThreadJoinFailedException @synthesize thread = _thread, errNo = _errNo; -+ (instancetype)exceptionWithThread: (OFThread *)thread - errNo: (int)errNo ++ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo { - return [[[self alloc] initWithThread: thread - errNo: errNo] autorelease]; + return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; } -- (instancetype)initWithThread: (OFThread *)thread - errNo: (int)errNo +- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo { self = [super init]; _thread = [thread retain]; _errNo = errNo; Index: src/exceptions/OFThreadStartFailedException.h ================================================================== --- src/exceptions/OFThreadStartFailedException.h +++ src/exceptions/OFThreadStartFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -24,19 +22,16 @@ #import "OFThread.h" @implementation OFThreadStartFailedException @synthesize thread = _thread, errNo = _errNo; -+ (instancetype)exceptionWithThread: (OFThread *)thread - errNo: (int)errNo ++ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo { - return [[[self alloc] initWithThread: thread - errNo: errNo] autorelease]; + return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; } -- (instancetype)initWithThread: (OFThread *)thread - errNo: (int)errNo +- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo { self = [super init]; _thread = [thread retain]; _errNo = errNo; Index: src/exceptions/OFThreadStillRunningException.h ================================================================== --- src/exceptions/OFThreadStillRunningException.h +++ src/exceptions/OFThreadStillRunningException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFThreadStillRunningException.m ================================================================== --- src/exceptions/OFThreadStillRunningException.m +++ src/exceptions/OFThreadStillRunningException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFTruncatedDataException.h ================================================================== --- src/exceptions/OFTruncatedDataException.h +++ src/exceptions/OFTruncatedDataException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFTruncatedDataException.m ================================================================== --- src/exceptions/OFTruncatedDataException.m +++ src/exceptions/OFTruncatedDataException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnboundNamespaceException.h ================================================================== --- src/exceptions/OFUnboundNamespaceException.h +++ src/exceptions/OFUnboundNamespaceException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnboundNamespaceException.m ================================================================== --- src/exceptions/OFUnboundNamespaceException.m +++ src/exceptions/OFUnboundNamespaceException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnboundPrefixException.h ================================================================== --- src/exceptions/OFUnboundPrefixException.h +++ src/exceptions/OFUnboundPrefixException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnboundPrefixException.m ================================================================== --- src/exceptions/OFUnboundPrefixException.m +++ src/exceptions/OFUnboundPrefixException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -39,12 +37,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithPrefix: (OFString *)prefix - parser: (OFXMLParser *)parser +- (instancetype)initWithPrefix: (OFString *)prefix parser: (OFXMLParser *)parser { self = [super init]; @try { _prefix = [prefix copy]; Index: src/exceptions/OFUndefinedKeyException.h ================================================================== --- src/exceptions/OFUndefinedKeyException.h +++ src/exceptions/OFUndefinedKeyException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -56,12 +54,11 @@ * @param object The object on which the key is undefined * @param key The key which is undefined * * @return A new, autoreleased undefined key exception */ -+ (instancetype)exceptionWithObject: (id)object - key: (OFString *)key; ++ (instancetype)exceptionWithObject: (id)object key: (OFString *)key; /** * @brief Creates a new, autoreleased undefined key exception. * * @param object The object on which the key is undefined @@ -82,12 +79,11 @@ * @param object The object on which the key is undefined * @param key The key which is undefined * * @return An initialized undefined key exception */ -- (instancetype)initWithObject: (id)object - key: (OFString *)key; +- (instancetype)initWithObject: (id)object key: (OFString *)key; /** * @brief Initializes an already allocated undefined key exception. * * @param object The object on which the key is undefined Index: src/exceptions/OFUndefinedKeyException.m ================================================================== --- src/exceptions/OFUndefinedKeyException.m +++ src/exceptions/OFUndefinedKeyException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -26,15 +24,13 @@ + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -+ (instancetype)exceptionWithObject: (id)object - key: (OFString *)key ++ (instancetype)exceptionWithObject: (id)object key: (OFString *)key { - return [[[self alloc] initWithObject: object - key: key] autorelease]; + return [[[self alloc] initWithObject: object key: key] autorelease]; } + (instancetype)exceptionWithObject: (id)object key: (OFString *)key value: (id)value @@ -47,21 +43,16 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithObject: (id)object - key: (OFString *)key +- (instancetype)initWithObject: (id)object key: (OFString *)key { - return [self initWithObject: object - key: key - value: nil]; + return [self initWithObject: object key: key value: nil]; } -- (instancetype)initWithObject: (id)object - key: (OFString *)key - value: (id)value +- (instancetype)initWithObject: (id)object key: (OFString *)key value: (id)value { self = [super init]; @try { _object = [object retain]; Index: src/exceptions/OFUnknownXMLEntityException.h ================================================================== --- src/exceptions/OFUnknownXMLEntityException.h +++ src/exceptions/OFUnknownXMLEntityException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnknownXMLEntityException.m ================================================================== --- src/exceptions/OFUnknownXMLEntityException.m +++ src/exceptions/OFUnknownXMLEntityException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnlockFailedException.h ================================================================== --- src/exceptions/OFUnlockFailedException.h +++ src/exceptions/OFUnlockFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnlockFailedException.m ================================================================== --- src/exceptions/OFUnlockFailedException.m +++ src/exceptions/OFUnlockFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -23,19 +21,16 @@ #import "OFString.h" @implementation OFUnlockFailedException @synthesize lock = _lock, errNo = _errNo; -+ (instancetype)exceptionWithLock: (id )lock - errNo: (int)errNo ++ (instancetype)exceptionWithLock: (id )lock errNo: (int)errNo { - return [[[self alloc] initWithLock: lock - errNo: errNo] autorelease]; + return [[[self alloc] initWithLock: lock errNo: errNo] autorelease]; } -- (instancetype)initWithLock: (id )lock - errNo: (int)errNo +- (instancetype)initWithLock: (id )lock errNo: (int)errNo { self = [super init]; _lock = [lock retain]; _errNo = errNo; Index: src/exceptions/OFUnsupportedProtocolException.h ================================================================== --- src/exceptions/OFUnsupportedProtocolException.h +++ src/exceptions/OFUnsupportedProtocolException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnsupportedProtocolException.m ================================================================== --- src/exceptions/OFUnsupportedProtocolException.m +++ src/exceptions/OFUnsupportedProtocolException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnsupportedVersionException.h ================================================================== --- src/exceptions/OFUnsupportedVersionException.h +++ src/exceptions/OFUnsupportedVersionException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFUnsupportedVersionException.m ================================================================== --- src/exceptions/OFUnsupportedVersionException.m +++ src/exceptions/OFUnsupportedVersionException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFWriteFailedException.h ================================================================== --- src/exceptions/OFWriteFailedException.h +++ src/exceptions/OFWriteFailedException.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/exceptions/OFWriteFailedException.m ================================================================== --- src/exceptions/OFWriteFailedException.m +++ src/exceptions/OFWriteFailedException.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/apple-forwarding-arm.S ================================================================== --- src/forwarding/apple-forwarding-arm.S +++ src/forwarding/apple-forwarding-arm.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/apple-forwarding-arm64.S ================================================================== --- src/forwarding/apple-forwarding-arm64.S +++ src/forwarding/apple-forwarding-arm64.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/apple-forwarding-i386.S ================================================================== --- src/forwarding/apple-forwarding-i386.S +++ src/forwarding/apple-forwarding-i386.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,133 +13,123 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl _of_forward .globl _of_forward_stret .section __TEXT, __cstring, cstring_literals -Lstr_forwardingTargetForSelector_: +str_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __OBJC, __message_refs, literal_pointers, no_dead_strip -Lsel_forwardingTargetForSelector_: - .long Lstr_forwardingTargetForSelector_ +sel_forwardingTargetForSelector_: + .long str_forwardingTargetForSelector_ .section __OBJC, __image_info .long 0, 0 .section __TEXT, __text, regular, pure_instructions _of_forward: - push ebp - mov ebp, esp + pushl %ebp + movl %esp, %ebp - push ebx - sub esp, 20 + pushl %ebx + subl $20, %esp call get_eip 0: - mov eax, [ebp+8] - mov [esp], eax + movl 8(%ebp), %eax + movl %eax, (%esp) call _object_getClass - mov [esp], eax - .att_syntax /* Next line is broken in Intel syntax */ - movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax - .intel_syntax noprefix - mov [esp+4], eax + movl %eax, (%esp) + movl sel_forwardingTargetForSelector_-0b(%ebx), %eax + movl %eax, 4(%esp) call _class_respondsToSelector - test eax, eax + testl %eax, %eax jz 0f - mov eax, [ebp+8] - mov [esp], eax - .att_syntax /* Next line is broken in Intel syntax */ - movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax - .intel_syntax noprefix - mov [esp+4], eax - mov eax, [ebp+12] - mov [esp+8], eax + movl 8(%ebp), %eax + movl %eax, (%esp) + movl sel_forwardingTargetForSelector_-0b(%ebx), %eax + movl %eax, 4(%esp) + movl 12(%ebp), %eax + movl %eax, 8(%esp) call _objc_msgSend - test eax, eax + testl %eax, %eax jz 0f - cmp eax, [ebp+8] + cmpl 8(%ebp), %eax je 0f - mov [ebp+8], eax + movl %eax, 8(%ebp) - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp jmp _objc_msgSend 0: - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp jmp _of_method_not_found _of_forward_stret: - push ebp - mov ebp, esp + pushl %ebp + movl %esp, %ebp - push ebx - sub esp, 20 + pushl %ebx + subl $20, %esp call get_eip 0: - mov eax, [ebp+12] - mov [esp], eax + movl 12(%ebp), %eax + movl %eax, (%esp) call _object_getClass - mov [esp], eax - .att_syntax /* Next line is broken in Intel syntax */ - movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax - .intel_syntax noprefix - mov [esp+4], eax + movl %eax, (%esp) + movl sel_forwardingTargetForSelector_-0b(%ebx), %eax + movl %eax, 4(%esp) call _class_respondsToSelector - test eax, eax + testl %eax, %eax jz 0f - mov eax, [ebp+12] - mov [esp], eax - .att_syntax /* Next line is broken in Intel syntax */ - movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax - .intel_syntax noprefix - mov [esp+4], eax - mov eax, [ebp+16] - mov [esp+8], eax + movl 12(%ebp), %eax + movl %eax, (%esp) + movl sel_forwardingTargetForSelector_-0b(%ebx), %eax + movl %eax, 4(%esp) + movl 16(%ebp), %eax + movl %eax, 8(%esp) call _objc_msgSend - test eax, eax + testl %eax, %eax jz 0f - cmp eax, [ebp+12] + cmpl 12(%ebp), %eax je 0f - mov [ebp+12], eax + movl %eax, 12(%ebp) - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp jmp _objc_msgSend_stret 0: - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp jmp _of_method_not_found_stret get_eip: - mov ebx, [esp] + movl (%esp), %ebx ret Index: src/forwarding/apple-forwarding-powerpc.S ================================================================== --- src/forwarding/apple-forwarding-powerpc.S +++ src/forwarding/apple-forwarding-powerpc.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/apple-forwarding-x86_64.S ================================================================== --- src/forwarding/apple-forwarding-x86_64.S +++ src/forwarding/apple-forwarding-x86_64.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,12 +13,10 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl _of_forward .globl _of_forward_stret .section __TEXT, __objc_methname, cstring_literals str_forwardingTargetForSelector_: @@ -33,150 +29,150 @@ .section __DATA, __objc_imageinfo, regular, no_dead_strip .long 0, 0 .section __TEXT, __text, regular, pure_instructions _of_forward: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) call _object_getClass - mov rdi, rax - mov rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + movq sel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector - test rax, rax + testq %rax, %rax jz 0f - mov rdi, [rbp-0x10] - mov rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x18] + movq -0x10(%rbp), %rdi + movq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x18(%rbp), %rdx call _objc_msgSend - test rax, rax + testq %rax, %rax jz 0f - cmp rax, [rbp-0x10] + cmpq -0x10(%rbp), %rax je 0f - mov rdi, rax + movq %rax, %rdi /* Restore all arguments, except %rdi */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rsi, [rbp-0x18] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x18(%rbp), %rsi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp jmp _objc_msgSend 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp _of_method_not_found _of_forward_stret: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 - - mov rdi, rsi + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) + + movq %rsi, %rdi call _object_getClass - mov rdi, rax - mov rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + movq sel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector - test rax, rax + testq %rax, %rax jz 0f - mov rdi, [rbp-0x18] - mov rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x20] + movq -0x18(%rbp), %rdi + movq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x20(%rbp), %rdx call _objc_msgSend - test rax, rax + testq %rax, %rax jz 0f - cmp rax, [rbp-0x18] + cmpq -0x18(%rbp), %rax je 0f - mov rsi, rax + movq %rax, %rsi /* Restore all arguments, except %rsi */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rdi, [rbp-0x10] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x10(%rbp), %rdi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp jmp _objc_msgSend_stret 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] - mov rdx, [rbp-0x20] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi + movq -0x20(%rbp), %rdx - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp _of_method_not_found_stret Index: src/forwarding/forwarding-arm-elf.S ================================================================== --- src/forwarding/forwarding-arm-elf.S +++ src/forwarding/forwarding-arm-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-arm64-elf.S ================================================================== --- src/forwarding/forwarding-arm64-elf.S +++ src/forwarding/forwarding-arm64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-mips-elf.S ================================================================== --- src/forwarding/forwarding-mips-elf.S +++ src/forwarding/forwarding-mips-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-powerpc-elf.S ================================================================== --- src/forwarding/forwarding-powerpc-elf.S +++ src/forwarding/forwarding-powerpc-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-sparc-elf.S ================================================================== --- src/forwarding/forwarding-sparc-elf.S +++ src/forwarding/forwarding-sparc-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-sparc64-elf.S ================================================================== --- src/forwarding/forwarding-sparc64-elf.S +++ src/forwarding/forwarding-sparc64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/forwarding/forwarding-x86-elf.S ================================================================== --- src/forwarding/forwarding-x86-elf.S +++ src/forwarding/forwarding-x86-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,165 +15,163 @@ #include "config.h" #include "platform.h" -.intel_syntax noprefix - .globl of_forward .globl of_forward_stret .section .text of_forward: - push ebp - mov ebp, esp + pushl %ebp + movl %esp, %ebp - push ebx - sub esp, 20 + pushl %ebx + subl $20, %esp call get_eip - add ebx, offset _GLOBAL_OFFSET_TABLE_ + addl $_GLOBAL_OFFSET_TABLE_, %ebx - mov eax, [ebp+8] - mov [esp], eax + movl 8(%ebp), %eax + movl %eax, (%esp) call object_getClass@PLT - mov [esp], eax - lea eax, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) call class_respondsToSelector@PLT - test eax, eax - jz short 0f - - mov eax, [ebp+8] - mov [esp], eax - lea eax, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], eax - call objc_msg_lookup@PLT - - mov edx, [ebp+8] - mov [esp], edx - lea edx, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], edx - mov edx, [ebp+12] - mov [esp+8], edx - call eax - - test eax, eax - jz short 0f - cmp eax, [ebp+8] - je short 0f - - mov [ebp+8], eax - mov [esp], eax - mov eax, [ebp+12] - mov [esp+4], eax - call objc_msg_lookup@PLT - - add esp, 20 - pop ebx - pop ebp - - jmp eax - -0: - lea eax, [ebx+of_method_not_found@GOTOFF] - - add esp, 20 - pop ebx - pop ebp - - jmp eax + testl %eax, %eax + jz 0f + + movl 8(%ebp), %eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) + call objc_msg_lookup@PLT + + movl 8(%ebp), %edx + movl %edx, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %edx + movl %edx, 4(%esp) + movl 12(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + testl %eax, %eax + jz 0f + cmpl 8(%ebp), %eax + je 0f + + movl %eax, 8(%ebp) + movl %eax, (%esp) + movl 12(%ebp), %eax + movl %eax, 4(%esp) + call objc_msg_lookup@PLT + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax + +0: + leal of_method_not_found@GOTOFF(%ebx), %eax + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: - push ebp - mov ebp, esp + pushl %ebp + movl %esp, %ebp - push ebx - sub esp, 20 + pushl %ebx + subl $20, %esp call get_eip - add ebx, offset _GLOBAL_OFFSET_TABLE_ + addl $_GLOBAL_OFFSET_TABLE_, %ebx - mov eax, [ebp+12] - mov [esp], eax + movl 12(%ebp), %eax + movl %eax, (%esp) call object_getClass@PLT - mov [esp], eax - lea eax, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) call class_respondsToSelector@PLT - test eax, eax - jz short 0f + testl %eax, %eax + jz 0f - mov eax, [ebp+12] - mov [esp], eax - lea eax, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], eax + movl 12(%ebp), %eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) call objc_msg_lookup@PLT - mov edx, [ebp+12] - mov [esp], edx - lea edx, [ebx+sel_forwardingTargetForSelector_@GOTOFF] - mov [esp+4], edx - mov edx, [ebp+16] - mov [esp+8], edx - call eax - - test eax, eax - jz short 0f - cmp eax, [ebp+12] - je short 0f - - mov [ebp+12], eax - mov [esp], eax - mov eax, [ebp+16] - mov [esp+4], eax + movl 12(%ebp), %edx + movl %edx, (%esp) + leal sel_forwardingTargetForSelector_@GOTOFF(%ebx), %edx + movl %edx, 4(%esp) + movl 16(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + testl %eax, %eax + jz 0f + cmpl 12(%ebp), %eax + je 0f + + movl %eax, 12(%ebp) + movl %eax, (%esp) + movl 16(%ebp), %eax + movl %eax, 4(%esp) call objc_msg_lookup_stret@PLT - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp - jmp eax + jmp *%eax 0: - lea eax, [ebx+of_method_not_found_stret@GOTOFF] + leal of_method_not_found_stret@GOTOFF(%ebx), %eax - add esp, 20 - pop ebx - pop ebp + addl $20, %esp + popl %ebx + popl %ebp - jmp eax + jmp *%eax .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: - push ebp - mov ebp, esp + pushl %ebp + movl %esp, %ebp - push ebx - sub esp, 4 + pushl %ebx + subl $4, %esp call get_eip - add ebx, offset _GLOBAL_OFFSET_TABLE_ + addl $_GLOBAL_OFFSET_TABLE_, %ebx - lea eax, [ebx+module@GOTOFF] - mov [esp], eax + leal module@GOTOFF(%ebx), %eax + movl %eax, (%esp) call __objc_exec_class@PLT - add esp, 4 - pop ebx - pop ebp + addl $4, %esp + popl %ebx + popl %ebp ret get_eip: - mov ebx, [esp] + movl (%esp), %ebx ret #ifdef OF_SOLARIS .section .init_array, "aw" #else Index: src/forwarding/forwarding-x86-win32.S ================================================================== --- src/forwarding/forwarding-x86-win32.S +++ src/forwarding/forwarding-x86-win32.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,144 +13,150 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl _of_forward .globl _of_forward_stret .section .text _of_forward: - push ebp - mov ebp, esp - - push ebx - sub esp, 20 - - mov eax, [ebp+8] - mov [esp], eax - call _object_getClass - - mov [esp], eax - mov eax, offset sel_forwardingTargetForSelector_ - mov [esp+4], eax - call _class_respondsToSelector - - test eax, eax - jz short 0f - - mov eax, [ebp+8] - mov [esp], eax - mov eax, offset sel_forwardingTargetForSelector_ - mov [esp+4], eax - call _objc_msg_lookup - - mov edx, [ebp+8] - mov [esp], edx - mov edx, offset sel_forwardingTargetForSelector_ - mov [esp+4], edx - mov edx, [ebp+12] - mov [esp+8], edx - call eax - - test eax, eax - jz short 0f - cmp eax, [ebp+8] - je short 0f - - mov [ebp+8], eax - mov [esp], eax - mov eax, [ebp+12] - mov [esp+4], eax - call _objc_msg_lookup - - add esp, 20 - pop ebx - pop ebp - - jmp eax - -0: - add esp, 20 - pop ebx - pop ebp - - jmp _of_method_not_found - -_of_forward_stret: - push ebp - mov ebp, esp - - push ebx - sub esp, 20 - - mov eax, [ebp+12] - mov [esp], eax - call _object_getClass - - mov [esp], eax - mov eax, offset sel_forwardingTargetForSelector_ - mov [esp+4], eax - call _class_respondsToSelector - - test eax, eax - jz short 0f - - mov eax, [ebp+12] - mov [esp], eax - mov eax, offset sel_forwardingTargetForSelector_ - mov [esp+4], eax - call _objc_msg_lookup - - mov edx, [ebp+12] - mov [esp], edx - mov edx, offset sel_forwardingTargetForSelector_ - mov [esp+4], edx - mov edx, [ebp+16] - mov [esp+8], edx - call eax - - test eax, eax - jz short 0f - cmp eax, [ebp+12] - je short 0f - - mov [ebp+12], eax - mov [esp], eax - mov eax, [ebp+16] - mov [esp+4], eax - call _objc_msg_lookup_stret - - add esp, 20 - pop ebx - pop ebp - - jmp eax - -0: - add esp, 20 - pop ebx - pop ebp - - jmp _of_method_not_found_stret - -init: - push ebp - mov ebp, esp - - push ebx - sub esp, 4 - - mov eax, offset module - mov [esp], eax - call ___objc_exec_class - - add esp, 4 - pop ebx - pop ebp + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $20, %esp + + movl 8(%ebp), %eax + movl %eax, (%esp) + call _object_getClass + + movl %eax, (%esp) + movl $sel_forwardingTargetForSelector_, %eax + movl %eax, 4(%esp) + call _class_respondsToSelector + + testl %eax, %eax + jz 0f + + movl 8(%ebp), %eax + movl %eax, (%esp) + movl $sel_forwardingTargetForSelector_, %eax + movl %eax, 4(%esp) + call _objc_msg_lookup + + movl 8(%ebp), %edx + movl %edx, (%esp) + movl $sel_forwardingTargetForSelector_, %edx + movl %edx, 4(%esp) + movl 12(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + testl %eax, %eax + jz 0f + cmpl 8(%ebp), %eax + je 0f + + movl %eax, 8(%ebp) + movl %eax, (%esp) + movl 12(%ebp), %eax + movl %eax, 4(%esp) + call _objc_msg_lookup + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax + +0: + addl $20, %esp + popl %ebx + popl %ebp + + jmp _of_method_not_found +.def _of_forward +.scl 2 +.type 32 +.endef + +_of_forward_stret: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $20, %esp + + movl 12(%ebp), %eax + movl %eax, (%esp) + call _object_getClass + + movl %eax, (%esp) + movl $sel_forwardingTargetForSelector_, %eax + movl %eax, 4(%esp) + call _class_respondsToSelector + + testl %eax, %eax + jz 0f + + movl 12(%ebp), %eax + movl %eax, (%esp) + movl $sel_forwardingTargetForSelector_, %eax + movl %eax, 4(%esp) + call _objc_msg_lookup + + movl 12(%ebp), %edx + movl %edx, (%esp) + movl $sel_forwardingTargetForSelector_, %edx + movl %edx, 4(%esp) + movl 16(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + testl %eax, %eax + jz 0f + cmpl 12(%ebp), %eax + je 0f + + movl %eax, 12(%ebp) + movl %eax, (%esp) + movl 16(%ebp), %eax + movl %eax, 4(%esp) + call _objc_msg_lookup_stret + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax + +0: + addl $20, %esp + popl %ebx + popl %ebp + + jmp _of_method_not_found_stret +.def _of_forward_stret +.scl 2 +.type 32 +.endef + +init: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $4, %esp + + movl $module, %eax + movl %eax, (%esp) + call ___objc_exec_class + + addl $4, %esp + popl %ebx + popl %ebp ret .section .ctors, "aw" .long init Index: src/forwarding/forwarding-x86_64-elf.S ================================================================== --- src/forwarding/forwarding-x86_64-elf.S +++ src/forwarding/forwarding-x86_64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,190 +15,188 @@ #include "config.h" #include "platform.h" -.intel_syntax noprefix - .globl of_forward .globl of_forward_stret .section .text of_forward: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) call object_getClass@PLT - mov rdi, rax - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call class_respondsToSelector@PLT - test rax, rax - jz short 0f - - mov rdi, [rbp-0x10] - lea rsi, [rip+sel_forwardingTargetForSelector_] - call objc_msg_lookup@PLT - - mov rdi, [rbp-0x10] - lea rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x18] - call rax - - test rax, rax - jz short 0f - cmp rax, [rbp-0x10] - je short 0f - - mov [rbp-0x10], rax - - mov rdi, rax - mov rsi, [rbp-0x18] - call objc_msg_lookup@PLT - mov r11, rax + testq %rax, %rax + jz 0f + + movq -0x10(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + call objc_msg_lookup@PLT + + movq -0x10(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x18(%rbp), %rdx + call *%rax + + testq %rax, %rax + jz 0f + cmpq -0x10(%rbp), %rax + je 0f + + movq %rax, -0x10(%rbp) + + movq %rax, %rdi + movq -0x18(%rbp), %rsi + call objc_msg_lookup@PLT + movq %rax, %r11 /* Restore all arguments */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rsi, [rbp-0x18] - mov rdi, [rbp-0x10] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x18(%rbp), %rsi + movq -0x10(%rbp), %rdi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp of_method_not_found@PLT .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 - - mov rdi, rsi + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) + + movq %rsi, %rdi call object_getClass@PLT - mov rdi, rax - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call class_respondsToSelector@PLT - test rax, rax - jz short 0f + testq %rax, %rax + jz 0f - mov rdi, [rbp-0x18] - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq -0x18(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call objc_msg_lookup@PLT - mov rdi, [rbp-0x18] - lea rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x20] - call rax - - test rax, rax - jz short 0f - cmp rax, [rbp-0x18] - je short 0f - - mov [rbp-0x18], rax - - mov rdi, rax - mov rsi, [rbp-0x20] + movq -0x18(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x20(%rbp), %rdx + call *%rax + + testq %rax, %rax + jz 0f + cmpq -0x18(%rbp), %rax + je 0f + + movq %rax, -0x18(%rbp) + + movq %rax, %rdi + movq -0x20(%rbp), %rsi call objc_msg_lookup_stret@PLT - mov r11, rax + movq %rax, %r11 /* Restore all arguments */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rsi, [rbp-0x18] - mov rdi, [rbp-0x10] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x18(%rbp), %rsi + movq -0x10(%rbp), %rdi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] - mov rdx, [rbp-0x20] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi + movq -0x20(%rbp), %rdx - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp of_method_not_found_stret@PLT .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: - lea rdi, [rip+module] + leaq module(%rip), %rdi jmp __objc_exec_class@PLT #ifdef OF_SOLARIS .section .init_array, "aw" #else Index: src/forwarding/forwarding-x86_64-macho.S ================================================================== --- src/forwarding/forwarding-x86_64-macho.S +++ src/forwarding/forwarding-x86_64-macho.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,186 +15,184 @@ #include "config.h" #include "platform.h" -.intel_syntax noprefix - .globl _of_forward .globl _of_forward_stret .section __TEXT, __text, regular, pure_instructions _of_forward: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) call _object_getClass - mov rdi, rax - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector - test rax, rax - jz 0f - - mov rdi, [rbp-0x10] - lea rsi, [rip+sel_forwardingTargetForSelector_] - call _objc_msg_lookup - - mov rdi, [rbp-0x10] - lea rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x18] - call rax - - test rax, rax - jz 0f - cmp rax, [rbp-0x10] + testq %rax, %rax + jz 0f + + movq -0x10(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + call _objc_msg_lookup + + movq -0x10(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x18(%rbp), %rdx + call *%rax + + testq %rax, %rax + jz 0f + cmpq -0x10(%rbp), %rax je 0f - mov [rbp-0x10], rax + movq %rax, -0x10(%rbp) - mov rdi, rax - mov rsi, [rbp-0x18] + movq %rax, %rdi + movq -0x18(%rbp), %rsi call _objc_msg_lookup - mov r11, rax + movq %rax, %r11 /* Restore all arguments */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rsi, [rbp-0x18] - mov rdi, [rbp-0x10] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x18(%rbp), %rsi + movq -0x10(%rbp), %rdi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp _of_method_not_found _of_forward_stret: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0xC0 /* 16-byte alignment */ - mov [rbp-0x08], rax - mov [rbp-0x10], rdi - mov [rbp-0x18], rsi - mov [rbp-0x20], rdx - mov [rbp-0x28], rcx - mov [rbp-0x30], r8 - mov [rbp-0x38], r9 - movaps [rbp-0x50], xmm0 - movaps [rbp-0x60], xmm1 - movaps [rbp-0x70], xmm2 - movaps [rbp-0x80], xmm3 - movaps [rbp-0x90], xmm4 - movaps [rbp-0xA0], xmm5 - movaps [rbp-0xB0], xmm6 - movaps [rbp-0xC0], xmm7 - - mov rdi, rsi + subq $0xC0, %rsp /* 16-byte alignment */ + movq %rax, -0x8(%rbp) + movq %rdi, -0x10(%rbp) + movq %rsi, -0x18(%rbp) + movq %rdx, -0x20(%rbp) + movq %rcx, -0x28(%rbp) + movq %r8, -0x30(%rbp) + movq %r9, -0x38(%rbp) + movaps %xmm0, -0x50(%rbp) + movaps %xmm1, -0x60(%rbp) + movaps %xmm2, -0x70(%rbp) + movaps %xmm3, -0x80(%rbp) + movaps %xmm4, -0x90(%rbp) + movaps %xmm5, -0xA0(%rbp) + movaps %xmm6, -0xB0(%rbp) + movaps %xmm7, -0xC0(%rbp) + + movq %rsi, %rdi call _object_getClass - mov rdi, rax - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq %rax, %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector - test rax, rax + testq %rax, %rax jz 0f - mov rdi, [rbp-0x18] - lea rsi, [rip+sel_forwardingTargetForSelector_] + movq -0x18(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi call _objc_msg_lookup - mov rdi, [rbp-0x18] - lea rsi, [rip+sel_forwardingTargetForSelector_] - mov rdx, [rbp-0x20] - call rax + movq -0x18(%rbp), %rdi + leaq sel_forwardingTargetForSelector_(%rip), %rsi + movq -0x20(%rbp), %rdx + call *%rax - test rax, rax + testq %rax, %rax jz 0f - cmp rax, [rbp-0x18] + cmpq -0x18(%rbp), %rax je 0f - mov [rbp-0x18], rax + movq %rax, -0x18(%rbp) - mov rdi, rax - mov rsi, [rbp-0x20] + movq %rax, %rdi + movq -0x20(%rbp), %rsi call _objc_msg_lookup_stret - mov r11, rax + movq %rax, %r11 /* Restore all arguments */ - movaps xmm7, [rbp-0xC0] - movaps xmm6, [rbp-0xB0] - movaps xmm5, [rbp-0xA0] - movaps xmm4, [rbp-0x90] - movaps xmm3, [rbp-0x80] - movaps xmm2, [rbp-0x70] - movaps xmm1, [rbp-0x60] - movaps xmm0, [rbp-0x50] - mov r9, [rbp-0x38] - mov r8, [rbp-0x30] - mov rcx, [rbp-0x28] - mov rdx, [rbp-0x20] - mov rsi, [rbp-0x18] - mov rdi, [rbp-0x10] - mov rax, [rbp-0x08] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0xC0(%rbp), %xmm7 + movaps -0xB0(%rbp), %xmm6 + movaps -0xA0(%rbp), %xmm5 + movaps -0x90(%rbp), %xmm4 + movaps -0x80(%rbp), %xmm3 + movaps -0x70(%rbp), %xmm2 + movaps -0x60(%rbp), %xmm1 + movaps -0x50(%rbp), %xmm0 + movq -0x38(%rbp), %r9 + movq -0x30(%rbp), %r8 + movq -0x28(%rbp), %rcx + movq -0x20(%rbp), %rdx + movq -0x18(%rbp), %rsi + movq -0x10(%rbp), %rdi + movq -0x8(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rdi, [rbp-0x10] - mov rsi, [rbp-0x18] - mov rdx, [rbp-0x20] + movq -0x10(%rbp), %rdi + movq -0x18(%rbp), %rsi + movq -0x20(%rbp), %rdx - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp _of_method_not_found_stret init: - lea rdi, [rip+module] + leaq module(%rip), %rdi jmp ___objc_exec_class .section __DATA, __mod_init_func, mod_init_funcs .quad init Index: src/forwarding/forwarding-x86_64-win64.S ================================================================== --- src/forwarding/forwarding-x86_64-win64.S +++ src/forwarding/forwarding-x86_64-win64.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,162 +13,168 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl of_forward .globl of_forward_stret .section .text of_forward: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0x90 /* 16-byte alignment */ - mov [rbp-0x28], rax - mov [rbp-0x30], rcx - mov [rbp-0x38], rdx - mov [rbp-0x40], r8 - mov [rbp-0x48], r9 - movaps [rbp-0x60], xmm0 - movaps [rbp-0x70], xmm1 - movaps [rbp-0x80], xmm2 - movaps [rbp-0x90], xmm3 + subq $0x90, %rsp /* 16-byte alignment */ + movq %rax, -0x28(%rbp) + movq %rcx, -0x30(%rbp) + movq %rdx, -0x38(%rbp) + movq %r8, -0x40(%rbp) + movq %r9, -0x48(%rbp) + movaps %xmm0, -0x60(%rbp) + movaps %xmm1, -0x70(%rbp) + movaps %xmm2, -0x80(%rbp) + movaps %xmm3, -0x90(%rbp) call object_getClass - mov rcx, rax - mov rdx, offset sel_forwardingTargetForSelector_ + movq %rax, %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx call class_respondsToSelector - test rax, rax - jz short 0f - - mov rcx, [rbp-0x30] - mov rdx, offset sel_forwardingTargetForSelector_ - call objc_msg_lookup - - mov rcx, [rbp-0x30] - mov rdx, offset sel_forwardingTargetForSelector_ - mov r8, [rbp-0x38] - call rax - - test rax, rax - jz short 0f - cmp rax, [rbp-0x30] - je short 0f - - mov [rbp-0x30], rax - - mov rcx, rax - mov rdx, [rbp-0x38] - call objc_msg_lookup - mov r11, rax + testq %rax, %rax + jz 0f + + movq -0x30(%rbp), %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx + call objc_msg_lookup + + movq -0x30(%rbp), %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx + movq -0x38(%rbp), %r8 + call *%rax + + testq %rax, %rax + jz 0f + cmpq -0x30(%rbp), %rax + je 0f + + movq %rax, -0x30(%rbp) + + movq %rax, %rcx + movq -0x38(%rbp), %rdx + call objc_msg_lookup + movq %rax, %r11 /* Restore all arguments */ - movaps xmm3, [rbp-0x90] - movaps xmm2, [rbp-0x80] - movaps xmm1, [rbp-0x70] - movaps xmm0, [rbp-0x60] - mov r9, [rbp-0x48] - mov r8, [rbp-0x40] - mov rdx, [rbp-0x38] - mov rcx, [rbp-0x30] - mov rax, [rbp-0x28] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0x90(%rbp), %xmm3 + movaps -0x80(%rbp), %xmm2 + movaps -0x70(%rbp), %xmm1 + movaps -0x60(%rbp), %xmm0 + movq -0x48(%rbp), %r9 + movq -0x40(%rbp), %r8 + movq -0x38(%rbp), %rdx + movq -0x30(%rbp), %rcx + movq -0x28(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rcx, [rbp-0x30] - mov rdx, [rbp-0x38] + movq -0x30(%rbp), %rcx + movq -0x38(%rbp), %rdx - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp of_method_not_found +.def of_forward +.scl 2 +.type 32 +.endef of_forward_stret: - push rbp - mov rbp, rsp + pushq %rbp + movq %rsp, %rbp /* Save all arguments */ - sub rsp, 0x90 /* 16-byte alignment */ - mov [rbp-0x28], rax - mov [rbp-0x30], rcx - mov [rbp-0x38], rdx - mov [rbp-0x40], r8 - mov [rbp-0x48], r9 - movaps [rbp-0x60], xmm0 - movaps [rbp-0x70], xmm1 - movaps [rbp-0x80], xmm2 - movaps [rbp-0x90], xmm3 - - mov rcx, rdx + subq $0x90, %rsp /* 16-byte alignment */ + movq %rax, -0x28(%rbp) + movq %rcx, -0x30(%rbp) + movq %rdx, -0x38(%rbp) + movq %r8, -0x40(%rbp) + movq %r9, -0x48(%rbp) + movaps %xmm0, -0x60(%rbp) + movaps %xmm1, -0x70(%rbp) + movaps %xmm2, -0x80(%rbp) + movaps %xmm3, -0x90(%rbp) + + movq %rdx, %rcx call object_getClass - mov rcx, rax - mov rdx, offset sel_forwardingTargetForSelector_ + movq %rax, %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx call class_respondsToSelector - test rax, rax - jz short 0f + testq %rax, %rax + jz 0f - mov rcx, [rbp-0x38] - mov rdx, offset sel_forwardingTargetForSelector_ + movq -0x38(%rbp), %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx call objc_msg_lookup - mov rcx, [rbp-0x38] - mov rdx, offset sel_forwardingTargetForSelector_ - mov r8, [rbp-0x40] - call rax - - test rax, rax - jz short 0f - cmp rax, [rbp-0x38] - je short 0f - - mov [rbp-0x38], rax - - mov rcx, rax - mov rdx, [rbp-0x40] + movq -0x38(%rbp), %rcx + leaq sel_forwardingTargetForSelector_(%rip), %rdx + movq -0x40(%rbp), %r8 + call *%rax + + testq %rax, %rax + jz 0f + cmpq -0x38(%rbp), %rax + je 0f + + movq %rax, -0x38(%rbp) + + movq %rax, %rcx + movq -0x40(%rbp), %rdx call objc_msg_lookup_stret - mov r11, rax + movq %rax, %r11 /* Restore all arguments */ - movaps xmm3, [rbp-0x90] - movaps xmm2, [rbp-0x80] - movaps xmm1, [rbp-0x70] - movaps xmm0, [rbp-0x60] - mov r9, [rbp-0x48] - mov r8, [rbp-0x40] - mov rdx, [rbp-0x38] - mov rcx, [rbp-0x30] - mov rax, [rbp-0x28] - - mov rsp, rbp - pop rbp - - jmp r11 + movaps -0x90(%rbp), %xmm3 + movaps -0x80(%rbp), %xmm2 + movaps -0x70(%rbp), %xmm1 + movaps -0x60(%rbp), %xmm0 + movq -0x48(%rbp), %r9 + movq -0x40(%rbp), %r8 + movq -0x38(%rbp), %rdx + movq -0x30(%rbp), %rcx + movq -0x28(%rbp), %rax + + movq %rbp, %rsp + popq %rbp + + jmpq *%r11 0: - mov rcx, [rbp-0x30] - mov rdx, [rbp-0x38] - mov r8, [rbp-0x40] + movq -0x30(%rbp), %rcx + movq -0x38(%rbp), %rdx + movq -0x40(%rbp), %r8 - mov rsp, rbp - pop rbp + movq %rbp, %rsp + popq %rbp jmp of_method_not_found_stret +.def of_forward_stret +.scl 2 +.type 32 +.endef init: - mov rcx, offset module + leaq module(%rip), %rcx jmp __objc_exec_class .section .ctors, "aw" .quad init Index: src/forwarding/forwarding.S ================================================================== --- src/forwarding/forwarding.S +++ src/forwarding/forwarding.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/huffman_tree.h ================================================================== --- src/huffman_tree.h +++ src/huffman_tree.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/huffman_tree.m ================================================================== --- src/huffman_tree.m +++ src/huffman_tree.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/libbases.m ================================================================== --- src/libbases.m +++ src/libbases.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/mutex.h ================================================================== --- src/mutex.h +++ src/mutex.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/mutex.m ================================================================== --- src/mutex.m +++ src/mutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/of_asprintf.h ================================================================== --- src/of_asprintf.h +++ src/of_asprintf.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -97,43 +95,40 @@ #ifndef HAVE_ASPRINTF static int vasprintf(char **string, const char *format, va_list arguments) { - int expectedLength, length; - va_list argumentsCopy; - - va_copy(argumentsCopy, arguments); - - expectedLength = vsnprintf(NULL, 0, format, argumentsCopy); - if (expectedLength == -1) - /* - * We have no way to know how large it is. Let's try 64 KB and - * hope. - */ - expectedLength = 65535; - - if ((*string = malloc((size_t)expectedLength + 1)) == NULL) - return -1; - - length = vsnprintf(*string, (size_t)expectedLength + 1, - format, arguments); - - if (length == -1 || length > expectedLength) { + int length; + size_t bufferLength = 128; + + *string = NULL; + + for (;;) { free(*string); - *string = NULL; - return -1; + + if ((*string = malloc(bufferLength)) == NULL) + return -1; + + length = vsnprintf(*string, bufferLength - 1, format, + arguments); + + if (length >= 0 && (size_t)length < bufferLength - 1) + break; + + if (bufferLength > INT_MAX / 2) { + free(*string); + return -1; + } + + bufferLength <<= 1; } - /* - * In case we could not determine the size, resize to the actual size - * needed, but ignore any failure to do so. - */ - if (length < expectedLength) { - char *resized; - - if ((resized = realloc(*string, length + 1)) != NULL) + if (length > 0 && (size_t)length != bufferLength - 1) { + char *resized = realloc(*string, length + 1); + + /* Ignore if making it smaller failed. */ + if (resized != NULL) *string = resized; } return length; } @@ -291,11 +286,11 @@ break; case 'j': #if defined(OF_WINDOWS) if (!appendSubformat(ctx, "I64", 3)) return false; -#elif defined(_NEWLIB_VERSION) +#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX) if (!appendSubformat(ctx, "ll", 2)) return false; #else if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; @@ -307,11 +302,11 @@ case 'z': #if defined(OF_WINDOWS) if (sizeof(size_t) == 8) if (!appendSubformat(ctx, "I64", 3)) return false; -#elif defined(_NEWLIB_VERSION) +#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX) if (!appendSubformat(ctx, "l", 1)) return false; #else if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; @@ -323,11 +318,11 @@ case 't': #if defined(OF_WINDOWS) if (sizeof(ptrdiff_t) == 8) if (!appendSubformat(ctx, "I64", 3)) return false; -#elif defined(_NEWLIB_VERSION) +#elif defined(_NEWLIB_VERSION) || defined(OF_HPUX) if (!appendSubformat(ctx, "l", 1)) return false; #else if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; Index: src/of_strptime.h ================================================================== --- src/of_strptime.h +++ src/of_strptime.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/of_strptime.m ================================================================== --- src/of_strptime.m +++ src/of_strptime.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/once.h ================================================================== --- src/once.h +++ src/once.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/once.m ================================================================== --- src/once.m +++ src/once.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/pbkdf2.h ================================================================== --- src/pbkdf2.h +++ src/pbkdf2.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/pbkdf2.m ================================================================== --- src/pbkdf2.m +++ src/pbkdf2.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -66,12 +64,13 @@ # define OF_MIPS_EABI #elif defined(__sparc64__) || (defined(__sparc__) && defined(__arch64__)) # define OF_SPARC64 #elif defined(__sparc__) && !defined(__arch64__) # define OF_SPARC -#elif defined(__hppa__) || defined(__HPPA__) || \ - defined(_PA_RISC1_0) || defined(_PA_RISC1_1) +#elif defined(__hppa64__) || defined(_PA_RISC2_0) +# define OF_PA_RISC_2_0 +#elif defined(__hppa__) || defined(_PA_RISC1_0) || defined(_PA_RISC1_1) # define OF_PA_RISC #elif defined(__ia64__) || defined(__IA64__) # define OF_ITANIUM #elif defined(__m68k__) # define OF_M68K @@ -139,10 +138,12 @@ # define OF_AMIGAOS #elif defined(__sun__) # define OF_SOLARIS #elif defined(__QNX__) # define OF_QNX +#elif defined(__hpux__) +# define OF_HPUX #elif defined(_PSP) # define OF_PSP #elif defined(__DJGPP__) # define OF_DJGPP # define OF_MSDOS Index: src/platform/amiga/OFString+PathAdditions.m ================================================================== --- src/platform/amiga/OFString+PathAdditions.m +++ src/platform/amiga/OFString+PathAdditions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -324,12 +322,11 @@ i--; continue; } if ([component isEqual: @".."]) - [components replaceObjectAtIndex: i - withObject: @"/"]; + [components replaceObjectAtIndex: i withObject: @"/"]; } return [OFString pathWithComponents: components]; } Index: src/platform/amiga/condition.m ================================================================== --- src/platform/amiga/condition.m +++ src/platform/amiga/condition.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/amiga/mutex.m ================================================================== --- src/platform/amiga/mutex.m +++ src/platform/amiga/mutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/amiga/thread.m ================================================================== --- src/platform/amiga/thread.m +++ src/platform/amiga/thread.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/amiga/tlskey.m ================================================================== --- src/platform/amiga/tlskey.m +++ src/platform/amiga/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/libfat/OFString+PathAdditions.m ================================================================== --- src/platform/libfat/OFString+PathAdditions.m +++ src/platform/libfat/OFString+PathAdditions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/morphos/tlskey.m ================================================================== --- src/platform/morphos/tlskey.m +++ src/platform/morphos/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in DELETED src/platform/posix/OFProcess.m Index: src/platform/posix/OFProcess.m ================================================================== --- src/platform/posix/OFProcess.m +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#include -#include - -#include - -#ifdef HAVE_SYS_WAIT_H -# include -#endif - -#include "unistd_wrapper.h" -#ifdef HAVE_SPAWN_H -# include -#endif - -#import "OFProcess.h" -#import "OFString.h" -#import "OFArray.h" -#import "OFDictionary.h" -#import "OFLocale.h" - -#import "OFInitializationFailedException.h" -#import "OFNotOpenException.h" -#import "OFOutOfRangeException.h" -#import "OFReadFailedException.h" -#import "OFWriteFailedException.h" - -#ifndef HAVE_POSIX_SPAWNP -extern char **environ; -#endif - -@interface OFProcess () -- (void)of_getArgv: (char ***)argv - forProgramName: (OFString *)programName - andArguments: (OFArray *)arguments; -- (char **)of_environmentForDictionary: (OFDictionary *)dictionary; -@end - -@implementation OFProcess -+ (instancetype)processWithProgram: (OFString *)program -{ - return [[[self alloc] initWithProgram: program] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - arguments: (OFArray *)arguments -{ - return [[[self alloc] initWithProgram: program - arguments: arguments] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments -{ - return [[[self alloc] initWithProgram: program - programName: programName - arguments: arguments] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments - environment: (OFDictionary *)environment -{ - return [[[self alloc] initWithProgram: program - programName: programName - arguments: arguments - environment: environment] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithProgram: (OFString *)program -{ - return [self initWithProgram: program - programName: program - arguments: nil - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - arguments: (OFArray *)arguments -{ - return [self initWithProgram: program - programName: program - arguments: arguments - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments -{ - return [self initWithProgram: program - programName: program - arguments: arguments - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments - environment: (OFDictionary *)environment -{ - self = [super init]; - - @try { - void *pool = objc_autoreleasePoolPush(); - const char *path; - char **argv, **env = NULL; - - _pid = -1; - _readPipe[0] = _writePipe[1] = -1; - - if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - path = [program cStringWithEncoding: [OFLocale encoding]]; - [self of_getArgv: &argv - forProgramName: programName - andArguments: arguments]; - - @try { - env = [self of_environmentForDictionary: environment]; -#ifdef HAVE_POSIX_SPAWNP - posix_spawn_file_actions_t actions; - posix_spawnattr_t attr; - - if (posix_spawn_file_actions_init(&actions) != 0) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - if (posix_spawnattr_init(&attr) != 0) { - posix_spawn_file_actions_destroy(&actions); - - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - } - - @try { - if (posix_spawn_file_actions_addclose(&actions, - _readPipe[0]) != 0 || - posix_spawn_file_actions_addclose(&actions, - _writePipe[1]) != 0 || - posix_spawn_file_actions_adddup2(&actions, - _writePipe[0], 0) != 0 || - posix_spawn_file_actions_adddup2(&actions, - _readPipe[1], 1) != 0) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - -# ifdef POSIX_SPAWN_CLOEXEC_DEFAULT - if (posix_spawnattr_setflags(&attr, - POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; -# endif - - if (posix_spawnp(&_pid, path, &actions, &attr, - argv, env) != 0) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - } @finally { - posix_spawn_file_actions_destroy(&actions); - posix_spawnattr_destroy(&attr); - } -#else - if ((_pid = vfork()) == 0) { - environ = env; - - close(_readPipe[0]); - close(_writePipe[1]); - dup2(_writePipe[0], 0); - dup2(_readPipe[1], 1); - execvp(path, argv); - - _exit(EXIT_FAILURE); - } - - if (_pid == -1) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; -#endif - } @finally { - char **iter; - - close(_readPipe[1]); - close(_writePipe[0]); - free(argv); - - for (iter = env; *iter != NULL; iter++) - free(*iter); - - free(env); - } - - objc_autoreleasePoolPop(pool); - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (void)dealloc -{ - if (_readPipe[0] != -1) - [self close]; - - [super dealloc]; -} - -- (void)of_getArgv: (char ***)argv - forProgramName: (OFString *)programName - andArguments: (OFArray *)arguments -{ - OFString *const *objects = arguments.objects; - size_t i, count = arguments.count; - of_string_encoding_t encoding; - - *argv = of_alloc(count + 2, sizeof(char *)); - - encoding = [OFLocale encoding]; - - (*argv)[0] = (char *)[programName cStringWithEncoding: encoding]; - - for (i = 0; i < count; i++) - (*argv)[i + 1] = - (char *)[objects[i] cStringWithEncoding: encoding]; - - (*argv)[i + 1] = NULL; -} - -- (char **)of_environmentForDictionary: (OFDictionary *)environment -{ - char **envp; - size_t count; - of_string_encoding_t encoding; - - if (environment == nil) - return NULL; - - encoding = [OFLocale encoding]; - - count = environment.count; - envp = of_alloc_zeroed(count + 1, sizeof(char *)); - - @try { - OFEnumerator *keyEnumerator = [environment keyEnumerator]; - OFEnumerator *objectEnumerator = [environment objectEnumerator]; - - for (size_t i = 0; i < count; i++) { - OFString *key; - OFString *object; - size_t keyLen, objectLen; - - key = [keyEnumerator nextObject]; - object = [objectEnumerator nextObject]; - - keyLen = [key cStringLengthWithEncoding: encoding]; - objectLen = [object - cStringLengthWithEncoding: encoding]; - - envp[i] = of_alloc(keyLen + objectLen + 2, 1); - - memcpy(envp[i], - [key cStringWithEncoding: encoding], keyLen); - envp[i][keyLen] = '='; - memcpy(envp[i] + keyLen + 1, - [object cStringWithEncoding: encoding], objectLen); - envp[i][keyLen + objectLen + 1] = '\0'; - } - } @catch (id e) { - for (size_t i = 0; i < count; i++) - free(envp[i]); - - free(envp); - - @throw e; - } - - return envp; -} - -- (bool)lowlevelIsAtEndOfStream -{ - if (_readPipe[0] == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - return _atEndOfStream; -} - -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length -{ - ssize_t ret; - - if (_readPipe[0] == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - if ((ret = read(_readPipe[0], buffer, length)) < 0) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length - errNo: errno]; - - if (ret == 0) - _atEndOfStream = true; - - return ret; -} - -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length -{ - ssize_t bytesWritten; - - if (_writePipe[1] == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (length > SSIZE_MAX) - @throw [OFOutOfRangeException exception]; - - if ((bytesWritten = write(_writePipe[1], buffer, length)) < 0) - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length - bytesWritten: 0 - errNo: errno]; - - return (size_t)bytesWritten; -} - -- (int)fileDescriptorForReading -{ - return _readPipe[0]; -} - -- (int)fileDescriptorForWriting -{ - return _writePipe[1]; -} - -- (void)closeForWriting -{ - if (_writePipe[1] != -1) - close(_writePipe[1]); - - _writePipe[1] = -1; -} - -- (void)close -{ - if (_readPipe[0] == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - [self closeForWriting]; - close(_readPipe[0]); - - if (_pid != -1) { - kill(_pid, SIGTERM); - waitpid(_pid, &_status, WNOHANG); - } - - _pid = -1; - _readPipe[0] = -1; - - [super close]; -} - -- (int)waitForTermination -{ - if (_readPipe[0] == -1) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (_pid != -1) { - waitpid(_pid, &_status, 0); - _pid = -1; - } - - return WEXITSTATUS(_status); -} -@end Index: src/platform/posix/OFString+PathAdditions.m ================================================================== --- src/platform/posix/OFString+PathAdditions.m +++ src/platform/posix/OFString+PathAdditions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -286,12 +284,11 @@ } } } if (startsWithSlash) - [array insertObject: @"" - atIndex: 0]; + [array insertObject: @"" atIndex: 0]; if ([self hasSuffix: @"/"]) [array addObject: @""]; ret = [[array componentsJoinedByString: @"/"] retain]; ADDED src/platform/posix/OFSubprocess.m Index: src/platform/posix/OFSubprocess.m ================================================================== --- /dev/null +++ src/platform/posix/OFSubprocess.m @@ -0,0 +1,403 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#include +#include + +#include + +#ifdef HAVE_SYS_WAIT_H +# include +#endif + +#include "unistd_wrapper.h" +#ifdef HAVE_SPAWN_H +# include +#endif + +#import "OFSubprocess.h" +#import "OFString.h" +#import "OFArray.h" +#import "OFDictionary.h" +#import "OFLocale.h" + +#import "OFInitializationFailedException.h" +#import "OFNotOpenException.h" +#import "OFOutOfRangeException.h" +#import "OFReadFailedException.h" +#import "OFWriteFailedException.h" + +#ifndef HAVE_POSIX_SPAWNP +extern char **environ; +#endif + +@interface OFSubprocess () +- (void)of_getArgv: (char ***)argv + forProgramName: (OFString *)programName + andArguments: (OFArray *)arguments; +- (char **)of_environmentForDictionary: (OFDictionary *)dictionary; +@end + +@implementation OFSubprocess ++ (instancetype)subprocessWithProgram: (OFString *)program +{ + return [[[self alloc] initWithProgram: program] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + arguments: (OFArray *)arguments +{ + return [[[self alloc] initWithProgram: program + arguments: arguments] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments +{ + return [[[self alloc] initWithProgram: program + programName: programName + arguments: arguments] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments + environment: (OFDictionary *)environment +{ + return [[[self alloc] initWithProgram: program + programName: programName + arguments: arguments + environment: environment] autorelease]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithProgram: (OFString *)program +{ + return [self initWithProgram: program + programName: program + arguments: nil + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + arguments: (OFArray *)arguments +{ + return [self initWithProgram: program + programName: program + arguments: arguments + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments +{ + return [self initWithProgram: program + programName: program + arguments: arguments + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments + environment: (OFDictionary *)environment +{ + self = [super init]; + + @try { + void *pool = objc_autoreleasePoolPush(); + const char *path; + char **argv, **env = NULL; + + _pid = -1; + _readPipe[0] = _writePipe[1] = -1; + + if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + path = [program cStringWithEncoding: [OFLocale encoding]]; + [self of_getArgv: &argv + forProgramName: programName + andArguments: arguments]; + + @try { + env = [self of_environmentForDictionary: environment]; +#ifdef HAVE_POSIX_SPAWNP + posix_spawn_file_actions_t actions; + posix_spawnattr_t attr; + + if (posix_spawn_file_actions_init(&actions) != 0) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + if (posix_spawnattr_init(&attr) != 0) { + posix_spawn_file_actions_destroy(&actions); + + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + } + + @try { + if (posix_spawn_file_actions_addclose(&actions, + _readPipe[0]) != 0 || + posix_spawn_file_actions_addclose(&actions, + _writePipe[1]) != 0 || + posix_spawn_file_actions_adddup2(&actions, + _writePipe[0], 0) != 0 || + posix_spawn_file_actions_adddup2(&actions, + _readPipe[1], 1) != 0) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + +# ifdef POSIX_SPAWN_CLOEXEC_DEFAULT + if (posix_spawnattr_setflags(&attr, + POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; +# endif + + if (posix_spawnp(&_pid, path, &actions, &attr, + argv, env) != 0) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + } @finally { + posix_spawn_file_actions_destroy(&actions); + posix_spawnattr_destroy(&attr); + } +#else + if ((_pid = vfork()) == 0) { + environ = env; + + close(_readPipe[0]); + close(_writePipe[1]); + dup2(_writePipe[0], 0); + dup2(_readPipe[1], 1); + execvp(path, argv); + + _exit(EXIT_FAILURE); + } + + if (_pid == -1) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; +#endif + } @finally { + char **iter; + + close(_readPipe[1]); + close(_writePipe[0]); + free(argv); + + for (iter = env; *iter != NULL; iter++) + free(*iter); + + free(env); + } + + objc_autoreleasePoolPop(pool); + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + if (_readPipe[0] != -1) + [self close]; + + [super dealloc]; +} + +- (void)of_getArgv: (char ***)argv + forProgramName: (OFString *)programName + andArguments: (OFArray *)arguments +{ + OFString *const *objects = arguments.objects; + size_t i, count = arguments.count; + of_string_encoding_t encoding; + + *argv = of_alloc(count + 2, sizeof(char *)); + + encoding = [OFLocale encoding]; + + (*argv)[0] = (char *)[programName cStringWithEncoding: encoding]; + + for (i = 0; i < count; i++) + (*argv)[i + 1] = + (char *)[objects[i] cStringWithEncoding: encoding]; + + (*argv)[i + 1] = NULL; +} + +- (char **)of_environmentForDictionary: (OFDictionary *)environment +{ + char **envp; + size_t count; + of_string_encoding_t encoding; + + if (environment == nil) + return NULL; + + encoding = [OFLocale encoding]; + + count = environment.count; + envp = of_alloc_zeroed(count + 1, sizeof(char *)); + + @try { + OFEnumerator *keyEnumerator = [environment keyEnumerator]; + OFEnumerator *objectEnumerator = [environment objectEnumerator]; + + for (size_t i = 0; i < count; i++) { + OFString *key; + OFString *object; + size_t keyLen, objectLen; + + key = [keyEnumerator nextObject]; + object = [objectEnumerator nextObject]; + + keyLen = [key cStringLengthWithEncoding: encoding]; + objectLen = [object + cStringLengthWithEncoding: encoding]; + + envp[i] = of_alloc(keyLen + objectLen + 2, 1); + + memcpy(envp[i], + [key cStringWithEncoding: encoding], keyLen); + envp[i][keyLen] = '='; + memcpy(envp[i] + keyLen + 1, + [object cStringWithEncoding: encoding], objectLen); + envp[i][keyLen + objectLen + 1] = '\0'; + } + } @catch (id e) { + for (size_t i = 0; i < count; i++) + free(envp[i]); + + free(envp); + + @throw e; + } + + return envp; +} + +- (bool)lowlevelIsAtEndOfStream +{ + if (_readPipe[0] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + return _atEndOfStream; +} + +- (size_t)lowlevelReadIntoBuffer: (void *)buffer + length: (size_t)length +{ + ssize_t ret; + + if (_readPipe[0] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + if ((ret = read(_readPipe[0], buffer, length)) < 0) + @throw [OFReadFailedException exceptionWithObject: self + requestedLength: length + errNo: errno]; + + if (ret == 0) + _atEndOfStream = true; + + return ret; +} + +- (size_t)lowlevelWriteBuffer: (const void *)buffer + length: (size_t)length +{ + ssize_t bytesWritten; + + if (_writePipe[1] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (length > SSIZE_MAX) + @throw [OFOutOfRangeException exception]; + + if ((bytesWritten = write(_writePipe[1], buffer, length)) < 0) + @throw [OFWriteFailedException exceptionWithObject: self + requestedLength: length + bytesWritten: 0 + errNo: errno]; + + return (size_t)bytesWritten; +} + +- (int)fileDescriptorForReading +{ + return _readPipe[0]; +} + +- (int)fileDescriptorForWriting +{ + return _writePipe[1]; +} + +- (void)closeForWriting +{ + if (_writePipe[1] != -1) + close(_writePipe[1]); + + _writePipe[1] = -1; +} + +- (void)close +{ + if (_readPipe[0] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + [self closeForWriting]; + close(_readPipe[0]); + + if (_pid != -1) { + kill(_pid, SIGTERM); + waitpid(_pid, &_status, WNOHANG); + } + + _pid = -1; + _readPipe[0] = -1; + + [super close]; +} + +- (int)waitForTermination +{ + if (_readPipe[0] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (_pid != -1) { + waitpid(_pid, &_status, 0); + _pid = -1; + } + + return WEXITSTATUS(_status); +} +@end Index: src/platform/posix/condition.m ================================================================== --- src/platform/posix/condition.m +++ src/platform/posix/condition.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/posix/mutex.m ================================================================== --- src/platform/posix/mutex.m +++ src/platform/posix/mutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/posix/thread.m ================================================================== --- src/platform/posix/thread.m +++ src/platform/posix/thread.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -42,34 +40,34 @@ * This is done here to make sure this is done as early as possible in the main * thread. */ OF_CONSTRUCTOR() { - pthread_attr_t pattr; + pthread_attr_t attr; - if (pthread_attr_init(&pattr) == 0) { + if (pthread_attr_init(&attr) == 0) { #ifdef HAVE_PTHREAD_ATTR_GETSCHEDPOLICY int policy; #endif struct sched_param param; #ifdef HAVE_PTHREAD_ATTR_GETSCHEDPOLICY - if (pthread_attr_getschedpolicy(&pattr, &policy) == 0) { + if (pthread_attr_getschedpolicy(&attr, &policy) == 0) { minPrio = sched_get_priority_min(policy); maxPrio = sched_get_priority_max(policy); if (minPrio == -1 || maxPrio == -1) minPrio = maxPrio = 0; } #endif - if (pthread_attr_getschedparam(&pattr, ¶m) != 0) + if (pthread_attr_getschedparam(&attr, ¶m) != 0) normalPrio = param.sched_priority; else minPrio = maxPrio = 0; - pthread_attr_destroy(&pattr); + pthread_attr_destroy(&attr); } } static void * functionWrapper(void *data) @@ -89,63 +87,82 @@ int of_thread_attr_init(of_thread_attr_t *attr) { int error; - pthread_attr_t pattr; - - if ((error = pthread_attr_init(&pattr)) != 0) - return error; + pthread_attr_t POSIXAttr; attr->priority = 0; - error = pthread_attr_getstacksize(&pattr, &attr->stackSize); + attr->stackSize = 0; + + if ((error = pthread_attr_init(&POSIXAttr)) != 0) { + if (error == ENOSYS) + return 0; + + return error; + } + + error = pthread_attr_getstacksize(&POSIXAttr, &attr->stackSize); - pthread_attr_destroy(&pattr); + pthread_attr_destroy(&POSIXAttr); return error; } int of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), id object, const of_thread_attr_t *attr) { int error = 0; - pthread_attr_t pattr; + pthread_attr_t POSIXAttr; + bool POSIXAttrAvailable = true; - if ((error = pthread_attr_init(&pattr)) != 0) - return error; + if ((error = pthread_attr_init(&POSIXAttr)) != 0) { + if (error == ENOSYS) + POSIXAttrAvailable = false; + else + return error; + } @try { struct thread_ctx *ctx; - if (attr != NULL) { + if (attr != NULL && POSIXAttrAvailable) { +#ifndef OF_HPUX struct sched_param param; +#endif if (attr->priority < -1 || attr->priority > 1) return EINVAL; -#ifdef HAVE_PTHREAD_ATTR_SETINHERITSCHED - if ((error = pthread_attr_setinheritsched(&pattr, +#ifndef OF_HPUX +# ifdef HAVE_PTHREAD_ATTR_SETINHERITSCHED + if ((error = pthread_attr_setinheritsched(&POSIXAttr, PTHREAD_EXPLICIT_SCHED)) != 0) return error; -#endif +# endif + + if ((error = pthread_attr_getschedparam(&POSIXAttr, + ¶m)) != 0) + return error; if (attr->priority < 0) { param.sched_priority = minPrio + (1.0f + attr->priority) * (normalPrio - minPrio); } else param.sched_priority = normalPrio + attr->priority * (maxPrio - normalPrio); - if ((error = pthread_attr_setschedparam(&pattr, + if ((error = pthread_attr_setschedparam(&POSIXAttr, ¶m)) != 0) return error; +#endif if (attr->stackSize > 0) { - if ((error = pthread_attr_setstacksize(&pattr, - attr->stackSize)) != 0) + if ((error = pthread_attr_setstacksize( + &POSIXAttr, attr->stackSize)) != 0) return error; } } if ((ctx = malloc(sizeof(*ctx))) == NULL) @@ -153,13 +170,16 @@ ctx->function = function; ctx->object = object; ctx->name = name; - error = pthread_create(thread, &pattr, functionWrapper, ctx); + error = pthread_create(thread, + (POSIXAttrAvailable ? &POSIXAttr : NULL), functionWrapper, + ctx); } @finally { - pthread_attr_destroy(&pattr); + if (POSIXAttrAvailable) + pthread_attr_destroy(&POSIXAttr); } return error; } Index: src/platform/posix/tlskey.m ================================================================== --- src/platform/posix/tlskey.m +++ src/platform/posix/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in DELETED src/platform/windows/OFProcess.m Index: src/platform/windows/OFProcess.m ================================================================== --- src/platform/windows/OFProcess.m +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#include -#include - -#import "OFProcess.h" -#import "OFArray.h" -#import "OFData.h" -#import "OFDictionary.h" -#import "OFLocale.h" -#import "OFString.h" -#import "OFSystemInfo.h" - -#import "OFInitializationFailedException.h" -#import "OFNotOpenException.h" -#import "OFOutOfRangeException.h" -#import "OFReadFailedException.h" -#import "OFWriteFailedException.h" - -#include - -@interface OFProcess () -- (of_char16_t *)of_wideEnvironmentForDictionary: (OFDictionary *)dictionary; -- (char *)of_environmentForDictionary: (OFDictionary *)environment; -@end - -@implementation OFProcess -+ (instancetype)processWithProgram: (OFString *)program -{ - return [[[self alloc] initWithProgram: program] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - arguments: (OFArray *)arguments -{ - return [[[self alloc] initWithProgram: program - arguments: arguments] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments -{ - return [[[self alloc] initWithProgram: program - programName: programName - arguments: arguments] autorelease]; -} - -+ (instancetype)processWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments - environment: (OFDictionary *)environment -{ - return [[[self alloc] initWithProgram: program - programName: programName - arguments: arguments - environment: environment] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithProgram: (OFString *)program -{ - return [self initWithProgram: program - programName: program - arguments: nil - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - arguments: (OFArray *)arguments -{ - return [self initWithProgram: program - programName: program - arguments: arguments - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments -{ - return [self initWithProgram: program - programName: program - arguments: arguments - environment: nil]; -} - -- (instancetype)initWithProgram: (OFString *)program - programName: (OFString *)programName - arguments: (OFArray *)arguments - environment: (OFDictionary *)environment -{ - self = [super init]; - - @try { - SECURITY_ATTRIBUTES sa; - PROCESS_INFORMATION pi; - void *pool; - OFMutableString *argumentsString; - - _process = INVALID_HANDLE_VALUE; - _readPipe[0] = _writePipe[1] = NULL; - - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - - if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0)) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - if (!SetHandleInformation(_readPipe[0], HANDLE_FLAG_INHERIT, 0)) - if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - if (!CreatePipe(&_writePipe[0], &_writePipe[1], &sa, 0)) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - if (!SetHandleInformation(_writePipe[1], - HANDLE_FLAG_INHERIT, 0)) - if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - - memset(&pi, 0, sizeof(pi)); - - pool = objc_autoreleasePoolPush(); - - argumentsString = - [OFMutableString stringWithString: programName]; - [argumentsString replaceOccurrencesOfString: @"\\\"" - withString: @"\\\\\""]; - [argumentsString replaceOccurrencesOfString: @"\"" - withString: @"\\\""]; - - if ([argumentsString containsString: @" "]) { - [argumentsString prependString: @"\""]; - [argumentsString appendString: @"\""]; - } - - for (OFString *argument in arguments) { - OFMutableString *tmp = - [[argument mutableCopy] autorelease]; - bool containsSpaces = [tmp containsString: @" "]; - - [argumentsString appendString: @" "]; - - if (containsSpaces) - [argumentsString appendString: @"\""]; - - [tmp replaceOccurrencesOfString: @"\\\"" - withString: @"\\\\\""]; - [tmp replaceOccurrencesOfString: @"\"" - withString: @"\\\""]; - - [argumentsString appendString: tmp]; - - if (containsSpaces) - [argumentsString appendString: @"\""]; - } - - if ([OFSystemInfo isWindowsNT]) { - size_t length; - of_char16_t *argumentsCopy; - STARTUPINFOW si; - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - si.hStdInput = _writePipe[0]; - si.hStdOutput = _readPipe[1]; - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - si.dwFlags |= STARTF_USESTDHANDLES; - - length = argumentsString.UTF16StringLength; - argumentsCopy = of_alloc(length + 1, - sizeof(of_char16_t)); - memcpy(argumentsCopy, argumentsString.UTF16String, - (length + 1) * 2); - @try { - if (!CreateProcessW(program.UTF16String, - argumentsCopy, NULL, NULL, TRUE, - CREATE_UNICODE_ENVIRONMENT, - [self of_wideEnvironmentForDictionary: - environment], NULL, &si, &pi)) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - } @finally { - free(argumentsCopy); - } - } else { - of_string_encoding_t encoding = [OFLocale encoding]; - STARTUPINFO si; - - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - si.hStdInput = _writePipe[0]; - si.hStdOutput = _readPipe[1]; - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - si.dwFlags |= STARTF_USESTDHANDLES; - - if (!CreateProcessA([program cStringWithEncoding: - encoding], (char *)[argumentsString - cStringWithEncoding: encoding], NULL, NULL, TRUE, 0, - [self of_environmentForDictionary: environment], - NULL, &si, &pi)) - @throw [OFInitializationFailedException - exceptionWithClass: self.class]; - } - - objc_autoreleasePoolPop(pool); - - _process = pi.hProcess; - CloseHandle(pi.hThread); - - CloseHandle(_readPipe[1]); - CloseHandle(_writePipe[0]); - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (void)dealloc -{ - if (_readPipe[0] != NULL) - [self close]; - - [super dealloc]; -} - -- (of_char16_t *)of_wideEnvironmentForDictionary: (OFDictionary *)environment -{ - OFMutableData *env; - OFEnumerator *keyEnumerator, *objectEnumerator; - OFString *key, *object; - const of_char16_t equal = '='; - const of_char16_t zero[2] = { 0, 0 }; - - if (environment == nil) - return NULL; - - env = [OFMutableData dataWithItemSize: sizeof(of_char16_t)]; - - keyEnumerator = [environment keyEnumerator]; - objectEnumerator = [environment objectEnumerator]; - while ((key = [keyEnumerator nextObject]) != nil && - (object = [objectEnumerator nextObject]) != nil) { - [env addItems: key.UTF16String - count: key.UTF16StringLength]; - [env addItems: &equal - count: 1]; - [env addItems: object.UTF16String - count: object.UTF16StringLength]; - [env addItems: &zero - count: 1]; - } - [env addItems: zero - count: 2]; - - return env.mutableItems; -} - -- (char *)of_environmentForDictionary: (OFDictionary *)environment -{ - of_string_encoding_t encoding = [OFLocale encoding]; - OFMutableData *env; - OFEnumerator *keyEnumerator, *objectEnumerator; - OFString *key, *object; - - if (environment == nil) - return NULL; - - env = [OFMutableData data]; - - keyEnumerator = [environment keyEnumerator]; - objectEnumerator = [environment objectEnumerator]; - while ((key = [keyEnumerator nextObject]) != nil && - (object = [objectEnumerator nextObject]) != nil) { - [env addItems: [key cStringWithEncoding: encoding] - count: [key cStringLengthWithEncoding: encoding]]; - [env addItems: "=" - count: 1]; - [env addItems: [object cStringWithEncoding: encoding] - count: [object cStringLengthWithEncoding: encoding]]; - [env addItems: "" - count: 1]; - } - [env addItems: "\0" - count: 2]; - - return env.mutableItems; -} - -- (bool)lowlevelIsAtEndOfStream -{ - if (_readPipe[0] == NULL) - @throw [OFNotOpenException exceptionWithObject: self]; - - return _atEndOfStream; -} - -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length -{ - DWORD ret; - - if (length > UINT32_MAX) - @throw [OFOutOfRangeException exception]; - - if (_readPipe[0] == NULL) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (!ReadFile(_readPipe[0], buffer, (DWORD)length, &ret, NULL)) { - if (GetLastError() == ERROR_BROKEN_PIPE) { - _atEndOfStream = true; - return 0; - } - - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length - errNo: EIO]; - } - - if (ret == 0) - _atEndOfStream = true; - - return ret; -} - -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length -{ - DWORD bytesWritten; - - if (length > UINT32_MAX) - @throw [OFOutOfRangeException exception]; - - if (_writePipe[1] == NULL) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (!WriteFile(_writePipe[1], buffer, (DWORD)length, &bytesWritten, - NULL)) { - int errNo = EIO; - - if (GetLastError() == ERROR_BROKEN_PIPE) - errNo = EPIPE; - - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length - bytesWritten: 0 - errNo: errNo]; - } - - return (size_t)bytesWritten; -} - -- (void)closeForWriting -{ - if (_writePipe[1] != NULL) - CloseHandle(_writePipe[1]); - - _writePipe[1] = NULL; -} - -- (void)close -{ - if (_readPipe[0] == NULL) - @throw [OFNotOpenException exceptionWithObject: self]; - - [self closeForWriting]; - CloseHandle(_readPipe[0]); - - if (_process != INVALID_HANDLE_VALUE) { - TerminateProcess(_process, 0); - CloseHandle(_process); - } - - _process = INVALID_HANDLE_VALUE; - _readPipe[0] = NULL; - - [super close]; -} - -- (int)waitForTermination -{ - if (_readPipe[0] == NULL) - @throw [OFNotOpenException exceptionWithObject: self]; - - if (_process != INVALID_HANDLE_VALUE) { - DWORD exitCode; - - WaitForSingleObject(_process, INFINITE); - - if (GetExitCodeProcess(_process, &exitCode)) - _status = exitCode; - else - _status = GetLastError(); - - CloseHandle(_process); - _process = INVALID_HANDLE_VALUE; - } - - return _status; -} -@end Index: src/platform/windows/OFString+PathAdditions.m ================================================================== --- src/platform/windows/OFString+PathAdditions.m +++ src/platform/windows/OFString+PathAdditions.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in ADDED src/platform/windows/OFSubprocess.m Index: src/platform/windows/OFSubprocess.m ================================================================== --- /dev/null +++ src/platform/windows/OFSubprocess.m @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#include +#include + +#import "OFSubprocess.h" +#import "OFArray.h" +#import "OFData.h" +#import "OFDictionary.h" +#import "OFLocale.h" +#import "OFString.h" +#import "OFSystemInfo.h" + +#import "OFInitializationFailedException.h" +#import "OFNotOpenException.h" +#import "OFOutOfRangeException.h" +#import "OFReadFailedException.h" +#import "OFWriteFailedException.h" + +#include + +@interface OFSubprocess () +- (of_char16_t *)of_wideEnvironmentForDictionary: (OFDictionary *)dictionary; +- (char *)of_environmentForDictionary: (OFDictionary *)environment; +@end + +@implementation OFSubprocess ++ (instancetype)subprocessWithProgram: (OFString *)program +{ + return [[[self alloc] initWithProgram: program] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + arguments: (OFArray *)arguments +{ + return [[[self alloc] initWithProgram: program + arguments: arguments] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments +{ + return [[[self alloc] initWithProgram: program + programName: programName + arguments: arguments] autorelease]; +} + ++ (instancetype)subprocessWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments + environment: (OFDictionary *)environment +{ + return [[[self alloc] initWithProgram: program + programName: programName + arguments: arguments + environment: environment] autorelease]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithProgram: (OFString *)program +{ + return [self initWithProgram: program + programName: program + arguments: nil + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + arguments: (OFArray *)arguments +{ + return [self initWithProgram: program + programName: program + arguments: arguments + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments +{ + return [self initWithProgram: program + programName: program + arguments: arguments + environment: nil]; +} + +- (instancetype)initWithProgram: (OFString *)program + programName: (OFString *)programName + arguments: (OFArray *)arguments + environment: (OFDictionary *)environment +{ + self = [super init]; + + @try { + SECURITY_ATTRIBUTES sa; + PROCESS_INFORMATION pi; + void *pool; + OFMutableString *argumentsString; + + _handle = INVALID_HANDLE_VALUE; + _readPipe[0] = _writePipe[1] = NULL; + + sa.nLength = sizeof(sa); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + + if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0)) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + if (!SetHandleInformation(_readPipe[0], HANDLE_FLAG_INHERIT, 0)) + if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + if (!CreatePipe(&_writePipe[0], &_writePipe[1], &sa, 0)) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + if (!SetHandleInformation(_writePipe[1], + HANDLE_FLAG_INHERIT, 0)) + if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + + memset(&pi, 0, sizeof(pi)); + + pool = objc_autoreleasePoolPush(); + + argumentsString = + [OFMutableString stringWithString: programName]; + [argumentsString replaceOccurrencesOfString: @"\\\"" + withString: @"\\\\\""]; + [argumentsString replaceOccurrencesOfString: @"\"" + withString: @"\\\""]; + + if ([argumentsString containsString: @" "]) { + [argumentsString prependString: @"\""]; + [argumentsString appendString: @"\""]; + } + + for (OFString *argument in arguments) { + OFMutableString *tmp = + [[argument mutableCopy] autorelease]; + bool containsSpaces = [tmp containsString: @" "]; + + [argumentsString appendString: @" "]; + + if (containsSpaces) + [argumentsString appendString: @"\""]; + + [tmp replaceOccurrencesOfString: @"\\\"" + withString: @"\\\\\""]; + [tmp replaceOccurrencesOfString: @"\"" + withString: @"\\\""]; + + [argumentsString appendString: tmp]; + + if (containsSpaces) + [argumentsString appendString: @"\""]; + } + + if ([OFSystemInfo isWindowsNT]) { + size_t length; + of_char16_t *argumentsCopy; + STARTUPINFOW si; + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + si.hStdInput = _writePipe[0]; + si.hStdOutput = _readPipe[1]; + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + si.dwFlags |= STARTF_USESTDHANDLES; + + length = argumentsString.UTF16StringLength; + argumentsCopy = of_alloc(length + 1, + sizeof(of_char16_t)); + memcpy(argumentsCopy, argumentsString.UTF16String, + (length + 1) * 2); + @try { + if (!CreateProcessW(program.UTF16String, + argumentsCopy, NULL, NULL, TRUE, + CREATE_UNICODE_ENVIRONMENT, + [self of_wideEnvironmentForDictionary: + environment], NULL, &si, &pi)) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + } @finally { + free(argumentsCopy); + } + } else { + of_string_encoding_t encoding = [OFLocale encoding]; + STARTUPINFO si; + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + si.hStdInput = _writePipe[0]; + si.hStdOutput = _readPipe[1]; + si.hStdError = GetStdHandle(STD_ERROR_HANDLE); + si.dwFlags |= STARTF_USESTDHANDLES; + + if (!CreateProcessA([program cStringWithEncoding: + encoding], (char *)[argumentsString + cStringWithEncoding: encoding], NULL, NULL, TRUE, 0, + [self of_environmentForDictionary: environment], + NULL, &si, &pi)) + @throw [OFInitializationFailedException + exceptionWithClass: self.class]; + } + + objc_autoreleasePoolPop(pool); + + _handle = pi.hProcess; + CloseHandle(pi.hThread); + + CloseHandle(_readPipe[1]); + CloseHandle(_writePipe[0]); + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + if (_readPipe[0] != NULL) + [self close]; + + [super dealloc]; +} + +- (of_char16_t *)of_wideEnvironmentForDictionary: (OFDictionary *)environment +{ + OFMutableData *env; + OFEnumerator *keyEnumerator, *objectEnumerator; + OFString *key, *object; + const of_char16_t equal = '='; + const of_char16_t zero[2] = { 0, 0 }; + + if (environment == nil) + return NULL; + + env = [OFMutableData dataWithItemSize: sizeof(of_char16_t)]; + + keyEnumerator = [environment keyEnumerator]; + objectEnumerator = [environment objectEnumerator]; + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) { + [env addItems: key.UTF16String count: key.UTF16StringLength]; + [env addItems: &equal count: 1]; + [env addItems: object.UTF16String + count: object.UTF16StringLength]; + [env addItems: &zero count: 1]; + } + [env addItems: zero count: 2]; + + return env.mutableItems; +} + +- (char *)of_environmentForDictionary: (OFDictionary *)environment +{ + of_string_encoding_t encoding = [OFLocale encoding]; + OFMutableData *env; + OFEnumerator *keyEnumerator, *objectEnumerator; + OFString *key, *object; + + if (environment == nil) + return NULL; + + env = [OFMutableData data]; + + keyEnumerator = [environment keyEnumerator]; + objectEnumerator = [environment objectEnumerator]; + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) { + [env addItems: [key cStringWithEncoding: encoding] + count: [key cStringLengthWithEncoding: encoding]]; + [env addItems: "=" count: 1]; + [env addItems: [object cStringWithEncoding: encoding] + count: [object cStringLengthWithEncoding: encoding]]; + [env addItems: "" count: 1]; + } + [env addItems: "\0" count: 2]; + + return env.mutableItems; +} + +- (bool)lowlevelIsAtEndOfStream +{ + if (_readPipe[0] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + + return _atEndOfStream; +} + +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length +{ + DWORD ret; + + if (length > UINT32_MAX) + @throw [OFOutOfRangeException exception]; + + if (_readPipe[0] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (!ReadFile(_readPipe[0], buffer, (DWORD)length, &ret, NULL)) { + if (GetLastError() == ERROR_BROKEN_PIPE) { + _atEndOfStream = true; + return 0; + } + + @throw [OFReadFailedException exceptionWithObject: self + requestedLength: length + errNo: EIO]; + } + + if (ret == 0) + _atEndOfStream = true; + + return ret; +} + +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length +{ + DWORD bytesWritten; + + if (length > UINT32_MAX) + @throw [OFOutOfRangeException exception]; + + if (_writePipe[1] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (!WriteFile(_writePipe[1], buffer, (DWORD)length, &bytesWritten, + NULL)) { + int errNo = EIO; + + if (GetLastError() == ERROR_BROKEN_PIPE) + errNo = EPIPE; + + @throw [OFWriteFailedException exceptionWithObject: self + requestedLength: length + bytesWritten: 0 + errNo: errNo]; + } + + return (size_t)bytesWritten; +} + +- (void)closeForWriting +{ + if (_writePipe[1] != NULL) + CloseHandle(_writePipe[1]); + + _writePipe[1] = NULL; +} + +- (void)close +{ + if (_readPipe[0] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + + [self closeForWriting]; + CloseHandle(_readPipe[0]); + + if (_handle != INVALID_HANDLE_VALUE) { + TerminateProcess(_handle, 0); + CloseHandle(_handle); + } + + _handle = INVALID_HANDLE_VALUE; + _readPipe[0] = NULL; + + [super close]; +} + +- (int)waitForTermination +{ + if (_readPipe[0] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; + + if (_handle != INVALID_HANDLE_VALUE) { + DWORD exitCode; + + WaitForSingleObject(_handle, INFINITE); + + if (GetExitCodeProcess(_handle, &exitCode)) + _status = exitCode; + else + _status = GetLastError(); + + CloseHandle(_handle); + _handle = INVALID_HANDLE_VALUE; + } + + return _status; +} +@end Index: src/platform/windows/condition.m ================================================================== --- src/platform/windows/condition.m +++ src/platform/windows/condition.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/windows/mutex.m ================================================================== --- src/platform/windows/mutex.m +++ src/platform/windows/mutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/windows/thread.m ================================================================== --- src/platform/windows/thread.m +++ src/platform/windows/thread.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/platform/windows/tlskey.m ================================================================== --- src/platform/windows/tlskey.m +++ src/platform/windows/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/Makefile ================================================================== --- src/runtime/Makefile +++ src/runtime/Makefile @@ -1,10 +1,9 @@ include ../../extra.mk SUBDIRS = lookup-asm SUBDIRS_AFTER = ${LINKLIB} -CLEAN = amiga-library-functable.inc inline.h DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWRT_SHARED_LIB} STATIC_LIB = ${OBJFWRT_STATIC_LIB} FRAMEWORK = ${OBJFWRT_FRAMEWORK} @@ -47,21 +46,13 @@ lookup-asm/lookup-asm.amigalib.a \ amiga-end.amigalib.o include ../../buildsys.mk -${OBJFWRT_AMIGA_LIB}: inline.h - -${SFDC_INLINE_H}: ${SFD_FILE} - sfdc -q --target=${SFDC_TARGET} --mode=macros -o $@ $<; \ - -${CVINCLUDE_INLINE_H}: morphos.fd morphos-clib.h - cvinclude.pl --quiet --fd=morphos.fd --clib=morphos-clib.h --inlines=$@ - CPPFLAGS += -I. -I.. -I../.. \ -DOBJC_COMPILING_RUNTIME \ -DOBJFWRT_AMIGA_LIB=\"${OBJFWRT_AMIGA_LIB}\" \ -DOBJFWRT_LIB_MAJOR=${OBJFWRT_LIB_MAJOR} \ -DOBJFWRT_LIB_MINOR=${OBJFWRT_LIB_MINOR} AMIGA_LIB_CFLAGS += -DOBJC_COMPILING_AMIGA_LIBRARY LD = ${OBJC} FRAMEWORK_LIBS = ${LIBS} Index: src/runtime/ObjFWRT.h ================================================================== --- src/runtime/ObjFWRT.h +++ src/runtime/ObjFWRT.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/amiga-end.m ================================================================== --- src/runtime/amiga-end.m +++ src/runtime/amiga-end.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in ADDED src/runtime/amiga-funcarray.inc Index: src/runtime/amiga-funcarray.inc ================================================================== --- /dev/null +++ src/runtime/amiga-funcarray.inc @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +/* This file is automatically generated from library.xml */ + +(CONST_APTR)glue_objc_init, +(CONST_APTR)glue___objc_exec_class, +(CONST_APTR)glue_objc_msg_lookup, +(CONST_APTR)glue_objc_msg_lookup_stret, +(CONST_APTR)glue_objc_msg_lookup_super, +(CONST_APTR)glue_objc_msg_lookup_super_stret, +(CONST_APTR)glue_objc_lookUpClass, +(CONST_APTR)glue_objc_getClass, +(CONST_APTR)glue_objc_getRequiredClass, +(CONST_APTR)glue_objc_lookup_class, +(CONST_APTR)glue_objc_get_class, +(CONST_APTR)glue_objc_exception_throw, +(CONST_APTR)glue_objc_sync_enter, +(CONST_APTR)glue_objc_sync_exit, +(CONST_APTR)glue_objc_getProperty, +(CONST_APTR)glue_objc_setProperty, +(CONST_APTR)glue_objc_getPropertyStruct, +(CONST_APTR)glue_objc_setPropertyStruct, +(CONST_APTR)glue_objc_enumerationMutation, +(CONST_APTR)glue___gnu_objc_personality, +(CONST_APTR)glue_objc_retain, +(CONST_APTR)glue_objc_retainBlock, +(CONST_APTR)glue_objc_retainAutorelease, +(CONST_APTR)glue_objc_release, +(CONST_APTR)glue_objc_autorelease, +(CONST_APTR)glue_objc_autoreleaseReturnValue, +(CONST_APTR)glue_objc_retainAutoreleaseReturnValue, +(CONST_APTR)glue_objc_retainAutoreleasedReturnValue, +(CONST_APTR)glue_objc_storeStrong, +(CONST_APTR)glue_objc_storeWeak, +(CONST_APTR)glue_objc_loadWeakRetained, +(CONST_APTR)glue_objc_initWeak, +(CONST_APTR)glue_objc_destroyWeak, +(CONST_APTR)glue_objc_loadWeak, +(CONST_APTR)glue_objc_copyWeak, +(CONST_APTR)glue_objc_moveWeak, +(CONST_APTR)glue_sel_registerName, +(CONST_APTR)glue_sel_getName, +(CONST_APTR)glue_sel_isEqual, +(CONST_APTR)glue_objc_allocateClassPair, +(CONST_APTR)glue_objc_registerClassPair, +(CONST_APTR)glue_objc_getClassList, +(CONST_APTR)glue_objc_copyClassList, +(CONST_APTR)glue_class_isMetaClass, +(CONST_APTR)glue_class_getName, +(CONST_APTR)glue_class_getSuperclass, +(CONST_APTR)glue_class_getInstanceSize, +(CONST_APTR)glue_class_respondsToSelector, +(CONST_APTR)glue_class_conformsToProtocol, +(CONST_APTR)glue_class_getMethodImplementation, +(CONST_APTR)glue_class_getMethodImplementation_stret, +(CONST_APTR)glue_class_getInstanceMethod, +(CONST_APTR)glue_class_addMethod, +(CONST_APTR)glue_class_replaceMethod, +(CONST_APTR)glue_object_getClass, +(CONST_APTR)glue_object_setClass, +(CONST_APTR)glue_object_getClassName, +(CONST_APTR)glue_protocol_getName, +(CONST_APTR)glue_protocol_isEqual, +(CONST_APTR)glue_protocol_conformsToProtocol, +(CONST_APTR)glue_objc_setUncaughtExceptionHandler, +(CONST_APTR)glue_objc_setForwardHandler, +(CONST_APTR)glue_objc_setEnumerationMutationHandler, +(CONST_APTR)glue_objc_constructInstance, +(CONST_APTR)glue_objc_exit, +(CONST_APTR)glue_class_copyIvarList, +(CONST_APTR)glue_ivar_getName, +(CONST_APTR)glue_ivar_getTypeEncoding, +(CONST_APTR)glue_ivar_getOffset, +(CONST_APTR)glue_class_copyMethodList, +(CONST_APTR)glue_method_getName, +(CONST_APTR)glue_method_getTypeEncoding, +(CONST_APTR)glue_class_copyPropertyList, +(CONST_APTR)glue_property_getName, +(CONST_APTR)glue_property_copyAttributeValue, +(CONST_APTR)glue_objc_destructInstance, +(CONST_APTR)glue_objc_autoreleasePoolPush, +(CONST_APTR)glue_objc_autoreleasePoolPop, +(CONST_APTR)glue__objc_rootAutorelease, +(CONST_APTR)glue_objc_hashtable_new, +(CONST_APTR)glue_objc_hashtable_set, +(CONST_APTR)glue_objc_hashtable_get, +(CONST_APTR)glue_objc_hashtable_delete, +(CONST_APTR)glue_objc_hashtable_free, +(CONST_APTR)glue_objc_setTaggedPointerSecret, +(CONST_APTR)glue_objc_registerTaggedPointerClass, +(CONST_APTR)glue_object_isTaggedPointer, +(CONST_APTR)glue_object_getTaggedPointerValue, +(CONST_APTR)glue_objc_createTaggedPointer, ADDED src/runtime/amiga-glue.h Index: src/runtime/amiga-glue.h ================================================================== --- /dev/null +++ src/runtime/amiga-glue.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +/* This file is automatically generated from library.xml */ + +#import "ObjFWRT.h" +#import "private.h" + +#ifdef OF_AMIGAOS_M68K +# define PPC_PARAMS(...) (void) +# define M68K_ARG(type, name, reg) \ + register type reg##name __asm__(#reg); \ + type name = reg##name; +#else +# define PPC_PARAMS(...) (__VA_ARGS__) +# define M68K_ARG(...) +#endif + +extern bool glue_objc_init PPC_PARAMS(unsigned int version, struct objc_libc *libc); +extern void glue___objc_exec_class PPC_PARAMS(struct objc_module *_Nonnull module); +extern IMP _Nonnull glue_objc_msg_lookup PPC_PARAMS(id _Nullable object, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_stret PPC_PARAMS(id _Nullable object, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_super PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_super_stret PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector); +extern Class _Nullable glue_objc_lookUpClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nullable glue_objc_getClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nonnull glue_objc_getRequiredClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nullable glue_objc_lookup_class PPC_PARAMS(const char *_Nonnull name); +extern Class _Nonnull glue_objc_get_class PPC_PARAMS(const char *_Nonnull name); +extern void glue_objc_exception_throw PPC_PARAMS(id _Nonnull object); +extern int glue_objc_sync_enter PPC_PARAMS(id _Nullable object); +extern int glue_objc_sync_exit PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_getProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic); +extern void glue_objc_setProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy); +extern void glue_objc_getPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong); +extern void glue_objc_setPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong); +extern void glue_objc_enumerationMutation PPC_PARAMS(id _Nonnull object); +extern int glue___gnu_objc_personality PPC_PARAMS(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx); +extern id _Nullable glue_objc_retain PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainBlock PPC_PARAMS(id _Nullable block); +extern id _Nullable glue_objc_retainAutorelease PPC_PARAMS(id _Nullable object); +extern void glue_objc_release PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_autorelease PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_autoreleaseReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainAutoreleaseReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainAutoreleasedReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_storeStrong PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern id _Nullable glue_objc_storeWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern id _Nullable glue_objc_loadWeakRetained PPC_PARAMS(id _Nullable *_Nonnull object); +extern id _Nullable glue_objc_initWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern void glue_objc_destroyWeak PPC_PARAMS(id _Nullable *_Nonnull object); +extern id _Nullable glue_objc_loadWeak PPC_PARAMS(id _Nullable *_Nonnull object); +extern void glue_objc_copyWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src); +extern void glue_objc_moveWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src); +extern SEL _Nonnull glue_sel_registerName PPC_PARAMS(const char *_Nonnull name); +extern const char *_Nonnull glue_sel_getName PPC_PARAMS(SEL _Nonnull selector); +extern bool glue_sel_isEqual PPC_PARAMS(SEL _Nonnull selector1, SEL _Nonnull selector2); +extern Class _Nonnull glue_objc_allocateClassPair PPC_PARAMS(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes); +extern void glue_objc_registerClassPair PPC_PARAMS(Class _Nonnull class); +extern unsigned int glue_objc_getClassList PPC_PARAMS(Class _Nonnull *_Nullable buffer, unsigned int count); +extern Class _Nonnull *_Nonnull glue_objc_copyClassList PPC_PARAMS(unsigned int *_Nullable length); +extern bool glue_class_isMetaClass PPC_PARAMS(Class _Nullable class); +extern const char *_Nullable glue_class_getName PPC_PARAMS(Class _Nullable class); +extern Class _Nullable glue_class_getSuperclass PPC_PARAMS(Class _Nullable class); +extern unsigned long glue_class_getInstanceSize PPC_PARAMS(Class _Nullable class); +extern bool glue_class_respondsToSelector PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern bool glue_class_conformsToProtocol PPC_PARAMS(Class _Nullable class, Protocol *_Nonnull p); +extern IMP _Nullable glue_class_getMethodImplementation PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern IMP _Nullable glue_class_getMethodImplementation_stret PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern Method _Nullable glue_class_getInstanceMethod PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern bool glue_class_addMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); +extern IMP _Nullable glue_class_replaceMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); +extern Class _Nullable glue_object_getClass PPC_PARAMS(id _Nullable object); +extern Class _Nullable glue_object_setClass PPC_PARAMS(id _Nullable object, Class _Nonnull class); +extern const char *_Nullable glue_object_getClassName PPC_PARAMS(id _Nullable object); +extern const char *_Nonnull glue_protocol_getName PPC_PARAMS(Protocol *_Nonnull protocol); +extern bool glue_protocol_isEqual PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); +extern bool glue_protocol_conformsToProtocol PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); +extern _Nullable objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler PPC_PARAMS(objc_uncaught_exception_handler_t _Nullable handler); +extern void glue_objc_setForwardHandler PPC_PARAMS(IMP _Nullable forward, IMP _Nullable stretForward); +extern void glue_objc_setEnumerationMutationHandler PPC_PARAMS(objc_enumeration_mutation_handler_t _Nullable hadler); +extern id _Nullable glue_objc_constructInstance PPC_PARAMS(Class _Nullable class, void *_Nullable bytes); +extern void glue_objc_exit(void); +extern Ivar _Nullable *_Nullable glue_class_copyIvarList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern const char *_Nonnull glue_ivar_getName PPC_PARAMS(Ivar _Nonnull ivar); +extern const char *_Nonnull glue_ivar_getTypeEncoding PPC_PARAMS(Ivar _Nonnull ivar); +extern ptrdiff_t glue_ivar_getOffset PPC_PARAMS(Ivar _Nonnull ivar); +extern Method _Nullable *_Nullable glue_class_copyMethodList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern SEL _Nonnull glue_method_getName PPC_PARAMS(Method _Nonnull method); +extern const char *_Nullable glue_method_getTypeEncoding PPC_PARAMS(Method _Nonnull method); +extern objc_property_t _Nullable *_Nullable glue_class_copyPropertyList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern const char *_Nonnull glue_property_getName PPC_PARAMS(objc_property_t _Nonnull property); +extern char *_Nullable glue_property_copyAttributeValue PPC_PARAMS(objc_property_t _Nonnull property, const char *_Nonnull name); +extern void *_Nullable glue_objc_destructInstance PPC_PARAMS(id _Nullable object); +extern void *_Null_unspecified glue_objc_autoreleasePoolPush(void); +extern void glue_objc_autoreleasePoolPop PPC_PARAMS(void *_Null_unspecified pool); +extern id _Nullable glue__objc_rootAutorelease PPC_PARAMS(id _Nullable object); +extern struct objc_hashtable *_Nonnull glue_objc_hashtable_new PPC_PARAMS(objc_hashtable_hash_func hash, objc_hashtable_equal_func equal, uint32_t size); +extern void glue_objc_hashtable_set PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key, const void *_Nonnull object); +extern void *_Nullable glue_objc_hashtable_get PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key); +extern void glue_objc_hashtable_delete PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key); +extern void glue_objc_hashtable_free PPC_PARAMS(struct objc_hashtable *_Nonnull table); +extern void glue_objc_setTaggedPointerSecret PPC_PARAMS(uintptr_t secret); +extern int glue_objc_registerTaggedPointerClass PPC_PARAMS(Class _Nonnull class); +extern bool glue_object_isTaggedPointer PPC_PARAMS(id _Nullable object); +extern uintptr_t glue_object_getTaggedPointerValue PPC_PARAMS(id _Nonnull object); +extern id _Nullable glue_objc_createTaggedPointer PPC_PARAMS(int class, uintptr_t value); Index: src/runtime/amiga-glue.m ================================================================== --- src/runtime/amiga-glue.m +++ src/runtime/amiga-glue.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -13,25 +11,15 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +/* This file is automatically generated from library.xml */ + #include "config.h" -#import "ObjFWRT.h" -#import "private.h" -#import "macros.h" - -#ifdef OF_AMIGAOS_M68K -# define PPC_PARAMS(...) (void) -# define M68K_ARG OBJC_M68K_ARG -#else -# define PPC_PARAMS(...) (__VA_ARGS__) -# define M68K_ARG(...) -#endif - -extern bool objc_init(unsigned int, struct objc_libc *); +#import "amiga-glue.h" #ifdef OF_MORPHOS /* All __saveds functions in this file need to use the SysV ABI */ __asm__ ( ".section .text\n" @@ -50,580 +38,558 @@ return objc_init(version, libc); } void __saveds -glue___objc_exec_class PPC_PARAMS(struct objc_module *module) +glue___objc_exec_class PPC_PARAMS(struct objc_module *_Nonnull module) { - M68K_ARG(struct objc_module *, module, a0) + M68K_ARG(struct objc_module *_Nonnull, module, a0) __objc_exec_class(module); } -IMP __saveds -glue_objc_msg_lookup PPC_PARAMS(id object, SEL selector) +IMP _Nonnull __saveds +glue_objc_msg_lookup PPC_PARAMS(id _Nullable object, SEL _Nonnull selector) { - M68K_ARG(id, object, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(id _Nullable, object, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return objc_msg_lookup(object, selector); } -IMP __saveds -glue_objc_msg_lookup_stret PPC_PARAMS(id object, SEL selector) +IMP _Nonnull __saveds +glue_objc_msg_lookup_stret PPC_PARAMS(id _Nullable object, SEL _Nonnull selector) { - M68K_ARG(id, object, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(id _Nullable, object, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return objc_msg_lookup_stret(object, selector); } -IMP __saveds -glue_objc_msg_lookup_super PPC_PARAMS(struct objc_super *super, SEL selector) +IMP _Nonnull __saveds +glue_objc_msg_lookup_super PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector) { - M68K_ARG(struct objc_super *, super, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(struct objc_super *_Nonnull, super, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return objc_msg_lookup_super(super, selector); } -IMP __saveds -glue_objc_msg_lookup_super_stret PPC_PARAMS(struct objc_super *super, - SEL selector) +IMP _Nonnull __saveds +glue_objc_msg_lookup_super_stret PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector) { - M68K_ARG(struct objc_super *, super, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(struct objc_super *_Nonnull, super, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return objc_msg_lookup_super_stret(super, selector); } -Class __saveds -glue_objc_lookUpClass PPC_PARAMS(const char *name) +Class _Nullable __saveds +glue_objc_lookUpClass PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return objc_lookUpClass(name); } -Class __saveds -glue_objc_getClass PPC_PARAMS(const char *name) +Class _Nullable __saveds +glue_objc_getClass PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return objc_getClass(name); } -Class __saveds -glue_objc_getRequiredClass PPC_PARAMS(const char *name) +Class _Nonnull __saveds +glue_objc_getRequiredClass PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return objc_getRequiredClass(name); } -Class __saveds -glue_objc_lookup_class PPC_PARAMS(const char *name) +Class _Nullable __saveds +glue_objc_lookup_class PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return objc_lookup_class(name); } -Class __saveds -glue_objc_get_class PPC_PARAMS(const char *name) +Class _Nonnull __saveds +glue_objc_get_class PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return objc_get_class(name); } void __saveds -glue_objc_exception_throw PPC_PARAMS(id object) +glue_objc_exception_throw PPC_PARAMS(id _Nonnull object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nonnull, object, a0) objc_exception_throw(object); - - OF_UNREACHABLE } int __saveds -glue_objc_sync_enter PPC_PARAMS(id object) +glue_objc_sync_enter PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_sync_enter(object); } int __saveds -glue_objc_sync_exit PPC_PARAMS(id object) +glue_objc_sync_exit PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_sync_exit(object); } -id __saveds -glue_objc_getProperty PPC_PARAMS(id self, SEL _cmd, ptrdiff_t offset, - bool atomic) +id _Nullable __saveds +glue_objc_getProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic) { - M68K_ARG(id, self, a0) - M68K_ARG(SEL, _cmd, a1) + M68K_ARG(id _Nonnull, self, a0) + M68K_ARG(SEL _Nonnull, _cmd, a1) M68K_ARG(ptrdiff_t, offset, d0) M68K_ARG(bool, atomic, d1) return objc_getProperty(self, _cmd, offset, atomic); } void __saveds -glue_objc_setProperty PPC_PARAMS(id self, SEL _cmd, ptrdiff_t offset, id value, - bool atomic, signed char copy) +glue_objc_setProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy) { - M68K_ARG(id, self, a0) - M68K_ARG(SEL, _cmd, a1) + M68K_ARG(id _Nonnull, self, a0) + M68K_ARG(SEL _Nonnull, _cmd, a1) M68K_ARG(ptrdiff_t, offset, d0) - M68K_ARG(id, value, a2) + M68K_ARG(id _Nullable, value, a2) M68K_ARG(bool, atomic, d1) M68K_ARG(signed char, copy, d2) objc_setProperty(self, _cmd, offset, value, atomic, copy); } void __saveds -glue_objc_getPropertyStruct PPC_PARAMS(void *dest, const void *src, - ptrdiff_t size, bool atomic, bool strong) +glue_objc_getPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong) { - M68K_ARG(void *, dest, a0) - M68K_ARG(const void *, src, a1) + M68K_ARG(void *_Nonnull, dest, a0) + M68K_ARG(const void *_Nonnull, src, a1) M68K_ARG(ptrdiff_t, size, d0) M68K_ARG(bool, atomic, d1) M68K_ARG(bool, strong, d2) objc_getPropertyStruct(dest, src, size, atomic, strong); } void __saveds -glue_objc_setPropertyStruct PPC_PARAMS(void *dest, const void *src, - ptrdiff_t size, bool atomic, bool strong) +glue_objc_setPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong) { - M68K_ARG(void *, dest, a0) - M68K_ARG(const void *, src, a1) + M68K_ARG(void *_Nonnull, dest, a0) + M68K_ARG(const void *_Nonnull, src, a1) M68K_ARG(ptrdiff_t, size, d0) M68K_ARG(bool, atomic, d1) M68K_ARG(bool, strong, d2) objc_setPropertyStruct(dest, src, size, atomic, strong); } void __saveds -glue_objc_enumerationMutation PPC_PARAMS(id object) +glue_objc_enumerationMutation PPC_PARAMS(id _Nonnull object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nonnull, object, a0) objc_enumerationMutation(object); } int __saveds -glue___gnu_objc_personality PPC_PARAMS(int version, int actions, - uint64_t exClass, void *ex, void *ctx) +glue___gnu_objc_personality PPC_PARAMS(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx) { M68K_ARG(int, version, d0) M68K_ARG(int, actions, d1) - M68K_ARG(uint64_t *, exClassPtr, d2) - M68K_ARG(void *, ex, a0) - M68K_ARG(void *, ctx, a1) -#ifdef OF_AMIGAOS_M68K - uint64_t exClass = *exClassPtr; -#endif - -#ifdef HAVE_SJLJ_EXCEPTIONS - return __gnu_objc_personality_sj0(version, actions, exClass, ex, ctx); -#else - return __gnu_objc_personality_v0(version, actions, exClass, ex, ctx); -#endif -} - -id __saveds -glue_objc_retain PPC_PARAMS(id object) -{ - M68K_ARG(id, object, a0) + M68K_ARG(uint64_t *_Nonnull, exClass, d2) + M68K_ARG(void *_Nonnull, ex, a0) + M68K_ARG(void *_Nonnull, ctx, a1) + + return __gnu_objc_personality(version, actions, exClass, ex, ctx); +} + +id _Nullable __saveds +glue_objc_retain PPC_PARAMS(id _Nullable object) +{ + M68K_ARG(id _Nullable, object, a0) return objc_retain(object); } -id __saveds -glue_objc_retainBlock PPC_PARAMS(id block) +id _Nullable __saveds +glue_objc_retainBlock PPC_PARAMS(id _Nullable block) { - M68K_ARG(id, block, a0) + M68K_ARG(id _Nullable, block, a0) return objc_retainBlock(block); } -id __saveds -glue_objc_retainAutorelease PPC_PARAMS(id object) +id _Nullable __saveds +glue_objc_retainAutorelease PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_retainAutorelease(object); } void __saveds -glue_objc_release PPC_PARAMS(id object) +glue_objc_release PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) objc_release(object); } -id __saveds -glue_objc_autorelease PPC_PARAMS(id object) +id _Nullable __saveds +glue_objc_autorelease PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_autorelease(object); } -id __saveds -glue_objc_autoreleaseReturnValue PPC_PARAMS(id object) +id _Nullable __saveds +glue_objc_autoreleaseReturnValue PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_autoreleaseReturnValue(object); } -id __saveds -glue_objc_retainAutoreleaseReturnValue PPC_PARAMS(id object) +id _Nullable __saveds +glue_objc_retainAutoreleaseReturnValue PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_retainAutoreleaseReturnValue(object); } -id __saveds -glue_objc_retainAutoreleasedReturnValue PPC_PARAMS(id object) +id _Nullable __saveds +glue_objc_retainAutoreleasedReturnValue PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_retainAutoreleasedReturnValue(object); } -id __saveds -glue_objc_storeStrong PPC_PARAMS(id *object, id value) +id _Nullable __saveds +glue_objc_storeStrong PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value) { - M68K_ARG(id *, object, a0) - M68K_ARG(id, value, a1) + M68K_ARG(id _Nullable *_Nonnull, object, a0) + M68K_ARG(id _Nullable, value, a1) return objc_storeStrong(object, value); } -id __saveds -glue_objc_storeWeak PPC_PARAMS(id *object, id value) +id _Nullable __saveds +glue_objc_storeWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value) { - M68K_ARG(id *, object, a0) - M68K_ARG(id, value, a1) + M68K_ARG(id _Nullable *_Nonnull, object, a0) + M68K_ARG(id _Nullable, value, a1) return objc_storeWeak(object, value); } -id __saveds -glue_objc_loadWeakRetained PPC_PARAMS(id *object) +id _Nullable __saveds +glue_objc_loadWeakRetained PPC_PARAMS(id _Nullable *_Nonnull object) { - M68K_ARG(id *, object, a0) + M68K_ARG(id _Nullable *_Nonnull, object, a0) return objc_loadWeakRetained(object); } -id __saveds -glue_objc_initWeak PPC_PARAMS(id *object, id value) +id _Nullable __saveds +glue_objc_initWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value) { - M68K_ARG(id *, object, a0) - M68K_ARG(id, value, a1) + M68K_ARG(id _Nullable *_Nonnull, object, a0) + M68K_ARG(id _Nullable, value, a1) return objc_initWeak(object, value); } void __saveds -glue_objc_destroyWeak PPC_PARAMS(id *object) +glue_objc_destroyWeak PPC_PARAMS(id _Nullable *_Nonnull object) { - M68K_ARG(id *, object, a0) + M68K_ARG(id _Nullable *_Nonnull, object, a0) objc_destroyWeak(object); } -id __saveds -glue_objc_loadWeak PPC_PARAMS(id *object) +id _Nullable __saveds +glue_objc_loadWeak PPC_PARAMS(id _Nullable *_Nonnull object) { - M68K_ARG(id *, object, a0) + M68K_ARG(id _Nullable *_Nonnull, object, a0) return objc_loadWeak(object); } void __saveds -glue_objc_copyWeak PPC_PARAMS(id *dest, id *src) +glue_objc_copyWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src) { - M68K_ARG(id *, dest, a0) - M68K_ARG(id *, src, a1) + M68K_ARG(id _Nullable *_Nonnull, dest, a0) + M68K_ARG(id _Nullable *_Nonnull, src, a1) objc_copyWeak(dest, src); } void __saveds -glue_objc_moveWeak PPC_PARAMS(id *dest, id *src) +glue_objc_moveWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src) { - M68K_ARG(id *, dest, a0) - M68K_ARG(id *, src, a1) + M68K_ARG(id _Nullable *_Nonnull, dest, a0) + M68K_ARG(id _Nullable *_Nonnull, src, a1) objc_moveWeak(dest, src); } -SEL __saveds -glue_sel_registerName PPC_PARAMS(const char *name) +SEL _Nonnull __saveds +glue_sel_registerName PPC_PARAMS(const char *_Nonnull name) { - M68K_ARG(const char *, name, a0) + M68K_ARG(const char *_Nonnull, name, a0) return sel_registerName(name); } -const char *__saveds -glue_sel_getName PPC_PARAMS(SEL selector) +const char *_Nonnull __saveds +glue_sel_getName PPC_PARAMS(SEL _Nonnull selector) { - M68K_ARG(SEL, selector, a0) + M68K_ARG(SEL _Nonnull, selector, a0) return sel_getName(selector); } bool __saveds -glue_sel_isEqual PPC_PARAMS(SEL selector1, SEL selector2) +glue_sel_isEqual PPC_PARAMS(SEL _Nonnull selector1, SEL _Nonnull selector2) { - M68K_ARG(SEL, selector1, a0) - M68K_ARG(SEL, selector2, a1) + M68K_ARG(SEL _Nonnull, selector1, a0) + M68K_ARG(SEL _Nonnull, selector2, a1) return sel_isEqual(selector1, selector2); } -Class __saveds -glue_objc_allocateClassPair PPC_PARAMS(Class superclass, const char *name, - size_t extraBytes) +Class _Nonnull __saveds +glue_objc_allocateClassPair PPC_PARAMS(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes) { - M68K_ARG(Class, superclass, a0) - M68K_ARG(const char *, name, a1) + M68K_ARG(Class _Nullable, superclass, a0) + M68K_ARG(const char *_Nonnull, name, a1) M68K_ARG(size_t, extraBytes, d0) return objc_allocateClassPair(superclass, name, extraBytes); } void __saveds -glue_objc_registerClassPair PPC_PARAMS(Class class) +glue_objc_registerClassPair PPC_PARAMS(Class _Nonnull class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nonnull, class, a0) objc_registerClassPair(class); } unsigned int __saveds -glue_objc_getClassList PPC_PARAMS(Class *buffer, unsigned int count) +glue_objc_getClassList PPC_PARAMS(Class _Nonnull *_Nullable buffer, unsigned int count) { - M68K_ARG(Class *, buffer, a0) + M68K_ARG(Class _Nonnull *_Nullable, buffer, a0) M68K_ARG(unsigned int, count, d0) return objc_getClassList(buffer, count); } -Class *__saveds -glue_objc_copyClassList PPC_PARAMS(unsigned int *length) +Class _Nonnull *_Nonnull __saveds +glue_objc_copyClassList PPC_PARAMS(unsigned int *_Nullable length) { - M68K_ARG(unsigned int *, length, a0) + M68K_ARG(unsigned int *_Nullable, length, a0) return objc_copyClassList(length); } bool __saveds -glue_class_isMetaClass PPC_PARAMS(Class class) +glue_class_isMetaClass PPC_PARAMS(Class _Nullable class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nullable, class, a0) return class_isMetaClass(class); } -const char *__saveds -glue_class_getName PPC_PARAMS(Class class) +const char *_Nullable __saveds +glue_class_getName PPC_PARAMS(Class _Nullable class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nullable, class, a0) return class_getName(class); } -Class __saveds -glue_class_getSuperclass PPC_PARAMS(Class class) +Class _Nullable __saveds +glue_class_getSuperclass PPC_PARAMS(Class _Nullable class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nullable, class, a0) return class_getSuperclass(class); } unsigned long __saveds -glue_class_getInstanceSize PPC_PARAMS(Class class) +glue_class_getInstanceSize PPC_PARAMS(Class _Nullable class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nullable, class, a0) return class_getInstanceSize(class); } bool __saveds -glue_class_respondsToSelector PPC_PARAMS(Class class, SEL selector) +glue_class_respondsToSelector PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector) { - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return class_respondsToSelector(class, selector); } bool __saveds -glue_class_conformsToProtocol PPC_PARAMS(Class class, Protocol *protocol) +glue_class_conformsToProtocol PPC_PARAMS(Class _Nullable class, Protocol *_Nonnull p) { - M68K_ARG(Class, class, a0) - M68K_ARG(Protocol *, protocol, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(Protocol *_Nonnull, p, a1) - return class_conformsToProtocol(class, protocol); + return class_conformsToProtocol(class, p); } -IMP __saveds -glue_class_getMethodImplementation PPC_PARAMS(Class class, SEL selector) +IMP _Nullable __saveds +glue_class_getMethodImplementation PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector) { - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return class_getMethodImplementation(class, selector); } -IMP __saveds -glue_class_getMethodImplementation_stret PPC_PARAMS(Class class, SEL selector) +IMP _Nullable __saveds +glue_class_getMethodImplementation_stret PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector) { - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return class_getMethodImplementation_stret(class, selector); } -Method __saveds -glue_class_getInstanceMethod PPC_PARAMS(Class class, SEL selector) +Method _Nullable __saveds +glue_class_getInstanceMethod PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector) { - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) return class_getInstanceMethod(class, selector); } bool __saveds -glue_class_addMethod PPC_PARAMS(Class class, SEL selector, IMP implementation, - const char *typeEncoding) +glue_class_addMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) { - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) - M68K_ARG(IMP, implementation, a2) - M68K_ARG(const char *, typeEncoding, a3) + M68K_ARG(Class _Nonnull, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) + M68K_ARG(IMP _Nonnull, implementation, a2) + M68K_ARG(const char *_Nullable, typeEncoding, a3) return class_addMethod(class, selector, implementation, typeEncoding); } -IMP __saveds -glue_class_replaceMethod PPC_PARAMS(Class class, SEL selector, - IMP implementation, const char *typeEncoding) -{ - M68K_ARG(Class, class, a0) - M68K_ARG(SEL, selector, a1) - M68K_ARG(IMP, implementation, a2) - M68K_ARG(const char *, typeEncoding, a3) - - return class_replaceMethod(class, selector, implementation, - typeEncoding); -} - -Class __saveds -glue_object_getClass PPC_PARAMS(id object) -{ - M68K_ARG(id, object, a0) +IMP _Nullable __saveds +glue_class_replaceMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) +{ + M68K_ARG(Class _Nonnull, class, a0) + M68K_ARG(SEL _Nonnull, selector, a1) + M68K_ARG(IMP _Nonnull, implementation, a2) + M68K_ARG(const char *_Nullable, typeEncoding, a3) + + return class_replaceMethod(class, selector, implementation, typeEncoding); +} + +Class _Nullable __saveds +glue_object_getClass PPC_PARAMS(id _Nullable object) +{ + M68K_ARG(id _Nullable, object, a0) return object_getClass(object); } -Class __saveds -glue_object_setClass PPC_PARAMS(id object, Class class) +Class _Nullable __saveds +glue_object_setClass PPC_PARAMS(id _Nullable object, Class _Nonnull class) { - M68K_ARG(id, object, a0) - M68K_ARG(Class, class, a1) + M68K_ARG(id _Nullable, object, a0) + M68K_ARG(Class _Nonnull, class, a1) return object_setClass(object, class); } -const char *__saveds -glue_object_getClassName PPC_PARAMS(id object) +const char *_Nullable __saveds +glue_object_getClassName PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return object_getClassName(object); } -const char *__saveds -glue_protocol_getName PPC_PARAMS(Protocol *protocol) +const char *_Nonnull __saveds +glue_protocol_getName PPC_PARAMS(Protocol *_Nonnull protocol) { - M68K_ARG(Protocol *, protocol, a0) + M68K_ARG(Protocol *_Nonnull, protocol, a0) return protocol_getName(protocol); } bool __saveds -glue_protocol_isEqual PPC_PARAMS(Protocol *protocol1, Protocol *protocol2) +glue_protocol_isEqual PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) { - M68K_ARG(Protocol *, protocol1, a0) - M68K_ARG(Protocol *, protocol2, a1) + M68K_ARG(Protocol *_Nonnull, protocol1, a0) + M68K_ARG(Protocol *_Nonnull, protocol2, a1) return protocol_isEqual(protocol1, protocol2); } bool __saveds -glue_protocol_conformsToProtocol PPC_PARAMS(Protocol *protocol1, - Protocol *protocol2) +glue_protocol_conformsToProtocol PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) { - M68K_ARG(Protocol *, protocol1, a0) - M68K_ARG(Protocol *, protocol2, a1) + M68K_ARG(Protocol *_Nonnull, protocol1, a0) + M68K_ARG(Protocol *_Nonnull, protocol2, a1) return protocol_conformsToProtocol(protocol1, protocol2); } -objc_uncaught_exception_handler_t __saveds -glue_objc_setUncaughtExceptionHandler PPC_PARAMS( - objc_uncaught_exception_handler_t handler) +_Nullable objc_uncaught_exception_handler_t __saveds +glue_objc_setUncaughtExceptionHandler PPC_PARAMS(objc_uncaught_exception_handler_t _Nullable handler) { - M68K_ARG(objc_uncaught_exception_handler_t, handler, a0) + M68K_ARG(objc_uncaught_exception_handler_t _Nullable, handler, a0) return objc_setUncaughtExceptionHandler(handler); } void __saveds -glue_objc_setForwardHandler PPC_PARAMS(IMP forward, IMP stretForward) +glue_objc_setForwardHandler PPC_PARAMS(IMP _Nullable forward, IMP _Nullable stretForward) { - M68K_ARG(IMP, forward, a0) - M68K_ARG(IMP, stretForward, a1) + M68K_ARG(IMP _Nullable, forward, a0) + M68K_ARG(IMP _Nullable, stretForward, a1) objc_setForwardHandler(forward, stretForward); } void __saveds -glue_objc_setEnumerationMutationHandler PPC_PARAMS( - objc_enumeration_mutation_handler_t handler) +glue_objc_setEnumerationMutationHandler PPC_PARAMS(objc_enumeration_mutation_handler_t _Nullable hadler) { - M68K_ARG(objc_enumeration_mutation_handler_t, handler, a0) + M68K_ARG(objc_enumeration_mutation_handler_t _Nullable, hadler, a0) - objc_setEnumerationMutationHandler(handler); + objc_setEnumerationMutationHandler(hadler); } -id __saveds -glue_objc_constructInstance PPC_PARAMS(Class class, void *bytes) +id _Nullable __saveds +glue_objc_constructInstance PPC_PARAMS(Class _Nullable class, void *_Nullable bytes) { - M68K_ARG(Class, class, a0) - M68K_ARG(void *, bytes, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(void *_Nullable, bytes, a1) return objc_constructInstance(class, bytes); } void __saveds @@ -630,171 +596,166 @@ glue_objc_exit(void) { objc_exit(); } -Ivar *__saveds -glue_class_copyIvarList PPC_PARAMS(Class class, unsigned int *outCount) +Ivar _Nullable *_Nullable __saveds +glue_class_copyIvarList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount) { - M68K_ARG(Class, class, a0) - M68K_ARG(unsigned int *, outCount, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(unsigned int *_Nullable, outCount, a1) return class_copyIvarList(class, outCount); } -const char *__saveds -glue_ivar_getName PPC_PARAMS(Ivar ivar) +const char *_Nonnull __saveds +glue_ivar_getName PPC_PARAMS(Ivar _Nonnull ivar) { - M68K_ARG(Ivar, ivar, a0) + M68K_ARG(Ivar _Nonnull, ivar, a0) return ivar_getName(ivar); } -const char *__saveds -glue_ivar_getTypeEncoding PPC_PARAMS(Ivar ivar) +const char *_Nonnull __saveds +glue_ivar_getTypeEncoding PPC_PARAMS(Ivar _Nonnull ivar) { - M68K_ARG(Ivar, ivar, a0) + M68K_ARG(Ivar _Nonnull, ivar, a0) return ivar_getTypeEncoding(ivar); } ptrdiff_t __saveds -glue_ivar_getOffset PPC_PARAMS(Ivar ivar) +glue_ivar_getOffset PPC_PARAMS(Ivar _Nonnull ivar) { - M68K_ARG(Ivar, ivar, a0) + M68K_ARG(Ivar _Nonnull, ivar, a0) return ivar_getOffset(ivar); } -Method *__saveds -glue_class_copyMethodList PPC_PARAMS(Class class, unsigned int *outCount) +Method _Nullable *_Nullable __saveds +glue_class_copyMethodList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount) { - M68K_ARG(Class, class, a0) - M68K_ARG(unsigned int *, outCount, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(unsigned int *_Nullable, outCount, a1) return class_copyMethodList(class, outCount); } -SEL __saveds -glue_method_getName PPC_PARAMS(Method method) +SEL _Nonnull __saveds +glue_method_getName PPC_PARAMS(Method _Nonnull method) { - M68K_ARG(Method, method, a0) + M68K_ARG(Method _Nonnull, method, a0) return method_getName(method); } -const char *__saveds -glue_method_getTypeEncoding PPC_PARAMS(Method method) +const char *_Nullable __saveds +glue_method_getTypeEncoding PPC_PARAMS(Method _Nonnull method) { - M68K_ARG(Method, method, a0) + M68K_ARG(Method _Nonnull, method, a0) return method_getTypeEncoding(method); } -objc_property_t *__saveds -glue_class_copyPropertyList PPC_PARAMS(Class class, unsigned int *outCount) +objc_property_t _Nullable *_Nullable __saveds +glue_class_copyPropertyList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount) { - M68K_ARG(Class, class, a0) - M68K_ARG(unsigned int *, outCount, a1) + M68K_ARG(Class _Nullable, class, a0) + M68K_ARG(unsigned int *_Nullable, outCount, a1) return class_copyPropertyList(class, outCount); } -const char *__saveds -glue_property_getName PPC_PARAMS(objc_property_t property) +const char *_Nonnull __saveds +glue_property_getName PPC_PARAMS(objc_property_t _Nonnull property) { - M68K_ARG(objc_property_t, property, a0) + M68K_ARG(objc_property_t _Nonnull, property, a0) return property_getName(property); } -char *__saveds -glue_property_copyAttributeValue PPC_PARAMS(objc_property_t property, - const char *name) +char *_Nullable __saveds +glue_property_copyAttributeValue PPC_PARAMS(objc_property_t _Nonnull property, const char *_Nonnull name) { - M68K_ARG(objc_property_t, property, a0) - M68K_ARG(const char *, name, a1) + M68K_ARG(objc_property_t _Nonnull, property, a0) + M68K_ARG(const char *_Nonnull, name, a1) return property_copyAttributeValue(property, name); } -void *__saveds -glue_objc_destructInstance PPC_PARAMS(id object) +void *_Nullable __saveds +glue_objc_destructInstance PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return objc_destructInstance(object); } -void *__saveds +void *_Null_unspecified __saveds glue_objc_autoreleasePoolPush(void) { return objc_autoreleasePoolPush(); } void __saveds -glue_objc_autoreleasePoolPop PPC_PARAMS(void *pool) +glue_objc_autoreleasePoolPop PPC_PARAMS(void *_Null_unspecified pool) { - M68K_ARG(void *, pool, a0) + M68K_ARG(void *_Null_unspecified, pool, a0) objc_autoreleasePoolPop(pool); } -id __saveds -glue__objc_rootAutorelease PPC_PARAMS(id object) +id _Nullable __saveds +glue__objc_rootAutorelease PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return _objc_rootAutorelease(object); } -struct objc_hashtable *__saveds -glue_objc_hashtable_new PPC_PARAMS(objc_hashtable_hash_func hash, - objc_hashtable_equal_func equal, uint32_t size) +struct objc_hashtable *_Nonnull __saveds +glue_objc_hashtable_new PPC_PARAMS(objc_hashtable_hash_func hash, objc_hashtable_equal_func equal, uint32_t size) { M68K_ARG(objc_hashtable_hash_func, hash, a0) M68K_ARG(objc_hashtable_equal_func, equal, a1) M68K_ARG(uint32_t, size, d0) return objc_hashtable_new(hash, equal, size); } void __saveds -glue_objc_hashtable_set PPC_PARAMS(struct objc_hashtable *table, - const void *key, const void *object) +glue_objc_hashtable_set PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key, const void *_Nonnull object) { - M68K_ARG(struct objc_hashtable *, table, a0) - M68K_ARG(const void *, key, a1) - M68K_ARG(const void *, object, a2) + M68K_ARG(struct objc_hashtable *_Nonnull, table, a0) + M68K_ARG(const void *_Nonnull, key, a1) + M68K_ARG(const void *_Nonnull, object, a2) objc_hashtable_set(table, key, object); } -void *__saveds -glue_objc_hashtable_get PPC_PARAMS(struct objc_hashtable *table, - const void *key) +void *_Nullable __saveds +glue_objc_hashtable_get PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key) { - M68K_ARG(struct objc_hashtable *, table, a0) - M68K_ARG(const void *, key, a1) + M68K_ARG(struct objc_hashtable *_Nonnull, table, a0) + M68K_ARG(const void *_Nonnull, key, a1) return objc_hashtable_get(table, key); } void __saveds -glue_objc_hashtable_delete PPC_PARAMS(struct objc_hashtable *table, - const void *key) +glue_objc_hashtable_delete PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key) { - M68K_ARG(struct objc_hashtable *, table, a0) - M68K_ARG(const void *, key, a1) + M68K_ARG(struct objc_hashtable *_Nonnull, table, a0) + M68K_ARG(const void *_Nonnull, key, a1) objc_hashtable_delete(table, key); } void __saveds -glue_objc_hashtable_free PPC_PARAMS(struct objc_hashtable *table) +glue_objc_hashtable_free PPC_PARAMS(struct objc_hashtable *_Nonnull table) { - M68K_ARG(struct objc_hashtable *, table, a0) + M68K_ARG(struct objc_hashtable *_Nonnull, table, a0) objc_hashtable_free(table); } void __saveds @@ -804,36 +765,36 @@ objc_setTaggedPointerSecret(secret); } int __saveds -glue_objc_registerTaggedPointerClass PPC_PARAMS(Class class) +glue_objc_registerTaggedPointerClass PPC_PARAMS(Class _Nonnull class) { - M68K_ARG(Class, class, a0) + M68K_ARG(Class _Nonnull, class, a0) return objc_registerTaggedPointerClass(class); } bool __saveds -glue_object_isTaggedPointer PPC_PARAMS(id object) +glue_object_isTaggedPointer PPC_PARAMS(id _Nullable object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nullable, object, a0) return object_isTaggedPointer(object); } uintptr_t __saveds -glue_object_getTaggedPointerValue PPC_PARAMS(id object) +glue_object_getTaggedPointerValue PPC_PARAMS(id _Nonnull object) { - M68K_ARG(id, object, a0) + M68K_ARG(id _Nonnull, object, a0) return object_getTaggedPointerValue(object); } -id __saveds +id _Nullable __saveds glue_objc_createTaggedPointer PPC_PARAMS(int class, uintptr_t value) { M68K_ARG(int, class, d0) M68K_ARG(uintptr_t, value, d1) return objc_createTaggedPointer(class, value); } Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,10 +15,12 @@ #include "config.h" #import "ObjFWRT.h" #import "private.h" + +#import "amiga-glue.h" #include #include #include #include @@ -67,101 +67,10 @@ extern uintptr_t __CTOR_LIST__[]; extern const void *_EH_FRAME_BEGINS__; extern void *_EH_FRAME_OBJECTS__; #endif -extern bool glue_objc_init(void); -extern void glue___objc_exec_class(void); -extern IMP glue_objc_msg_lookup(void); -extern IMP glue_objc_msg_lookup_stret(void); -extern IMP glue_objc_msg_lookup_super(void); -extern IMP glue_objc_msg_lookup_super_stret(void); -extern Class glue_objc_lookUpClass(void); -extern Class glue_objc_getClass(void); -extern Class glue_objc_getRequiredClass(void); -extern Class glue_objc_lookup_class(void); -extern Class glue_objc_get_class(void); -extern void glue_objc_exception_throw(void); -extern int glue_objc_sync_enter(void); -extern int glue_objc_sync_exit(void); -extern id glue_objc_getProperty(void); -extern void glue_objc_setProperty(void); -extern void glue_objc_getPropertyStruct(void); -extern void glue_objc_setPropertyStruct(void); -extern void glue_objc_enumerationMutation(void); -extern int glue___gnu_objc_personality(void); -extern id glue_objc_retain(void); -extern id glue_objc_retainBlock(void); -extern id glue_objc_retainAutorelease(void); -extern void glue_objc_release(void); -extern id glue_objc_autorelease(void); -extern id glue_objc_autoreleaseReturnValue(void); -extern id glue_objc_retainAutoreleaseReturnValue(void); -extern id glue_objc_retainAutoreleasedReturnValue(void); -extern id glue_objc_storeStrong(void); -extern id glue_objc_storeWeak(void); -extern id glue_objc_loadWeakRetained(void); -extern id glue_objc_initWeak(void); -extern void glue_objc_destroyWeak(void); -extern id glue_objc_loadWeak(void); -extern void glue_objc_copyWeak(void); -extern void glue_objc_moveWeak(void); -extern SEL glue_sel_registerName(void); -extern const char *glue_sel_getName(void); -extern bool glue_sel_isEqual(void); -extern Class glue_objc_allocateClassPair(void); -extern void glue_objc_registerClassPair(void); -extern unsigned int glue_objc_getClassList(void); -extern Class *glue_objc_copyClassList(void); -extern bool glue_class_isMetaClass(void); -extern const char *glue_class_getName(void); -extern Class glue_class_getSuperclass(void); -extern unsigned long glue_class_getInstanceSize(void); -extern bool glue_class_respondsToSelector(void); -extern bool glue_class_conformsToProtocol(void); -extern IMP glue_class_getMethodImplementation(void); -extern IMP glue_class_getMethodImplementation_stret(void); -extern Method glue_class_getInstanceMethod(void); -extern bool glue_class_addMethod(void); -extern IMP glue_class_replaceMethod(void); -extern Class glue_object_getClass(void); -extern Class glue_object_setClass(void); -extern const char *glue_object_getClassName(void); -extern const char *glue_protocol_getName(void); -extern bool glue_protocol_isEqual(void); -extern bool glue_protocol_conformsToProtocol(void); -extern objc_uncaught_exception_handler_t - glue_objc_setUncaughtExceptionHandler(void); -extern void glue_objc_setForwardHandler(void); -extern void glue_objc_setEnumerationMutationHandler(void); -extern id glue_objc_constructInstance(void); -extern void glue_objc_exit(void); -extern Ivar *glue_class_copyIvarList(void); -extern const char *glue_ivar_getName(void); -extern const char *glue_ivar_getTypeEncoding(void); -extern ptrdiff_t glue_ivar_getOffset(void); -extern Method *glue_class_copyMethodList(void); -extern SEL glue_method_getName(void); -extern const char *glue_method_getTypeEncoding(void); -extern objc_property_t *glue_class_copyPropertyList(void); -extern const char *glue_property_getName(void); -extern char *glue_property_copyAttributeValue(void); -extern void *glue_objc_destructInstance(void); -extern void *glue_objc_autoreleasePoolPush(void); -extern void glue_objc_autoreleasePoolPop(void); -extern id glue__objc_rootAutorelease(void); -extern struct objc_hashtable *glue_objc_hashtable_new(void); -extern void glue_objc_hashtable_set(void); -extern void *glue_objc_hashtable_get(void); -extern void glue_objc_hashtable_delete(void); -extern void glue_objc_hashtable_free(void); -extern void glue_objc_setTaggedPointerSecret(void); -extern int glue_objc_registerTaggedPointerClass(void); -extern bool glue_object_isTaggedPointer(void); -extern uintptr_t glue_object_getTaggedPointerValue(void); -extern id glue_objc_createTaggedPointer(void); - #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct objc_libc libc; @@ -620,99 +529,11 @@ (CONST_APTR)lib_null, #ifdef OF_MORPHOS (CONST_APTR)-1, (CONST_APTR)FUNCARRAY_32BIT_SYSTEMV, #endif - (CONST_APTR)glue_objc_init, - (CONST_APTR)glue___objc_exec_class, - (CONST_APTR)glue_objc_msg_lookup, - (CONST_APTR)glue_objc_msg_lookup_stret, - (CONST_APTR)glue_objc_msg_lookup_super, - (CONST_APTR)glue_objc_msg_lookup_super_stret, - (CONST_APTR)glue_objc_lookUpClass, - (CONST_APTR)glue_objc_getClass, - (CONST_APTR)glue_objc_getRequiredClass, - (CONST_APTR)glue_objc_lookup_class, - (CONST_APTR)glue_objc_get_class, - (CONST_APTR)glue_objc_exception_throw, - (CONST_APTR)glue_objc_sync_enter, - (CONST_APTR)glue_objc_sync_exit, - (CONST_APTR)glue_objc_getProperty, - (CONST_APTR)glue_objc_setProperty, - (CONST_APTR)glue_objc_getPropertyStruct, - (CONST_APTR)glue_objc_setPropertyStruct, - (CONST_APTR)glue_objc_enumerationMutation, - (CONST_APTR)glue___gnu_objc_personality, - (CONST_APTR)glue_objc_retain, - (CONST_APTR)glue_objc_retainBlock, - (CONST_APTR)glue_objc_retainAutorelease, - (CONST_APTR)glue_objc_release, - (CONST_APTR)glue_objc_autorelease, - (CONST_APTR)glue_objc_autoreleaseReturnValue, - (CONST_APTR)glue_objc_retainAutoreleaseReturnValue, - (CONST_APTR)glue_objc_retainAutoreleasedReturnValue, - (CONST_APTR)glue_objc_storeStrong, - (CONST_APTR)glue_objc_storeWeak, - (CONST_APTR)glue_objc_loadWeakRetained, - (CONST_APTR)glue_objc_initWeak, - (CONST_APTR)glue_objc_destroyWeak, - (CONST_APTR)glue_objc_loadWeak, - (CONST_APTR)glue_objc_copyWeak, - (CONST_APTR)glue_objc_moveWeak, - (CONST_APTR)glue_sel_registerName, - (CONST_APTR)glue_sel_getName, - (CONST_APTR)glue_sel_isEqual, - (CONST_APTR)glue_objc_allocateClassPair, - (CONST_APTR)glue_objc_registerClassPair, - (CONST_APTR)glue_objc_getClassList, - (CONST_APTR)glue_objc_copyClassList, - (CONST_APTR)glue_class_isMetaClass, - (CONST_APTR)glue_class_getName, - (CONST_APTR)glue_class_getSuperclass, - (CONST_APTR)glue_class_getInstanceSize, - (CONST_APTR)glue_class_respondsToSelector, - (CONST_APTR)glue_class_conformsToProtocol, - (CONST_APTR)glue_class_getMethodImplementation, - (CONST_APTR)glue_class_getMethodImplementation_stret, - (CONST_APTR)glue_class_getInstanceMethod, - (CONST_APTR)glue_class_addMethod, - (CONST_APTR)glue_class_replaceMethod, - (CONST_APTR)glue_object_getClass, - (CONST_APTR)glue_object_setClass, - (CONST_APTR)glue_object_getClassName, - (CONST_APTR)glue_protocol_getName, - (CONST_APTR)glue_protocol_isEqual, - (CONST_APTR)glue_protocol_conformsToProtocol, - (CONST_APTR)glue_objc_setUncaughtExceptionHandler, - (CONST_APTR)glue_objc_setForwardHandler, - (CONST_APTR)glue_objc_setEnumerationMutationHandler, - (CONST_APTR)glue_objc_constructInstance, - (CONST_APTR)glue_objc_exit, - (CONST_APTR)glue_class_copyIvarList, - (CONST_APTR)glue_ivar_getName, - (CONST_APTR)glue_ivar_getTypeEncoding, - (CONST_APTR)glue_ivar_getOffset, - (CONST_APTR)glue_class_copyMethodList, - (CONST_APTR)glue_method_getName, - (CONST_APTR)glue_method_getTypeEncoding, - (CONST_APTR)glue_class_copyPropertyList, - (CONST_APTR)glue_property_getName, - (CONST_APTR)glue_property_copyAttributeValue, - (CONST_APTR)glue_objc_destructInstance, - (CONST_APTR)glue_objc_autoreleasePoolPush, - (CONST_APTR)glue_objc_autoreleasePoolPop, - (CONST_APTR)glue__objc_rootAutorelease, - (CONST_APTR)glue_objc_hashtable_new, - (CONST_APTR)glue_objc_hashtable_set, - (CONST_APTR)glue_objc_hashtable_get, - (CONST_APTR)glue_objc_hashtable_delete, - (CONST_APTR)glue_objc_hashtable_free, - (CONST_APTR)glue_objc_setTaggedPointerSecret, - (CONST_APTR)glue_objc_registerTaggedPointerClass, - (CONST_APTR)glue_object_isTaggedPointer, - (CONST_APTR)glue_object_getTaggedPointerValue, - (CONST_APTR)glue_objc_createTaggedPointer, +#include "amiga-funcarray.inc" (CONST_APTR)-1, #ifdef OF_MORPHOS (CONST_APTR)FUNCARRAY_END #endif }; @@ -745,11 +566,11 @@ .rt_Version = OBJFWRT_LIB_MAJOR, .rt_Type = NT_LIBRARY, .rt_Pri = 0, .rt_Name = (char *)OBJFWRT_AMIGA_LIB, .rt_IdString = (char *)"ObjFWRT " VERSION_STRING - " \xA9 2008-2019 Jonathan Schleifer", + " \xA9 2008-2021 Jonathan Schleifer", .rt_Init = &init_table, #ifdef OF_MORPHOS .rt_Revision = OBJFWRT_LIB_MINOR, .rt_Tags = NULL, #endif Index: src/runtime/arc.m ================================================================== --- src/runtime/arc.m +++ src/runtime/arc.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/autorelease.m ================================================================== --- src/runtime/autorelease.m +++ src/runtime/autorelease.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/category.m ================================================================== --- src/runtime/category.m +++ src/runtime/category.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/dtable.m ================================================================== --- src/runtime/dtable.m +++ src/runtime/dtable.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/exception.m ================================================================== --- src/runtime/exception.m +++ src/runtime/exception.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -336,12 +334,18 @@ static uint64_t readValue(uint8_t enc, const uint8_t **ptr) { uint64_t value; - if (enc == DW_EH_PE_aligned) - OBJC_ERROR("DW_EH_PE_aligned is not implemented!"); + if (enc == DW_EH_PE_aligned) { + const uintptr_t *aligned = (const uintptr_t *) + OF_ROUND_UP_POW2(sizeof(void *), (uintptr_t)*ptr); + + *ptr = (const uint8_t *)(aligned + 1); + + return *aligned; + } #define READ(type) \ { \ type tmp; \ memcpy(&tmp, *ptr, sizeof(type)); \ @@ -380,12 +384,12 @@ #ifndef HAVE_ARM_EHABI_EXCEPTIONS static uint64_t resolveValue(uint64_t value, uint8_t enc, const uint8_t *start, uint64_t base) { - if (value == 0) - return 0; + if (value == 0 || enc == DW_EH_PE_aligned) + return value; value += ((enc & 0x70) == DW_EH_PE_pcrel ? (uintptr_t)start : base); if (enc & DW_EH_PE_indirect) value = *(uintptr_t *)(uintptr_t)value; Index: src/runtime/hashtable.m ================================================================== --- src/runtime/hashtable.m +++ src/runtime/hashtable.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/init.m ================================================================== --- src/runtime/init.m +++ src/runtime/init.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/instance.m ================================================================== --- src/runtime/instance.m +++ src/runtime/instance.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/ivar.m ================================================================== --- src/runtime/ivar.m +++ src/runtime/ivar.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in ADDED src/runtime/library.xml Index: src/runtime/library.xml ================================================================== --- /dev/null +++ src/runtime/library.xml @@ -0,0 +1,345 @@ + + ObjFWRT.h + private.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: src/runtime/linklib/Makefile ================================================================== --- src/runtime/linklib/Makefile +++ src/runtime/linklib/Makefile @@ -1,9 +1,10 @@ include ../../../extra.mk STATIC_LIB = libobjfwrt.library.a -SRCS = linklib.m +SRCS = init.m \ + linklib.m include ../../../buildsys.mk CPPFLAGS += -I.. -I../.. -I../../.. \ -DOBJC_COMPILING_AMIGA_LINKLIB \ ADDED src/runtime/linklib/init.m Index: src/runtime/linklib/init.m ================================================================== --- /dev/null +++ src/runtime/linklib/init.m @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2008-2021 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "ObjFWRT.h" +#import "private.h" +#import "macros.h" + +#include +#include + +struct ObjFWRTBase; + +#include +#include + +#if defined(OF_AMIGAOS_M68K) +# include +#elif defined(OF_MORPHOS) +# include +#endif + +#ifdef HAVE_SJLJ_EXCEPTIONS +extern int _Unwind_SjLj_RaiseException(void *); +#else +extern int _Unwind_RaiseException(void *); +#endif +extern void _Unwind_DeleteException(void *); +extern void *_Unwind_GetLanguageSpecificData(void *); +extern uintptr_t _Unwind_GetRegionStart(void *); +extern uintptr_t _Unwind_GetDataRelBase(void *); +extern uintptr_t _Unwind_GetTextRelBase(void *); +extern uintptr_t _Unwind_GetIP(void *); +extern uintptr_t _Unwind_GetGR(void *, int); +extern void _Unwind_SetIP(void *, uintptr_t); +extern void _Unwind_SetGR(void *, int, uintptr_t); +#ifdef HAVE_SJLJ_EXCEPTIONS +extern void _Unwind_SjLj_Resume(void *); +#else +extern void _Unwind_Resume(void *); +#endif +#ifdef OF_AMIGAOS_M68K +extern void __register_frame_info(const void *, void *); +extern void *__deregister_frame_info(const void *); +#endif +#ifdef OF_MORPHOS +extern void __register_frame(void *); +extern void __deregister_frame(void *); +#endif + +struct Library *ObjFWRTBase; +void *__objc_class_name_Protocol; + +extern bool objc_init(unsigned int version, struct objc_libc *libc); + +static void +error(const char *string, ULONG arg) +{ + struct Library *IntuitionBase = OpenLibrary("intuition.library", 0); + + if (IntuitionBase != NULL) { + struct EasyStruct easy = { + .es_StructSize = sizeof(easy), + .es_Flags = 0, + .es_Title = (void *)NULL, + .es_TextFormat = (void *)string, + (void *)"OK" + }; + + EasyRequest(NULL, &easy, NULL, arg); + + CloseLibrary(IntuitionBase); + } + + exit(EXIT_FAILURE); +} + +static void __attribute__((__used__)) +ctor(void) +{ + static bool initialized = false; + struct objc_libc libc = { + .malloc = malloc, + .calloc = calloc, + .realloc = realloc, + .free = free, +#ifdef HAVE_SJLJ_EXCEPTIONS + ._Unwind_SjLj_RaiseException = _Unwind_SjLj_RaiseException, +#else + ._Unwind_RaiseException = _Unwind_RaiseException, +#endif + ._Unwind_DeleteException = _Unwind_DeleteException, + ._Unwind_GetLanguageSpecificData = + _Unwind_GetLanguageSpecificData, + ._Unwind_GetRegionStart = _Unwind_GetRegionStart, + ._Unwind_GetDataRelBase = _Unwind_GetDataRelBase, + ._Unwind_GetTextRelBase = _Unwind_GetTextRelBase, + ._Unwind_GetIP = _Unwind_GetIP, + ._Unwind_GetGR = _Unwind_GetGR, + ._Unwind_SetIP = _Unwind_SetIP, + ._Unwind_SetGR = _Unwind_SetGR, +#ifdef HAVE_SJLJ_EXCEPTIONS + ._Unwind_SjLj_Resume = _Unwind_SjLj_Resume, +#else + ._Unwind_Resume = _Unwind_Resume, +#endif +#ifdef OF_AMIGAOS_M68K + .__register_frame_info = __register_frame_info, + .__deregister_frame_info = __deregister_frame_info, +#endif +#ifdef OF_MORPHOS + .__register_frame = __register_frame, + .__deregister_frame = __deregister_frame, +#endif +#ifdef OF_AMIGAOS_M68K + .vsnprintf = vsnprintf, +#endif + .atexit = atexit, + .exit = exit, + }; + + if (initialized) + return; + + if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB, + OBJFWRT_LIB_MINOR)) == NULL) + error("Failed to open " OBJFWRT_AMIGA_LIB " version %lu!", + OBJFWRT_LIB_MINOR); + + if (!objc_init(1, &libc)) + error("Failed to initialize " OBJFWRT_AMIGA_LIB "!", 0); + + initialized = true; +} + +static void __attribute__((__used__)) +dtor(void) +{ + CloseLibrary(ObjFWRTBase); +} + +#if defined(OF_AMIGAOS_M68K) +ADD2INIT(ctor, -5); +ADD2EXIT(dtor, -5); +#elif defined(OF_MORPHOS) +CONSTRUCTOR_P(ObjFWRT, 4000) +{ + ctor(); + + return 0; +} + +DESTRUCTOR_P(ObjFWRT, 4000) +{ + dtor(); +} +#endif + +extern int __gnu_objc_personality(int version, int actions, uint64_t *exClass, + void *ex, void *ctx); + +int +#ifdef HAVE_SJLJ_EXCEPTIONS +__gnu_objc_personality_sj0( +#else +__gnu_objc_personality_v0( +#endif + int version, int actions, uint64_t exClass, void *ex, void *ctx) +{ +#ifdef OF_AMIGAOS_M68K + return __gnu_objc_personality(version, actions, &exClass, ex, ctx); +#else + return __gnu_objc_personality(version, actions, &exClass, ex, ctx); +#endif +} Index: src/runtime/linklib/linklib.m ================================================================== --- src/runtime/linklib/linklib.m +++ src/runtime/linklib/linklib.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -13,761 +11,1528 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +/* This file is automatically generated from library.xml */ + #include "config.h" #import "ObjFWRT.h" #import "private.h" -#import "macros.h" - -#include -#include - -struct ObjFWRTBase; - -#import "inline.h" - -#include -#include - -#if defined(OF_AMIGAOS_M68K) -# include -# define SYM(name) __asm__("_" name) -#elif defined(OF_MORPHOS) -# include -# define SYM(name) __asm__(name) -#endif - -#ifdef HAVE_SJLJ_EXCEPTIONS -extern int _Unwind_SjLj_RaiseException(void *); -#else -extern int _Unwind_RaiseException(void *); -#endif -extern void _Unwind_DeleteException(void *); -extern void *_Unwind_GetLanguageSpecificData(void *); -extern uintptr_t _Unwind_GetRegionStart(void *); -extern uintptr_t _Unwind_GetDataRelBase(void *); -extern uintptr_t _Unwind_GetTextRelBase(void *); -extern uintptr_t _Unwind_GetIP(void *); -extern uintptr_t _Unwind_GetGR(void *, int); -extern void _Unwind_SetIP(void *, uintptr_t); -extern void _Unwind_SetGR(void *, int, uintptr_t); -#ifdef HAVE_SJLJ_EXCEPTIONS -extern void _Unwind_SjLj_Resume(void *); -#else -extern void _Unwind_Resume(void *); -#endif -#ifdef OF_AMIGAOS_M68K -extern void __register_frame_info(const void *, void *); -extern void *__deregister_frame_info(const void *); -#endif -#ifdef OF_MORPHOS -extern void __register_frame(void *); -extern void __deregister_frame(void *); -#endif - -struct Library *ObjFWRTBase; -void *__objc_class_name_Protocol; - -static void -error(const char *string, ULONG arg) -{ - struct Library *IntuitionBase = OpenLibrary("intuition.library", 0); - - if (IntuitionBase != NULL) { - struct EasyStruct easy = { - .es_StructSize = sizeof(easy), - .es_Flags = 0, - .es_Title = (void *)NULL, - .es_TextFormat = (void *)string, - (void *)"OK" - }; - - EasyRequest(NULL, &easy, NULL, arg); - - CloseLibrary(IntuitionBase); - } - - exit(EXIT_FAILURE); -} - -static void __attribute__((__used__)) -ctor(void) -{ - static bool initialized = false; - struct objc_libc libc = { - .malloc = malloc, - .calloc = calloc, - .realloc = realloc, - .free = free, -#ifdef HAVE_SJLJ_EXCEPTIONS - ._Unwind_SjLj_RaiseException = _Unwind_SjLj_RaiseException, -#else - ._Unwind_RaiseException = _Unwind_RaiseException, -#endif - ._Unwind_DeleteException = _Unwind_DeleteException, - ._Unwind_GetLanguageSpecificData = - _Unwind_GetLanguageSpecificData, - ._Unwind_GetRegionStart = _Unwind_GetRegionStart, - ._Unwind_GetDataRelBase = _Unwind_GetDataRelBase, - ._Unwind_GetTextRelBase = _Unwind_GetTextRelBase, - ._Unwind_GetIP = _Unwind_GetIP, - ._Unwind_GetGR = _Unwind_GetGR, - ._Unwind_SetIP = _Unwind_SetIP, - ._Unwind_SetGR = _Unwind_SetGR, -#ifdef HAVE_SJLJ_EXCEPTIONS - ._Unwind_SjLj_Resume = _Unwind_SjLj_Resume, -#else - ._Unwind_Resume = _Unwind_Resume, -#endif -#ifdef OF_AMIGAOS_M68K - .__register_frame_info = __register_frame_info, - .__deregister_frame_info = __deregister_frame_info, -#endif -#ifdef OF_MORPHOS - .__register_frame = __register_frame, - .__deregister_frame = __deregister_frame, -#endif -#ifdef OF_AMIGAOS_M68K - .vsnprintf = vsnprintf, -#endif - .atexit = atexit, - .exit = exit, - }; - - if (initialized) - return; - - if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB, - OBJFWRT_LIB_MINOR)) == NULL) - error("Failed to open " OBJFWRT_AMIGA_LIB " version %lu!", - OBJFWRT_LIB_MINOR); - - if (!glue_objc_init(1, &libc)) - error("Failed to initialize " OBJFWRT_AMIGA_LIB "!", 0); - - initialized = true; -} - -static void __attribute__((__used__)) -dtor(void) -{ - CloseLibrary(ObjFWRTBase); -} - -#if defined(OF_AMIGAOS_M68K) -ADD2INIT(ctor, -2); -ADD2EXIT(dtor, -2); -#elif defined(OF_MORPHOS) -CONSTRUCTOR_P(ObjFWRT, 4000) -{ - ctor(); - - return 0; -} - -DESTRUCTOR_P(ObjFWRT, 4000) -{ - dtor(); -} -#endif - -void -__objc_exec_class(struct objc_module *module) -{ - /* - * The compiler generates constructors that call into this, so it is - * possible that we are not set up yet when we get called. - */ - ctor(); - - glue___objc_exec_class(module); -} - -IMP -objc_msg_lookup(id object, SEL selector) -{ - return glue_objc_msg_lookup(object, selector); -} - -IMP -objc_msg_lookup_stret(id object, SEL selector) -{ - return glue_objc_msg_lookup_stret(object, selector); -} - -IMP -objc_msg_lookup_super(struct objc_super *super, SEL selector) -{ - return glue_objc_msg_lookup_super(super, selector); -} - -IMP -objc_msg_lookup_super_stret(struct objc_super *super, SEL selector) -{ - return glue_objc_msg_lookup_super_stret(super, selector); -} - -Class -objc_lookUpClass(const char *name) -{ - return glue_objc_lookUpClass(name); -} - -Class -objc_getClass(const char *name) -{ - return glue_objc_getClass(name); -} - -Class -objc_getRequiredClass(const char *name) -{ - return glue_objc_getRequiredClass(name); -} - -Class -objc_lookup_class(const char *name) -{ - return glue_objc_lookup_class(name); -} - -Class -objc_get_class(const char *name) -{ - return glue_objc_get_class(name); -} - -void -objc_exception_throw(id object) -{ -#ifdef OF_AMIGAOS_M68K - /* - * This does not use the glue code to hack around a compiler bug. - * - * When using the generated inline stubs, the compiler does not emit - * any frame information, making the unwind fail. As unwind always - * starts from objc_exception_throw(), this means exceptions would - * never work. If, however, we're using a function pointer instead of - * the inline stub, the compiler does generate a frame and everything - * works fine. - */ - register void *a6 __asm__("a6") = ObjFWRTBase; - uintptr_t throw = (((uintptr_t)ObjFWRTBase) - 0x60); - ((void (*)(id __asm__("a0")))throw)(object); - (void)a6; -#else - glue_objc_exception_throw(object); + +extern struct Library *ObjFWRTBase; + +bool +objc_init(unsigned int version, struct objc_libc *libc) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(unsigned int __asm__("d0"), struct objc_libc *__asm__("a0")))(((uintptr_t)ObjFWRTBase) - 30))(version, libc); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(unsigned int, struct objc_libc *))*(void **)(((uintptr_t)ObjFWRTBase) - 28))(version, libc); +#endif +} + +void +__objc_exec_class(struct objc_module *_Nonnull module) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(struct objc_module *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 36))(module); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(struct objc_module *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 34))(module); +#endif +} + +IMP _Nonnull +objc_msg_lookup(id _Nullable object, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nonnull (*)(id _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 42))(object, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nonnull (*)(id _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 40))(object, selector); +#endif +} + +IMP _Nonnull +objc_msg_lookup_stret(id _Nullable object, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nonnull (*)(id _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 48))(object, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nonnull (*)(id _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 46))(object, selector); +#endif +} + +IMP _Nonnull +objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nonnull (*)(struct objc_super *_Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 54))(super, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nonnull (*)(struct objc_super *_Nonnull, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 52))(super, selector); +#endif +} + +IMP _Nonnull +objc_msg_lookup_super_stret(struct objc_super *_Nonnull super, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nonnull (*)(struct objc_super *_Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 60))(super, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nonnull (*)(struct objc_super *_Nonnull, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 58))(super, selector); +#endif +} + +Class _Nullable +objc_lookUpClass(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 66))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 64))(name); +#endif +} + +Class _Nullable +objc_getClass(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 72))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 70))(name); +#endif +} + +Class _Nonnull +objc_getRequiredClass(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nonnull (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 78))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nonnull (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 76))(name); +#endif +} + +Class _Nullable +objc_lookup_class(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 84))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 82))(name); +#endif +} + +Class _Nonnull +objc_get_class(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nonnull (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 90))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nonnull (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 88))(name); +#endif +} + +void +objc_exception_throw(id _Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 96))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 94))(object); #endif OF_UNREACHABLE } int -objc_sync_enter(id object) -{ - return glue_objc_sync_enter(object); -} - -int -objc_sync_exit(id object) -{ - return glue_objc_sync_exit(object); -} - -id -objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, bool atomic) -{ - return glue_objc_getProperty(self, _cmd, offset, atomic); -} - -void -objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, bool atomic, - signed char copy) -{ - glue_objc_setProperty(self, _cmd, offset, value, atomic, copy); -} - -void -objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic, - bool strong) -{ - glue_objc_getPropertyStruct(dest, src, size, atomic, strong); -} - -void -objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic, - bool strong) -{ - glue_objc_setPropertyStruct(dest, src, size, atomic, strong); -} - -void -objc_enumerationMutation(id object) -{ -#ifdef OF_AMIGAOS_M68K - /* - * This does not use the glue code to hack around a compiler bug. - * - * When using the generated inline stubs, the compiler does not emit - * any frame information, making the unwind fail. As a result - * objc_enumerationMutation() might throw an exception that could never - * be caught. If, however, we're using a function pointer instead of - * the inline stub, the compiler does generate a frame and everything - * works fine. - */ - register void *a6 __asm__("a6") = ObjFWRTBase; - uintptr_t enumerationMutation = (((uintptr_t)ObjFWRTBase) - 0x8A); - ((void (*)(id __asm__("a0")))enumerationMutation)(object); - (void)a6; -#else - glue_objc_enumerationMutation(object); -#endif - - OF_UNREACHABLE -} - -#ifdef HAVE_SJLJ_EXCEPTIONS -int -__gnu_objc_personality_sj0(int version, int actions, uint64_t exClass, - void *ex, void *ctx) -{ -# ifdef OF_AMIGAOS_M68K - return glue___gnu_objc_personality(version, actions, &exClass, ex, ctx); -# else - return glue___gnu_objc_personality(version, actions, exClass, ex, ctx); -# endif -} -#else -int -__gnu_objc_personality_v0(int version, int actions, uint64_t exClass, - void *ex, void *ctx) -{ -# ifdef OF_AMIGAOS_M68K - return glue___gnu_objc_personality(version, actions, &exClass, ex, ctx); -# else - return glue___gnu_objc_personality(version, actions, exClass, ex, ctx); -# endif -} -#endif - -id -objc_retain(id object) -{ - return glue_objc_retain(object); -} - -id -objc_retainBlock(id block) -{ - return glue_objc_retainBlock(block); -} - -id -objc_retainAutorelease(id object) -{ - return glue_objc_retainAutorelease(object); -} - -void -objc_release(id object) -{ - glue_objc_release(object); -} - -id -objc_autorelease(id object) -{ - return glue_objc_autorelease(object); -} - -id -objc_autoreleaseReturnValue(id object) -{ - return glue_objc_autoreleaseReturnValue(object); -} - -id -objc_retainAutoreleaseReturnValue(id object) -{ - return glue_objc_retainAutoreleaseReturnValue(object); -} - -id -objc_retainAutoreleasedReturnValue(id object) -{ - return glue_objc_retainAutoreleasedReturnValue(object); -} - -id -objc_storeStrong(id *object, id value) -{ - return glue_objc_storeStrong(object, value); -} - -id -objc_storeWeak(id *object, id value) -{ - return glue_objc_storeWeak(object, value); -} - -id -objc_loadWeakRetained(id *object) -{ - return glue_objc_loadWeakRetained(object); -} - -id -objc_initWeak(id *object, id value) -{ - return glue_objc_initWeak(object, value); -} - -void -objc_destroyWeak(id *object) -{ - glue_objc_destroyWeak(object); -} - -id -objc_loadWeak(id *object) -{ - return glue_objc_loadWeak(object); -} - -void -objc_copyWeak(id *dest, id *src) -{ - glue_objc_copyWeak(dest, src); -} - -void -objc_moveWeak(id *dest, id *src) -{ - glue_objc_moveWeak(dest, src); -} - -SEL -sel_registerName(const char *name) -{ - return glue_sel_registerName(name); -} - -const char * -sel_getName(SEL selector) -{ - return glue_sel_getName(selector); -} - -bool -sel_isEqual(SEL selector1, SEL selector2) -{ - return glue_sel_isEqual(selector1, selector2); -} - -Class -objc_allocateClassPair(Class superclass, const char *name, size_t extraBytes) -{ - return glue_objc_allocateClassPair(superclass, name, extraBytes); -} - -void -objc_registerClassPair(Class class) -{ - glue_objc_registerClassPair(class); +objc_sync_enter(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((int (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 102))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((int (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 100))(object); +#endif +} + +int +objc_sync_exit(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((int (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 108))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((int (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 106))(object); +#endif +} + +id _Nullable +objc_getProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1"), ptrdiff_t __asm__("d0"), bool __asm__("d1")))(((uintptr_t)ObjFWRTBase) - 114))(self, _cmd, offset, atomic); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nonnull, SEL _Nonnull, ptrdiff_t, bool))*(void **)(((uintptr_t)ObjFWRTBase) - 112))(self, _cmd, offset, atomic); +#endif +} + +void +objc_setProperty(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1"), ptrdiff_t __asm__("d0"), id _Nullable __asm__("a2"), bool __asm__("d1"), signed char __asm__("d2")))(((uintptr_t)ObjFWRTBase) - 120))(self, _cmd, offset, value, atomic, copy); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nonnull, SEL _Nonnull, ptrdiff_t, id _Nullable, bool, signed char))*(void **)(((uintptr_t)ObjFWRTBase) - 118))(self, _cmd, offset, value, atomic, copy); +#endif +} + +void +objc_getPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(void *_Nonnull __asm__("a0"), const void *_Nonnull __asm__("a1"), ptrdiff_t __asm__("d0"), bool __asm__("d1"), bool __asm__("d2")))(((uintptr_t)ObjFWRTBase) - 126))(dest, src, size, atomic, strong); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(void *_Nonnull, const void *_Nonnull, ptrdiff_t, bool, bool))*(void **)(((uintptr_t)ObjFWRTBase) - 124))(dest, src, size, atomic, strong); +#endif +} + +void +objc_setPropertyStruct(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(void *_Nonnull __asm__("a0"), const void *_Nonnull __asm__("a1"), ptrdiff_t __asm__("d0"), bool __asm__("d1"), bool __asm__("d2")))(((uintptr_t)ObjFWRTBase) - 132))(dest, src, size, atomic, strong); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(void *_Nonnull, const void *_Nonnull, ptrdiff_t, bool, bool))*(void **)(((uintptr_t)ObjFWRTBase) - 130))(dest, src, size, atomic, strong); +#endif +} + +void +objc_enumerationMutation(id _Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 138))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 136))(object); +#endif +} + +int +__gnu_objc_personality(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((int (*)(int __asm__("d0"), int __asm__("d1"), uint64_t *_Nonnull __asm__("d2"), void *_Nonnull __asm__("a0"), void *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 144))(version, actions, exClass, ex, ctx); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((int (*)(int, int, uint64_t *_Nonnull, void *_Nonnull, void *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 142))(version, actions, exClass, ex, ctx); +#endif +} + +id _Nullable +objc_retain(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 150))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 148))(object); +#endif +} + +id _Nullable +objc_retainBlock(id _Nullable block) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 156))(block); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 154))(block); +#endif +} + +id _Nullable +objc_retainAutorelease(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 162))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 160))(object); +#endif +} + +void +objc_release(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 168))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 166))(object); +#endif +} + +id _Nullable +objc_autorelease(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 174))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 172))(object); +#endif +} + +id _Nullable +objc_autoreleaseReturnValue(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 180))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 178))(object); +#endif +} + +id _Nullable +objc_retainAutoreleaseReturnValue(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 186))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 184))(object); +#endif +} + +id _Nullable +objc_retainAutoreleasedReturnValue(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 192))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 190))(object); +#endif +} + +id _Nullable +objc_storeStrong(id _Nullable *_Nonnull object, id _Nullable value) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable *_Nonnull __asm__("a0"), id _Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 198))(object, value); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable *_Nonnull, id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 196))(object, value); +#endif +} + +id _Nullable +objc_storeWeak(id _Nullable *_Nonnull object, id _Nullable value) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable *_Nonnull __asm__("a0"), id _Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 204))(object, value); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable *_Nonnull, id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 202))(object, value); +#endif +} + +id _Nullable +objc_loadWeakRetained(id _Nullable *_Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 210))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 208))(object); +#endif +} + +id _Nullable +objc_initWeak(id _Nullable *_Nonnull object, id _Nullable value) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable *_Nonnull __asm__("a0"), id _Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 216))(object, value); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable *_Nonnull, id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 214))(object, value); +#endif +} + +void +objc_destroyWeak(id _Nullable *_Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nullable *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 222))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nullable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 220))(object); +#endif +} + +id _Nullable +objc_loadWeak(id _Nullable *_Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 228))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 226))(object); +#endif +} + +void +objc_copyWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nullable *_Nonnull __asm__("a0"), id _Nullable *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 234))(dest, src); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nullable *_Nonnull, id _Nullable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 232))(dest, src); +#endif +} + +void +objc_moveWeak(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(id _Nullable *_Nonnull __asm__("a0"), id _Nullable *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 240))(dest, src); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(id _Nullable *_Nonnull, id _Nullable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 238))(dest, src); +#endif +} + +SEL _Nonnull +sel_registerName(const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((SEL _Nonnull (*)(const char *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 246))(name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((SEL _Nonnull (*)(const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 244))(name); +#endif +} + +const char *_Nonnull +sel_getName(SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nonnull (*)(SEL _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 252))(selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nonnull (*)(SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 250))(selector); +#endif +} + +bool +sel_isEqual(SEL _Nonnull selector1, SEL _Nonnull selector2) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(SEL _Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 258))(selector1, selector2); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(SEL _Nonnull, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 256))(selector1, selector2); +#endif +} + +Class _Nonnull +objc_allocateClassPair(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nonnull (*)(Class _Nullable __asm__("a0"), const char *_Nonnull __asm__("a1"), size_t __asm__("d0")))(((uintptr_t)ObjFWRTBase) - 264))(superclass, name, extraBytes); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nonnull (*)(Class _Nullable, const char *_Nonnull, size_t))*(void **)(((uintptr_t)ObjFWRTBase) - 262))(superclass, name, extraBytes); +#endif +} + +void +objc_registerClassPair(Class _Nonnull class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(Class _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 270))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(Class _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 268))(class); +#endif } unsigned int -objc_getClassList(Class *buffer, unsigned int count) +objc_getClassList(Class _Nonnull *_Nullable buffer, unsigned int count) { - return glue_objc_getClassList(buffer, count); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((unsigned int (*)(Class _Nonnull *_Nullable __asm__("a0"), unsigned int __asm__("d0")))(((uintptr_t)ObjFWRTBase) - 276))(buffer, count); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((unsigned int (*)(Class _Nonnull *_Nullable, unsigned int))*(void **)(((uintptr_t)ObjFWRTBase) - 274))(buffer, count); +#endif } -Class * -objc_copyClassList(unsigned int *length) +Class _Nonnull *_Nonnull +objc_copyClassList(unsigned int *_Nullable length) { - return glue_objc_copyClassList(length); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nonnull *_Nonnull (*)(unsigned int *_Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 282))(length); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nonnull *_Nonnull (*)(unsigned int *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 280))(length); +#endif } bool -class_isMetaClass(Class class) -{ - return glue_class_isMetaClass(class); -} - -const char * -class_getName(Class class) -{ - return glue_class_getName(class); -} - -Class -class_getSuperclass(Class class) -{ - return glue_class_getSuperclass(class); +class_isMetaClass(Class _Nullable class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Class _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 288))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Class _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 286))(class); +#endif +} + +const char *_Nullable +class_getName(Class _Nullable class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nullable (*)(Class _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 294))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nullable (*)(Class _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 292))(class); +#endif +} + +Class _Nullable +class_getSuperclass(Class _Nullable class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(Class _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 300))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(Class _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 298))(class); +#endif } unsigned long -class_getInstanceSize(Class class) -{ - return glue_class_getInstanceSize(class); -} - -bool -class_respondsToSelector(Class class, SEL selector) -{ - return glue_class_respondsToSelector(class, selector); -} - -bool -class_conformsToProtocol(Class class, Protocol *protocol) -{ - return glue_class_conformsToProtocol(class, protocol); -} - -IMP -class_getMethodImplementation(Class class, SEL selector) -{ - return glue_class_getMethodImplementation(class, selector); -} - -IMP -class_getMethodImplementation_stret(Class class, SEL selector) -{ - return glue_class_getMethodImplementation_stret(class, selector); -} - -Method -class_getInstanceMethod(Class class, SEL selector) -{ - return glue_class_getInstanceMethod(class, selector); -} - -bool -class_addMethod(Class class, SEL selector, IMP implementation, - const char *typeEncoding) -{ - return glue_class_addMethod(class, selector, implementation, - typeEncoding); -} - -IMP -class_replaceMethod(Class class, SEL selector, IMP implementation, - const char *typeEncoding) -{ - return glue_class_replaceMethod(class, selector, implementation, - typeEncoding); -} - -Class -object_getClass(id object) -{ - return glue_object_getClass(object); -} - -Class -object_setClass(id object, Class class) -{ - return glue_object_setClass(object, class); -} - -const char * -object_getClassName(id object) -{ - return glue_object_getClassName(object); -} - -const char * -protocol_getName(Protocol *protocol) -{ - return glue_protocol_getName(protocol); -} - -bool -protocol_isEqual(Protocol *protocol1, Protocol *protocol2) -{ - return glue_protocol_isEqual(protocol1, protocol2); -} - -bool -protocol_conformsToProtocol(Protocol *protocol1, Protocol *protocol2) -{ - return glue_protocol_conformsToProtocol(protocol1, protocol2); -} - -objc_uncaught_exception_handler_t -objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t handler) -{ - return glue_objc_setUncaughtExceptionHandler(handler); -} - -void -objc_setForwardHandler(IMP forward, IMP stretForward) -{ - glue_objc_setForwardHandler(forward, stretForward); -} - -void -objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler) -{ - glue_objc_setEnumerationMutationHandler(handler); -} - -id -objc_constructInstance(Class class, void *_Nullable bytes) -{ - return glue_objc_constructInstance(class, bytes); -} - -void -objc_exit(void) -{ - glue_objc_exit(); -} - -Ivar * -class_copyIvarList(Class class, unsigned int *outCount) -{ - return glue_class_copyIvarList(class, outCount); -} - -const char * -ivar_getName(Ivar ivar) -{ - return glue_ivar_getName(ivar); -} - -const char * -ivar_getTypeEncoding(Ivar ivar) -{ - return glue_ivar_getTypeEncoding(ivar); -} - -ptrdiff_t -ivar_getOffset(Ivar ivar) -{ - return glue_ivar_getOffset(ivar); -} - -Method * -class_copyMethodList(Class class, unsigned int *outCount) -{ - return glue_class_copyMethodList(class, outCount); -} - -SEL -method_getName(Method method) -{ - return glue_method_getName(method); -} - -const char * -method_getTypeEncoding(Method method) -{ - return glue_method_getTypeEncoding(method); -} - -objc_property_t * -class_copyPropertyList(Class class, unsigned int *outCount) -{ - return glue_class_copyPropertyList(class, outCount); -} - -const char * -property_getName(objc_property_t property) -{ - return glue_property_getName(property); -} - -char * -property_copyAttributeValue(objc_property_t property, const char *name) -{ - return glue_property_copyAttributeValue(property, name); -} - -void * -objc_destructInstance(id object) -{ - return glue_objc_destructInstance(object); -} - -void * -objc_autoreleasePoolPush(void) -{ - return glue_objc_autoreleasePoolPush(); -} - -void -objc_autoreleasePoolPop(void *pool) -{ - glue_objc_autoreleasePoolPop(pool); -} - -id -_objc_rootAutorelease(id object) -{ - return glue__objc_rootAutorelease(object); -} - -struct objc_hashtable * -objc_hashtable_new(objc_hashtable_hash_func hash, - objc_hashtable_equal_func equal, uint32_t size) -{ - return glue_objc_hashtable_new(hash, equal, size); -} - -void -objc_hashtable_set(struct objc_hashtable *table, const void *key, - const void *object) -{ - glue_objc_hashtable_set(table, key, object); -} - -void * -objc_hashtable_get(struct objc_hashtable *table, const void *key) -{ - return glue_objc_hashtable_get(table, key); -} - -void -objc_hashtable_delete(struct objc_hashtable *table, const void *key) -{ - glue_objc_hashtable_delete(table, key); -} - -void -objc_hashtable_free(struct objc_hashtable *table) -{ - glue_objc_hashtable_free(table); +class_getInstanceSize(Class _Nullable class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((unsigned long (*)(Class _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 306))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((unsigned long (*)(Class _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 304))(class); +#endif +} + +bool +class_respondsToSelector(Class _Nullable class, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Class _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 312))(class, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Class _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 310))(class, selector); +#endif +} + +bool +class_conformsToProtocol(Class _Nullable class, Protocol *_Nonnull p) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Class _Nullable __asm__("a0"), Protocol *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 318))(class, p); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Class _Nullable, Protocol *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 316))(class, p); +#endif +} + +IMP _Nullable +class_getMethodImplementation(Class _Nullable class, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nullable (*)(Class _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 324))(class, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nullable (*)(Class _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 322))(class, selector); +#endif +} + +IMP _Nullable +class_getMethodImplementation_stret(Class _Nullable class, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nullable (*)(Class _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 330))(class, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nullable (*)(Class _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 328))(class, selector); +#endif +} + +Method _Nullable +class_getInstanceMethod(Class _Nullable class, SEL _Nonnull selector) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Method _Nullable (*)(Class _Nullable __asm__("a0"), SEL _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 336))(class, selector); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Method _Nullable (*)(Class _Nullable, SEL _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 334))(class, selector); +#endif +} + +bool +class_addMethod(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Class _Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1"), IMP _Nonnull __asm__("a2"), const char *_Nullable __asm__("a3")))(((uintptr_t)ObjFWRTBase) - 342))(class, selector, implementation, typeEncoding); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, const char *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 340))(class, selector, implementation, typeEncoding); +#endif +} + +IMP _Nullable +class_replaceMethod(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((IMP _Nullable (*)(Class _Nonnull __asm__("a0"), SEL _Nonnull __asm__("a1"), IMP _Nonnull __asm__("a2"), const char *_Nullable __asm__("a3")))(((uintptr_t)ObjFWRTBase) - 348))(class, selector, implementation, typeEncoding); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((IMP _Nullable (*)(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, const char *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 346))(class, selector, implementation, typeEncoding); +#endif +} + +Class _Nullable +object_getClass(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 354))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 352))(object); +#endif +} + +Class _Nullable +object_setClass(id _Nullable object, Class _Nonnull class) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Class _Nullable (*)(id _Nullable __asm__("a0"), Class _Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 360))(object, class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Class _Nullable (*)(id _Nullable, Class _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 358))(object, class); +#endif +} + +const char *_Nullable +object_getClassName(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 366))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 364))(object); +#endif +} + +const char *_Nonnull +protocol_getName(Protocol *_Nonnull protocol) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nonnull (*)(Protocol *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 372))(protocol); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nonnull (*)(Protocol *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 370))(protocol); +#endif +} + +bool +protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Protocol *_Nonnull __asm__("a0"), Protocol *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 378))(protocol1, protocol2); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Protocol *_Nonnull, Protocol *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 376))(protocol1, protocol2); +#endif +} + +bool +protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(Protocol *_Nonnull __asm__("a0"), Protocol *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 384))(protocol1, protocol2); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(Protocol *_Nonnull, Protocol *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 382))(protocol1, protocol2); +#endif +} + +_Nullable objc_uncaught_exception_handler_t +objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t _Nullable handler) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((_Nullable objc_uncaught_exception_handler_t (*)(objc_uncaught_exception_handler_t _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 390))(handler); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((_Nullable objc_uncaught_exception_handler_t (*)(objc_uncaught_exception_handler_t _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 388))(handler); +#endif +} + +void +objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(IMP _Nullable __asm__("a0"), IMP _Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 396))(forward, stretForward); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(IMP _Nullable, IMP _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 394))(forward, stretForward); +#endif +} + +void +objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t _Nullable hadler) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(objc_enumeration_mutation_handler_t _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 402))(hadler); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(objc_enumeration_mutation_handler_t _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 400))(hadler); +#endif +} + +id _Nullable +objc_constructInstance(Class _Nullable class, void *_Nullable bytes) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(Class _Nullable __asm__("a0"), void *_Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 408))(class, bytes); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(Class _Nullable, void *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 406))(class, bytes); +#endif +} + +void +objc_exit() +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)())(((uintptr_t)ObjFWRTBase) - 414))(); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)())*(void **)(((uintptr_t)ObjFWRTBase) - 412))(); +#endif +} + +Ivar _Nullable *_Nullable +class_copyIvarList(Class _Nullable class, unsigned int *_Nullable outCount) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Ivar _Nullable *_Nullable (*)(Class _Nullable __asm__("a0"), unsigned int *_Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 420))(class, outCount); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Ivar _Nullable *_Nullable (*)(Class _Nullable, unsigned int *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 418))(class, outCount); +#endif +} + +const char *_Nonnull +ivar_getName(Ivar _Nonnull ivar) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nonnull (*)(Ivar _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 426))(ivar); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nonnull (*)(Ivar _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 424))(ivar); +#endif +} + +const char *_Nonnull +ivar_getTypeEncoding(Ivar _Nonnull ivar) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nonnull (*)(Ivar _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 432))(ivar); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nonnull (*)(Ivar _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 430))(ivar); +#endif +} + +ptrdiff_t +ivar_getOffset(Ivar _Nonnull ivar) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((ptrdiff_t (*)(Ivar _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 438))(ivar); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((ptrdiff_t (*)(Ivar _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 436))(ivar); +#endif +} + +Method _Nullable *_Nullable +class_copyMethodList(Class _Nullable class, unsigned int *_Nullable outCount) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((Method _Nullable *_Nullable (*)(Class _Nullable __asm__("a0"), unsigned int *_Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 444))(class, outCount); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((Method _Nullable *_Nullable (*)(Class _Nullable, unsigned int *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 442))(class, outCount); +#endif +} + +SEL _Nonnull +method_getName(Method _Nonnull method) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((SEL _Nonnull (*)(Method _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 450))(method); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((SEL _Nonnull (*)(Method _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 448))(method); +#endif +} + +const char *_Nullable +method_getTypeEncoding(Method _Nonnull method) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nullable (*)(Method _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 456))(method); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nullable (*)(Method _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 454))(method); +#endif +} + +objc_property_t _Nullable *_Nullable +class_copyPropertyList(Class _Nullable class, unsigned int *_Nullable outCount) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((objc_property_t _Nullable *_Nullable (*)(Class _Nullable __asm__("a0"), unsigned int *_Nullable __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 462))(class, outCount); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((objc_property_t _Nullable *_Nullable (*)(Class _Nullable, unsigned int *_Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 460))(class, outCount); +#endif +} + +const char *_Nonnull +property_getName(objc_property_t _Nonnull property) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((const char *_Nonnull (*)(objc_property_t _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 468))(property); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((const char *_Nonnull (*)(objc_property_t _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 466))(property); +#endif +} + +char *_Nullable +property_copyAttributeValue(objc_property_t _Nonnull property, const char *_Nonnull name) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((char *_Nullable (*)(objc_property_t _Nonnull __asm__("a0"), const char *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 474))(property, name); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((char *_Nullable (*)(objc_property_t _Nonnull, const char *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 472))(property, name); +#endif +} + +void *_Nullable +objc_destructInstance(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((void *_Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 480))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((void *_Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 478))(object); +#endif +} + +void *_Null_unspecified +objc_autoreleasePoolPush() +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((void *_Null_unspecified (*)())(((uintptr_t)ObjFWRTBase) - 486))(); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((void *_Null_unspecified (*)())*(void **)(((uintptr_t)ObjFWRTBase) - 484))(); +#endif +} + +void +objc_autoreleasePoolPop(void *_Null_unspecified pool) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(void *_Null_unspecified __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 492))(pool); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(void *_Null_unspecified))*(void **)(((uintptr_t)ObjFWRTBase) - 490))(pool); +#endif +} + +id _Nullable +_objc_rootAutorelease(id _Nullable object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 498))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 496))(object); +#endif +} + +struct objc_hashtable *_Nonnull +objc_hashtable_new(objc_hashtable_hash_func hash, objc_hashtable_equal_func equal, uint32_t size) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((struct objc_hashtable *_Nonnull (*)(objc_hashtable_hash_func __asm__("a0"), objc_hashtable_equal_func __asm__("a1"), uint32_t __asm__("d0")))(((uintptr_t)ObjFWRTBase) - 504))(hash, equal, size); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((struct objc_hashtable *_Nonnull (*)(objc_hashtable_hash_func, objc_hashtable_equal_func, uint32_t))*(void **)(((uintptr_t)ObjFWRTBase) - 502))(hash, equal, size); +#endif +} + +void +objc_hashtable_set(struct objc_hashtable *_Nonnull table, const void *_Nonnull key, const void *_Nonnull object) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(struct objc_hashtable *_Nonnull __asm__("a0"), const void *_Nonnull __asm__("a1"), const void *_Nonnull __asm__("a2")))(((uintptr_t)ObjFWRTBase) - 510))(table, key, object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(struct objc_hashtable *_Nonnull, const void *_Nonnull, const void *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 508))(table, key, object); +#endif +} + +void *_Nullable +objc_hashtable_get(struct objc_hashtable *_Nonnull table, const void *_Nonnull key) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((void *_Nullable (*)(struct objc_hashtable *_Nonnull __asm__("a0"), const void *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 516))(table, key); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((void *_Nullable (*)(struct objc_hashtable *_Nonnull, const void *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 514))(table, key); +#endif +} + +void +objc_hashtable_delete(struct objc_hashtable *_Nonnull table, const void *_Nonnull key) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(struct objc_hashtable *_Nonnull __asm__("a0"), const void *_Nonnull __asm__("a1")))(((uintptr_t)ObjFWRTBase) - 522))(table, key); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(struct objc_hashtable *_Nonnull, const void *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 520))(table, key); +#endif +} + +void +objc_hashtable_free(struct objc_hashtable *_Nonnull table) +{ +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(struct objc_hashtable *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 528))(table); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(struct objc_hashtable *_Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 526))(table); +#endif } void objc_setTaggedPointerSecret(uintptr_t secret) { - glue_objc_setTaggedPointerSecret(secret); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + ((void (*)(uintptr_t __asm__("d0")))(((uintptr_t)ObjFWRTBase) - 534))(secret); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + __extension__ ((void (*)(uintptr_t))*(void **)(((uintptr_t)ObjFWRTBase) - 532))(secret); +#endif } int -objc_registerTaggedPointerClass(Class class) +objc_registerTaggedPointerClass(Class _Nonnull class) { - return glue_objc_registerTaggedPointerClass(class); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((int (*)(Class _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 540))(class); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((int (*)(Class _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 538))(class); +#endif } bool -object_isTaggedPointer(id object) +object_isTaggedPointer(id _Nullable object) { - return glue_object_isTaggedPointer(object); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((bool (*)(id _Nullable __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 546))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((bool (*)(id _Nullable))*(void **)(((uintptr_t)ObjFWRTBase) - 544))(object); +#endif } uintptr_t -object_getTaggedPointerValue(id object) +object_getTaggedPointerValue(id _Nonnull object) { - return glue_object_getTaggedPointerValue(object); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((uintptr_t (*)(id _Nonnull __asm__("a0")))(((uintptr_t)ObjFWRTBase) - 552))(object); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((uintptr_t (*)(id _Nonnull))*(void **)(((uintptr_t)ObjFWRTBase) - 550))(object); +#endif } -id +id _Nullable objc_createTaggedPointer(int class, uintptr_t value) { - return glue_objc_createTaggedPointer(class, value); +#if defined(OF_AMIGAOS_M68K) + register struct Library *a6 __asm__("a6") = ObjFWRTBase; + (void)a6; + return ((id _Nullable (*)(int __asm__("d0"), uintptr_t __asm__("d1")))(((uintptr_t)ObjFWRTBase) - 558))(class, value); +#elif defined(OF_MORPHOS) + __asm__ __volatile__ ( + "mr %%r12, %0" + :: "r"(ObjFWRTBase) : "r12" + ); + + return __extension__ ((id _Nullable (*)(int, uintptr_t))*(void **)(((uintptr_t)ObjFWRTBase) - 556))(class, value); +#endif } Index: src/runtime/lookup-asm/lookup-asm-arm-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-arm-elf.S +++ src/runtime/lookup-asm/lookup-asm-arm-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-arm64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-arm64-elf.S +++ src/runtime/lookup-asm/lookup-asm-arm64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-mips-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-mips-elf.S +++ src/runtime/lookup-asm/lookup-asm-mips-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-mips64-n64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-mips64-n64-elf.S +++ src/runtime/lookup-asm/lookup-asm-mips64-n64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-powerpc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-powerpc-elf.S +++ src/runtime/lookup-asm/lookup-asm-powerpc-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-sparc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-sparc-elf.S +++ src/runtime/lookup-asm/lookup-asm-sparc-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-sparc64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-sparc64-elf.S +++ src/runtime/lookup-asm/lookup-asm-sparc64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup-asm/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,82 +15,80 @@ #include "config.h" #include "platform.h" -.intel_syntax noprefix - .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: - mov edx, [esp+4] - test edx, edx - jz short ret_nil - - bt edx, 0 - jc short .Ltagged_pointer_\name - - mov edx, [edx] - mov edx, [edx+32] + movl 4(%esp), %edx + testl %edx, %edx + jz ret_nil + + testb $1, %dl + jnz .Ltagged_pointer_\name + + movl (%edx), %edx + movl 32(%edx), %edx .Lmain_\name: - mov eax, [esp+8] + movl 8(%esp), %eax #ifdef OF_SELUID24 - movzx ecx, byte ptr [eax+2] - mov edx, [edx+ecx*4] + movzbl 2(%eax), %ecx + movl (%edx,%ecx,4), %edx #endif - movzx ecx, byte ptr [eax+1] - mov edx, [edx+ecx*4] - movzx ecx, byte ptr [eax] - mov eax, [edx+ecx*4] + movzbl 1(%eax), %ecx + movl (%edx,%ecx,4), %edx + movzbl (%eax), %ecx + movl (%edx,%ecx,4), %eax - test eax, eax - jz short 0f + testl %eax, %eax + jz 0f ret 0: call get_eip - add eax, offset _GLOBAL_OFFSET_TABLE_ - lea eax, [eax+\not_found@GOTOFF] - jmp eax + addl $_GLOBAL_OFFSET_TABLE_, %eax + lea \not_found@GOTOFF(%eax), %eax + jmp *%eax .Ltagged_pointer_\name: call get_eip - add eax, offset _GLOBAL_OFFSET_TABLE_ - - lea ecx, [eax+objc_tagged_pointer_secret@GOTOFF] - xor edx, [ecx] - and dl, 0xE - movzx edx, dl - - lea eax, [eax+objc_tagged_pointer_classes@GOTOFF] - mov edx, [eax+edx*2] - mov edx, [edx+32] - - jmp short .Lmain_\name + addl $_GLOBAL_OFFSET_TABLE_, %eax + + leal objc_tagged_pointer_secret@GOTOFF(%eax), %ecx + xorl (%ecx), %edx + andb $0xE, %dl + movzbl %dl, %edx + + leal objc_tagged_pointer_classes@GOTOFF(%eax), %eax + movl (%eax,%edx,2), %edx + movl 32(%edx), %edx + + jmp .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro generate_lookup_super name lookup \name: - mov edx, [esp+4] - mov eax, [edx] - test eax, eax - jz short ret_nil - - mov [esp+4], eax - mov edx, [edx+4] - mov edx, [edx+32] - jmp short .Lmain_\lookup + movl 4(%esp), %edx + movl (%edx), %eax + testl %eax, %eax + jz ret_nil + + movl %eax, 4(%esp) + mov 4(%edx), %edx + mov 32(%edx), %edx + jmp .Lmain_\lookup .type \name, %function .size \name, .-\name .endm generate_lookup objc_msg_lookup objc_method_not_found @@ -100,20 +96,20 @@ generate_lookup_super objc_msg_lookup_super objc_msg_lookup generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret ret_nil: call get_eip - add eax, offset _GLOBAL_OFFSET_TABLE_ - lea eax, [eax+nil_method@GOTOFF] + addl $_GLOBAL_OFFSET_TABLE_, %eax + leal nil_method@GOTOFF(%eax), %eax ret nil_method: - xor eax, eax + xorl %eax, %eax ret get_eip: - mov eax, [esp] + movl (%esp), %eax ret #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-x86-win32.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-win32.S +++ src/runtime/lookup-asm/lookup-asm-x86-win32.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,78 +13,84 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl _objc_msg_lookup .globl _objc_msg_lookup_stret .globl _objc_msg_lookup_super .globl _objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: - mov edx, [esp+4] - test edx, edx - jz short ret_nil - - bt edx, 0 - jc short .Ltagged_pointer_\name - - mov edx, [edx] - mov edx, [edx+32] + movl 4(%esp), %edx + testl %edx, %edx + jz ret_nil + + testb $1, %dl + jnz .Ltagged_pointer_\name + + movl (%edx), %edx + movl 32(%edx), %edx .Lmain_\name: - mov eax, [esp+8] + movl 8(%esp), %eax #ifdef OF_SELUID24 - movzx ecx, byte ptr [eax+2] - mov edx, [edx+ecx*4] + movzbl 2(%eax), %ecx + movl (%edx,%ecx,4), %edx #endif - movzx ecx, byte ptr [eax+1] - mov edx, [edx+ecx*4] - movzx ecx, byte ptr [eax] - mov eax, [edx+ecx*4] + movzbl 1(%eax), %ecx + movl (%edx,%ecx,4), %edx + movzbl (%eax), %ecx + movl (%edx,%ecx,4), %eax - test eax, eax + testl %eax, %eax jz \not_found ret .Ltagged_pointer_\name: - xor edx, _objc_tagged_pointer_secret - and dl, 0xE - movzx edx, dl - - mov edx, [_objc_tagged_pointer_classes+edx*2] - mov edx, [edx+32] - - jmp short .Lmain_\name + xorl _objc_tagged_pointer_secret, %edx + andb $0xE, %dl + movzbl %dl, %edx + + movl _objc_tagged_pointer_classes(,%edx,2), %edx + movl 32(%edx), %edx + + jmp .Lmain_\name +.def \name +.scl 2 +.type 32 +.endef .endm .macro generate_lookup_super name lookup \name: - mov edx, [esp+4] - mov eax, [edx] - test eax, eax - jz short ret_nil - - mov [esp+4], eax - mov edx, [edx+4] - mov edx, [edx+32] - jmp short .Lmain_\lookup + movl 4(%esp), %edx + movl (%edx), %eax + test %eax, %eax + jz ret_nil + + movl %eax, 4(%esp) + movl 4(%edx), %edx + movl 32(%edx), %edx + jmp .Lmain_\lookup +.def \name +.scl 2 +.type 32 +.endef .endm generate_lookup _objc_msg_lookup _objc_method_not_found generate_lookup _objc_msg_lookup_stret _objc_method_not_found_stret generate_lookup_super _objc_msg_lookup_super _objc_msg_lookup generate_lookup_super _objc_msg_lookup_super_stret _objc_msg_lookup_stret ret_nil: - mov eax, offset nil_method + movl $nil_method, %eax ret nil_method: - xor eax, eax + xorl %eax, %eax ret Index: src/runtime/lookup-asm/lookup-asm-x86_64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-elf.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -17,71 +15,69 @@ #include "config.h" #include "platform.h" -.intel_syntax noprefix - .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: - test rdi, rdi - jz short ret_nil - - bt edi, 0 - jc short .Ltagged_pointer_\name - - mov r8, [rdi] - mov r8, [r8+64] + testq %rdi, %rdi + jz ret_nil + + testb $1, %dil + jnz .Ltagged_pointer_\name + + movq (%rdi), %r8 + movq 64(%r8), %r8 .Lmain_\name: - mov rax, [rsi] - movzx ecx, ah - movzx edx, al + movq (%rsi), %rax + movzbl %ah, %ecx + movzbl %al, %edx #ifdef OF_SELUID24 - shr eax, 16 + shrl $16, %eax - mov r8, [r8+rax*8] + movq (%r8,%rax,8), %r8 #endif - mov r8, [r8+rcx*8] - mov rax, [r8+rdx*8] + movq (%r8,%rcx,8), %r8 + movq (%r8,%rdx,8), %rax - test rax, rax - jz short \not_found@PLT + testq %rax, %rax + jz \not_found@PLT ret .Ltagged_pointer_\name: - mov rax, [rip+objc_tagged_pointer_secret@GOTPCREL] - xor rdi, [rax] - and dil, 0xE - movzx r8, dil - - mov rax, [rip+objc_tagged_pointer_classes@GOTPCREL] - mov r8, [rax+r8*4] - mov r8, [r8+64] - - jmp short .Lmain_\name + movq objc_tagged_pointer_secret@GOTPCREL(%rip), %rax + xorq (%rax), %rdi + andb $0xE, %dil + movzbl %dil, %r8d + + movq objc_tagged_pointer_classes@GOTPCREL(%rip), %rax + movq (%rax,%r8,4), %r8 + movq 64(%r8), %r8 + + jmp .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro generate_lookup_super name lookup \name: - mov r8, rdi - mov rdi, [rdi] - test rdi, rdi - jz short ret_nil - - mov r8, [r8+8] - mov r8, [r8+64] - jmp short .Lmain_\lookup + movq %rdi, %r8 + movq (%rdi), %rdi + testq %rdi, %rdi + jz ret_nil + + movq 8(%r8), %r8 + movq 64(%r8), %r8 + jmp .Lmain_\lookup .type \name, %function .size \name, .-\name .endm generate_lookup objc_msg_lookup objc_method_not_found @@ -88,15 +84,15 @@ generate_lookup objc_msg_lookup_stret objc_method_not_found_stret generate_lookup_super objc_msg_lookup_super objc_msg_lookup generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret ret_nil: - lea rax, [rip+nil_method] + leaq nil_method(%rip), %rax ret nil_method: - xor rax, rax + xorq %rax, %rax ret #ifdef OF_LINUX .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm/lookup-asm-x86_64-win64.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-win64.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-win64.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,84 +13,91 @@ * file. */ #include "config.h" -.intel_syntax noprefix - .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro generate_lookup name not_found \name: - test rcx, rcx - jz short ret_nil - - bt ecx, 0 - jc short .Ltagged_pointer_\name - - mov r8, [rcx] - mov r8, [r8+56] + testq %rcx, %rcx + jz ret_nil + + testb $1, %cl + jnz .Ltagged_pointer_\name + + movq (%rcx), %r8 + movq 56(%r8), %r8 .Lmain_\name: - mov r10, rcx - mov r11, rdx + movq %rcx, %r10 + movq %rdx, %r11 - mov rax, [rdx] - movzx ecx, ah - movzx edx, al + movq (%rdx), %rax + movzbl %ah, %ecx + movzbl %al, %edx #ifdef OF_SELUID24 - shr eax, 16 + shrl $16, %eax - mov r8, [r8+rax*8] + movq (%r8,%rax,8), %r8 #endif - mov r8, [r8+rcx*8] - mov rax, [r8+rdx*8] + movq (%r8,%rcx,8), %r8 + movq (%r8,%rdx,8), %rax - test rax, rax - jz short 0f + testq %rax, %rax + jz 0f ret 0: - mov rcx, r10 - mov rdx, r11 + movq %r10, %rcx + movq %r11, %rdx jmp \not_found .Ltagged_pointer_\name: - xor rcx, objc_tagged_pointer_secret - and cl, 0xE - movzx r8, cl - - mov r8, [objc_tagged_pointer_classes+r8*4] - mov r8, [r8+56] - - jmp short .Lmain_\name + xorq objc_tagged_pointer_secret(%rip), %rcx + andb $0xE, %cl + movzbl %cl, %r8d + + leaq objc_tagged_pointer_classes(%rip), %rax + movq (%rax,%r8,4), %r8 + movq 56(%r8), %r8 + + jmp .Lmain_\name +.def \name +.scl 2 +.type 32 +.endef .endm .macro generate_lookup_super name lookup \name: - mov r8, rcx - mov rcx, [rcx] - test rcx, rcx - jz short ret_nil - - mov r8, [r8+8] - mov r8, [r8+56] - jmp short .Lmain_\lookup + movq %rcx, %r8 + movq (%rcx), %rcx + testq %rcx, %rcx + jz ret_nil + + movq 8(%r8), %r8 + movq 56(%r8), %r8 + jmp .Lmain_\lookup +.def \name +.scl 2 +.type 32 +.endef .endm generate_lookup objc_msg_lookup objc_method_not_found generate_lookup objc_msg_lookup_stret objc_method_not_found_stret generate_lookup_super objc_msg_lookup_super objc_msg_lookup generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret ret_nil: - mov rax, offset nil_method + leaq nil_method(%rip), %rax ret nil_method: - xor rax, rax + xorq %rax, %rax ret Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/lookup.m ================================================================== --- src/runtime/lookup.m +++ src/runtime/lookup.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/method.m ================================================================== --- src/runtime/method.m +++ src/runtime/method.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/misc.m ================================================================== --- src/runtime/misc.m +++ src/runtime/misc.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/mutex.m ================================================================== --- src/runtime/mutex.m +++ src/runtime/mutex.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/once.m ================================================================== --- src/runtime/once.m +++ src/runtime/once.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -270,10 +268,19 @@ # else # define OBJC_M68K_ARG(type, name, reg) \ register type reg_##name __asm__(#reg); \ type name = reg_##name; # endif + +extern bool objc_init(unsigned int, struct objc_libc *); +# ifdef HAVE_SJLJ_EXCEPTIONS +# define __gnu_objc_personality(version, actions, exClass, ex, ctx) \ + __gnu_objc_personality_sj0(version, actions, *exClass, ex, ctx) +# else +# define __gnu_objc_personality(version, actions, exClass, ex, ctx) \ + __gnu_objc_personality_v0(version, actions, *exClass, ex, ctx) +# endif #endif extern void objc_register_all_categories(struct objc_symtab *_Nonnull); extern struct objc_category *_Nullable *_Nullable objc_categories_for_class(Class _Nonnull); Index: src/runtime/property.m ================================================================== --- src/runtime/property.m +++ src/runtime/property.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/protocol.m ================================================================== --- src/runtime/protocol.m +++ src/runtime/protocol.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/sparsearray.m ================================================================== --- src/runtime/sparsearray.m +++ src/runtime/sparsearray.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/static-instances.m ================================================================== --- src/runtime/static-instances.m +++ src/runtime/static-instances.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/synchronized.m ================================================================== --- src/runtime/synchronized.m +++ src/runtime/synchronized.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/tagged-pointer.m ================================================================== --- src/runtime/tagged-pointer.m +++ src/runtime/tagged-pointer.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/threading.m ================================================================== --- src/runtime/threading.m +++ src/runtime/threading.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/runtime/tlskey.m ================================================================== --- src/runtime/tlskey.m +++ src/runtime/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/scrypt.h ================================================================== --- src/scrypt.h +++ src/scrypt.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/scrypt.m ================================================================== --- src/scrypt.m +++ src/scrypt.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,10 +13,15 @@ * file. */ #include "config.h" +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED +#endif +#define _HPUX_ALT_XOPEN_SOCKET_API + #ifdef OF_NINTENDO_3DS # include /* For memalign() */ #endif #include Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/thread.h ================================================================== --- src/thread.h +++ src/thread.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/thread.m ================================================================== --- src/thread.m +++ src/thread.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/tlskey.h ================================================================== --- src/tlskey.h +++ src/tlskey.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/tlskey.m ================================================================== --- src/tlskey.m +++ src/tlskey.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/unicode.h ================================================================== --- src/unicode.h +++ src/unicode.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/unicode.m ================================================================== --- src/unicode.m +++ src/unicode.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: src/unistd_wrapper.h ================================================================== --- src/unistd_wrapper.h +++ src/unistd_wrapper.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/ForwardingTests.m ================================================================== --- tests/ForwardingTests.m +++ tests/ForwardingTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/ImportTest.m ================================================================== --- tests/ImportTest.m +++ tests/ImportTest.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFArrayTests.m ================================================================== --- tests/OFArrayTests.m +++ tests/OFArrayTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -51,12 +49,11 @@ } return self; } -- (instancetype)initWithObject: (id)object - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)object arguments: (va_list)arguments { self = [super init]; @try { _array = [[OFMutableArray alloc] initWithObject: object @@ -67,12 +64,11 @@ } return self; } -- (instancetype)initWithObjects: (id const *)objects - count: (size_t)count +- (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { _array = [[OFMutableArray alloc] initWithObjects: objects @@ -108,22 +104,18 @@ { if (self == [SimpleMutableArray class]) [self inheritMethodsFromClass: [SimpleArray class]]; } -- (void)insertObject: (id)object - atIndex: (size_t)idx +- (void)insertObject: (id)object atIndex: (size_t)idx { - [_array insertObject: object - atIndex: idx]; + [_array insertObject: object atIndex: idx]; } -- (void)replaceObjectAtIndex: (size_t)idx - withObject: (id)object +- (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object { - [_array replaceObjectAtIndex: idx - withObject: object]; + [_array replaceObjectAtIndex: idx withObject: object]; } - (void)removeObjectAtIndex: (size_t)idx { [_array removeObjectAtIndex: idx]; @@ -146,22 +138,21 @@ TEST(@"+[arrayWithObjects:]", (a[0] = [arrayClass arrayWithObjects: @"Foo", @"Bar", @"Baz", nil])) TEST(@"+[arrayWithObjects:count:]", - (a[1] = [arrayClass arrayWithObjects: c_ary - count: 3]) && + (a[1] = [arrayClass arrayWithObjects: c_ary count: 3]) && [a[1] isEqual: a[0]]) TEST(@"-[description]", [a[0].description isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"]) TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) && R([m[0] addObject: c_ary[2]])) - TEST(@"-[insertObject:atIndex:]", R([m[0] insertObject: c_ary[1] - atIndex: 1])) + TEST(@"-[insertObject:atIndex:]", + R([m[0] insertObject: c_ary[1] atIndex: 1])) TEST(@"-[count]", m[0].count == 3 && a[0].count == 3 && a[1].count == 3) TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]]) @@ -193,26 +184,23 @@ TEST(@"-[objectsInRange:]", [[a[0] objectsInRange: of_range(1, 2)] isEqual: [arrayClass arrayWithObjects: c_ary[1], c_ary[2], nil]]) TEST(@"-[replaceObject:withObject:]", - R([m[0] replaceObject: c_ary[1] - withObject: c_ary[0]]) && + R([m[0] replaceObject: c_ary[1] withObject: c_ary[0]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[replaceObject:identicalTo:]", - R([m[0] replaceObjectIdenticalTo: c_ary[0] - withObject: c_ary[1]]) && + R([m[0] replaceObjectIdenticalTo: c_ary[0] withObject: c_ary[1]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[1]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[replaceObjectAtIndex:withObject:]", - R([m[0] replaceObjectAtIndex: 0 - withObject: c_ary[0]]) && + R([m[0] replaceObjectAtIndex: 0 withObject: c_ary[0]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[removeObject:]", @@ -282,12 +270,11 @@ TEST(@"-[objectEnumerator]", (enumerator = [m[0] objectEnumerator])) while ((obj = [enumerator nextObject]) != nil) { if (![obj isEqual: c_ary[i]]) ok = false; - [m[0] replaceObjectAtIndex: i - withObject: @""]; + [m[0] replaceObjectAtIndex: i withObject: @""]; i++; } if (m[0].count != i) ok = false; @@ -304,26 +291,22 @@ i = 0; for (OFString *s in m[0]) { if (![s isEqual: c_ary[i]]) ok = false; - [m[0] replaceObjectAtIndex: i - withObject: @""]; + [m[0] replaceObjectAtIndex: i withObject: @""]; i++; } if (m[0].count != i) ok = false; TEST(@"Fast Enumeration", ok) - [m[0] replaceObjectAtIndex: 0 - withObject: c_ary[0]]; - [m[0] replaceObjectAtIndex: 1 - withObject: c_ary[1]]; - [m[0] replaceObjectAtIndex: 2 - withObject: c_ary[2]]; + [m[0] replaceObjectAtIndex: 0 withObject: c_ary[0]]; + [m[0] replaceObjectAtIndex: 1 withObject: c_ary[1]]; + [m[0] replaceObjectAtIndex: 2 withObject: c_ary[2]]; ok = false; i = 0; @try { for (OFString *s in m[0]) { Index: tests/OFBlockTests.m ================================================================== --- tests/OFBlockTests.m +++ tests/OFBlockTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFCharacterSetTests.m ================================================================== --- tests/OFCharacterSetTests.m +++ tests/OFCharacterSetTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFDNSResolverTests.m ================================================================== --- tests/OFDNSResolverTests.m +++ tests/OFDNSResolverTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFDataTests.m ================================================================== --- tests/OFDataTests.m +++ tests/OFDataTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -65,76 +63,82 @@ TEST(@"-[compare]", [mutable compare: immutable] == 0 && R([mutable removeLastItem]) && [immutable compare: mutable] == OF_ORDERED_DESCENDING && [mutable compare: immutable] == OF_ORDERED_ASCENDING && - [[OFData dataWithItems: "aa" - count: 2] compare: - [OFData dataWithItems: "z" - count: 1]] == OF_ORDERED_ASCENDING) + [[OFData dataWithItems: "aa" count: 2] compare: + [OFData dataWithItems: "z" count: 1]] == OF_ORDERED_ASCENDING) TEST(@"-[hash]", immutable.hash == 0x634A529F) - mutable = [OFMutableData dataWithItems: "abcdef" - count: 6]; + mutable = [OFMutableData dataWithItems: "abcdef" count: 6]; TEST(@"-[removeLastItem]", R([mutable removeLastItem]) && mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0) TEST(@"-[removeItemsInRange:]", R([mutable removeItemsInRange: of_range(1, 2)]) && mutable.count == 3 && memcmp(mutable.items, "ade", 3) == 0) TEST(@"-[insertItems:atIndex:count:]", - R([mutable insertItems: "bc" - atIndex: 1 - count: 2]) && mutable.count == 5 && - memcmp(mutable.items, "abcde", 5) == 0) + R([mutable insertItems: "bc" atIndex: 1 count: 2]) && + mutable.count == 5 && memcmp(mutable.items, "abcde", 5) == 0) immutable = [OFData dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; - TEST(@"-[rangeOfString:options:range:]", - R(range = [immutable rangeOfData: [OFData dataWithItems: "aa" - count: 1 - itemSize: 2] - options: 0 - range: of_range(0, 7)]) && - range.location == 0 && range.length == 1 && - R(range = [immutable rangeOfData: [OFData dataWithItems: "aa" - count: 1 - itemSize: 2] - options: OF_DATA_SEARCH_BACKWARDS - range: of_range(0, 7)]) && - range.location == 5 && range.length == 1 && - R(range = [immutable rangeOfData: [OFData dataWithItems: "ac" - count: 1 - itemSize: 2] - options: 0 - range: of_range(0, 7)]) && - range.location == 2 && range.length == 1 && - R(range = [immutable rangeOfData: [OFData dataWithItems: "aabb" - count: 2 - itemSize: 2] - options: 0 - range: of_range(0, 7)]) && - range.location == 5 && range.length == 2 && + + range = [immutable rangeOfData: [OFData dataWithItems: "aa" + count: 1 + itemSize: 2] + options: 0 + range: of_range(0, 7)]; + TEST(@"-[rangeOfData:options:range:] #1", + range.location == 0 && range.length == 1) + + range = [immutable rangeOfData: [OFData dataWithItems: "aa" + count: 1 + itemSize: 2] + options: OF_DATA_SEARCH_BACKWARDS + range: of_range(0, 7)]; + TEST(@"-[rangeOfData:options:range:] #2", + range.location == 5 && range.length == 1) + + range = [immutable rangeOfData: [OFData dataWithItems: "ac" + count: 1 + itemSize: 2] + options: 0 + range: of_range(0, 7)]; + TEST(@"-[rangeOfData:options:range:] #3", + range.location == 2 && range.length == 1) + + range = [immutable rangeOfData: [OFData dataWithItems: "aabb" + count: 2 + itemSize: 2] + options: 0 + range: of_range(0, 7)]; + TEST(@"-[rangeOfData:options:range:] #4", + range.location == 5 && range.length == 2) + + TEST(@"-[rangeOfData:options:range:] #5", R(range = [immutable rangeOfData: [OFData dataWithItems: "aa" count: 1 itemSize: 2] options: 0 range: of_range(1, 6)]) && - range.location == 5 && range.length == 1 && - R(range = [immutable rangeOfData: [OFData dataWithItems: "aa" - count: 1 - itemSize: 2] - options: OF_DATA_SEARCH_BACKWARDS - range: of_range(0, 5)]) && + range.location == 5 && range.length == 1) + + range = [immutable rangeOfData: [OFData dataWithItems: "aa" + count: 1 + itemSize: 2] + options: OF_DATA_SEARCH_BACKWARDS + range: of_range(0, 5)]; + TEST(@"-[rangeOfData:options:range:] #6", range.location == 0 && range.length == 1) EXPECT_EXCEPTION( - @"-[rangeOfString:options:range:] failing on different itemSize", + @"-[rangeOfData:options:range:] failing on different itemSize", OFInvalidArgumentException, [immutable rangeOfData: [OFData dataWithItems: "aaa" count: 1 itemSize: 3] options: 0 @@ -189,21 +193,19 @@ TEST(@"+[dataWithBase64EncodedString:]", memcmp([[OFData dataWithBase64EncodedString: @"YWJjZGU="] items], "abcde", 5) == 0) TEST(@"Building strings", - (mutable = [OFMutableData dataWithItems: str - count: 6]) && + (mutable = [OFMutableData dataWithItems: str count: 6]) && R([mutable addItem: ""]) && strcmp(mutable.items, str) == 0) EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]", OFOutOfRangeException, [mutable itemAtIndex: mutable.count]) EXPECT_EXCEPTION(@"Detect out of range in -[addItems:count:]", - OFOutOfRangeException, [mutable addItems: raw[0] - count: SIZE_MAX]) + OFOutOfRangeException, [mutable addItems: raw[0] count: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]", OFOutOfRangeException, [mutable removeItemsInRange: of_range(mutable.count, 1)]) Index: tests/OFDateTests.m ================================================================== --- tests/OFDateTests.m +++ tests/OFDateTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFDictionaryTests.m ================================================================== --- tests/OFDictionaryTests.m +++ tests/OFDictionaryTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -55,12 +53,11 @@ } return self; } -- (instancetype)initWithKey: (id)key - arguments: (va_list)arguments +- (instancetype)initWithKey: (id)key arguments: (va_list)arguments { self = [super init]; @try { _dictionary = [[OFMutableDictionary alloc] @@ -121,17 +118,15 @@ { if (self == [SimpleMutableDictionary class]) [self inheritMethodsFromClass: [SimpleDictionary class]]; } -- (void)setObject: (id)object - forKey: (id)key +- (void)setObject: (id)object forKey: (id)key { bool existed = ([_dictionary objectForKey: key] == nil); - [_dictionary setObject: object - forKey: key]; + [_dictionary setObject: object forKey: key]; if (existed) _mutations++; } @@ -167,14 +162,12 @@ OFMutableDictionary *mutDict = [mutableDictionaryClass dictionary]; OFDictionary *dict; OFEnumerator *keyEnumerator, *objectEnumerator; OFArray *keysArray, *valuesArray; - [mutDict setObject: values[0] - forKey: keys[0]]; - [mutDict setValue: values[1] - forKey: keys[1]]; + [mutDict setObject: values[0] forKey: keys[0]]; + [mutDict setValue: values[1] forKey: keys[1]]; TEST(@"-[objectForKey:]", [[mutDict objectForKey: keys[0]] isEqual: values[0]] && [[mutDict objectForKey: keys[1]] isEqual: values[1]] && [mutDict objectForKey: @"key3"] == nil) @@ -184,12 +177,11 @@ [[mutDict valueForKey: @"@count"] isEqual: [OFNumber numberWithInt: 2]]) EXPECT_EXCEPTION(@"Catching -[setValue:forKey:] on immutable " @"dictionary", OFUndefinedKeyException, - [[dictionaryClass dictionary] setValue: @"x" - forKey: @"x"]) + [[dictionaryClass dictionary] setValue: @"x" forKey: @"x"]) TEST(@"-[containsObject:]", [mutDict containsObject: values[0]] && ![mutDict containsObject: @"nonexistent"]) @@ -225,12 +217,11 @@ [mutDict removeObjectForKey: keys[0]]; EXPECT_EXCEPTION(@"Detection of mutation during enumeration", OFEnumerationMutationException, [keyEnumerator nextObject]); - [mutDict setObject: values[0] - forKey: keys[0]]; + [mutDict setObject: values[0] forKey: keys[0]]; size_t i = 0; bool ok = true; for (OFString *key in mutDict) { @@ -237,24 +228,21 @@ if (i > 1 || ![key isEqual: keys[i]]) { ok = false; break; } - [mutDict setObject: [mutDict objectForKey: key] - forKey: key]; + [mutDict setObject: [mutDict objectForKey: key] forKey: key]; i++; } TEST(@"Fast Enumeration", ok) ok = false; @try { for (OFString *key in mutDict) { (void)key; - - [mutDict setObject: @"" - forKey: @""]; + [mutDict setObject: @"" forKey: @""]; } } @catch (OFEnumerationMutationException *e) { ok = true; } @@ -361,29 +349,25 @@ TEST(@"-[mutableCopy]", (mutDict = [[dict mutableCopy] autorelease]) && mutDict.count == dict.count && [[mutDict objectForKey: keys[0]] isEqual: values[0]] && [[mutDict objectForKey: keys[1]] isEqual: values[1]] && - R([mutDict setObject: @"value3" - forKey: @"key3"]) && + R([mutDict setObject: @"value3" forKey: @"key3"]) && [[mutDict objectForKey: @"key3"] isEqual: @"value3"] && [[mutDict objectForKey: keys[0]] isEqual: values[0]] && - R([mutDict setObject: @"foo" - forKey: keys[0]]) && + R([mutDict setObject: @"foo" forKey: keys[0]]) && [[mutDict objectForKey: keys[0]] isEqual: @"foo"]) TEST(@"-[removeObjectForKey:]", R([mutDict removeObjectForKey: keys[0]]) && [mutDict objectForKey: keys[0]] == nil) - [mutDict setObject: @"foo" - forKey: keys[0]]; + [mutDict setObject: @"foo" forKey: keys[0]]; TEST(@"-[isEqual:]", ![mutDict isEqual: dict] && R([mutDict removeObjectForKey: @"key3"]) && ![mutDict isEqual: dict] && - R([mutDict setObject: values[0] - forKey: keys[0]]) && + R([mutDict setObject: values[0] forKey: keys[0]]) && [mutDict isEqual: dict]) objc_autoreleasePoolPop(pool); } Index: tests/OFHMACTests.m ================================================================== --- tests/OFHMACTests.m +++ tests/OFHMACTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -51,12 +49,11 @@ @implementation TestsAppDelegate (OFHMACTests) - (void)HMACTests { void *pool = objc_autoreleasePoolPush(); - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; OFHMAC *HMAC_MD5, *HMAC_SHA1, *HMAC_RMD160; OFHMAC *HMAC_SHA256, *HMAC_SHA384, *HMAC_SHA512; TEST(@"+[HMACWithHashClass:] with MD5", (HMAC_MD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class] @@ -80,44 +77,31 @@ EXPECT_EXCEPTION(@"Detection of missing key", OFInvalidArgumentException, [HMAC_MD5 updateWithBuffer: "" length: 0]) TEST(@"-[setKey:length:] with MD5", - R([HMAC_MD5 setKey: key - length: key_length])) + R([HMAC_MD5 setKey: key length: key_length])) TEST(@"-[setKey:length:] with SHA-1", - R([HMAC_SHA1 setKey: key - length: key_length])) + R([HMAC_SHA1 setKey: key length: key_length])) TEST(@"-[setKey:length:] with RIPEMD-160", - R([HMAC_RMD160 setKey: key - length: key_length])) + R([HMAC_RMD160 setKey: key length: key_length])) TEST(@"-[setKey:length:] with SHA-256", - R([HMAC_SHA256 setKey: key - length: key_length])) + R([HMAC_SHA256 setKey: key length: key_length])) TEST(@"-[setKey:length:] with SHA-384", - R([HMAC_SHA384 setKey: key - length: key_length])) + R([HMAC_SHA384 setKey: key length: key_length])) TEST(@"-[setKey:length:] with SHA-512", - R([HMAC_SHA512 setKey: key - length: key_length])) + R([HMAC_SHA512 setKey: key length: key_length])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [HMAC_MD5 updateWithBuffer: buf - length: len]; - [HMAC_SHA1 updateWithBuffer: buf - length: len]; - [HMAC_RMD160 updateWithBuffer: buf - length: len]; - [HMAC_SHA256 updateWithBuffer: buf - length: len]; - [HMAC_SHA384 updateWithBuffer: buf - length: len]; - [HMAC_SHA512 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [HMAC_MD5 updateWithBuffer: buf length: len]; + [HMAC_SHA1 updateWithBuffer: buf length: len]; + [HMAC_RMD160 updateWithBuffer: buf length: len]; + [HMAC_SHA256 updateWithBuffer: buf length: len]; + [HMAC_SHA384 updateWithBuffer: buf length: len]; + [HMAC_SHA512 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[digest] with MD5", memcmp(HMAC_MD5.digest, digest_md5, HMAC_MD5.digestSize) == 0) Index: tests/OFHTTPClientTests.m ================================================================== --- tests/OFHTTPClientTests.m +++ tests/OFHTTPClientTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -43,12 +41,11 @@ char buffer[5]; [cond lock]; listener = [OFTCPSocket socket]; - _port = [listener bindToHost: @"127.0.0.1" - port: 0]; + _port = [listener bindToHost: @"127.0.0.1" port: 0]; [listener listen]; [cond signal]; [cond unlock]; @@ -72,12 +69,11 @@ OF_ENSURE(0); if (![[client readLine] isEqual: @""]) OF_ENSURE(0); - [client readIntoBuffer: buffer - exactLength: 5]; + [client readIntoBuffer: buffer exactLength: 5]; if (memcmp(buffer, "Hello", 5) != 0) OF_ENSURE(0); [client writeString: @"HTTP/1.0 200 OK\r\n" @"cONTeNT-lENgTH: 7\r\n" Index: tests/OFHTTPCookieManagerTests.m ================================================================== --- tests/OFHTTPCookieManagerTests.m +++ tests/OFHTTPCookieManagerTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -45,12 +43,12 @@ [OFArray arrayWithObject: cookie[0]]]) cookie[1] = [OFHTTPCookie cookieWithName: @"test" value: @"2" domain: @"webkeks.org"]; - TEST(@"-[addCookie:forURL:] #2", R([manager addCookie: cookie[1] - forURL: URL[0]])) + TEST(@"-[addCookie:forURL:] #2", + R([manager addCookie: cookie[1] forURL: URL[0]])) TEST(@"-[cookiesForURL:] #2", [[manager cookiesForURL: URL[0]] isEqual: [OFArray arrayWithObject: cookie[0]]] && [[manager cookiesForURL: URL[3]] isEqual: [OFArray array]]) @@ -57,12 +55,12 @@ cookie[2] = [OFHTTPCookie cookieWithName: @"test" value: @"3" domain: @"nil.im"]; cookie[2].secure = true; - TEST(@"-[addCookie:forURL:] #3", R([manager addCookie: cookie[2] - forURL: URL[1]])) + TEST(@"-[addCookie:forURL:] #3", + R([manager addCookie: cookie[2] forURL: URL[1]])) TEST(@"-[cookiesForURL:] #3", [[manager cookiesForURL: URL[1]] isEqual: [OFArray arrayWithObject: cookie[2]]] && [[manager cookiesForURL: URL[0]] isEqual: [OFArray array]]) @@ -70,12 +68,12 @@ cookie[2].expires = [OFDate dateWithTimeIntervalSinceNow: -1]; cookie[3] = [OFHTTPCookie cookieWithName: @"test" value: @"4" domain: @"nil.im"]; cookie[3].domain = @".nil.im"; - TEST(@"-[addCookie:forURL:] #4", R([manager addCookie: cookie[3] - forURL: URL[1]])) + TEST(@"-[addCookie:forURL:] #4", + R([manager addCookie: cookie[3] forURL: URL[1]])) TEST(@"-[cookiesForURL:] #4", [[manager cookiesForURL: URL[1]] isEqual: [OFArray arrayWithObject: cookie[3]]] && [[manager cookiesForURL: URL[2]] isEqual: @@ -82,12 +80,12 @@ [OFArray arrayWithObject: cookie[3]]]) cookie[4] = [OFHTTPCookie cookieWithName: @"bar" value: @"5" domain: @"test.nil.im"]; - TEST(@"-[addCookie:forURL:] #5", R([manager addCookie: cookie[4] - forURL: URL[0]])) + TEST(@"-[addCookie:forURL:] #5", + R([manager addCookie: cookie[4] forURL: URL[0]])) TEST(@"-[cookiesForURL:] #5", [[manager cookiesForURL: URL[0]] isEqual: [OFArray arrayWithObject: cookie[3]]] && [[manager cookiesForURL: URL[2]] isEqual: Index: tests/OFHTTPCookieTests.m ================================================================== --- tests/OFHTTPCookieTests.m +++ tests/OFHTTPCookieTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFINIFileTests.m ================================================================== --- tests/OFINIFileTests.m +++ tests/OFINIFileTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -67,54 +65,46 @@ TEST(@"-[stringForKey:]", [[tests stringForKey: @"foo"] isEqual: @"bar"] && [[foobar stringForKey: @"quxquxqux"] isEqual: @"hello\"wΓΆrld"]) TEST(@"-[setString:forKey:]", - R([tests setString: @"baz" - forKey: @"foo"]) && - R([tests setString: @"new" - forKey: @"new"]) && - R([foobar setString: @"a\fb" - forKey: @"qux3"])) - - TEST(@"-[integerForKey:defaultValue:]", - [types integerForKey: @"integer" - defaultValue: 2] == 0x20) - - TEST(@"-[setInteger:forKey:]", R([types setInteger: 0x10 - forKey: @"integer"])) + R([tests setString: @"baz" forKey: @"foo"]) && + R([tests setString: @"new" forKey: @"new"]) && + R([foobar setString: @"a\fb" forKey: @"qux3"])) + + TEST(@"-[longLongForKey:defaultValue:]", + [types longLongForKey: @"integer" defaultValue: 2] == 0x20) + + TEST(@"-[setLongLong:forKey:]", + R([types setLongLong: 0x10 forKey: @"integer"])) TEST(@"-[boolForKey:defaultValue:]", - [types boolForKey: @"bool" - defaultValue: false] == true) + [types boolForKey: @"bool" defaultValue: false] == true) - TEST(@"-[setBool:forKey:]", R([types setBool: false - forKey: @"bool"])) + TEST(@"-[setBool:forKey:]", R([types setBool: false forKey: @"bool"])) TEST(@"-[floatForKey:defaultValue:]", - [types floatForKey: @"float" - defaultValue: 1] == 0.5f) + [types floatForKey: @"float" defaultValue: 1] == 0.5f) - TEST(@"-[setFloat:forKey:]", R([types setFloat: 0.25f - forKey: @"float"])) + TEST(@"-[setFloat:forKey:]", + R([types setFloat: 0.25f forKey: @"float"])) TEST(@"-[doubleForKey:defaultValue:]", - [types doubleForKey: @"double" - defaultValue: 3] == 0.25) + [types doubleForKey: @"double" defaultValue: 3] == 0.25) - TEST(@"-[setDouble:forKey:]", R([types setDouble: 0.75 - forKey: @"double"])) + TEST(@"-[setDouble:forKey:]", + R([types setDouble: 0.75 forKey: @"double"])) array = [OFArray arrayWithObjects: @"1", @"2", nil]; - TEST(@"-[arrayForKey:]", - [[types arrayForKey: @"array1"] isEqual: array] && - [[types arrayForKey: @"array2"] isEqual: array] && - [[types arrayForKey: @"array3"] isEqual: [OFArray array]]) + TEST(@"-[stringArrayForKey:]", + [[types stringArrayForKey: @"array1"] isEqual: array] && + [[types stringArrayForKey: @"array2"] isEqual: array] && + [[types stringArrayForKey: @"array3"] isEqual: [OFArray array]]) array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; - TEST(@"-[setArray:forKey:]", R([types setArray: array - forKey: @"array1"])) + TEST(@"-[setStringArray:forKey:]", + R([types setStringArray: array forKey: @"array1"])) TEST(@"-[removeValueForKey:]", R([foobar removeValueForKey: @"quxqux "]) && R([types removeValueForKey: @"array2"])) Index: tests/OFIPXSocketTests.m ================================================================== --- tests/OFIPXSocketTests.m +++ tests/OFIPXSocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -33,24 +31,23 @@ TEST(@"+[socket]", (sock = [OFIPXSocket socket])) @try { TEST(@"-[bindToPort:packetType:]", - R(address1 = [sock bindToPort: 0 - packetType: 0])) + R(address1 = [sock bindToPort: 0 packetType: 0])) } @catch (OFBindFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFIPXSocket] -[bindToPort:packetType:]: " + @"\r[OFIPXSocket] -[bindToPort:packetType:]: " @"IPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFIPXSocket] -[bindToPort:packetType:]: " + @"\r[OFIPXSocket] -[bindToPort:packetType:]: " @"IPX not configured, skipping tests"]; break; default: @throw e; } @@ -58,21 +55,17 @@ objc_autoreleasePoolPop(pool); return; } TEST(@"-[sendBuffer:length:receiver:]", - R([sock sendBuffer: "Hello" - length: 5 - receiver: &address1])) + R([sock sendBuffer: "Hello" length: 5 receiver: &address1])) TEST(@"-[receiveIntoBuffer:length:sender:]", - [sock receiveIntoBuffer: buffer - length: 5 - sender: &address2] == 5 && + [sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 && memcmp(buffer, "Hello", 5) == 0 && of_socket_address_equal(&address1, &address2) && of_socket_address_hash(&address1) == of_socket_address_hash(&address2)) objc_autoreleasePoolPop(pool); } @end Index: tests/OFInvocationTests.m ================================================================== --- tests/OFInvocationTests.m +++ tests/OFInvocationTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -283,36 +281,33 @@ TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) && memcmp(&st, &st2, sizeof(st)) == 0) memset(&st2, '\0', sizeof(st2)); - TEST(@"-[setArgument:atIndex:] #1", R([invocation setArgument: &c - atIndex: 2])) - - TEST(@"-[setArgument:atIndex:] #2", R([invocation setArgument: &i - atIndex: 3])) - - TEST(@"-[setArgument:atIndex:] #3", R([invocation setArgument: &stp - atIndex: 4])) - - TEST(@"-[setArgument:atIndex:] #4", R([invocation setArgument: &st - atIndex: 5])) - - TEST(@"-[getArgument:atIndex:] #1", R([invocation getArgument: &c2 - atIndex: 2]) && - c == c2) - - TEST(@"-[getArgument:atIndex:] #2", R([invocation getArgument: &i2 - atIndex: 3]) && - i == i2) - - TEST(@"-[getArgument:atIndex:] #3", R([invocation getArgument: &stp2 - atIndex: 4]) && - stp == stp2) - - TEST(@"-[getArgument:atIndex:] #4", R([invocation getArgument: &st2 - atIndex: 5]) && + TEST(@"-[setArgument:atIndex:] #1", + R([invocation setArgument: &c atIndex: 2])) + + TEST(@"-[setArgument:atIndex:] #2", + R([invocation setArgument: &i atIndex: 3])) + + TEST(@"-[setArgument:atIndex:] #3", + R([invocation setArgument: &stp atIndex: 4])) + + TEST(@"-[setArgument:atIndex:] #4", + R([invocation setArgument: &st atIndex: 5])) + + TEST(@"-[getArgument:atIndex:] #1", + R([invocation getArgument: &c2 atIndex: 2]) && c == c2) + + TEST(@"-[getArgument:atIndex:] #2", + R([invocation getArgument: &i2 atIndex: 3]) && i == i2) + + TEST(@"-[getArgument:atIndex:] #3", + R([invocation getArgument: &stp2 atIndex: 4]) && stp == stp2) + + TEST(@"-[getArgument:atIndex:] #4", + R([invocation getArgument: &st2 atIndex: 5]) && memcmp(&st, &st2, sizeof(st)) == 0) objc_autoreleasePoolPop(pool); } @end Index: tests/OFJSONTests.m ================================================================== --- tests/OFJSONTests.m +++ tests/OFJSONTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFKernelEventObserverTests.m ================================================================== --- tests/OFKernelEventObserverTests.m +++ tests/OFKernelEventObserverTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -58,20 +56,16 @@ uint16_t port; _testsAppDelegate = testsAppDelegate; _server = [[OFTCPSocket alloc] init]; - port = [_server bindToHost: @"127.0.0.1" - port: 0]; + port = [_server bindToHost: @"127.0.0.1" port: 0]; [_server listen]; _client = [[OFTCPSocket alloc] init]; - [_client connectToHost: @"127.0.0.1" - port: port]; - - [_client writeBuffer: "0" - length: 1]; + [_client connectToHost: @"127.0.0.1" port: port]; + [_client writeBuffer: "0" length: 1]; } @catch (id e) { [self release]; @throw e; } @@ -153,12 +147,11 @@ inModule: module]; break; case 1: if (object == _accepted && - [object readIntoBuffer: &buf - length: 1] == 1 && buf == '0') + [object readIntoBuffer: &buf length: 1] == 1 && buf == '0') [_testsAppDelegate outputSuccess: @"-[observe] with data ready to read" inModule: module]; else { [_testsAppDelegate @@ -174,12 +167,11 @@ inModule: module]; break; case 2: if (object == _accepted && - [object readIntoBuffer: &buf - length: 1] == 0) + [object readIntoBuffer: &buf length: 1] == 0) [_testsAppDelegate outputSuccess: @"-[observe] with closed connection" inModule: module]; else { [_testsAppDelegate Index: tests/OFListTests.m ================================================================== --- tests/OFListTests.m +++ tests/OFListTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFLocaleTests.m ================================================================== --- tests/OFLocaleTests.m +++ tests/OFLocaleTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFMD5HashTests.m ================================================================== --- tests/OFMD5HashTests.m +++ tests/OFMD5HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -29,22 +27,19 @@ @implementation TestsAppDelegate (OFMD5HashTests) - (void)MD5HashTests { void *pool = objc_autoreleasePoolPush(); OFMD5Hash *md5, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (md5 = [OFMD5Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [md5 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [md5 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[md5 copy] autorelease])) @@ -52,11 +47,10 @@ memcmp(md5.digest, testfile_md5, 16) == 0 && memcmp(copy.digest, testfile_md5, 16) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length]", OFHashAlreadyCalculatedException, - [md5 updateWithBuffer: "" - length: 1]) + [md5 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFMethodSignatureTests.m ================================================================== --- tests/OFMethodSignatureTests.m +++ tests/OFMethodSignatureTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFNumberTests.m ================================================================== --- tests/OFNumberTests.m +++ tests/OFNumberTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -110,20 +108,17 @@ EXPECT_EXCEPTION(@"-[valueForKey:] with undefined key", OFUndefinedKeyException, [m valueForKey: @"undefined"]) TEST(@"-[setValue:forKey:]", - R([m setValue: @"World" - forKey: @"objectValue"]) && - R([m setValue: [OFObject class] - forKey: @"classValue"]) && + R([m setValue: @"World" forKey: @"objectValue"]) && + R([m setValue: [OFObject class] forKey: @"classValue"]) && [m.objectValue isEqual: @"World"] && [m.classValue isEqual: [OFObject class]]) EXPECT_EXCEPTION(@"-[setValue:forKey:] with undefined key", - OFUndefinedKeyException, [m setValue: @"x" - forKey: @"undefined"]) + OFUndefinedKeyException, [m setValue: @"x" forKey: @"undefined"]) m.boolValue = 1; m.charValue = 2; m.shortValue = 3; m.intValue = 4; Index: tests/OFPluginTests.m ================================================================== --- tests/OFPluginTests.m +++ tests/OFPluginTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFPropertyListTests.m ================================================================== --- tests/OFPropertyListTests.m +++ tests/OFPropertyListTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,12 +57,11 @@ - (void)propertyListTests { void *pool = objc_autoreleasePoolPush(); OFArray *array = [OFArray arrayWithObjects: @"Hello", - [OFData dataWithItems: "World!" - count: 6], + [OFData dataWithItems: "World!" count: 6], [OFDate dateWithTimeIntervalSince1970: 1521030896], [OFNumber numberWithBool: true], [OFNumber numberWithBool: false], [OFNumber numberWithFloat: 12.25f], [OFNumber numberWithInt: -10], Index: tests/OFRIPEMD160HashTests.m ================================================================== --- tests/OFRIPEMD160HashTests.m +++ tests/OFRIPEMD160HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,23 +28,20 @@ @implementation TestsAppDelegate (OFRIPEMD160HashTests) - (void)RIPEMD160HashTests { void *pool = objc_autoreleasePoolPush(); OFRIPEMD160Hash *rmd160, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (rmd160 = [OFRIPEMD160Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [rmd160 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [rmd160 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[rmd160 copy] autorelease])) @@ -54,11 +49,10 @@ memcmp(rmd160.digest, testfile_rmd160, 20) == 0 && memcmp(copy.digest, testfile_rmd160, 20) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length]", OFHashAlreadyCalculatedException, - [rmd160 updateWithBuffer: "" - length: 1]) + [rmd160 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSHA1HashTests.m ================================================================== --- tests/OFSHA1HashTests.m +++ tests/OFSHA1HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,22 +28,19 @@ @implementation TestsAppDelegate (SHA1HashTests) - (void)SHA1HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA1Hash *sha1, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (sha1 = [OFSHA1Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [sha1 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [sha1 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[sha1 copy] autorelease])) @@ -53,11 +48,10 @@ memcmp(sha1.digest, testfile_sha1, 20) == 0 && memcmp(copy.digest, testfile_sha1, 20) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, - [sha1 updateWithBuffer: "" - length: 1]) + [sha1 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSHA224HashTests.m ================================================================== --- tests/OFSHA224HashTests.m +++ tests/OFSHA224HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,22 +28,19 @@ @implementation TestsAppDelegate (SHA224HashTests) - (void)SHA224HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA224Hash *sha224, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (sha224 = [OFSHA224Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [sha224 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [sha224 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[sha224 copy] autorelease])) @@ -53,11 +48,10 @@ memcmp(sha224.digest, testfile_sha224, 28) == 0 && memcmp(copy.digest, testfile_sha224, 28) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, - [sha224 updateWithBuffer: "" - length: 1]) + [sha224 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSHA256HashTests.m ================================================================== --- tests/OFSHA256HashTests.m +++ tests/OFSHA256HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,22 +28,19 @@ @implementation TestsAppDelegate (SHA256HashTests) - (void)SHA256HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA256Hash *sha256, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (sha256 = [OFSHA256Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[64]; - size_t len = [f readIntoBuffer: buf - length: 64]; - [sha256 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 64]; + [sha256 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[sha256 copy] autorelease])) @@ -53,11 +48,10 @@ memcmp(sha256.digest, testfile_sha256, 32) == 0 && memcmp(copy.digest, testfile_sha256, 32) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, - [sha256 updateWithBuffer: "" - length: 1]) + [sha256 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSHA384HashTests.m ================================================================== --- tests/OFSHA384HashTests.m +++ tests/OFSHA384HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,22 +29,19 @@ @implementation TestsAppDelegate (SHA384HashTests) - (void)SHA384HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA384Hash *sha384, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (sha384 = [OFSHA384Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[128]; - size_t len = [f readIntoBuffer: buf - length: 128]; - [sha384 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 128]; + [sha384 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[sha384 copy] autorelease])) @@ -54,11 +49,10 @@ memcmp(sha384.digest, testfile_sha384, 48) == 0 && memcmp(copy.digest, testfile_sha384, 48) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, - [sha384 updateWithBuffer: "" - length: 1]) + [sha384 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSHA512HashTests.m ================================================================== --- tests/OFSHA512HashTests.m +++ tests/OFSHA512HashTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -32,22 +30,19 @@ @implementation TestsAppDelegate (SHA512HashTests) - (void)SHA512HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA512Hash *sha512, *copy; - OFFile *f = [OFFile fileWithPath: @"testfile.bin" - mode: @"r"]; + OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", (sha512 = [OFSHA512Hash cryptoHashWithAllowsSwappableMemory: true])) while (!f.atEndOfStream) { char buf[128]; - size_t len = [f readIntoBuffer: buf - length: 128]; - [sha512 updateWithBuffer: buf - length: len]; + size_t len = [f readIntoBuffer: buf length: 128]; + [sha512 updateWithBuffer: buf length: len]; } [f close]; TEST(@"-[copy]", (copy = [[sha512 copy] autorelease])) @@ -55,11 +50,10 @@ memcmp(sha512.digest, testfile_sha512, 64) == 0 && memcmp(copy.digest, testfile_sha512, 64) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, - [sha512 updateWithBuffer: "" - length: 1]) + [sha512 updateWithBuffer: "" length: 1]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFSPXSocketTests.m ================================================================== --- tests/OFSPXSocketTests.m +++ tests/OFSPXSocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -92,23 +90,23 @@ } @catch (OFBindFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToPort:]: " @"IPX unsupported, skipping tests"]; break; case ESOCKTNOSUPPORT: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToPort:]: " @"SPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXSocket] -[bindToPort:]: " + @"\r[OFSPXSocket] -[bindToPort:]: " @"IPX not configured, skipping tests"]; break; default: @throw e; } @@ -122,23 +120,19 @@ port = of_socket_address_get_port(&address1); TEST(@"-[listen]", R([sockServer listen])) TEST(@"-[connectToNode:network:port:]", - R([sockClient connectToNode: node - network: network - port: port])) + R([sockClient connectToNode: node network: network port: port])) TEST(@"-[accept]", (sockAccepted = [sockServer accept])) TEST(@"-[sendBuffer:length:]", - R([sockAccepted sendBuffer: "Hello" - length: 5])) + R([sockAccepted sendBuffer: "Hello" length: 5])) TEST(@"-[receiveIntoBuffer:length:]", - [sockClient receiveIntoBuffer: buffer - length: 5] == 5 && + [sockClient receiveIntoBuffer: buffer length: 5] == 5 && memcmp(buffer, "Hello", 5) == 0) TEST(@"-[remoteAddress]", (address2 = sockAccepted.remoteAddress) && R(of_socket_address_get_ipx_node(address2, node2)) && @@ -178,11 +172,11 @@ } @catch (OFObserveFailedException *e) { switch (e.errNo) { case ENOTSOCK: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXSocket] -[asyncAccept] & " + @"\r[OFSPXSocket] -[asyncAccept] & " @"-[asyncConnectToNode:network:port:]: select() " @"not supported for SPX, skipping test"]; break; default: @throw e; Index: tests/OFSPXStreamSocketTests.m ================================================================== --- tests/OFSPXStreamSocketTests.m +++ tests/OFSPXStreamSocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -92,23 +90,23 @@ } @catch (OFBindFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXStreamSocket] -[bindToPort:]: " + @"\r[OFSPXStreamSocket] -[bindToPort:]: " @"IPX unsupported, skipping tests"]; break; case ESOCKTNOSUPPORT: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXStreamSocket] -[bindToPort:]: " + @"\r[OFSPXStreamSocket] -[bindToPort:]: " @"SPX unsupported, skipping tests"]; break; case EADDRNOTAVAIL: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXStreamSocket] -[bindToPort:]: " + @"\r[OFSPXStreamSocket] -[bindToPort:]: " @"IPX not configured, skipping tests"]; break; default: @throw e; } @@ -122,27 +120,22 @@ port = of_socket_address_get_port(&address1); TEST(@"-[listen]", R([sockServer listen])) TEST(@"-[connectToNode:network:port:]", - R([sockClient connectToNode: node - network: network - port: port])) + R([sockClient connectToNode: node network: network port: port])) TEST(@"-[accept]", (sockAccepted = [sockServer accept])) /* Test reassembly (this would not work with OFSPXSocket) */ TEST(@"-[writeBuffer:length:]", - R([sockAccepted writeBuffer: "Hello" - length: 5])) + R([sockAccepted writeBuffer: "Hello" length: 5])) TEST(@"-[readIntoBuffer:length:]", - [sockClient readIntoBuffer: buffer - length: 2] == 2 && + [sockClient readIntoBuffer: buffer length: 2] == 2 && memcmp(buffer, "He", 2) == 0 && - [sockClient readIntoBuffer: buffer - length: 3] == 3 && + [sockClient readIntoBuffer: buffer length: 3] == 3 && memcmp(buffer, "llo", 3) == 0) TEST(@"-[remoteAddress]", (address2 = sockAccepted.remoteAddress) && R(of_socket_address_get_ipx_node(address2, node2)) && @@ -182,11 +175,11 @@ } @catch (OFObserveFailedException *e) { switch (e.errNo) { case ENOTSOCK: [of_stdout setForegroundColor: [OFColor lime]]; [of_stdout writeLine: - @"[OFSPXStreamSocket] -[asyncAccept] & " + @"\r[OFSPXStreamSocket] -[asyncAccept] & " @"-[asyncConnectToNode:network:port:]: select() " @"not supported for SPX, skipping test"]; break; default: @throw e; Index: tests/OFSerializationTests.m ================================================================== --- tests/OFSerializationTests.m +++ tests/OFSerializationTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -35,14 +33,12 @@ [a addObject: [OFNumber numberWithInt: 1234]]; [a addObject: [OFNumber numberWithDouble: 1234.5678]]; [a addObject: [OFMutableString stringWithString: @"asd"]]; [a addObject: [OFDate dateWithTimeIntervalSince1970: 1234.5678]]; - [d setObject: @"Hello" - forKey: a]; - [d setObject: @"B\"la" - forKey: @"Blub"]; + [d setObject: @"Hello" forKey: a]; + [d setObject: @"B\"la" forKey: @"Blub"]; [l appendObject: @"Hello"]; [l appendObject: @"Wo\rld!\nHow are you?"]; [l appendObject: [OFURL URLWithString: @"https://objfw.nil.im/"]]; [l appendObject: @@ -49,17 +45,15 @@ [OFXMLElement elementWithXMLString: @""]]; [l appendObject: [OFSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [l appendObject: [OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]]; - [d setObject: @"list" - forKey: l]; + [d setObject: @"list" forKey: l]; data = [OFData dataWithItems: "0123456789:; + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -79,12 +77,11 @@ } return self; } -- (instancetype)initWithObject: (id)firstObject - arguments: (va_list)arguments +- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { self = [super init]; @try { _set = [[OFMutableSet alloc] initWithObject: firstObject @@ -160,12 +157,11 @@ return ret; } @end @implementation TestsAppDelegate (OFSetTests) -- (void)setTestsWithClass: (Class)setClass - mutableClass: (Class)mutableSetClass +- (void)setTestsWithClass: (Class)setClass mutableClass: (Class)mutableSetClass { void *pool = objc_autoreleasePoolPush(); OFSet *set1, *set2; OFMutableSet *mutableSet; bool ok; Index: tests/OFStreamTests.m ================================================================== --- tests/OFStreamTests.m +++ tests/OFStreamTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -31,12 +29,11 @@ - (bool)lowlevelIsAtEndOfStream { return (state > 1); } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)size +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)size { size_t pageSize = [OFSystemInfo pageSize]; switch (state) { case 0: Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -190,12 +188,11 @@ } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString *)string { - [_string replaceCharactersInRange: range - withString: string]; + [_string replaceCharactersInRange: range withString: string]; } @end @interface EntityHandler: OFObject @end @@ -275,18 +272,19 @@ TEST(@"-[appendString:] and -[appendUTF8String:]", R([s[1] appendUTF8String: "1π„ž"]) && R([s[1] appendString: @"3"]) && R([s[0] appendString: s[1]]) && [s[0] isEqual: @"tΓ€s€1π„ž3"]) TEST(@"-[appendCharacters:length:]", - R([s[1] appendCharacters: ucstr + 6 - length: 2]) && [s[1] isEqual: @"1π„ž3rπŸ€Ί"]) + R([s[1] appendCharacters: ucstr + 6 length: 2]) && + [s[1] isEqual: @"1π„ž3rπŸ€Ί"]) TEST(@"-[length]", s[0].length == 7) TEST(@"-[UTF8StringLength]", s[0].UTF8StringLength == 13) TEST(@"-[hash]", s[0].hash == 0x705583C0) - TEST(@"-[characterAtIndex:]", [s[0] characterAtIndex: 0] == 't' && + TEST(@"-[characterAtIndex:]", + [s[0] characterAtIndex: 0] == 't' && [s[0] characterAtIndex: 1] == 0xE4 && [s[0] characterAtIndex: 3] == 0x20AC && [s[0] characterAtIndex: 5] == 0x1D11E) EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]", @@ -360,12 +358,12 @@ encoding: OF_STRING_ENCODING_ISO_8859_1]) && [is isEqual: @"testÀâü"]) #endif TEST(@"-[appendUTFString:length:]", - R([s[0] appendUTF8String: "\xEF\xBB\xBF" "barqux" - length: 6]) && [s[0] isEqual: @"foobar"]) + R([s[0] appendUTF8String: "\xEF\xBB\xBF" "barqux" length: 6]) && + [s[0] isEqual: @"foobar"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1", OFInvalidEncodingException, [stringClass stringWithUTF8String: "\xE0\x80"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2", @@ -500,13 +498,11 @@ options: OF_STRING_SEARCH_BACKWARDS].location == OF_NOT_FOUND) EXPECT_EXCEPTION( @"Detect out of range in -[rangeOfString:options:range:]", OFOutOfRangeException, - [C(@"π„žΓΆΓΆ") rangeOfString: @"ΓΆ" - options: 0 - range: of_range(3, 1)]) + [C(@"π„žΓΆΓΆ") rangeOfString: @"ΓΆ" options: 0 range: of_range(3, 1)]) cs = [OFCharacterSet characterSetWithCharactersInString: @"cΔ‘"]; TEST(@"-[indexOfCharacterFromSet:]", [C(@"abcΔ‘abcΔ‘e") indexOfCharacterFromSet: cs] == 2 && [C(@"abcΔ‘abcΔ‘Γ«") @@ -1081,10 +1077,11 @@ C(@"\r\n+123 ").longLongValue == 123 && C(@"-500\t").longLongValue == -500 && [C(@"-0x10\t") longLongValueWithBase: 0] == -0x10 && C(@"\t\t\r\n").longLongValue == 0 && [C(@"123f") longLongValueWithBase: 16] == 0x123f && + [C(@"-1234") longLongValueWithBase: 0] == -1234 && [C(@"\t\n0xABcd\r") longLongValueWithBase: 0] == 0xABCD && [C(@"1234567") longLongValueWithBase: 8] == 01234567 && [C(@"\r\n0123") longLongValueWithBase: 0] == 0123 && [C(@"765\t") longLongValueWithBase: 8] == 0765 && [C(@"\t\t\r\n") longLongValueWithBase: 8] == 0) @@ -1092,10 +1089,11 @@ TEST(@"-[unsignedLongLongValue]", C(@"1234").unsignedLongLongValue == 1234 && C(@"\r\n+123 ").unsignedLongLongValue == 123 && C(@"\t\t\r\n").unsignedLongLongValue == 0 && [C(@"123f") unsignedLongLongValueWithBase: 16] == 0x123f && + [C(@"1234") unsignedLongLongValueWithBase: 0] == 1234 && [C(@"\t\n0xABcd\r") unsignedLongLongValueWithBase: 0] == 0xABCD && [C(@"1234567") unsignedLongLongValueWithBase: 8] == 01234567 && [C(@"\r\n0123") unsignedLongLongValueWithBase: 0] == 0123 && [C(@"765\t") unsignedLongLongValueWithBase: 8] == 0765 && [C(@"\t\t\r\n") unsignedLongLongValueWithBase: 8] == 0) @@ -1106,18 +1104,19 @@ */ TEST(@"-[floatValue]", C(@"\t-0.25 ").floatValue == -0.25 && C(@"\r\n\tINF\t\n").floatValue == INFINITY && C(@"\r -INFINITY\n").floatValue == -INFINITY && - isnan(C(@" NAN\t\t").floatValue)) + isnan(C(@" NAN\t\t").floatValue) && + isnan(C(@" -NaN\t\t").floatValue)) -#if !defined(OF_ANDROID) && !defined(OF_SOLARIS) && !defined(OF_DJGPP) && \ - !defined(OF_AMIGAOS_M68K) +#if !defined(OF_ANDROID) && !defined(OF_SOLARIS) && !defined(OF_HPUX) && \ + !defined(OF_DJGPP) && !defined(OF_AMIGAOS_M68K) # define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 " # define EXPECTED -0x1.FFFFFFFFFFFFFP-1020 #else -/* Android, Solaris, DJGPP and AmigaOS3 do not accept 0x for strtod() */ +/* Android, Solaris, HP-UX, DJGPP and AmigaOS 3 do not accept 0x for strtod() */ # if (!defined(OF_SOLARIS) || !defined(OF_X86)) && !defined(OF_AMIGAOS_M68K) # define INPUT @"\t-0.123456789 " # define EXPECTED -0.123456789 # else /* @@ -1243,12 +1242,11 @@ [C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByURLDecoding isEqual: @"foo bar\"+$🍌"]) TEST(@"-[insertString:atIndex:]", (s[0] = [mutableStringClass stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && - R([s[0] insertString: @"Àâü" - atIndex: 3]) && + R([s[0] insertString: @"Àâü" atIndex: 3]) && [s[0] isEqual: @"π„žΓΆΓΆΓ€ΓΆΓΌΓΆbÀ€"]) EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] " @"#1", OFInvalidFormatException, [C(@"foo%xbar") stringByURLDecoding]) @@ -1256,22 +1254,17 @@ @"#2", OFInvalidEncodingException, [C(@"foo%FFbar") stringByURLDecoding]) TEST(@"-[setCharacter:atIndex:]", (s[0] = [mutableStringClass stringWithString: @"abΓ€de"]) && - R([s[0] setCharacter: 0xF6 - atIndex: 2]) && + R([s[0] setCharacter: 0xF6 atIndex: 2]) && [s[0] isEqual: @"abΓΆde"] && - R([s[0] setCharacter: 'c' - atIndex: 2]) && + R([s[0] setCharacter: 'c' atIndex: 2]) && [s[0] isEqual: @"abcde"] && - R([s[0] setCharacter: 0x20AC - atIndex: 3]) && + R([s[0] setCharacter: 0x20AC atIndex: 3]) && [s[0] isEqual: @"abc€e"] && - R([s[0] setCharacter: 'x' - atIndex: 1]) && - [s[0] isEqual: @"axc€e"]) + R([s[0] setCharacter: 'x' atIndex: 1]) && [s[0] isEqual: @"axc€e"]) TEST(@"-[deleteCharactersInRange:]", (s[0] = [mutableStringClass stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && R([s[0] deleteCharactersInRange: of_range(1, 3)]) && [s[0] isEqual: @"π„žbÀ€"] && @@ -1302,28 +1295,24 @@ [s[0] deleteCharactersInRange: of_range(4, 0)]) EXPECT_EXCEPTION(@"Detect OoR in " @"-[replaceCharactersInRange:withString:] #1", OFOutOfRangeException, - [s[0] replaceCharactersInRange: of_range(2, 2) - withString: @""]) + [s[0] replaceCharactersInRange: of_range(2, 2) withString: @""]) EXPECT_EXCEPTION(@"Detect OoR in " @"-[replaceCharactersInRange:withString:] #2", OFOutOfRangeException, - [s[0] replaceCharactersInRange: of_range(4, 0) - withString: @""]) + [s[0] replaceCharactersInRange: of_range(4, 0) withString: @""]) TEST(@"-[replaceOccurrencesOfString:withString:]", (s[0] = [mutableStringClass stringWithString: @"asd fo asd fofo asd"]) && - R([s[0] replaceOccurrencesOfString: @"fo" - withString: @"foo"]) && + R([s[0] replaceOccurrencesOfString: @"fo" withString: @"foo"]) && [s[0] isEqual: @"asd foo asd foofoo asd"] && (s[0] = [mutableStringClass stringWithString: @"XX"]) && - R([s[0] replaceOccurrencesOfString: @"X" - withString: @"XX"]) && + R([s[0] replaceOccurrencesOfString: @"X" withString: @"XX"]) && [s[0] isEqual: @"XXXX"]) TEST(@"-[replaceOccurrencesOfString:withString:options:range:]", (s[0] = [mutableStringClass stringWithString: @"foofoobarfoobarfoo"]) && Index: tests/OFSystemInfoTests.m ================================================================== --- tests/OFSystemInfoTests.m +++ tests/OFSystemInfoTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFTCPSocketTests.m ================================================================== --- tests/OFTCPSocketTests.m +++ tests/OFTCPSocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -33,29 +31,27 @@ TEST(@"+[socket]", (server = [OFTCPSocket socket]) && (client = [OFTCPSocket socket])) TEST(@"-[bindToHost:port:]", - (port = [server bindToHost: @"127.0.0.1" - port: 0])) + (port = [server bindToHost: @"127.0.0.1" port: 0])) TEST(@"-[listen]", R([server listen])) TEST(@"-[connectToHost:port:]", - R([client connectToHost: @"127.0.0.1" - port: port])) + R([client connectToHost: @"127.0.0.1" port: port])) TEST(@"-[accept]", (accepted = [server accept])) TEST(@"-[remoteAddress]", [of_socket_address_ip_string(accepted.remoteAddress, NULL) isEqual: @"127.0.0.1"]) TEST(@"-[writeString:]", [client writeString: @"Hello!"]) - TEST(@"-[readIntoBuffer:length:]", [accepted readIntoBuffer: buf - length: 6] && + TEST(@"-[readIntoBuffer:length:]", + [accepted readIntoBuffer: buf length: 6] && !memcmp(buf, "Hello!", 6)) objc_autoreleasePoolPop(pool); } @end Index: tests/OFThreadTests.m ================================================================== --- tests/OFThreadTests.m +++ tests/OFThreadTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -25,12 +23,11 @@ @end @implementation TestThread - (id)main { - [[OFThread threadDictionary] setObject: @"bar" - forKey: @"foo"]; + [[OFThread threadDictionary] setObject: @"bar" forKey: @"foo"]; return @"success"; } @end Index: tests/OFUDPSocketTests.m ================================================================== --- tests/OFUDPSocketTests.m +++ tests/OFUDPSocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -34,24 +32,19 @@ OFString *host; TEST(@"+[socket]", (sock = [OFUDPSocket socket])) TEST(@"-[bindToHost:port:]", - (port1 = [sock bindToHost: @"127.0.0.1" - port: 0])) + (port1 = [sock bindToHost: @"127.0.0.1" port: 0])) addr1 = of_socket_address_parse_ip(@"127.0.0.1", port1); TEST(@"-[sendBuffer:length:receiver:]", - R([sock sendBuffer: "Hello" - length: 6 - receiver: &addr1])) + R([sock sendBuffer: "Hello" length: 6 receiver: &addr1])) TEST(@"-[receiveIntoBuffer:length:sender:]", - [sock receiveIntoBuffer: buf - length: 6 - sender: &addr2] == 6 && + [sock receiveIntoBuffer: buf length: 6 sender: &addr2] == 6 && !memcmp(buf, "Hello", 6) && (host = of_socket_address_ip_string(&addr2, &port2)) && [host isEqual: @"127.0.0.1"] && port2 == port1) addr3 = of_socket_address_parse_ip(@"127.0.0.1", port1 + 1); Index: tests/OFURLTests.m ================================================================== --- tests/OFURLTests.m +++ tests/OFURLTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -70,12 +68,11 @@ EXPECT_EXCEPTION(@"+[URLWithString:] fails with invalid characters #8", OFInvalidFormatException, [OFURL URLWithString: @"https://[f]:f/"]) TEST(@"+[URLWithString:relativeToURL:]", - [[[OFURL URLWithString: @"/foo" - relativeToURL: u1] string] isEqual: + [[[OFURL URLWithString: @"/foo" relativeToURL: u1] string] isEqual: @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/foo"] && [[[OFURL URLWithString: @"foo/bar?q" relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]] string] isEqual: @"http://h/qux/foo/bar?q"] && [[[OFURL URLWithString: @"foo/bar" @@ -91,30 +88,26 @@ string] isEqual: @"http://foo/foo"]) EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #1", OFInvalidFormatException, - [OFURL URLWithString: @"`" - relativeToURL: u1]) + [OFURL URLWithString: @"`" relativeToURL: u1]) EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #2", OFInvalidFormatException, - [OFURL URLWithString: @"/`" - relativeToURL: u1]) + [OFURL URLWithString: @"/`" relativeToURL: u1]) EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #3", OFInvalidFormatException, - [OFURL URLWithString: @"?`" - relativeToURL: u1]) + [OFURL URLWithString: @"?`" relativeToURL: u1]) EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #4", OFInvalidFormatException, - [OFURL URLWithString: @"#`" - relativeToURL: u1]) + [OFURL URLWithString: @"#`" relativeToURL: u1]) #ifdef OF_HAVE_FILES TEST(@"+[fileURLWithPath:]", [[[OFURL fileURLWithPath: @"testfile.txt"] fileSystemRepresentation] isEqual: [[OFFileManager defaultManager].currentDirectoryPath @@ -291,24 +284,20 @@ @"-[setURLEncodedFragment:] with invalid characters fails", OFInvalidFormatException, mu.URLEncodedFragment = @"`") TEST(@"-[URLByAppendingPathComponent:isDirectory:]", [[[OFURL URLWithString: @"file:///foo/bar"] - URLByAppendingPathComponent: @"qux" - isDirectory: false] isEqual: + URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual: [OFURL URLWithString: @"file:///foo/bar/qux"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] - URLByAppendingPathComponent: @"qux" - isDirectory: false] isEqual: + URLByAppendingPathComponent: @"qux" isDirectory: false] isEqual: [OFURL URLWithString: @"file:///foo/bar/qux"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] - URLByAppendingPathComponent: @"qu?x" - isDirectory: false] isEqual: + URLByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual: [OFURL URLWithString: @"file:///foo/bar/qu%3Fx"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] - URLByAppendingPathComponent: @"qu?x" - isDirectory: true] isEqual: + URLByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual: [OFURL URLWithString: @"file:///foo/bar/qu%3Fx/"]]) TEST(@"-[URLByStandardizingPath]", [[[OFURL URLWithString: @"http://foo/bar/.."] URLByStandardizingPath] isEqual: Index: tests/OFValueTests.m ================================================================== --- tests/OFValueTests.m +++ tests/OFValueTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -40,18 +38,16 @@ objCType: @encode(of_range_t)])) TEST(@"-[objCType]", strcmp(value.objCType, @encode(of_range_t)) == 0) TEST(@"-[getValue:size:]", - R([value getValue: &range2 - size: sizeof(of_range_t)]) && + R([value getValue: &range2 size: sizeof(of_range_t)]) && of_range_equal(range2, range)) EXPECT_EXCEPTION(@"-[getValue:size:] with wrong size throws", OFOutOfRangeException, - [value getValue: &range - size: sizeof(of_range_t) - 1]) + [value getValue: &range size: sizeof(of_range_t) - 1]) TEST(@"+[valueWithPointer:]", (value = [OFValue valueWithPointer: pointer])) TEST(@"-[pointerValue]", @@ -86,12 +82,11 @@ objCType: @encode(of_range_t)]) && of_range_equal(value.rangeValue, range)) TEST(@"-[getValue:size:] for OFRangeValue", (value = [OFValue valueWithRange: range]) && - R([value getValue: &range2 - size: sizeof(range2)]) && + R([value getValue: &range2 size: sizeof(range2)]) && of_range_equal(range2, range)) EXPECT_EXCEPTION(@"-[rangeValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" @@ -106,12 +101,11 @@ objCType: @encode(of_point_t)]) && of_point_equal(value.pointValue, point)) TEST(@"-[getValue:size:] for OFPointValue", (value = [OFValue valueWithPoint: point]) && - R([value getValue: &point2 - size: sizeof(point2)]) && + R([value getValue: &point2 size: sizeof(point2)]) && of_point_equal(point2, point)) EXPECT_EXCEPTION(@"-[pointValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" @@ -126,12 +120,11 @@ objCType: @encode(of_dimension_t)]) && of_dimension_equal(value.dimensionValue, dimension)) TEST(@"-[getValue:size:] for OFDimensionValue", (value = [OFValue valueWithDimension: dimension]) && - R([value getValue: &dimension2 - size: sizeof(dimension2)]) && + R([value getValue: &dimension2 size: sizeof(dimension2)]) && of_dimension_equal(dimension2, dimension)) EXPECT_EXCEPTION(@"-[dimensionValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" @@ -146,12 +139,11 @@ objCType: @encode(of_rectangle_t)]) && of_rectangle_equal(value.rectangleValue, rectangle)) TEST(@"-[getValue:size:] for OFRectangleValue", (value = [OFValue valueWithRectangle: rectangle]) && - R([value getValue: &rectangle2 - size: sizeof(rectangle2)]) && + R([value getValue: &rectangle2 size: sizeof(rectangle2)]) && of_rectangle_equal(rectangle2, rectangle)) EXPECT_EXCEPTION(@"-[rectangleValue] with wrong size throws", OFOutOfRangeException, [[OFValue valueWithBytes: "a" @@ -159,17 +151,14 @@ TEST(@"-[isEqual:]", [[OFValue valueWithRectangle: rectangle] isEqual: [OFValue valueWithBytes: &rectangle objCType: @encode(of_rectangle_t)]] && - ![[OFValue valueWithBytes: "a" - objCType: @encode(signed char)] + ![[OFValue valueWithBytes: "a" objCType: @encode(signed char)] isEqual: [OFValue valueWithBytes: "a" objCType: @encode(unsigned char)]] && - ![[OFValue valueWithBytes: "a" - objCType: @encode(char)] - isEqual: [OFValue valueWithBytes: "b" - objCType: @encode(char)]]) + ![[OFValue valueWithBytes: "a" objCType: @encode(char)] + isEqual: [OFValue valueWithBytes: "b" objCType: @encode(char)]]) objc_autoreleasePoolPop(pool); } @end Index: tests/OFWindowsRegistryKeyTests.m ================================================================== --- tests/OFWindowsRegistryKeyTests.m +++ tests/OFWindowsRegistryKeyTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -23,12 +21,11 @@ @implementation TestsAppDelegate (OFWindowsRegistryKeyTests) - (void)windowsRegistryKeyTests { void *pool = objc_autoreleasePoolPush(); - OFData *data = [OFData dataWithItems: "abcdef" - count: 6]; + OFData *data = [OFData dataWithItems: "abcdef" count: 6]; OFWindowsRegistryKey *softwareKey, *ObjFWKey; DWORD type; TEST(@"+[OFWindowsRegistryKey classesRootKey]", [OFWindowsRegistryKey classesRootKey]) @@ -55,36 +52,32 @@ TEST(@"-[createSubkeyAtPath:securityAndAccessRights:]", (ObjFWKey = [softwareKey createSubkeyAtPath: @"ObjFW" securityAndAccessRights: KEY_ALL_ACCESS])) - TEST(@"-[setData:forValue:type:]", - R([ObjFWKey setData: data - forValue: @"data" - type: REG_BINARY])) - - TEST(@"-[dataForValue:subkeyPath:flags:type:]", - [[ObjFWKey dataForValue: @"data" - type: &type] isEqual: data] && + TEST(@"-[setData:forValueNamed:type:]", + R([ObjFWKey setData: data forValueNamed: @"data" type: REG_BINARY])) + + TEST(@"-[dataForValueNamed:subkeyPath:flags:type:]", + [[ObjFWKey dataForValueNamed: @"data" type: &type] isEqual: data] && type == REG_BINARY) - TEST(@"-[setString:forValue:type:]", - R([ObjFWKey setString: @"foobar" - forValue: @"string"]) && + TEST(@"-[setString:forValueNamed:type:]", + R([ObjFWKey setString: @"foobar" forValueNamed: @"string"]) && R([ObjFWKey setString: @"%PATH%;foo" - forValue: @"expand" + forValueNamed: @"expand" type: REG_EXPAND_SZ])) TEST(@"-[stringForValue:subkeyPath:]", - [[ObjFWKey stringForValue: @"string"] isEqual: @"foobar"] && - [[ObjFWKey stringForValue: @"expand" - type: &type] isEqual: @"%PATH%;foo"] && + [[ObjFWKey stringForValueNamed: @"string"] isEqual: @"foobar"] && + [[ObjFWKey stringForValueNamed: @"expand" type: &type] + isEqual: @"%PATH%;foo"] && type == REG_EXPAND_SZ) - TEST(@"-[deleteValue:]", R([ObjFWKey deleteValue: @"data"])) + TEST(@"-[deleteValueNamed:]", R([ObjFWKey deleteValueNamed: @"data"])) TEST(@"-[deleteSubkeyAtPath:]", R([softwareKey deleteSubkeyAtPath: @"ObjFW"])) objc_autoreleasePoolPop(pool); } @end Index: tests/OFXMLElementBuilderTests.m ================================================================== --- tests/OFXMLElementBuilderTests.m +++ tests/OFXMLElementBuilderTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/OFXMLNodeTests.m ================================================================== --- tests/OFXMLNodeTests.m +++ tests/OFXMLNodeTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -38,19 +36,17 @@ [[nodes[1] XMLString] isEqual: @"b&ar"]) TEST(@"+[elementWithName:namespace:]", (nodes[2] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && - R([nodes[2] addAttributeWithName: @"test" - stringValue: @"test"]) && + R([nodes[2] addAttributeWithName: @"test" stringValue: @"test"]) && R([nodes[2] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && [[nodes[2] XMLString] isEqual: @""] && (nodes[3] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && - R([nodes[3] addAttributeWithName: @"test" - stringValue: @"test"]) && + R([nodes[3] addAttributeWithName: @"test" stringValue: @"test"]) && [[nodes[3] XMLString] isEqual: @""]) TEST(@"+[elementWithName:namespace:stringValue:]", (nodes[3] = [OFXMLElement elementWithName: @"foo" @@ -74,15 +70,13 @@ [[nodes[3] XMLString] isEqual: @""]) module = @"OFXMLElement"; TEST(@"-[addAttributeWithName:stringValue:]", - R([nodes[0] addAttributeWithName: @"foo" - stringValue: @"b&ar"]) && + R([nodes[0] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[nodes[0] XMLString] isEqual: @""] && - R([nodes[1] addAttributeWithName: @"foo" - stringValue: @"b&ar"]) && + R([nodes[1] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[nodes[1] XMLString] isEqual: @"b&ar"]) TEST(@"-[setPrefix:forNamespace:]", R([nodes[1] setPrefix: @"objfw-test" Index: tests/OFXMLParserTests.m ================================================================== --- tests/OFXMLParserTests.m +++ tests/OFXMLParserTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -273,12 +271,11 @@ namespace: ns attributes: nil string: nil]; } -- (void)parser: (OFXMLParser *)parser - foundCharacters: (OFString *)string +- (void)parser: (OFXMLParser *)parser foundCharacters: (OFString *)string { [self parser: parser didCreateEvent: STRING name: nil prefix: nil @@ -285,12 +282,11 @@ namespace: nil attributes: nil string: string]; } -- (void)parser: (OFXMLParser *)parser - foundCDATA: (OFString *)cdata +- (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)cdata { [self parser: parser didCreateEvent: CDATA name: nil prefix: nil @@ -297,12 +293,11 @@ namespace: nil attributes: nil string: cdata]; } -- (void)parser: (OFXMLParser *)parser - foundComment: (OFString *)comment +- (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment { [self parser: parser didCreateEvent: COMMENT name: nil prefix: nil @@ -351,15 +346,13 @@ for (j = 0; j < len; j+= 2) { if (parser.hasFinishedParsing) abort(); if (j + 2 > len) - [parser parseBuffer: str + j - length: 1]; + [parser parseBuffer: str + j length: 1]; else - [parser parseBuffer: str + j - length: 2]; + [parser parseBuffer: str + j length: 2]; } TEST(@"Checking if everything was parsed", i == 32 && parser.lineNumber == 18) Index: tests/PBKDF2Tests.m ================================================================== --- tests/PBKDF2Tests.m +++ tests/PBKDF2Tests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/RuntimeARCTests.m ================================================================== --- tests/RuntimeARCTests.m +++ tests/RuntimeARCTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/RuntimeTests.m ================================================================== --- tests/RuntimeTests.m +++ tests/RuntimeTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/ScryptTests.m ================================================================== --- tests/ScryptTests.m +++ tests/ScryptTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/SocketTests.m ================================================================== --- tests/SocketTests.m +++ tests/SocketTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/TestsAppDelegate.h ================================================================== --- tests/TestsAppDelegate.h +++ tests/TestsAppDelegate.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,45 +13,39 @@ * file. */ #import "ObjFW.h" -#define TEST(test, ...) \ - { \ - [self outputTesting: test \ - inModule: module]; \ - \ - if (__VA_ARGS__) \ - [self outputSuccess: test \ - inModule: module]; \ - else { \ - [self outputFailure: test \ - inModule: module]; \ - _fails++; \ - } \ - } -#define EXPECT_EXCEPTION(test, exception, code) \ - { \ - bool caught = false; \ - \ - [self outputTesting: test \ - inModule: module]; \ - \ - @try { \ - code; \ - } @catch (exception *e) { \ - caught = true; \ - } \ - \ - if (caught) \ - [self outputSuccess: test \ - inModule: module]; \ - else { \ - [self outputFailure: test \ - inModule: module]; \ - _fails++; \ - } \ +#define TEST(test, ...) \ + { \ + [self outputTesting: test inModule: module]; \ + \ + if (__VA_ARGS__) \ + [self outputSuccess: test inModule: module]; \ + else { \ + [self outputFailure: test inModule: module]; \ + _fails++; \ + } \ + } +#define EXPECT_EXCEPTION(test, exception, code) \ + { \ + bool caught = false; \ + \ + [self outputTesting: test inModule: module]; \ + \ + @try { \ + code; \ + } @catch (exception *e) { \ + caught = true; \ + } \ + \ + if (caught) \ + [self outputSuccess: test inModule: module]; \ + else { \ + [self outputFailure: test inModule: module]; \ + _fails++; \ + } \ } #define R(...) (__VA_ARGS__, 1) @class OFString; @@ -60,16 +52,13 @@ @interface TestsAppDelegate: OFObject { int _fails; } -- (void)outputTesting: (OFString *)test - inModule: (OFString *)module; -- (void)outputSuccess: (OFString *)test - inModule: (OFString *)module; -- (void)outputFailure: (OFString *)test - inModule: (OFString *)module; +- (void)outputTesting: (OFString *)test inModule: (OFString *)module; +- (void)outputSuccess: (OFString *)test inModule: (OFString *)module; +- (void)outputFailure: (OFString *)test inModule: (OFString *)module; @end @interface TestsAppDelegate (OFArrayTests) - (void)arrayTests; @end Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/objc_sync/test.m ================================================================== --- tests/objc_sync/test.m +++ tests/objc_sync/test.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/plugin/TestPlugin.h ================================================================== --- tests/plugin/TestPlugin.h +++ tests/plugin/TestPlugin.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/plugin/TestPlugin.m ================================================================== --- tests/plugin/TestPlugin.m +++ tests/plugin/TestPlugin.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: tests/terminal/TerminalTests.m ================================================================== --- tests/terminal/TerminalTests.m +++ tests/terminal/TerminalTests.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/objfw-compile ================================================================== --- utils/objfw-compile +++ utils/objfw-compile @@ -1,10 +1,8 @@ #!/bin/sh # -# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, -# 2018, 2019, 2020 -# Jonathan Schleifer +# Copyright (c) 2008-2021 Jonathan Schleifer # # All rights reserved. # # This file is part of ObjFW. It may be distributed under the terms of the # Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -30,14 +28,14 @@ parse_packages() { packages="" while test x"$1" != "x"; do case "$1" in - --package) - shift - packages="$packages --package $1" - ;; + --package) + shift + packages="$packages --package $1" + ;; esac shift done } parse_packages "$@" @@ -122,141 +120,140 @@ out_prefix="" out_suffix="" while test x"$1" != "x"; do case "$1" in - -o|--out) - shift - out="$1" - ;; - --lib) - if test x"$plugin" = x"yes"; then - echo "You can't use --lib and --plugin!" - exit 1 - fi - - shift - - if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+$" >/dev/null - then - echo "$1 is not a valid library version!" - exit 1 - fi - - export LIB_MAJOR="${1%.*}" - export LIB_MINOR="${1#*.}" - - lib="yes" - OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --lib-cflags)" - out_prefix="$($OBJFW_CONFIG --lib-prefix)" - out_suffix="$($OBJFW_CONFIG --lib-suffix)" - ;; - --package) - # Already included into the flags. - shift - ;; - --plugin) - if test x"$lib" = x"yes"; then - echo "You can't use --lib and --plugin!" - exit 1 - fi - - plugin="yes" - OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --plugin-cflags)" - LDFLAGS="$LDFLAGS $($OBJFW_CONFIG --plugin-ldflags)" - out_suffix="$($OBJFW_CONFIG --plugin-suffix)" - ;; - --arc) - OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --arc)" - ;; - --builddir) - shift - builddir="$1" - ;; - -D) - shift - CPPFLAGS="$CPPFLAGS -D$1" - ;; - -D*) - CPPFLAGS="$CPPFLAGS $1" - ;; - -framework) - shift - LIBS="$LIBS -framework $1" - ;; - -f*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - -F) - shift - LIBS="$LIBS -F$1" - ;; - -F*) - LIBS="$LIBS $1" - ;; - -g*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - -I) - shift - CPPFLAGS="$CPPFLAGS -I$1" - ;; - -I*) - CPPFLAGS="$CPPFLAGS $1" - ;; - -l) - shift - LIBS="$LIBS -l$1" - ;; - -l*) - LIBS="$LIBS $1" - ;; - -L) - shift - LIBS="$LIBS -L$1" - ;; - -L*) - LIBS="$LIBS $1" - ;; - -m*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - -O*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - -pthread) - OBJCFLAGS="$OBJCFLAGS $1" - LDFLAGS="$LDFLAGS $1" - ;; - -std=*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - -Wl,*) - LDFLAGS="$LDFLAGS $1" - ;; - -W*) - OBJCFLAGS="$OBJCFLAGS $1" - ;; - --help) - show_help - exit 0 - ;; - -*) - echo "Unknown option: $1" - exit 1 - ;; - *.m) - srcs="$srcs $1" - ;; - *.mm) - srcs="$srcs $1" - link_stdcpp="yes" - ;; - *) - echo "Only .m and .mm files can be compiled!" 1>&2 - exit 1 - ;; + -o|--out) + shift + out="$1" + ;; + --lib) + if test x"$plugin" = x"yes"; then + echo "You can't use --lib and --plugin!" + exit 1 + fi + + shift + + if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+$" >/dev/null; then + echo "$1 is not a valid library version!" + exit 1 + fi + + export LIB_MAJOR="${1%.*}" + export LIB_MINOR="${1#*.}" + + lib="yes" + OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --lib-cflags)" + out_prefix="$($OBJFW_CONFIG --lib-prefix)" + out_suffix="$($OBJFW_CONFIG --lib-suffix)" + ;; + --package) + # Already included into the flags. + shift + ;; + --plugin) + if test x"$lib" = x"yes"; then + echo "You can't use --lib and --plugin!" + exit 1 + fi + + plugin="yes" + OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --plugin-cflags)" + LDFLAGS="$LDFLAGS $($OBJFW_CONFIG --plugin-ldflags)" + out_suffix="$($OBJFW_CONFIG --plugin-suffix)" + ;; + --arc) + OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --arc)" + ;; + --builddir) + shift + builddir="$1" + ;; + -D) + shift + CPPFLAGS="$CPPFLAGS -D$1" + ;; + -D*) + CPPFLAGS="$CPPFLAGS $1" + ;; + -framework) + shift + LIBS="$LIBS -framework $1" + ;; + -f*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + -F) + shift + LIBS="$LIBS -F$1" + ;; + -F*) + LIBS="$LIBS $1" + ;; + -g*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + -I) + shift + CPPFLAGS="$CPPFLAGS -I$1" + ;; + -I*) + CPPFLAGS="$CPPFLAGS $1" + ;; + -l) + shift + LIBS="$LIBS -l$1" + ;; + -l*) + LIBS="$LIBS $1" + ;; + -L) + shift + LIBS="$LIBS -L$1" + ;; + -L*) + LIBS="$LIBS $1" + ;; + -m*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + -O*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + -pthread) + OBJCFLAGS="$OBJCFLAGS $1" + LDFLAGS="$LDFLAGS $1" + ;; + -std=*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + -Wl,*) + LDFLAGS="$LDFLAGS $1" + ;; + -W*) + OBJCFLAGS="$OBJCFLAGS $1" + ;; + --help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" + exit 1 + ;; + *.m) + srcs="$srcs $1" + ;; + *.mm) + srcs="$srcs $1" + link_stdcpp="yes" + ;; + *) + echo "Only .m and .mm files can be compiled!" 1>&2 + exit 1 + ;; esac shift done @@ -264,39 +261,39 @@ echo "No output name specified! Use -o or --out!" exit 1 fi case "$builddir" in - "") - ;; - */) - ;; - *) - builddir="$builddir/" - ;; +"") + ;; +*/) + ;; +*) + builddir="$builddir/" + ;; esac for i in $srcs; do case $i in - *.m) - if test x"$lib" = x"yes"; then - obj="$builddir${i%.m}.lib.o" - elif test x"$plugin" = x"yes"; then - obj="$builddir${i%.m}.plugin.o" - else - obj="$builddir${i%.m}.o" - fi - ;; - *.mm) - if test x"$lib" = x"yes"; then - obj="$builddir${i%.mm}.lib.o" - elif test x"$plugin" = x"yes"; then - obj="$builddir${i%.mm}.plugin.o" - else - obj="$builddir${i%.mm}.o" - fi - ;; + *.m) + if test x"$lib" = x"yes"; then + obj="$builddir${i%.m}.lib.o" + elif test x"$plugin" = x"yes"; then + obj="$builddir${i%.m}.plugin.o" + else + obj="$builddir${i%.m}.o" + fi + ;; + *.mm) + if test x"$lib" = x"yes"; then + obj="$builddir${i%.mm}.lib.o" + elif test x"$plugin" = x"yes"; then + obj="$builddir${i%.mm}.plugin.o" + else + obj="$builddir${i%.mm}.o" + fi + ;; esac objs="$objs $obj" build="no" deps=$($OBJC -E -M $CPPFLAGS $OBJCFLAGS $i | sed 's/.*: //' | sed 's/\\//g') Index: utils/objfw-config.in ================================================================== --- utils/objfw-config.in +++ utils/objfw-config.in @@ -1,10 +1,8 @@ #!/bin/sh # -# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, -# 2018, 2019, 2020 -# Jonathan Schleifer +# Copyright (c) 2008-2021 Jonathan Schleifer # # All rights reserved. # # This file is part of ObjFW. It may be distributed under the terms of the # Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -96,14 +94,14 @@ } parse_packages() { while test x"$1" != "x"; do case "$1" in - --package) - shift - package_depends_on "$1" - ;; + --package) + shift + package_depends_on "$1" + ;; esac shift done } parse_packages "$@" @@ -118,118 +116,114 @@ fi } while test x"$1" != "x"; do case "$1" in - --all) - output_flag "$CFLAGS $CPPFLAGS $CXXFLAGS $OBJCFLAGS" - output_flag "$LDFLAGS $LDFLAGS_REEXPORT $LDFLAGS_RPATH" - output_flag "$LIBS" - ;; - --arc) - output_flag "-fobjc-arc -fobjc-arc-exceptions" - ;; - --cflags) - output_flag "$CFLAGS" - ;; - --cppflags) - output_flag "$CPPFLAGS" - ;; - --cxxflags) - output_flag "$CXXFLAGS" - ;; - --framework-libs) - output_flag "$FRAMEWORK_LIBS" - ;; - --help) - show_help 0 - ;; - --objc) - output_flag "$OBJC" - ;; - --objcflags) - output_flag "$OBJCFLAGS" - ;; - --libs) - output_flag "$LIBS" - ;; - --lib-cflags) - if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then - echo "LIB_MAJOR and LIB_MINOR need to be set!" \ - 1>&2 - exit 1 - fi - - output_flag "$LIB_CFLAGS" - ;; - --lib-ldflags) - if test x"$SHARED_LIB" = x"" -o x"$LIB_MAJOR" = x"" \ - -o x"$LIB_MINOR" = x""; then - printf "SHARED_LIB, LIB_MAJOR and " 2>&1 - echo "LIB_MINOR need to be set!" 1>&2 - exit 1 - fi - - output_flag "$LIB_LDFLAGS" - ;; - --lib-prefix) - if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then - echo "LIB_MAJOR and LIB_MINOR need to be set!" \ - 1>&2 - exit 1 - fi - - output_flag "$LIB_PREFIX" - ;; - --lib-suffix) - if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then - echo "LIB_MAJOR and LIB_MINOR need to be set!" \ - 1>&2 - exit 1 - fi - - output_flag "$LIB_SUFFIX" - ;; - --ldflags) - output_flag "$LDFLAGS" - ;; - --reexport) - output_flag "$LDFLAGS_REEXPORT" - ;; - --rpath) - output_flag "$LDFLAGS_RPATH" - ;; - --package) - # Already included into the flags. - shift - ;; - --packages-dir) - output_flag "$packagesdir" - ;; - --plugin-cflags) - output_flag "$PLUGIN_CFLAGS" - ;; - --plugin-ldflags) - output_flag "$PLUGIN_LDFLAGS" - ;; - --plugin-suffix) - output_flag "$PLUGIN_SUFFIX" - ;; - --prog-suffix) - output_flag "$PROG_SUFFIX" - ;; - --static-libs) - output_flag "$STATIC_LIBS" - ;; - --version) - output_flag "$VERSION" - ;; - *) - echo "Invalid option: $1" 1>&2 - exit 1 - ;; + --all) + output_flag "$CFLAGS $CPPFLAGS $CXXFLAGS $OBJCFLAGS" + output_flag "$LDFLAGS $LDFLAGS_REEXPORT $LDFLAGS_RPATH $LIBS" + ;; + --arc) + output_flag "-fobjc-arc -fobjc-arc-exceptions" + ;; + --cflags) + output_flag "$CFLAGS" + ;; + --cppflags) + output_flag "$CPPFLAGS" + ;; + --cxxflags) + output_flag "$CXXFLAGS" + ;; + --framework-libs) + output_flag "$FRAMEWORK_LIBS" + ;; + --help) + show_help 0 + ;; + --objc) + output_flag "$OBJC" + ;; + --objcflags) + output_flag "$OBJCFLAGS" + ;; + --libs) + output_flag "$LIBS" + ;; + --lib-cflags) + if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then + echo "LIB_MAJOR and LIB_MINOR need to be set!" 1>&2 + exit 1 + fi + + output_flag "$LIB_CFLAGS" + ;; + --lib-ldflags) + if test x"$SHARED_LIB" = x"" -o x"$LIB_MAJOR" = x"" \ + -o x"$LIB_MINOR" = x""; then + printf "SHARED_LIB, LIB_MAJOR and " 2>&1 + echo "LIB_MINOR need to be set!" 1>&2 + exit 1 + fi + + output_flag "$LIB_LDFLAGS" + ;; + --lib-prefix) + if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then + echo "LIB_MAJOR and LIB_MINOR need to be set!" 1>&2 + exit 1 + fi + + output_flag "$LIB_PREFIX" + ;; + --lib-suffix) + if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then + echo "LIB_MAJOR and LIB_MINOR need to be set!" 1>&2 + exit 1 + fi + + output_flag "$LIB_SUFFIX" + ;; + --ldflags) + output_flag "$LDFLAGS" + ;; + --reexport) + output_flag "$LDFLAGS_REEXPORT" + ;; + --rpath) + output_flag "$LDFLAGS_RPATH" + ;; + --package) + # Already included into the flags. + shift + ;; + --packages-dir) + output_flag "$packagesdir" + ;; + --plugin-cflags) + output_flag "$PLUGIN_CFLAGS" + ;; + --plugin-ldflags) + output_flag "$PLUGIN_LDFLAGS" + ;; + --plugin-suffix) + output_flag "$PLUGIN_SUFFIX" + ;; + --prog-suffix) + output_flag "$PROG_SUFFIX" + ;; + --static-libs) + output_flag "$STATIC_LIBS" + ;; + --version) + output_flag "$VERSION" + ;; + *) + echo "Invalid option: $1" 1>&2 + exit 1 + ;; esac shift done test x"$flag_printed" = x"yes" && echo exit 0 Index: utils/objfw-new ================================================================== --- utils/objfw-new +++ utils/objfw-new @@ -14,14 +14,14 @@ name="$2" test -z "$name" && show_help case "$1" in - app) - test -f "$name.m" && already_exists "$name.m" +app) + test -f "$name.m" && already_exists "$name.m" - cat >"$name.m" <<__EOF__ + cat >"$name.m" <<__EOF__ #import @interface $name: OFObject @end @@ -32,16 +32,16 @@ { [OFApplication terminate]; } @end __EOF__ - ;; - class) - test -f "$name.h" && already_exists "$name.h" - test -f "$name.m" && already_exists "$name.m" + ;; +class) + test -f "$name.h" && already_exists "$name.h" + test -f "$name.m" && already_exists "$name.m" - cat >"$name.h" <<__EOF__ + cat >"$name.h" <<__EOF__ #import @interface $name: OFObject @end __EOF__ @@ -49,10 +49,10 @@ #import "$name.h" @implementation $name @end __EOF__ - ;; - *) - show_help - ;; + ;; +*) + show_help + ;; esac Index: utils/ofarc/Archive.h ================================================================== --- utils/ofarc/Archive.h +++ utils/ofarc/Archive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/GZIPArchive.h ================================================================== --- utils/ofarc/GZIPArchive.h +++ utils/ofarc/GZIPArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/GZIPArchive.m ================================================================== --- utils/ofarc/GZIPArchive.m +++ utils/ofarc/GZIPArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -126,16 +124,14 @@ if (app->_outputLevel >= 0) [of_stdout writeString: OF_LOCALIZED(@"extracting_file", @"Extracting %[file]...", @"file", fileName)]; - if (![app shouldExtractFile: fileName - outFileName: fileName]) + if (![app shouldExtractFile: fileName outFileName: fileName]) return; - output = [OFFile fileWithPath: fileName - mode: @"w"]; + output = [OFFile fileWithPath: fileName mode: @"w"]; setPermissions(fileName, app->_archivePath); while (!_stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: _stream toStream: output Index: utils/ofarc/LHAArchive.h ================================================================== --- utils/ofarc/LHAArchive.h +++ utils/ofarc/LHAArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/LHAArchive.m ================================================================== --- utils/ofarc/LHAArchive.m +++ utils/ofarc/LHAArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -328,17 +326,15 @@ directory = outFileName.stringByDeletingLastPathComponent; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; - if (![app shouldExtractFile: fileName - outFileName: outFileName]) + if (![app shouldExtractFile: fileName outFileName: outFileName]) goto outer_loop_end; stream = [_archive streamForReadingCurrentEntry]; - output = [OFFile fileWithPath: outFileName - mode: @"w"]; + output = [OFFile fileWithPath: outFileName mode: @"w"]; setPermissions(outFileName, entry); while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: output Index: utils/ofarc/OFArc.h ================================================================== --- utils/ofarc/OFArc.h +++ utils/ofarc/OFArc.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/OFArc.m ================================================================== --- utils/ofarc/OFArc.m +++ utils/ofarc/OFArc.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -324,12 +322,11 @@ if (![remainingArguments.firstObject isEqual: @"-"]) [sandbox unveilPath: remainingArguments.firstObject permissions: (mode == 'a' ? @"rwc" : @"wc")]; for (OFString *path in files) - [sandbox unveilPath: path - permissions: @"r"]; + [sandbox unveilPath: path permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif @@ -398,18 +395,16 @@ [sandbox unveilPath: remainingArguments.firstObject permissions: @"r"]; if (files.count > 0) for (OFString *path in files) - [sandbox unveilPath: path - permissions: @"wc"]; + [sandbox unveilPath: path permissions: @"wc"]; else { OFString *path = (outputDir != nil ? outputDir : OF_PATH_CURRENT_DIRECTORY); /* We need 'r' to change the directory to it. */ - [sandbox unveilPath: path - permissions: @"rwc"]; + [sandbox unveilPath: path permissions: @"rwc"]; } sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif @@ -512,12 +507,11 @@ default: @throw [OFInvalidArgumentException exception]; } } else { @try { - file = [OFFile fileWithPath: path - mode: fileModeString]; + file = [OFFile fileWithPath: path mode: fileModeString]; } @catch (OFOpenItemFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stderr writeString: @"\r"]; @@ -691,12 +685,11 @@ { char buffer[BUFFER_SIZE]; size_t length; @try { - length = [input readIntoBuffer: buffer - length: BUFFER_SIZE]; + length = [input readIntoBuffer: buffer length: BUFFER_SIZE]; } @catch (OFReadFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stdout writeString: @"\r"]; @@ -706,12 +699,11 @@ @"error", error)]; return -1; } @try { - [output writeBuffer: buffer - length: length]; + [output writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; [of_stdout writeString: @"\r"]; Index: utils/ofarc/TarArchive.h ================================================================== --- utils/ofarc/TarArchive.h +++ utils/ofarc/TarArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/TarArchive.m ================================================================== --- utils/ofarc/TarArchive.m +++ utils/ofarc/TarArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -339,17 +337,15 @@ directory = outFileName.stringByDeletingLastPathComponent; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; - if (![app shouldExtractFile: fileName - outFileName: outFileName]) + if (![app shouldExtractFile: fileName outFileName: outFileName]) goto outer_loop_end; stream = [_archive streamForReadingCurrentEntry]; - output = [OFFile fileWithPath: outFileName - mode: @"w"]; + output = [OFFile fileWithPath: outFileName mode: @"w"]; setPermissions(outFileName, entry); while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: output Index: utils/ofarc/ZIPArchive.h ================================================================== --- utils/ofarc/ZIPArchive.h +++ utils/ofarc/ZIPArchive.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofarc/ZIPArchive.m ================================================================== --- utils/ofarc/ZIPArchive.m +++ utils/ofarc/ZIPArchive.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -46,13 +44,12 @@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX) { OFNumber *mode = [OFNumber numberWithUnsignedShort: (entry.versionSpecificAttributes >> 16) & 0777]; of_file_attribute_key_t key = of_file_attribute_key_posix_permissions; - of_file_attributes_t attributes = [OFDictionary - dictionaryWithObject: mode - forKey: key]; + of_file_attributes_t attributes = + [OFDictionary dictionaryWithObject: mode forKey: key]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } #endif @@ -295,17 +292,15 @@ directory = outFileName.stringByDeletingLastPathComponent; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; - if (![app shouldExtractFile: fileName - outFileName: outFileName]) + if (![app shouldExtractFile: fileName outFileName: outFileName]) goto outer_loop_end; stream = [_archive streamForReadingFile: fileName]; - output = [OFFile fileWithPath: outFileName - mode: @"w"]; + output = [OFFile fileWithPath: outFileName mode: @"w"]; setPermissions(outFileName, entry); while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: output Index: utils/ofdns/OFDNS.m ================================================================== --- utils/ofdns/OFDNS.m +++ utils/ofdns/OFDNS.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -201,11 +199,10 @@ [OFDNSQuery queryWithDomainName: domainName DNSClass: DNSClass recordType: recordType]; _inFlight++; - [resolver asyncPerformQuery: query - delegate: self]; + [resolver asyncPerformQuery: query delegate: self]; } } } @end Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -129,15 +127,13 @@ sandbox.allowsStdIO = true; sandbox.allowsReadingFiles = true; sandbox.allowsUserDatabaseReading = true; for (OFString *path in optionsParser.remainingArguments) - [sandbox unveilPath: path - permissions: @"r"]; + [sandbox unveilPath: path permissions: @"r"]; - [sandbox unveilPath: @LANGUAGE_DIR - permissions: @"r"]; + [sandbox unveilPath: @LANGUAGE_DIR permissions: @"r"]; [OFApplication of_activateSandbox: sandbox]; } @finally { [sandbox release]; } @@ -178,12 +174,11 @@ if ([path isEqual: @"-"]) file = of_stdin; else { @try { - file = [OFFile fileWithPath: path - mode: @"r"]; + file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -330,12 +328,11 @@ .stringByDeletingEnclosingWhitespaces; value = [header substringFromIndex: pos + 1] .stringByDeletingEnclosingWhitespaces; - [_clientHeaders setObject: value - forKey: name]; + [_clientHeaders setObject: value forKey: name]; } - (void)setBody: (OFString *)path { OFString *contentLength = nil; @@ -344,12 +341,11 @@ _body = nil; if ([path isEqual: @"-"]) _body = [of_stdin copy]; else { - _body = [[OFFile alloc] initWithPath: path - mode: @"r"]; + _body = [[OFFile alloc] initWithPath: path mode: @"r"]; @try { unsigned long long fileSize = [[OFFileManager defaultManager] attributesOfItemAtPath: path].fileSize; @@ -534,12 +530,11 @@ #ifdef OF_HAVE_SANDBOX [sandbox unveilPath: (outputPath != nil ? outputPath : OF_PATH_CURRENT_DIRECTORY) permissions: (_continue ? @"rwc" : @"wc")]; /* In case we use ObjOpenSSL for https later */ - [sandbox unveilPath: @"/etc/ssl" - permissions: @"r"]; + [sandbox unveilPath: @"/etc/ssl" permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif @@ -578,12 +573,11 @@ if (_insecure) _HTTPClient.allowsInsecureRedirects = true; _useUnicode = ([OFLocale encoding] == OF_STRING_ENCODING_UTF_8); - [self performSelector: @selector(downloadNextURL) - afterDelay: 0]; + [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } - (void)client: (OFHTTPClient *)client didCreateSocket: (OFTCPSocket *)sock request: (OFHTTPRequest *)request @@ -598,16 +592,12 @@ request: (OFHTTPRequest *)request { /* TODO: Do asynchronously and print status */ while (!_body.atEndOfStream) { char buffer[4096]; - size_t length; - - length = [_body readIntoBuffer: buffer - length: 4096]; - [body writeBuffer: buffer - length: length]; + size_t length = [_body readIntoBuffer: buffer length: 4096]; + [body writeBuffer: buffer length: length]; } } - (bool)client: (OFHTTPClient *)client shouldFollowRedirect: (OFURL *)URL @@ -623,12 +613,11 @@ OFEnumerator *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [of_stdout writeFormat: @" %@: %@\n", - key, object]; + [of_stdout writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } if (!_quiet) { @@ -675,15 +664,13 @@ [self performSelector: @selector(downloadNextURL) afterDelay: 0]; return false; } - _received += length; + [_output writeBuffer: buffer length: length]; - [_output writeBuffer: buffer - length: length]; - + _received += length; [_progressBar setReceived: _received]; if (response.atEndOfStream) { [_progressBar stop]; [_progressBar draw]; @@ -981,20 +968,18 @@ [_currentFileName release]; _currentFileName = nil; response.delegate = self; - [response asyncReadIntoBuffer: _buffer - length: [OFSystemInfo pageSize]]; + [response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]]; return; next: [_currentFileName release]; _currentFileName = nil; - [self performSelector: @selector(downloadNextURL) - afterDelay: 0]; + [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } - (void)downloadNextURL { OFString *URLString = nil; @@ -1063,10 +1048,18 @@ _currentFileName = [_outputPath copy]; if (_currentFileName == nil) _currentFileName = [URL.path.lastPathComponent copy]; + if ([_currentFileName isEqual: @"/"]) { + [_currentFileName release]; + _currentFileName = nil; + } + + if (_currentFileName == nil) + _currentFileName = @"unnamed"; + if (_continue) { @try { unsigned long long size = [[OFFileManager defaultManager] attributesOfItemAtPath: _currentFileName].fileSize; @@ -1077,12 +1070,11 @@ _resumedFrom = (unsigned long long)size; range = [OFString stringWithFormat: @"bytes=%jd-", _resumedFrom]; - [clientHeaders setObject: range - forKey: @"Range"]; + [clientHeaders setObject: range forKey: @"Range"]; } @catch (OFRetrieveItemAttributesFailedException *e) { } } if (!_quiet) { @@ -1099,9 +1091,8 @@ _detectFileNameRequest = false; [_HTTPClient asyncPerformRequest: request]; return; next: - [self performSelector: @selector(downloadNextURL) - afterDelay: 0]; + [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } @end Index: utils/ofhttp/ProgressBar.h ================================================================== --- utils/ofhttp/ProgressBar.h +++ utils/ofhttp/ProgressBar.h @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in Index: utils/ofhttp/ProgressBar.m ================================================================== --- utils/ofhttp/ProgressBar.m +++ utils/ofhttp/ProgressBar.m @@ -1,9 +1,7 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, - * 2018, 2019, 2020 - * Jonathan Schleifer + * Copyright (c) 2008-2021 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -29,10 +27,14 @@ #define GIBIBYTE (1024 * 1024 * 1024) #define MEBIBYTE (1024 * 1024) #define KIBIBYTE (1024) #define UPDATE_INTERVAL 0.1 + +#ifndef HAVE_TRUNCF +# define truncf(x) trunc(x) +#endif @implementation ProgressBar - (instancetype)initWithLength: (unsigned long long)length resumedFrom: (unsigned long long)resumedFrom useUnicode: (bool)useUnicode