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