Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -29,13 +29,10 @@ #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFThread.h" #import "OFThread+Private.h" -#import "autorelease.h" -#import "macros.h" - #if defined(__MACH__) && !defined(OF_IOS) # include #elif defined(_WIN32) # include Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -30,13 +30,10 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFArray (OF_PRIVATE_CATEGORY) Index: src/OFArray_adjacent.m ================================================================== --- src/OFArray_adjacent.m +++ src/OFArray_adjacent.m @@ -27,13 +27,10 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFArray_adjacent - init { self = [super init]; Index: src/OFAutoreleasePool+Private.h ================================================================== --- src/OFAutoreleasePool+Private.h +++ src/OFAutoreleasePool+Private.h @@ -14,11 +14,9 @@ * file. */ #import "OFAutoreleasePool.h" -#import "macros.h" - @interface OFAutoreleasePool (OF_PRIVATE_CATEGORY) + (void)OF_handleThreadTermination; - (void)OF_super_dealloc; @end Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -17,19 +17,16 @@ #include "config.h" #import "OFAutoreleasePool.h" #import "OFAutoreleasePool+Private.h" -#import "macros.h" #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" - +# # import "OFInitializationFailedException.h" #endif -#import "autorelease.h" - #define MAX_CACHE_SIZE 0x20 #if defined(OF_HAVE_COMPILER_TLS) static thread_local OFAutoreleasePool **cache = NULL; #elif defined(OF_HAVE_THREADS) Index: src/OFBigDataArray.m ================================================================== --- src/OFBigDataArray.m +++ src/OFBigDataArray.m @@ -23,12 +23,10 @@ #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "macros.h" - @implementation OFBigDataArray - init { return [self initWithItemSize: 1 capacity: 0]; Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -18,23 +18,19 @@ #include #include #include -#if defined(OF_OBJFW_RUNTIME) -# import "runtime.h" -# import "runtime-private.h" -#elif defined(OF_APPLE_RUNTIME) -# import -#endif - #import "OFBlock.h" #import "OFAllocFailedException.h" #import "OFInitializationFailedException.h" -#import "macros.h" +#if defined(OF_OBJFW_RUNTIME) +# import "runtime-private.h" +#endif + #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif #ifdef OF_HAVE_THREADS # import "threading.h" Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -26,12 +26,10 @@ #import "OFInitializationFailedException.h" #import "OFInvalidEncodingException.h" #import "OFOutOfMemoryException.h" -#import "macros.h" - #if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) # import struct { struct class *isa, *super_class; Index: src/OFCountedSet.m ================================================================== --- src/OFCountedSet.m +++ src/OFCountedSet.m @@ -22,13 +22,10 @@ #import "OFCountedSet_hashtable.h" #import "OFNumber.h" #import "OFString.h" #import "OFXMLElement.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFCountedSet_placeholder: OFCountedSet Index: src/OFCountedSet_hashtable.m ================================================================== --- src/OFCountedSet_hashtable.m +++ src/OFCountedSet_hashtable.m @@ -27,12 +27,10 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFEnumerationMutationException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" - @implementation OFCountedSet_hashtable + (void)initialize { if (self == [OFCountedSet_hashtable class]) [self inheritMethodsFromClass: [OFMutableSet_hashtable class]]; Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -20,12 +20,10 @@ #import "OFString.h" #import "OFHash.h" #import "OFMD5Hash.h" #import "OFSHA1Hash.h" -#import "autorelease.h" - int _OFDataArray_Hashing_reference; @implementation OFDataArray (Hashing) - (OFString*)OF_hashAsStringWithHash: (Class )hashClass { Index: src/OFDataArray+MessagePackValue.m ================================================================== --- src/OFDataArray+MessagePackValue.m +++ src/OFDataArray+MessagePackValue.m @@ -23,13 +23,10 @@ #import "OFDictionary.h" #import "OFMessagePackExtension.h" #import "OFInvalidFormatException.h" -#import "autorelease.h" -#import "macros.h" - int _OFDataArray_MessagePackValue_reference; static size_t parseObject(const uint8_t*, size_t, id*); static uint16_t Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -43,13 +43,11 @@ #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" -#import "autorelease.h" #import "base64.h" -#import "macros.h" /* References for static linking */ void _references_to_categories_of_OFDataArray(void) { _OFDataArray_MessagePackValue_reference = 1; Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -36,12 +36,10 @@ #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" #import "of_strptime.h" #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ defined(OF_HAVE_THREADS) static OFMutex *mutex; Index: src/OFDeflateStream.m ================================================================== --- src/OFDeflateStream.m +++ src/OFDeflateStream.m @@ -34,13 +34,10 @@ #import "OFInitializationFailedException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" -#import "autorelease.h" -#import "macros.h" - #define BLOCK_HEADER OF_DEFLATE_STREAM_BLOCK_HEADER #define UNCOMPRESSED_BLOCK_HEADER OF_DEFLATE_STREAM_UNCOMPRESSED_BLOCK_HEADER #define UNCOMPRESSED_BLOCK OF_DEFLATE_STREAM_UNCOMPRESSED_BLOCK #define HUFFMAN_BLOCK OF_DEFLATE_STREAM_HUFFMAN_BLOCK #define HUFFMAN_TREE OF_DEFLATE_STREAM_HUFFMAN_TREE Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -28,13 +28,10 @@ #import "OFDataArray.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFDictionary (OF_PRIVATE_CATEGORY) Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -28,12 +28,10 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "autorelease.h" - static void* copy(void *value) { return [(id)value copy]; } Index: src/OFEnumerator.m ================================================================== --- src/OFEnumerator.m +++ src/OFEnumerator.m @@ -19,13 +19,10 @@ #include #import "OFEnumerator.h" #import "OFArray.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFEnumerator - init { if (object_getClass(self) == [OFEnumerator class]) { @try { Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -83,13 +83,10 @@ #import "OFRemoveItemFailedException.h" #import "OFSeekFailedException.h" #import "OFUnlockFailedException.h" #import "OFWriteFailedException.h" -#import "autorelease.h" -#import "macros.h" - #ifdef _WIN32 # include # include #endif Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -42,13 +42,10 @@ #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" -#import "autorelease.h" -#import "macros.h" - static OF_INLINE void normalizeKey(char *str_) { uint8_t *str = (uint8_t*)str_; bool firstLetter = true; Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -23,13 +23,10 @@ #import "OFURL.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFArray.h" -#import "autorelease.h" -#import "macros.h" - #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" const char* Index: src/OFHTTPResponse.m ================================================================== --- src/OFHTTPResponse.m +++ src/OFHTTPResponse.m @@ -20,13 +20,10 @@ #import "OFString.h" #import "OFDictionary.h" #import "OFArray.h" #import "OFDataArray.h" -#import "autorelease.h" -#import "macros.h" - #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -35,13 +35,10 @@ #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFWriteFailedException.h" -#import "autorelease.h" -#import "macros.h" - #define BUFFER_SIZE 1024 /* * FIXME: Key normalization replaces headers like "DNT" with "Dnt". * FIXME: Errors are not reported to the user. Index: src/OFINICategory+Private.h ================================================================== --- src/OFINICategory+Private.h +++ src/OFINICategory+Private.h @@ -15,16 +15,14 @@ */ #import "OFINICategory.h" #import "OFString.h" -#import "macros.h" - @class OFStream; @interface OFINICategory (OF_PRIVATE_CATEGORY) - (instancetype)OF_init; - (void)OF_parseLine: (OFString*)line; - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first; @end Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -21,13 +21,10 @@ #import "OFStream.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" -#import "autorelease.h" -#import "macros.h" - @interface OFINICategory_Pair: OFObject { @public OFString *_key, *_value; } Index: src/OFINIFile.m ================================================================== --- src/OFINIFile.m +++ src/OFINIFile.m @@ -22,13 +22,10 @@ #import "OFINICategory+Private.h" #import "OFInvalidFormatException.h" #import "OFOpenFileFailedException.h" -#import "autorelease.h" -#import "macros.h" - @interface OFINIFile (OF_PRIVATE_CATEGORY) - (void)OF_parseFile: (OFString*)path encoding: (of_string_encoding_t)encoding; @end Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -17,23 +17,16 @@ #include "config.h" #include #include -#if defined(OF_APPLE_RUNTIME) -# import -#endif - #import "OFIntrospection.h" #import "OFString.h" #import "OFArray.h" #import "OFInitializationFailedException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFMethod #if defined(OF_OBJFW_RUNTIME) - (instancetype)OF_initWithMethod: (struct objc_method*)method { self = [super init]; Index: src/OFKernelEventObserver+Private.h ================================================================== --- src/OFKernelEventObserver+Private.h +++ src/OFKernelEventObserver+Private.h @@ -14,15 +14,13 @@ * file. */ #import "OFKernelEventObserver.h" -#import "macros.h" - @interface OFKernelEventObserver (OF_PRIVATE_CATEGORY) - (void)OF_addFileDescriptorForReading: (int)fd; - (void)OF_addFileDescriptorForWriting: (int)fd; - (void)OF_removeFileDescriptorForReading: (int)fd; - (void)OF_removeFileDescriptorForWriting: (int)fd; - (void)OF_processQueue; - (bool)OF_processCache; @end Index: src/OFKernelEventObserver.m ================================================================== --- src/OFKernelEventObserver.m +++ src/OFKernelEventObserver.m @@ -47,12 +47,10 @@ #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" #import "socket_helpers.h" enum { QUEUE_ADD = 0, QUEUE_REMOVE = 1, Index: src/OFKernelEventObserver_kqueue.m ================================================================== --- src/OFKernelEventObserver_kqueue.m +++ src/OFKernelEventObserver_kqueue.m @@ -32,12 +32,10 @@ #import "OFInitializationFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" #import "socket_helpers.h" #define EVENTLIST_SIZE 64 @implementation OFKernelEventObserver_kqueue Index: src/OFKernelEventObserver_poll.m ================================================================== --- src/OFKernelEventObserver_poll.m +++ src/OFKernelEventObserver_poll.m @@ -27,12 +27,10 @@ #import "OFKernelEventObserver_poll.h" #import "OFDataArray.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" #import "socket_helpers.h" #ifdef __wii__ # define pollfd pollsd # define fd socket Index: src/OFKernelEventObserver_select.m ================================================================== --- src/OFKernelEventObserver_select.m +++ src/OFKernelEventObserver_select.m @@ -26,12 +26,10 @@ #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFKernelEventObserver_select.h" #import "OFArray.h" -#import "autorelease.h" -#import "macros.h" #import "socket_helpers.h" @implementation OFKernelEventObserver_select - init { Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -25,13 +25,10 @@ #import "OFArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFList + (instancetype)list { return [[[self alloc] init] autorelease]; } Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -20,12 +20,10 @@ #import "OFMD5Hash.h" #import "OFHashAlreadyCalculatedException.h" -#import "macros.h" - /* The four MD5 core functions - F1 is optimized somewhat */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -26,12 +26,10 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "macros.h" - #define MIN_CAPACITY 16 struct of_map_table_bucket { void *key, *value; uint32_t hash; Index: src/OFMessagePackExtension.m ================================================================== --- src/OFMessagePackExtension.m +++ src/OFMessagePackExtension.m @@ -20,12 +20,10 @@ #import "OFDataArray.h" #import "OFString.h" #import "OFInvalidArgumentException.h" -#import "macros.h" - @implementation OFMessagePackExtension + (instancetype)extensionWithType: (int8_t)type data: (OFDataArray*)data { return [[[self alloc] initWithType: type Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -26,13 +26,10 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFMutableArray_placeholder: OFMutableArray Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -19,13 +19,10 @@ #include #import "OFMutableDictionary_hashtable.h" #import "OFArray.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFMutableDictionary_placeholder: OFDictionary Index: src/OFMutableDictionary_hashtable.m ================================================================== --- src/OFMutableDictionary_hashtable.m +++ src/OFMutableDictionary_hashtable.m @@ -23,12 +23,10 @@ #import "OFMapTable.h" #import "OFEnumerationMutationException.h" #import "OFOutOfRangeException.h" -#import "macros.h" - @implementation OFMutableDictionary_hashtable + (void)initialize { if (self == [OFMutableDictionary_hashtable class]) [self inheritMethodsFromClass: [OFDictionary_hashtable class]]; Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -21,13 +21,10 @@ #include #import "OFMutableSet.h" #import "OFMutableSet_hashtable.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFMutableSet_placeholder: OFMutableSet Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -27,13 +27,10 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - #import "of_asprintf.h" #import "unicode.h" static struct { Class isa; Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -29,13 +29,10 @@ #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - #import "of_asprintf.h" #import "unicode.h" @implementation OFMutableString_UTF8 + (void)initialize Index: src/OFMutex.m ================================================================== --- src/OFMutex.m +++ src/OFMutex.m @@ -22,12 +22,10 @@ #import "OFInitializationFailedException.h" #import "OFLockFailedException.h" #import "OFStillLockedException.h" #import "OFUnlockFailedException.h" -#import "macros.h" - @implementation OFMutex + (instancetype)mutex { return [[[self alloc] init] autorelease]; } Index: src/OFNull.m ================================================================== --- src/OFNull.m +++ src/OFNull.m @@ -21,13 +21,10 @@ #import "OFXMLElement.h" #import "OFDataArray.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" -#import "macros.h" - @interface OFNull (OF_PRIVATE_CATEGORY) - (OFString*)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -26,13 +26,10 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - #define RETURN_AS(t) \ switch (_type) { \ case OF_NUMBER_BOOL: \ return (t)_value.bool_; \ case OF_NUMBER_CHAR: \ Index: src/OFObject+Serialization.m ================================================================== --- src/OFObject+Serialization.m +++ src/OFObject+Serialization.m @@ -22,12 +22,10 @@ #import "OFObject+Serialization.h" #import "OFSerialization.h" #import "OFString.h" #import "OFXMLElement.h" -#import "autorelease.h" - int _OFObject_Serialization_reference; @implementation OFObject (Serialization) - (OFString*)stringBySerializing { Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -26,181 +26,15 @@ #include #include #include #include -#ifdef OF_OBJFW_RUNTIME -# import "runtime.h" -#else -# import -#endif - -#ifdef OF_APPLE_RUNTIME -# import -# import -#endif +#import "macros.h" +#import "autorelease.h" /*! @file */ -#if defined(__GNUC__) -# define restrict __restrict__ -#elif __STDC_VERSION__ < 199901L -# define restrict -#endif - -#if __STDC_VERSION__ >= 201112L -# ifdef OF_HAVE_STDNORETURN_H -# include -# else -# define noreturn _Noreturn -# endif -#elif defined(__GNUC__) -# define noreturn __attribute__((__noreturn__)) -#else -# define noreturn -#endif - -/* - * Work around Apple's libc headers breaking by defining noreturn. - * They use __attribute__((noreturn)) where they should be using - * __attribute__((__noreturn__)). - */ -#if defined(__APPLE__) && defined(__dead2) -# undef __dead2 -# define __dead2 __attribute__((__noreturn__)) -#endif - -#if defined(OF_HAVE__THREAD_LOCAL) -# define OF_HAVE_COMPILER_TLS -# ifdef OF_HAVE_THREADS_H -# include -# else -# define thread_local _Thread_local -# endif -#elif defined(OF_HAVE___THREAD) -# define OF_HAVE_COMPILER_TLS -# define thread_local __thread -#endif - -#ifndef __has_feature -# define __has_feature(x) 0 -#endif - -#ifndef __has_attribute -# define __has_attribute(x) 0 -#endif - -#ifdef __GNUC__ -# define __GCC_VERSION__ (__GNUC__ * 100 + __GNUC_MINOR__) -#else -# define __GCC_VERSION__ 0 -#endif - -#if defined(__clang__) || __GCC_VERSION__ >= 406 || defined(OBJC_NEW_PROPERTIES) -# define OF_HAVE_PROPERTIES -# define OF_HAVE_OPTIONAL_PROTOCOLS -# if defined(__clang__) || __GCC_VERSION__ >= 406 || defined(OF_APPLE_RUNTIME) -# define OF_HAVE_FAST_ENUMERATION -# endif -# define OF_HAVE_CLASS_EXTENSIONS -#endif - -#if !__has_feature(objc_instancetype) -# define instancetype id -#endif - -#if __has_feature(blocks) -# define OF_HAVE_BLOCKS -#endif - -#if __has_feature(objc_bool) -# undef YES -# define YES __objc_yes -# undef NO -# define NO __objc_no -# ifndef __cplusplus -# undef true -# define true ((bool)1) -# undef false -# define false ((bool)0) -# endif -#endif - -#if defined(__clang__) || __GCC_VERSION__ >= 406 -# define OF_SENTINEL __attribute__((__sentinel__)) -# define OF_METHOD_NORETURN __attribute__((__noreturn__)) -#else -# define OF_SENTINEL -# define OF_METHOD_NORETURN -#endif - -#if __has_attribute(__objc_requires_super__) -# define OF_REQUIRES_SUPER __attribute__((__objc_requires_super__)) -#else -# define OF_REQUIRES_SUPER -#endif - -#if __has_attribute(__objc_root_class__) -# define OF_ROOT_CLASS __attribute__((__objc_root_class__)) -#else -# define OF_ROOT_CLASS -#endif - -#ifdef OF_APPLE_RUNTIME -# if defined(__x86_64__) || defined(__i386__) || defined(__ARM64_ARCH_8__) || \ - defined(__arm__) || defined(__ppc__) -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET -# endif -#else -# if defined(__ELF__) -# if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) || \ - defined(__arm__) || defined(__ARM__) || defined(__ppc__) || \ - defined(__PPC__) -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR -# if __OBJFW_RUNTIME_ABI__ >= 800 -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET -# endif -# endif -# if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ - (defined(__mips_eabi) && _MIPS_SZPTR == 32) -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR -# if __OBJFW_RUNTIME_ABI__ >= 800 -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET -# endif -# endif -# elif defined(_WIN32) -# if defined(__x86_64__) || defined(__i386__) -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR -# if __OBJFW_RUNTIME_ABI__ >= 800 -# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET -# endif -# endif -# endif -#endif - -#if __has_feature(objc_arc) -# define OF_RETURNS_RETAINED __attribute__((__ns_returns_retained__)) -# define OF_RETURNS_NOT_RETAINED __attribute__((__ns_returns_not_retained__)) -# define OF_RETURNS_INNER_POINTER \ - __attribute__((__objc_returns_inner_pointer__)) -# define OF_CONSUMED __attribute__((__ns_consumed__)) -# define OF_WEAK_UNAVAILABLE __attribute__((__objc_arc_weak_unavailable__)) -#else -# define OF_RETURNS_RETAINED -# define OF_RETURNS_NOT_RETAINED -# define OF_RETURNS_INNER_POINTER -# define OF_CONSUMED -# define OF_WEAK_UNAVAILABLE -# define __unsafe_unretained -# define __bridge -# define __autoreleasing -#endif - -#define OF_RETAIN_COUNT_MAX UINT_MAX -#define OF_NOT_FOUND SIZE_MAX - /*! * @brief A result of a comparison. */ typedef enum { /*! The left object is smaller than the right */ @@ -230,10 +64,25 @@ /*! The start of the range */ size_t location; /*! The length of the range */ size_t length; } of_range_t; + +/*! + * @brief Creates a new of_range_t. + * + * @param start The starting index of the range + * @param length The length of the range + * @return An of_range with the specified start and length + */ +static OF_INLINE of_range_t OF_CONST_FUNC +of_range(size_t start, size_t length) +{ + of_range_t range = { start, length }; + + return range; +} /*! * @brief A time interval in seconds. */ typedef double of_time_interval_t; @@ -247,10 +96,25 @@ /*! The x coordinate of the point */ float x; /*! The y coordinate of the point */ float y; } of_point_t; + +/*! + * @brief Creates a new of_point_t. + * + * @param x The x coordinate of the point + * @param y The x coordinate of the point + * @return An of_point_t with the specified coordinates + */ +static OF_INLINE of_point_t OF_CONST_FUNC +of_point(float x, float y) +{ + of_point_t point = { x, y }; + + return point; +} /*! * @struct of_dimension_t OFObject.h ObjFW/OFObject.h * * @brief A dimension. @@ -259,10 +123,25 @@ /*! The width of the dimension */ float width; /*! The height of the dimension */ float height; } of_dimension_t; + +/*! + * @brief Creates a new of_dimension_t. + * + * @param width The width of the dimension + * @param height The height of the dimension + * @return An of_dimension_t with the specified width and height + */ +static OF_INLINE of_dimension_t OF_CONST_FUNC +of_dimension(float width, float height) +{ + of_dimension_t dimension = { width, height }; + + return dimension; +} /*! * @struct of_rectangle_t OFObject.h ObjFW/OFObject.h * * @brief A rectangle. @@ -271,10 +150,30 @@ /*! The point from where the rectangle originates */ of_point_t origin; /*! The size of the rectangle */ of_dimension_t size; } of_rectangle_t; + +/*! + * @brief Creates a new of_rectangle_t. + * + * @param x The x coordinate of the top left corner of the rectangle + * @param y The y coordinate of the top left corner of the rectangle + * @param width The width of the rectangle + * @param height The height of the rectangle + * @return An of_rectangle_t with the specified origin and size + */ +static OF_INLINE of_rectangle_t OF_CONST_FUNC +of_rectangle(float x, float y, float width, float height) +{ + of_rectangle_t rectangle = { + of_point(x, y), + of_dimension(width, height) + }; + + return rectangle; +} @class OFString; @class OFThread; /*! Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -37,13 +37,10 @@ #import "OFMemoryNotPartOfObjectException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" - #if defined(OF_APPLE_RUNTIME) && __OBJC2__ # import #elif defined(OF_OBJFW_RUNTIME) # import "runtime.h" #endif Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -18,13 +18,10 @@ #import "OFOptionsParser.h" #import "OFApplication.h" #import "OFArray.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFOptionsParser + (instancetype)parserWithOptions: (OFString*)options { return [[[self alloc] initWithOptions: options] autorelease]; } Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -26,12 +26,10 @@ #import "OFPlugin.h" #import "OFString.h" #import "OFInitializationFailedException.h" -#import "autorelease.h" - #ifdef _WIN32 # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -46,13 +46,10 @@ #ifdef _WIN32 # include #endif -#import "autorelease.h" -#import "macros.h" - #ifndef __MACH__ extern char **environ; #endif @interface OFProcess (OF_PRIVATE_CATEGORY) Index: src/OFRecursiveMutex.m ================================================================== --- src/OFRecursiveMutex.m +++ src/OFRecursiveMutex.m @@ -22,12 +22,10 @@ #import "OFInitializationFailedException.h" #import "OFLockFailedException.h" #import "OFStillLockedException.h" #import "OFUnlockFailedException.h" -#import "macros.h" - @implementation OFRecursiveMutex + (instancetype)mutex { return [[[self alloc] init] autorelease]; } Index: src/OFRunLoop+Private.h ================================================================== --- src/OFRunLoop+Private.h +++ src/OFRunLoop+Private.h @@ -18,12 +18,10 @@ #import "OFStream.h" #ifdef OF_HAVE_SOCKETS # import "OFUDPSocket.h" #endif -#import "macros.h" - @interface OFRunLoop (OF_PRIVATE_CATEGORY) + (void)OF_setMainRunLoop: (OFRunLoop*)runLoop; #ifdef OF_HAVE_SOCKETS + (void)OF_addAsyncReadForStream: (OFStream*)stream buffer: (void*)buffer Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -32,13 +32,10 @@ #import "OFSortedList.h" #import "OFTimer.h" #import "OFTimer+Private.h" #import "OFDate.h" -#import "autorelease.h" -#import "macros.h" - static OFRunLoop *mainRunLoop = nil; #ifdef OF_HAVE_SOCKETS @interface OFRunLoop_QueueItem: OFObject { Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -20,12 +20,10 @@ #import "OFSHA1Hash.h" #import "OFHashAlreadyCalculatedException.h" -#import "macros.h" - /* blk0() and blk() perform the initial expand. */ #ifndef OF_BIG_ENDIAN #define blk0(i) \ (block.l[i] = (OF_ROL(block.l[i], 24) & 0xFF00FF00) | \ (OF_ROL(block.l[i], 8) & 0x00FF00FF)) Index: src/OFSeekableStream.m ================================================================== --- src/OFSeekableStream.m +++ src/OFSeekableStream.m @@ -21,12 +21,10 @@ #include #include #import "OFSeekableStream.h" -#import "macros.h" - @implementation OFSeekableStream - init { if (object_getClass(self) == [OFSeekableStream class]) { @try { Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -22,13 +22,10 @@ #import "OFSet_hashtable.h" #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" -#import "autorelease.h" -#import "macros.h" - static struct { Class isa; } placeholder; @interface OFSet_placeholder: OFSet Index: src/OFSet_hashtable.m ================================================================== --- src/OFSet_hashtable.m +++ src/OFSet_hashtable.m @@ -26,12 +26,10 @@ #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" #import "OFEnumerationMutationException.h" -#import "autorelease.h" - static void* retain(void *value) { return [(id)value retain]; } Index: src/OFSettings.m ================================================================== --- src/OFSettings.m +++ src/OFSettings.m @@ -18,13 +18,10 @@ #import "OFSettings.h" #import "OFSettings_INIFile.h" #import "OFString.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFSettings + alloc { if (self == [OFSettings class]) return [OFSettings_INIFile alloc]; Index: src/OFSettings_INIFile.m ================================================================== --- src/OFSettings_INIFile.m +++ src/OFSettings_INIFile.m @@ -19,13 +19,10 @@ #import "OFSettings_INIFile.h" #import "OFString.h" #import "OFINIFile.h" #import "OFSystemInfo.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFSettings_INIFile - initWithApplicationName: (OFString*)applicationName { self = [super initWithApplicationName: applicationName]; Index: src/OFSortedList.m ================================================================== --- src/OFSortedList.m +++ src/OFSortedList.m @@ -16,12 +16,10 @@ #include "config.h" #import "OFSortedList.h" -#import "macros.h" - @implementation OFSortedList - (of_list_object_t*)appendObject: (id)object { OF_UNRECOGNIZED_SELECTOR } Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -30,13 +30,10 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" -#import "autorelease.h" -#import "macros.h" - OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; @interface OFStdIOStream (OF_PRIVATE_CATEGORY) Index: src/OFStream+Private.h ================================================================== --- src/OFStream+Private.h +++ src/OFStream+Private.h @@ -14,10 +14,8 @@ * file. */ #import "OFStream.h" -#import "macros.h" - @interface OFStream (OF_PRIVATE_CATEGORY) - (bool)OF_isWaitingForDelimiter; @end Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -43,11 +43,10 @@ #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" #import "OFSetOptionFailedException.h" -#import "macros.h" #import "of_asprintf.h" @implementation OFStream #ifndef _WIN32 + (void)initialize Index: src/OFString+Hashing.m ================================================================== --- src/OFString+Hashing.m +++ src/OFString+Hashing.m @@ -19,12 +19,10 @@ #import "OFString.h" #import "OFHash.h" #import "OFMD5Hash.h" #import "OFSHA1Hash.h" -#import "autorelease.h" - int _OFString_Hashing_reference; @implementation OFString (Hashing) - (OFString*)OF_hashAsStringWithHash: (Class )hashClass { Index: src/OFString+JSONValue.m ================================================================== --- src/OFString+JSONValue.m +++ src/OFString+JSONValue.m @@ -29,12 +29,10 @@ #import "OFNumber.h" #import "OFNull.h" #import "OFInvalidJSONException.h" -#import "macros.h" - int _OFString_JSONValue_reference; static id nextObject(const char *restrict *, const char*, size_t *restrict line, size_t depth, size_t depthLimit); Index: src/OFString+Serialization.m ================================================================== --- src/OFString+Serialization.m +++ src/OFString+Serialization.m @@ -26,12 +26,10 @@ #import "OFInvalidArgumentException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" #import "OFUnsupportedVersionException.h" -#import "autorelease.h" - int _OFString_Serialization_reference; @implementation OFString (Serialization) - (id)objectByDeserializing { Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -20,13 +20,10 @@ #import "OFString.h" #import "OFInvalidFormatException.h" -#import "autorelease.h" -#import "macros.h" - int _OFString_XMLUnescaping_reference; static OF_INLINE OFString* parseNumericEntity(const char *entity, size_t length) { Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -52,12 +52,10 @@ #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" -#import "autorelease.h" -#import "macros.h" #import "of_asprintf.h" #import "unicode.h" /* * It seems strtod is buggy on Win32. Index: src/OFString_UTF8+Private.h ================================================================== --- src/OFString_UTF8+Private.h +++ src/OFString_UTF8+Private.h @@ -14,12 +14,10 @@ * file. */ #import "OFString_UTF8.h" -#import "macros.h" - @interface OFString_UTF8 (OF_PRIVATE_CATEGORY) - (instancetype)OF_initWithUTF8String: (const char*)UTF8String length: (size_t)UTF8StringLength storage: (char*)storage; @end Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -33,12 +33,10 @@ #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "autorelease.h" -#import "macros.h" #import "of_asprintf.h" #import "unicode.h" extern const of_char16_t of_iso_8859_15[128]; extern const of_char16_t of_windows_1252[128]; Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -32,25 +32,19 @@ #import "OFDictionary.h" #import "OFApplication.h" #import "OFNotImplementedException.h" -#import "autorelease.h" -#import "macros.h" - #ifdef __APPLE__ # include #endif - #ifdef _WIN32 # include #endif - #ifdef __HAIKU__ # include #endif - #ifdef __QNX__ # include #endif static size_t pageSize; Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -41,12 +41,10 @@ #import "OFNotConnectedException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFSetOptionFailedException.h" -#import "autorelease.h" -#import "macros.h" #import "resolver.h" #import "socket_helpers.h" /* References for static linking */ void _references_to_categories_of_OFTCPSocket(void) Index: src/OFThread+Private.h ================================================================== --- src/OFThread+Private.h +++ src/OFThread+Private.h @@ -14,12 +14,10 @@ * file. */ #import "OFThread.h" -#import "macros.h" - #ifdef OF_HAVE_THREADS @interface OFThread (OF_PRIVATE_CATEGORY) + (void)OF_createMainThread; @end #endif Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -70,12 +70,10 @@ #endif #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif -#import "autorelease.h" -#import "macros.h" #ifdef __DJGPP__ # define lrint(x) rint(x) # define useconds_t unsigned int #endif Index: src/OFThreadPool.m ================================================================== --- src/OFThreadPool.m +++ src/OFThreadPool.m @@ -21,12 +21,10 @@ #import "OFList.h" #import "OFThread.h" #import "OFCondition.h" #import "OFSystemInfo.h" -#import "autorelease.h" - @interface OFThreadPoolJob: OFObject { id _target; SEL _selector; id _object; Index: src/OFTimer+Private.h ================================================================== --- src/OFTimer+Private.h +++ src/OFTimer+Private.h @@ -14,10 +14,8 @@ * file. */ #import "OFTimer.h" -#import "macros.h" - @interface OFTimer (OF_PRIVATE_CATEGORY) - (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop; @end Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -29,13 +29,10 @@ # import "OFCondition.h" #endif #import "OFInvalidArgumentException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFTimer + (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector repeats: (bool)repeats Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -33,12 +33,10 @@ #import "OFNotConnectedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" -#import "autorelease.h" -#import "macros.h" #import "resolver.h" #import "socket_helpers.h" #ifdef __wii__ static uint16_t freePort = 65532; Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -26,13 +26,10 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFURL + (instancetype)URL { return [[[self alloc] init] autorelease]; } Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -21,13 +21,10 @@ #import "OFDictionary.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" -#import "macros.h" - @implementation OFXMLAttribute + (instancetype)attributeWithName: (OFString*)name namespace: (OFString*)namespace stringValue: (OFString*)stringValue { Index: src/OFXMLCDATA.m ================================================================== --- src/OFXMLCDATA.m +++ src/OFXMLCDATA.m @@ -20,12 +20,10 @@ #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" - @implementation OFXMLCDATA + (instancetype)CDATAWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } Index: src/OFXMLCharacters.m ================================================================== --- src/OFXMLCharacters.m +++ src/OFXMLCharacters.m @@ -20,12 +20,10 @@ #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" - @implementation OFXMLCharacters + (instancetype)charactersWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -22,12 +22,10 @@ #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" - @implementation OFXMLComment + (instancetype)commentWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } Index: src/OFXMLElement+Serialization.m ================================================================== --- src/OFXMLElement+Serialization.m +++ src/OFXMLElement+Serialization.m @@ -21,13 +21,10 @@ #import "OFSerialization.h" #import "OFString.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" -#import "macros.h" - int _OFXMLElement_Serialization_reference; @implementation OFXMLElement (Serialization) - (id)objectByDeserializing { Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -35,13 +35,10 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" -#import "autorelease.h" -#import "macros.h" - /* References for static linking */ void _references_to_categories_of_OFXMLElement(void) { _OFXMLElement_Serialization_reference = 1; } Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -26,12 +26,10 @@ #import "OFXMLParser.h" #import "OFArray.h" #import "OFMalformedXMLException.h" -#import "macros.h" - @implementation OFXMLElementBuilder + (instancetype)elementBuilder { return [[[self alloc] init] autorelease]; } Index: src/OFXMLNode.m ================================================================== --- src/OFXMLNode.m +++ src/OFXMLNode.m @@ -17,12 +17,10 @@ #include "config.h" #import "OFXMLNode.h" #import "OFString.h" -#import "macros.h" - @implementation OFXMLNode - initWithSerialization: (OFXMLElement*)element { OF_INVALID_INIT_METHOD } Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -34,16 +34,13 @@ #import "OFInitializationFailedException.h" #import "OFMalformedXMLException.h" #import "OFUnboundPrefixException.h" -#import "autorelease.h" -#import "macros.h" - -typedef void (*state_function)(id, SEL); +typedef void (*state_function_t)(id, SEL); static SEL selectors[OF_XMLPARSER_NUM_STATES]; -static state_function lookupTable[OF_XMLPARSER_NUM_STATES]; +static state_function_t lookupTable[OF_XMLPARSER_NUM_STATES]; static OF_INLINE void appendToBuffer(OFDataArray *buffer, const char *string, of_string_encoding_t encoding, size_t length) { @@ -168,11 +165,11 @@ for (i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { if (![self instancesRespondToSelector: selectors[i]]) @throw [OFInitializationFailedException exceptionWithClass: self]; - lookupTable[i] = (state_function) + lookupTable[i] = (state_function_t) [self instanceMethodForSelector: selectors[i]]; } } + (instancetype)parser Index: src/OFXMLProcessingInstructions.m ================================================================== --- src/OFXMLProcessingInstructions.m +++ src/OFXMLProcessingInstructions.m @@ -22,12 +22,10 @@ #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" -#import "autorelease.h" - @implementation OFXMLProcessingInstructions + (instancetype)processingInstructionsWithString: (OFString*)string { return [[[self alloc] initWithString: string] autorelease]; } Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -34,13 +34,10 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFUnsupportedVersionException.h" -#import "autorelease.h" -#import "macros.h" - #define CRC32_MAGIC 0xEDB88320 /* * FIXME: Current limitations: * - Split archives are not supported. Index: src/OFZIPArchiveEntry+Private.h ================================================================== --- src/OFZIPArchiveEntry+Private.h +++ src/OFZIPArchiveEntry+Private.h @@ -14,14 +14,12 @@ * file. */ #import "OFZIPArchive.h" -#import "macros.h" - @interface OFZIPArchiveEntry (OF_PRIVATE_CATEGORY) - (instancetype)OF_initWithFile: (OFFile*)file; - (uint16_t)OF_generalPurposeBitFlag; - (uint16_t)OF_lastModifiedFileTime; - (uint16_t)OF_lastModifiedFileDate; - (uint64_t)OF_localFileHeaderOffset; @end Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -21,13 +21,10 @@ #import "OFString.h" #import "OFDataArray.h" #import "OFFile.h" #import "OFDate.h" -#import "autorelease.h" -#import "macros.h" - #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" extern uint32_t of_zip_archive_read_field32(uint8_t**, uint16_t*); extern uint64_t of_zip_archive_read_field64(uint8_t**, uint16_t*); Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -158,12 +158,10 @@ #import "OFUnlockFailedException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" -#import "macros.h" - #ifdef OF_HAVE_PLUGINS # import "OFPlugin.h" #endif #ifdef OF_HAVE_ATOMIC_OPS @@ -178,13 +176,12 @@ # import "OFMutex.h" # import "OFRecursiveMutex.h" # import "OFCondition.h" #endif -#import "autorelease.h" #import "asprintf.h" #import "base64.h" #import "of_asprintf.h" #import "of_strptime.h" #ifdef OF_HAVE_SOCKETS # import "resolver.h" #endif Index: src/autorelease.m ================================================================== --- src/autorelease.m +++ src/autorelease.m @@ -23,13 +23,10 @@ #import "OFSystemInfo.h" #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" #endif -#import "macros.h" - -#import "autorelease.h" #if defined(OF_HAVE_COMPILER_TLS) static thread_local id *objects = NULL; static thread_local id *top = NULL; static thread_local size_t size = 0; Index: src/codepage_437.m ================================================================== --- src/codepage_437.m +++ src/codepage_437.m @@ -14,12 +14,10 @@ * file. */ #import "OFString.h" -#import "macros.h" - const of_char16_t of_codepage_437[128] = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, Index: src/exceptions/OFAcceptFailedException.m ================================================================== --- src/exceptions/OFAcceptFailedException.m +++ src/exceptions/OFAcceptFailedException.m @@ -18,11 +18,10 @@ #import "OFAcceptFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFAcceptFailedException + (instancetype)exceptionWithSocket: (id)socket { return [[[self alloc] initWithSocket: socket] autorelease]; Index: src/exceptions/OFAddressTranslationFailedException.m ================================================================== --- src/exceptions/OFAddressTranslationFailedException.m +++ src/exceptions/OFAddressTranslationFailedException.m @@ -18,11 +18,10 @@ #import "OFAddressTranslationFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFAddressTranslationFailedException + (instancetype)exceptionWithHost: (OFString*)host { return [[[self alloc] initWithHost: host] autorelease]; Index: src/exceptions/OFAllocFailedException.m ================================================================== --- src/exceptions/OFAllocFailedException.m +++ src/exceptions/OFAllocFailedException.m @@ -17,12 +17,10 @@ #include "config.h" #import "OFAllocFailedException.h" #import "OFString.h" -#import "macros.h" - @implementation OFAllocFailedException + alloc { OF_UNRECOGNIZED_SELECTOR } Index: src/exceptions/OFBindFailedException.m ================================================================== --- src/exceptions/OFBindFailedException.m +++ src/exceptions/OFBindFailedException.m @@ -18,11 +18,10 @@ #import "OFBindFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFBindFailedException + (instancetype)exceptionWithHost: (OFString*)host port: (uint16_t)port socket: (id)socket Index: src/exceptions/OFChangeCurrentDirectoryPathFailedException.m ================================================================== --- src/exceptions/OFChangeCurrentDirectoryPathFailedException.m +++ src/exceptions/OFChangeCurrentDirectoryPathFailedException.m @@ -18,11 +18,10 @@ #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFChangeCurrentDirectoryPathFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; Index: src/exceptions/OFChangeOwnerFailedException.m ================================================================== --- src/exceptions/OFChangeOwnerFailedException.m +++ src/exceptions/OFChangeOwnerFailedException.m @@ -18,11 +18,10 @@ #import "OFChangeOwnerFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" #ifdef OF_HAVE_CHOWN @implementation OFChangeOwnerFailedException + (instancetype)exceptionWithPath: (OFString*)path owner: (OFString*)owner Index: src/exceptions/OFChangePermissionsFailedException.m ================================================================== --- src/exceptions/OFChangePermissionsFailedException.m +++ src/exceptions/OFChangePermissionsFailedException.m @@ -18,11 +18,10 @@ #import "OFChangePermissionsFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFChangePermissionsFailedException + (instancetype)exceptionWithPath: (OFString*)path permissions: (mode_t)permissions { Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -18,12 +18,10 @@ #import "OFConditionBroadcastFailedException.h" #import "OFString.h" #import "OFCondition.h" -#import "macros.h" - @implementation OFConditionBroadcastFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -18,12 +18,10 @@ #import "OFConditionSignalFailedException.h" #import "OFString.h" #import "OFCondition.h" -#import "macros.h" - @implementation OFConditionSignalFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -18,12 +18,10 @@ #import "OFConditionStillWaitingException.h" #import "OFString.h" #import "OFCondition.h" -#import "macros.h" - @implementation OFConditionStillWaitingException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -18,12 +18,10 @@ #import "OFConditionWaitFailedException.h" #import "OFString.h" #import "OFCondition.h" -#import "macros.h" - @implementation OFConditionWaitFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } Index: src/exceptions/OFConnectionFailedException.m ================================================================== --- src/exceptions/OFConnectionFailedException.m +++ src/exceptions/OFConnectionFailedException.m @@ -18,11 +18,10 @@ #import "OFConnectionFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFConnectionFailedException + (instancetype)exceptionWithHost: (OFString*)host port: (uint16_t)port socket: (id)socket Index: src/exceptions/OFCopyItemFailedException.m ================================================================== --- src/exceptions/OFCopyItemFailedException.m +++ src/exceptions/OFCopyItemFailedException.m @@ -18,11 +18,10 @@ #import "OFCopyItemFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFCopyItemFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFCreateDirectoryFailedException.m ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.m +++ src/exceptions/OFCreateDirectoryFailedException.m @@ -18,11 +18,10 @@ #import "OFCreateDirectoryFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFCreateDirectoryFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; Index: src/exceptions/OFCreateSymbolicLinkFailedException.m ================================================================== --- src/exceptions/OFCreateSymbolicLinkFailedException.m +++ src/exceptions/OFCreateSymbolicLinkFailedException.m @@ -18,11 +18,10 @@ #import "OFCreateSymbolicLinkFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" #ifdef OF_HAVE_SYMLINK @implementation OFCreateSymbolicLinkFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath Index: src/exceptions/OFEnumerationMutationException.m ================================================================== --- src/exceptions/OFEnumerationMutationException.m +++ src/exceptions/OFEnumerationMutationException.m @@ -18,11 +18,10 @@ #import "OFEnumerationMutationException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFEnumerationMutationException + (instancetype)exceptionWithObject: (id)object { return [[[self alloc] initWithObject: object] autorelease]; Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -24,12 +24,10 @@ #import "OFException.h" #import "OFString.h" #import "OFArray.h" -#import "autorelease.h" - #if defined(_WIN32) && defined(OF_HAVE_SOCKETS) # include # include #endif Index: src/exceptions/OFHTTPRequestFailedException.m ================================================================== --- src/exceptions/OFHTTPRequestFailedException.m +++ src/exceptions/OFHTTPRequestFailedException.m @@ -20,11 +20,10 @@ #import "OFString.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "common.h" -#import "macros.h" @implementation OFHTTPRequestFailedException + (instancetype)exceptionWithRequest: (OFHTTPRequest*)request response: (OFHTTPResponse*)response { Index: src/exceptions/OFHashAlreadyCalculatedException.m ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.m +++ src/exceptions/OFHashAlreadyCalculatedException.m @@ -18,11 +18,10 @@ #import "OFHashAlreadyCalculatedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFHashAlreadyCalculatedException + (instancetype)exceptionWithHash: (id )hash { return [[[self alloc] initWithHash: hash] autorelease]; Index: src/exceptions/OFInitializationFailedException.m ================================================================== --- src/exceptions/OFInitializationFailedException.m +++ src/exceptions/OFInitializationFailedException.m @@ -18,11 +18,10 @@ #import "OFInitializationFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFInitializationFailedException + (instancetype)exceptionWithClass: (Class)class { return [[[self alloc] initWithClass: class] autorelease]; Index: src/exceptions/OFInvalidJSONException.m ================================================================== --- src/exceptions/OFInvalidJSONException.m +++ src/exceptions/OFInvalidJSONException.m @@ -17,12 +17,10 @@ #include "config.h" #import "OFInvalidJSONException.h" #import "OFString.h" -#import "macros.h" - @implementation OFInvalidJSONException + (instancetype)exceptionWithString: (OFString*)string line: (size_t)line { return [[[self alloc] initWithString: string Index: src/exceptions/OFLinkFailedException.m ================================================================== --- src/exceptions/OFLinkFailedException.m +++ src/exceptions/OFLinkFailedException.m @@ -18,11 +18,10 @@ #import "OFLinkFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" #ifdef OF_HAVE_LINK @implementation OFLinkFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath Index: src/exceptions/OFListenFailedException.m ================================================================== --- src/exceptions/OFListenFailedException.m +++ src/exceptions/OFListenFailedException.m @@ -18,11 +18,10 @@ #import "OFListenFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFListenFailedException + (instancetype)exceptionWithSocket: (id)socket backLog: (int)backLog { Index: src/exceptions/OFMemoryNotPartOfObjectException.m ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.m +++ src/exceptions/OFMemoryNotPartOfObjectException.m @@ -17,12 +17,10 @@ #include "config.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFString.h" -#import "macros.h" - @implementation OFMemoryNotPartOfObjectException + (instancetype)exceptionWithPointer: (void*)pointer object: (id)object { return [[[self alloc] initWithPointer: pointer Index: src/exceptions/OFMoveItemFailedException.m ================================================================== --- src/exceptions/OFMoveItemFailedException.m +++ src/exceptions/OFMoveItemFailedException.m @@ -18,11 +18,10 @@ #import "OFMoveItemFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFMoveItemFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFNotConnectedException.m ================================================================== --- src/exceptions/OFNotConnectedException.m +++ src/exceptions/OFNotConnectedException.m @@ -18,11 +18,10 @@ #import "OFNotConnectedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFNotConnectedException + (instancetype)exceptionWithSocket: (id)socket { return [[[self alloc] initWithSocket: socket] autorelease]; Index: src/exceptions/OFNotImplementedException.m ================================================================== --- src/exceptions/OFNotImplementedException.m +++ src/exceptions/OFNotImplementedException.m @@ -18,11 +18,10 @@ #import "OFNotImplementedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFNotImplementedException + (instancetype)exceptionWithSelector: (SEL)selector object: (id)object { Index: src/exceptions/OFOpenFileFailedException.m ================================================================== --- src/exceptions/OFOpenFileFailedException.m +++ src/exceptions/OFOpenFileFailedException.m @@ -18,11 +18,10 @@ #import "OFOpenFileFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFOpenFileFailedException + (instancetype)exceptionWithPath: (OFString*)path mode: (OFString*)mode { Index: src/exceptions/OFReadOrWriteFailedException.m ================================================================== --- src/exceptions/OFReadOrWriteFailedException.m +++ src/exceptions/OFReadOrWriteFailedException.m @@ -22,11 +22,10 @@ # import "OFStreamSocket.h" # import "OFUDPSocket.h" #endif #import "common.h" -#import "macros.h" @implementation OFReadOrWriteFailedException + (instancetype)exceptionWithObject: (id)object requestedLength: (size_t)requestedLength { Index: src/exceptions/OFRemoveItemFailedException.m ================================================================== --- src/exceptions/OFRemoveItemFailedException.m +++ src/exceptions/OFRemoveItemFailedException.m @@ -18,11 +18,10 @@ #import "OFRemoveItemFailedException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFRemoveItemFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -19,11 +19,10 @@ #import "OFSeekFailedException.h" #import "OFString.h" #import "OFSeekableStream.h" #import "common.h" -#import "macros.h" @implementation OFSeekFailedException + (instancetype)exceptionWithStream: (OFSeekableStream*)stream offset: (off_t)offset whence: (int)whence Index: src/exceptions/OFSetOptionFailedException.m ================================================================== --- src/exceptions/OFSetOptionFailedException.m +++ src/exceptions/OFSetOptionFailedException.m @@ -19,11 +19,10 @@ #import "OFSetOptionFailedException.h" #import "OFString.h" #import "OFStream.h" #import "common.h" -#import "macros.h" @implementation OFSetOptionFailedException + (instancetype)exceptionWithStream: (OFStream*)stream { return [[[self alloc] initWithStream: stream] autorelease]; Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -18,12 +18,10 @@ #import "OFThreadJoinFailedException.h" #import "OFString.h" #import "OFThread.h" -#import "macros.h" - @implementation OFThreadJoinFailedException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -18,12 +18,10 @@ #import "OFThreadStartFailedException.h" #import "OFString.h" #import "OFThread.h" -#import "macros.h" - @implementation OFThreadStartFailedException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } Index: src/exceptions/OFThreadStillRunningException.m ================================================================== --- src/exceptions/OFThreadStillRunningException.m +++ src/exceptions/OFThreadStillRunningException.m @@ -18,12 +18,10 @@ #import "OFThreadStillRunningException.h" #import "OFString.h" #import "OFThread.h" -#import "macros.h" - @implementation OFThreadStillRunningException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } Index: src/exceptions/OFUnboundNamespaceException.m ================================================================== --- src/exceptions/OFUnboundNamespaceException.m +++ src/exceptions/OFUnboundNamespaceException.m @@ -19,11 +19,10 @@ #import "OFUnboundNamespaceException.h" #import "OFString.h" #import "OFXMLElement.h" #import "common.h" -#import "macros.h" @implementation OFUnboundNamespaceException + (instancetype)exceptionWithNamespace: (OFString*)namespace element: (OFXMLElement*)element { Index: src/exceptions/OFUnboundPrefixException.m ================================================================== --- src/exceptions/OFUnboundPrefixException.m +++ src/exceptions/OFUnboundPrefixException.m @@ -19,11 +19,10 @@ #import "OFUnboundPrefixException.h" #import "OFString.h" #import "OFXMLParser.h" #import "common.h" -#import "macros.h" @implementation OFUnboundPrefixException + (instancetype)exceptionWithPrefix: (OFString*)prefix parser: (OFXMLParser*)parser { Index: src/exceptions/OFUnsupportedProtocolException.m ================================================================== --- src/exceptions/OFUnsupportedProtocolException.m +++ src/exceptions/OFUnsupportedProtocolException.m @@ -19,11 +19,10 @@ #import "OFUnsupportedProtocolException.h" #import "OFString.h" #import "OFURL.h" #import "common.h" -#import "macros.h" @implementation OFUnsupportedProtocolException + (instancetype)exceptionWithURL: (OFURL*)url { return [[[self alloc] initWithURL: url] autorelease]; Index: src/exceptions/OFUnsupportedVersionException.m ================================================================== --- src/exceptions/OFUnsupportedVersionException.m +++ src/exceptions/OFUnsupportedVersionException.m @@ -18,11 +18,10 @@ #import "OFUnsupportedVersionException.h" #import "OFString.h" #import "common.h" -#import "macros.h" @implementation OFUnsupportedVersionException + (instancetype)exceptionWithVersion: (OFString*)version { return [[[self alloc] initWithVersion: version] autorelease]; Index: src/exceptions/common.h ================================================================== --- src/exceptions/common.h +++ src/exceptions/common.h @@ -15,12 +15,10 @@ */ #include #include -#import "macros.h" - #ifdef OF_HAVE_SOCKETS # include "socket.h" # include "socket_helpers.h" #endif Index: src/iso_8859_15.m ================================================================== --- src/iso_8859_15.m +++ src/iso_8859_15.m @@ -14,12 +14,10 @@ * file. */ #import "OFString.h" -#import "macros.h" - const of_char16_t of_iso_8859_15[128] = { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -12,20 +12,77 @@ * 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 "objfw-defs.h" + +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif #include #include #include #include #include -#if defined(OF_APPLE_RUNTIME) +#ifdef OF_OBJFW_RUNTIME +# import "runtime.h" +#endif +#ifdef OF_APPLE_RUNTIME +# import # import +# import +#endif + +#if defined(__GNUC__) +# define restrict __restrict__ +#elif __STDC_VERSION__ < 199901L +# define restrict +#endif + +#if __STDC_VERSION__ >= 201112L +# ifdef OF_HAVE_STDNORETURN_H +# include +# else +# define noreturn _Noreturn +# endif +#elif defined(__GNUC__) +# define noreturn __attribute__((__noreturn__)) +#else +# define noreturn +#endif + +/* + * Work around Apple's libc headers breaking by defining noreturn. + * They use __attribute__((noreturn)) where they should be using + * __attribute__((__noreturn__)). + */ +#if defined(__APPLE__) && defined(__dead2) +# undef __dead2 +# define __dead2 __attribute__((__noreturn__)) +#endif + +#if __STDC_VERSION__ >= 201112L && !defined(static_assert) +/* C11 compiler, but old libc */ +# define static_assert _Static_assert +#endif + +#if defined(OF_HAVE__THREAD_LOCAL) +# define OF_HAVE_COMPILER_TLS +# ifdef OF_HAVE_THREADS_H +# include +# else +# define thread_local _Thread_local +# endif +#elif defined(OF_HAVE___THREAD) +# define OF_HAVE_COMPILER_TLS +# define thread_local __thread #endif #ifdef __GNUC__ # define OF_INLINE inline __attribute__((__always_inline__)) # define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1)) @@ -62,10 +119,83 @@ # else # /* Hopefully no arch needs more than 16 byte alignment */ # define OF_BIGGEST_ALIGNMENT 16 # endif #endif + +#ifdef __GNUC__ +# define __GCC_VERSION__ (__GNUC__ * 100 + __GNUC_MINOR__) +#else +# define __GCC_VERSION__ 0 +#endif + +#if defined(__clang__) || __GCC_VERSION__ >= 406 || defined(OBJC_NEW_PROPERTIES) +# define OF_HAVE_PROPERTIES +# define OF_HAVE_OPTIONAL_PROTOCOLS +# if defined(__clang__) || __GCC_VERSION__ >= 406 || defined(OF_APPLE_RUNTIME) +# define OF_HAVE_FAST_ENUMERATION +# endif +# define OF_HAVE_CLASS_EXTENSIONS +# define OF_PRIVATE_CATEGORY +#else +# define OF_PRIVATE_CATEGORY Private +#endif + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if !__has_feature(objc_instancetype) +# define instancetype id +#endif + +#if __has_feature(blocks) +# define OF_HAVE_BLOCKS +#endif + +#if __has_feature(objc_bool) +# undef YES +# define YES __objc_yes +# undef NO +# define NO __objc_no +# ifndef __cplusplus +# undef true +# define true ((bool)1) +# undef false +# define false ((bool)0) +# endif +#endif + +#if defined(__clang__) || __GCC_VERSION__ >= 405 +# define OF_UNREACHABLE __builtin_unreachable(); +#else +# define OF_UNREACHABLE abort(); +#endif + +#if defined(__clang__) || __GCC_VERSION__ >= 406 +# define OF_SENTINEL __attribute__((__sentinel__)) +# define OF_METHOD_NORETURN __attribute__((__noreturn__)) +#else +# define OF_SENTINEL +# define OF_METHOD_NORETURN +#endif + +#if __has_attribute(__objc_requires_super__) +# define OF_REQUIRES_SUPER __attribute__((__objc_requires_super__)) +#else +# define OF_REQUIRES_SUPER +#endif + +#if __has_attribute(__objc_root_class__) +# define OF_ROOT_CLASS __attribute__((__objc_root_class__)) +#else +# define OF_ROOT_CLASS +#endif #ifdef __GNUC__ # if defined(__x86_64__) || defined(__amd64__) # define OF_X86_64_ASM # elif defined(__i386__) @@ -113,21 +243,63 @@ # elif defined(__arm64__) || defined(__aarch64__) # define OF_ARM64_ASM # endif #endif -#define OF_ENSURE(cond) \ - if (!(cond)) { \ - fprintf(stderr, "Failed to ensure condition in " \ - __FILE__ ":%d:\n" #cond "\n", __LINE__); \ - abort(); \ - } - -#if __STDC_VERSION__ >= 201112L && !defined(static_assert) -/* C11 compiler, but old libc */ -# define static_assert _Static_assert +#ifdef OF_APPLE_RUNTIME +# if defined(__x86_64__) || defined(__i386__) || defined(__ARM64_ARCH_8__) || \ + defined(__arm__) || defined(__ppc__) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET +# endif +#else +# if defined(__ELF__) +# if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) || \ + defined(__arm__) || defined(__ARM__) || defined(__ppc__) || \ + defined(__PPC__) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# if __OBJFW_RUNTIME_ABI__ >= 800 +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET +# endif +# endif +# if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ + (defined(__mips_eabi) && _MIPS_SZPTR == 32) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# if __OBJFW_RUNTIME_ABI__ >= 800 +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET +# endif +# endif +# elif defined(_WIN32) +# if defined(__x86_64__) || defined(__i386__) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# if __OBJFW_RUNTIME_ABI__ >= 800 +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET +# endif +# endif +# endif +#endif + +#if __has_feature(objc_arc) +# define OF_RETURNS_RETAINED __attribute__((__ns_returns_retained__)) +# define OF_RETURNS_NOT_RETAINED __attribute__((__ns_returns_not_retained__)) +# define OF_RETURNS_INNER_POINTER \ + __attribute__((__objc_returns_inner_pointer__)) +# define OF_CONSUMED __attribute__((__ns_consumed__)) +# define OF_WEAK_UNAVAILABLE __attribute__((__objc_arc_weak_unavailable__)) +#else +# define OF_RETURNS_RETAINED +# define OF_RETURNS_NOT_RETAINED +# define OF_RETURNS_INNER_POINTER +# define OF_CONSUMED +# define OF_WEAK_UNAVAILABLE +# define __unsafe_unretained +# define __bridge +# define __autoreleasing #endif + +#define OF_RETAIN_COUNT_MAX UINT_MAX +#define OF_NOT_FOUND SIZE_MAX #if !defined(_WIN32) && !defined(__DJGPP__) # define OF_PATH_DELIMITER '/' # define OF_PATH_DELIMITER_STRING @"/" # define OF_IS_PATH_DELIMITER(c) (c == '/') @@ -137,24 +309,16 @@ # define OF_IS_PATH_DELIMITER(c) (c == '\\' || c == '/') #endif #define OF_PATH_CURRENT_DIRECTORY @"." #define OF_PATH_PARENT_DIRECTORY @".." -extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL); -extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, signed char); - -#define OF_IVAR_OFFSET(ivar) ((intptr_t)&ivar - (intptr_t)self) -#define OF_GETTER(ivar, atomic) \ - return objc_getProperty(self, _cmd, OF_IVAR_OFFSET(ivar), atomic); -#define OF_SETTER(ivar, value, atomic, copy) \ - objc_setProperty(self, _cmd, OF_IVAR_OFFSET(ivar), value, atomic, copy); - -#if defined(__clang__) || __GCC_VERSION__ >= 405 -# define OF_UNREACHABLE __builtin_unreachable(); -#else -# define OF_UNREACHABLE abort(); -#endif +#define OF_ENSURE(cond) \ + if (!(cond)) { \ + fprintf(stderr, "Failed to ensure condition in " \ + __FILE__ ":%d:\n" #cond "\n", __LINE__); \ + abort(); \ + } #define OF_UNRECOGNIZED_SELECTOR \ [self doesNotRecognizeSelector: _cmd]; \ OF_UNREACHABLE #define OF_INVALID_INIT_METHOD \ @@ -165,16 +329,25 @@ @throw e; \ } \ \ abort(); -#ifdef OF_HAVE_CLASS_EXTENSIONS -# define OF_PRIVATE_CATEGORY -#else -# define OF_PRIVATE_CATEGORY Private +#ifdef __cplusplus +extern "C" { +#endif +extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL); +extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, signed char); +#ifdef __cplusplus +} #endif +#define OF_IVAR_OFFSET(ivar) ((intptr_t)&ivar - (intptr_t)self) +#define OF_GETTER(ivar, atomic) \ + return objc_getProperty(self, _cmd, OF_IVAR_OFFSET(ivar), atomic); +#define OF_SETTER(ivar, value, atomic, copy) \ + objc_setProperty(self, _cmd, OF_IVAR_OFFSET(ivar), value, atomic, copy); + static OF_INLINE uint16_t OF_CONST_FUNC OF_BSWAP16_CONST(uint16_t i) { return (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; @@ -388,45 +561,10 @@ OF_HASH_ADD(hash, (otherCopy >> 16) & 0xFF); \ OF_HASH_ADD(hash, (otherCopy >> 8) & 0xFF); \ OF_HASH_ADD(hash, otherCopy & 0xFF); \ } -static OF_INLINE of_range_t OF_CONST_FUNC -of_range(size_t start, size_t length) -{ - of_range_t range = { start, length }; - - return range; -} - -static OF_INLINE of_point_t OF_CONST_FUNC -of_point(float x, float y) -{ - of_point_t point = { x, y }; - - return point; -} - -static OF_INLINE of_dimension_t OF_CONST_FUNC -of_dimension(float width, float height) -{ - of_dimension_t dimension = { width, height }; - - return dimension; -} - -static OF_INLINE of_rectangle_t OF_CONST_FUNC -of_rectangle(float x, float y, float width, float height) -{ - of_rectangle_t rectangle = { - of_point(x, y), - of_dimension(width, height) - }; - - return rectangle; -} - static OF_INLINE char* of_strdup(const char *string) { char *copy; size_t length = strlen(string); Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -26,12 +26,10 @@ #include #import "OFString.h" #import "asprintf.h" -#import "autorelease.h" -#import "macros.h" #define MAX_SUBFORMAT_LEN 64 struct context { const char *format; Index: src/runtime/property.m ================================================================== --- src/runtime/property.m +++ src/runtime/property.m @@ -21,11 +21,10 @@ #import "runtime.h" #import "runtime-private.h" #import "OFObject.h" -#import "macros.h" #ifdef OF_HAVE_THREADS # import "threading.h" # define NUM_SPINLOCKS 8 /* needs to be a power of 2 */ # define SPINLOCK_HASH(p) ((unsigned)((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1)) static of_spinlock_t spinlocks[NUM_SPINLOCKS]; Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -23,12 +23,10 @@ #include #import "OFObject.h" -#import "macros.h" - #if defined(OF_HAVE_PTHREADS) # include typedef pthread_t of_thread_t; typedef pthread_key_t of_tlskey_t; typedef pthread_mutex_t of_mutex_t; Index: src/windows_1252.m ================================================================== --- src/windows_1252.m +++ src/windows_1252.m @@ -14,12 +14,10 @@ * file. */ #import "OFString.h" -#import "macros.h" - const of_char16_t of_windows_1252[128] = { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0x017D, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFD, 0x017E, 0x0178,