Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -204,55 +204,27 @@ } - initWithObject: (id)firstObject arguments: (va_list)arguments { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithArray: (OFArray*)array { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithObjects: (id const*)objects count: (size_t)count { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSerialization: (OFXMLElement*)element { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (size_t)count { [self doesNotRecognizeSelector: _cmd]; Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -390,18 +390,11 @@ abort(); } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (void*)allocMemoryWithSize: (size_t)size { [self doesNotRecognizeSelector: _cmd]; Index: src/OFDeflateStream.m ================================================================== --- src/OFDeflateStream.m +++ src/OFDeflateStream.m @@ -259,18 +259,11 @@ return [[[self alloc] initWithStream: stream] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithStream: (OFStream*)stream { self = [super init]; Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -202,18 +202,11 @@ return [super init]; } - initWithDictionary: (OFDictionary*)dictionary { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithObject: (id)object forKey: (id)key { @@ -249,18 +242,11 @@ - initWithObjects: (id const*)objects forKeys: (id const*)keys count: (size_t)count { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithKeysAndObjects: (id)firstKey, ... { id ret; @@ -275,30 +261,16 @@ } - initWithKey: (id)firstKey arguments: (va_list)arguments { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSerialization: (OFXMLElement*)element { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (id)objectForKey: (id)key { [self doesNotRecognizeSelector: _cmd]; Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -689,18 +689,11 @@ } #endif - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path mode: (OFString*)mode { Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -14,11 +14,10 @@ * file. */ #include "config.h" -#include #include #if defined(OF_APPLE_RUNTIME) # import #endif @@ -64,10 +63,15 @@ } return self; } #endif + +- init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_name release]; @@ -176,10 +180,15 @@ } return self; } #endif + +- init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_name release]; @@ -325,10 +334,15 @@ @throw e; } return self; } + +- init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_classMethods release]; [_instanceMethods release]; Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -101,18 +101,11 @@ capacity: capacity] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithKeyFunctions: (of_map_table_functions_t)keyFunctions valueFunctions: (of_map_table_functions_t)valueFunctions { @@ -677,18 +670,11 @@ @end @implementation OFMapTableEnumerator - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (instancetype)OF_initWithMapTable: (OFMapTable*)mapTable buckets: (struct of_map_table_bucket**)buckets capacity: (uint32_t)capacity Index: src/OFMessagePackExtension.m ================================================================== --- src/OFMessagePackExtension.m +++ src/OFMessagePackExtension.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #import "OFMessagePackExtension.h" #import "OFDataArray.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @@ -34,18 +32,11 @@ data: data] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithType: (int8_t)type data: (OFDataArray*)data { Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -194,18 +194,11 @@ return [super init]; } - initWithCapacity: (size_t)capacity { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - copy { return [[OFArray alloc] initWithArray: self]; Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -20,10 +20,11 @@ #import "OFMutableDictionary_hashtable.h" #import "OFArray.h" #import "autorelease.h" +#import "macros.h" static struct { Class isa; } placeholder; @@ -161,18 +162,11 @@ return [super init]; } - initWithCapacity: (size_t)capacity { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (void)setObject: (id)object forKey: (id)key { Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #include #import "OFNumber.h" #import "OFString.h" #import "OFXMLElement.h" @@ -477,18 +475,11 @@ return [[[self alloc] initWithDouble: double_] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithBool: (bool)bool_ { self = [super init]; Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #import "OFOptionsParser.h" #import "OFApplication.h" #import "OFArray.h" #import "autorelease.h" @@ -31,18 +29,11 @@ return [[[self alloc] initWithOptions: options] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithOptions: (OFString*)options { self = [super init]; Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -42,10 +42,11 @@ #ifdef _WIN32 # include #endif #import "autorelease.h" +#import "macros.h" #ifndef __MACH__ extern char **environ; #endif @@ -87,10 +88,15 @@ return [[[self alloc] initWithProgram: program programName: programName arguments: arguments environment: environment] autorelease]; } + +- init +{ + OF_INVALID_INIT_METHOD +} - initWithProgram: (OFString*)program { return [self initWithProgram: program programName: program Index: src/OFSeekableStream.m ================================================================== --- src/OFSeekableStream.m +++ src/OFSeekableStream.m @@ -20,10 +20,25 @@ #include #import "OFSeekableStream.h" @implementation OFSeekableStream +- init +{ + if (object_getClass(self) == [OFSeekableStream class]) { + @try { + [self doesNotRecognizeSelector: _cmd]; + abort(); + } @catch (id e) { + [self release]; + @throw e; + } + } + + return [super init]; +} + - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { [self doesNotRecognizeSelector: _cmd]; abort(); Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -23,10 +23,11 @@ #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" #import "autorelease.h" +#import "macros.h" static struct { Class isa; } placeholder; @@ -171,43 +172,22 @@ return [super init]; } - initWithSet: (OFSet*)set { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithArray: (OFArray*)array { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithObjects: (id const*)objects count: (size_t)count { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (id)initWithObjects: (id)firstObject, ... { id ret; @@ -222,30 +202,16 @@ } - initWithObject: (id)firstObject arguments: (va_list)arguments { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSerialization: (OFXMLElement*)element { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (size_t)count { [self doesNotRecognizeSelector: _cmd]; Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -25,10 +25,11 @@ #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #import "autorelease.h" +#import "macros.h" OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; @@ -67,18 +68,11 @@ of_stderr = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 2]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (instancetype)OF_initWithFileDescriptor: (int)fd { self = [super init]; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -692,43 +692,22 @@ - initWithCString: (const char*)cString encoding: (of_string_encoding_t)encoding length: (size_t)cStringLength { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithString: (OFString*)string { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithCharacters: (const of_unichar_t*)string length: (size_t)length { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithUTF16String: (const of_char16_t*)string { return [self initWithUTF16String: string @@ -754,18 +733,11 @@ - initWithUTF16String: (const of_char16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithUTF32String: (const of_char32_t*)string { return [self initWithUTF32String: string @@ -791,18 +763,11 @@ - initWithUTF32String: (const of_char32_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithFormat: (OFConstantString*)format, ... { id ret; @@ -817,18 +782,11 @@ } - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithContentsOfFile: (OFString*)path { return [self initWithContentsOfFile: path Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -62,10 +62,11 @@ #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif #import "autorelease.h" +#import "macros.h" #ifdef OF_HAVE_THREADS # import "threading.h" static of_tlskey_t threadSelfKey; @@ -372,16 +373,9 @@ [super dealloc]; } #else - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } #endif @end Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -207,18 +207,11 @@ } #endif - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (instancetype)OF_initWithFireDate: (OFDate*)fireDate interval: (double)interval target: (id)target Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -124,18 +124,11 @@ return [[[self alloc] initWithFile: path] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithName: (OFString*)name { return [self initWithName: name Index: src/OFXMLNode.m ================================================================== --- src/OFXMLNode.m +++ src/OFXMLNode.m @@ -18,22 +18,17 @@ #include #import "OFXMLNode.h" #import "OFString.h" + +#import "macros.h" @implementation OFXMLNode - initWithSerialization: (OFXMLElement*)element { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (OFString*)stringValue { [self doesNotRecognizeSelector: _cmd]; Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -178,18 +178,11 @@ return [[[self alloc] initWithPath: path] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path { self = [super init]; Index: src/exceptions/OFAcceptFailedException.m ================================================================== --- src/exceptions/OFAcceptFailedException.m +++ src/exceptions/OFAcceptFailedException.m @@ -14,34 +14,26 @@ * file. */ #include "config.h" -#include - #import "OFAcceptFailedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFAcceptFailedException + (instancetype)exceptionWithSocket: (OFTCPSocket*)socket { return [[[self alloc] initWithSocket: socket] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSocket: (OFTCPSocket*)socket { self = [super init]; Index: src/exceptions/OFAddressTranslationFailedException.m ================================================================== --- src/exceptions/OFAddressTranslationFailedException.m +++ src/exceptions/OFAddressTranslationFailedException.m @@ -19,10 +19,11 @@ #import "OFAddressTranslationFailedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFAddressTranslationFailedException + (instancetype)exceptionWithSocket: (OFTCPSocket*)socket { return [[[self alloc] initWithSocket: socket] autorelease]; @@ -37,10 +38,15 @@ socket: (OFTCPSocket*)socket { return [[[self alloc] initWithHost: host socket: socket] autorelease]; } + +- init +{ + OF_INVALID_INIT_METHOD +} - initWithSocket: (OFTCPSocket*)socket { return [self initWithHost: nil socket: socket]; Index: src/exceptions/OFAllocFailedException.m ================================================================== --- src/exceptions/OFAllocFailedException.m +++ src/exceptions/OFAllocFailedException.m @@ -18,10 +18,12 @@ #include #import "OFAllocFailedException.h" #import "OFString.h" + +#import "macros.h" @implementation OFAllocFailedException + alloc { [self doesNotRecognizeSelector: _cmd]; @@ -28,18 +30,11 @@ abort(); } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - (void*)allocMemoryWithSize: (size_t)size { [self doesNotRecognizeSelector: _cmd]; Index: src/exceptions/OFAlreadyConnectedException.m ================================================================== --- src/exceptions/OFAlreadyConnectedException.m +++ src/exceptions/OFAlreadyConnectedException.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #import "OFAlreadyConnectedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" Index: src/exceptions/OFBindFailedException.m ================================================================== --- src/exceptions/OFBindFailedException.m +++ src/exceptions/OFBindFailedException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #import "OFBindFailedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFBindFailedException + (instancetype)exceptionWithHost: (OFString*)host port: (uint16_t)port socket: (OFTCPSocket*)socket @@ -34,18 +33,11 @@ socket: socket] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithHost: (OFString*)host port: (uint16_t)port socket: (OFTCPSocket*)socket Index: src/exceptions/OFChangeCurrentDirectoryPathFailedException.m ================================================================== --- src/exceptions/OFChangeCurrentDirectoryPathFailedException.m +++ src/exceptions/OFChangeCurrentDirectoryPathFailedException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFChangeCurrentDirectoryPathFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path { self = [super init]; Index: src/exceptions/OFChangeOwnerFailedException.m ================================================================== --- src/exceptions/OFChangeOwnerFailedException.m +++ src/exceptions/OFChangeOwnerFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #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 @@ -34,18 +33,11 @@ group: group] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path owner: (OFString*)owner group: (OFString*)group Index: src/exceptions/OFChangePermissionsFailedException.m ================================================================== --- src/exceptions/OFChangePermissionsFailedException.m +++ src/exceptions/OFChangePermissionsFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #import "OFChangePermissionsFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFChangePermissionsFailedException + (instancetype)exceptionWithPath: (OFString*)path permissions: (mode_t)permissions { @@ -31,18 +30,11 @@ permissions: permissions] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path permissions: (mode_t)permissions { Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFConditionBroadcastFailedException.h" #import "OFString.h" #import "OFCondition.h" + +#import "macros.h" @implementation OFConditionBroadcastFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithCondition: (OFCondition*)condition { self = [super init]; Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFConditionSignalFailedException.h" #import "OFString.h" #import "OFCondition.h" + +#import "macros.h" @implementation OFConditionSignalFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithCondition: (OFCondition*)condition { self = [super init]; Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFConditionStillWaitingException.h" #import "OFString.h" #import "OFCondition.h" + +#import "macros.h" @implementation OFConditionStillWaitingException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithCondition: (OFCondition*)condition { self = [super init]; Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFConditionWaitFailedException.h" #import "OFString.h" #import "OFCondition.h" + +#import "macros.h" @implementation OFConditionWaitFailedException + (instancetype)exceptionWithCondition: (OFCondition*)condition { return [[[self alloc] initWithCondition: condition] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithCondition: (OFCondition*)condition { self = [super init]; Index: src/exceptions/OFConnectionFailedException.m ================================================================== --- src/exceptions/OFConnectionFailedException.m +++ src/exceptions/OFConnectionFailedException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #import "OFConnectionFailedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFConnectionFailedException + (instancetype)exceptionWithHost: (OFString*)host port: (uint16_t)port socket: (OFTCPSocket*)socket @@ -34,18 +33,11 @@ socket: socket] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithHost: (OFString*)host port: (uint16_t)port socket: (OFTCPSocket*)socket Index: src/exceptions/OFCopyFileFailedException.m ================================================================== --- src/exceptions/OFCopyFileFailedException.m +++ src/exceptions/OFCopyFileFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #import "OFCopyFileFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFCopyFileFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { @@ -31,18 +30,11 @@ destinationPath: destinationPath] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFCreateDirectoryFailedException.m ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.m +++ src/exceptions/OFCreateDirectoryFailedException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFCreateDirectoryFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFCreateDirectoryFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path { self = [super init]; Index: src/exceptions/OFCreateSymbolicLinkFailedException.m ================================================================== --- src/exceptions/OFCreateSymbolicLinkFailedException.m +++ src/exceptions/OFCreateSymbolicLinkFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #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 @@ -32,18 +31,11 @@ destinationPath: destinationPath] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFEnumerationMutationException.m ================================================================== --- src/exceptions/OFEnumerationMutationException.m +++ src/exceptions/OFEnumerationMutationException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFEnumerationMutationException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFEnumerationMutationException + (instancetype)exceptionWithObject: (id)object { return [[[self alloc] initWithObject: object] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithObject: (id)object { self = [super init]; Index: src/exceptions/OFHTTPRequestFailedException.m ================================================================== --- src/exceptions/OFHTTPRequestFailedException.m +++ src/exceptions/OFHTTPRequestFailedException.m @@ -14,18 +14,17 @@ * file. */ #include "config.h" -#include - #import "OFHTTPRequestFailedException.h" #import "OFString.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "common.h" +#import "macros.h" @implementation OFHTTPRequestFailedException + (instancetype)exceptionWithRequest: (OFHTTPRequest*)request response: (OFHTTPResponse*)response { @@ -33,18 +32,11 @@ response: response] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithRequest: (OFHTTPRequest*)request response: (OFHTTPResponse*)response { Index: src/exceptions/OFHashAlreadyCalculatedException.m ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.m +++ src/exceptions/OFHashAlreadyCalculatedException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFHashAlreadyCalculatedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFHashAlreadyCalculatedException + (instancetype)exceptionWithHash: (id )hash { return [[[self alloc] initWithHash: hash] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithHash: (id )hashObject { self = [super init]; Index: src/exceptions/OFInitializationFailedException.m ================================================================== --- src/exceptions/OFInitializationFailedException.m +++ src/exceptions/OFInitializationFailedException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFInitializationFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFInitializationFailedException + (instancetype)exceptionWithClass: (Class)class { return [[[self alloc] initWithClass: class] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithClass: (Class)class { self = [super init]; Index: src/exceptions/OFInvalidJSONException.m ================================================================== --- src/exceptions/OFInvalidJSONException.m +++ src/exceptions/OFInvalidJSONException.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #import "OFInvalidJSONException.h" #import "OFString.h" #import "macros.h" @@ -31,18 +29,11 @@ line: line] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithString: (OFString*)string line: (size_t)line { Index: src/exceptions/OFLinkFailedException.m ================================================================== --- src/exceptions/OFLinkFailedException.m +++ src/exceptions/OFLinkFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #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 @@ -32,18 +31,11 @@ destinationPath: destinationPath] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFListenFailedException.m ================================================================== --- src/exceptions/OFListenFailedException.m +++ src/exceptions/OFListenFailedException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #import "OFListenFailedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFListenFailedException + (instancetype)exceptionWithSocket: (OFTCPSocket*)socket backLog: (int)backLog { @@ -32,18 +31,11 @@ backLog: backLog] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSocket: (OFTCPSocket*)socket backLog: (int)backLog { Index: src/exceptions/OFMemoryNotPartOfObjectException.m ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.m +++ src/exceptions/OFMemoryNotPartOfObjectException.m @@ -14,12 +14,10 @@ * file. */ #include "config.h" -#include - #import "OFMemoryNotPartOfObjectException.h" #import "OFString.h" #import "macros.h" @@ -31,18 +29,11 @@ object: object] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPointer: (void*)pointer object: (id)object { Index: src/exceptions/OFNotConnectedException.m ================================================================== --- src/exceptions/OFNotConnectedException.m +++ src/exceptions/OFNotConnectedException.m @@ -14,34 +14,26 @@ * file. */ #include "config.h" -#include - #import "OFNotConnectedException.h" #import "OFString.h" #import "OFTCPSocket.h" #import "common.h" +#import "macros.h" @implementation OFNotConnectedException + (instancetype)exceptionWithSocket: (OFStreamSocket*)socket { return [[[self alloc] initWithSocket: socket] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSocket: (OFStreamSocket*)socket { self = [super init]; Index: src/exceptions/OFNotImplementedException.m ================================================================== --- src/exceptions/OFNotImplementedException.m +++ src/exceptions/OFNotImplementedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #import "OFNotImplementedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFNotImplementedException + (instancetype)exceptionWithSelector: (SEL)selector object: (id)object { @@ -31,18 +30,11 @@ object: object] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSelector: (SEL)selector object: (id)object { Index: src/exceptions/OFOpenFileFailedException.m ================================================================== --- src/exceptions/OFOpenFileFailedException.m +++ src/exceptions/OFOpenFileFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #import "OFOpenFileFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFOpenFileFailedException + (instancetype)exceptionWithPath: (OFString*)path mode: (OFString*)mode { @@ -31,18 +30,11 @@ mode: mode] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path mode: (OFString*)mode { Index: src/exceptions/OFReadOrWriteFailedException.m ================================================================== --- src/exceptions/OFReadOrWriteFailedException.m +++ src/exceptions/OFReadOrWriteFailedException.m @@ -14,20 +14,19 @@ * file. */ #include "config.h" -#include - #import "OFReadOrWriteFailedException.h" #import "OFString.h" #import "OFStream.h" #ifdef OF_HAVE_SOCKETS # import "OFStreamSocket.h" #endif #import "common.h" +#import "macros.h" @implementation OFReadOrWriteFailedException + (instancetype)exceptionWithStream: (OFStream*)stream requestedLength: (size_t)requestedLength { @@ -35,18 +34,11 @@ requestedLength: requestedLength] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithStream: (OFStream*)stream requestedLength: (size_t)requestedLength { Index: src/exceptions/OFRemoveItemFailedException.m ================================================================== --- src/exceptions/OFRemoveItemFailedException.m +++ src/exceptions/OFRemoveItemFailedException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFRemoveItemFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFRemoveItemFailedException + (instancetype)exceptionWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPath: (OFString*)path { self = [super init]; Index: src/exceptions/OFRenameItemFailedException.m ================================================================== --- src/exceptions/OFRenameItemFailedException.m +++ src/exceptions/OFRenameItemFailedException.m @@ -14,16 +14,15 @@ * file. */ #include "config.h" -#include - #import "OFRenameItemFailedException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFRenameItemFailedException + (instancetype)exceptionWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { @@ -31,18 +30,11 @@ destinationPath: destinationPath] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithSourcePath: (OFString*)sourcePath destinationPath: (OFString*)destinationPath { Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #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 @@ -34,18 +33,11 @@ whence: whence] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithStream: (OFSeekableStream*)stream offset: (off_t)offset whence: (int)whence Index: src/exceptions/OFSetOptionFailedException.m ================================================================== --- src/exceptions/OFSetOptionFailedException.m +++ src/exceptions/OFSetOptionFailedException.m @@ -14,34 +14,26 @@ * file. */ #include "config.h" -#include - #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]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithStream: (OFStream*)stream { self = [super init]; Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFThreadJoinFailedException.h" #import "OFString.h" #import "OFThread.h" + +#import "macros.h" @implementation OFThreadJoinFailedException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithThread: (OFThread*)thread { self = [super init]; Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFThreadStartFailedException.h" #import "OFString.h" #import "OFThread.h" + +#import "macros.h" @implementation OFThreadStartFailedException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithThread: (OFThread*)thread { self = [super init]; Index: src/exceptions/OFThreadStillRunningException.m ================================================================== --- src/exceptions/OFThreadStillRunningException.m +++ src/exceptions/OFThreadStillRunningException.m @@ -14,32 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFThreadStillRunningException.h" #import "OFString.h" #import "OFThread.h" + +#import "macros.h" @implementation OFThreadStillRunningException + (instancetype)exceptionWithThread: (OFThread*)thread { return [[[self alloc] initWithThread: thread] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithThread: (OFThread*)thread { self = [super init]; Index: src/exceptions/OFUnboundNamespaceException.m ================================================================== --- src/exceptions/OFUnboundNamespaceException.m +++ src/exceptions/OFUnboundNamespaceException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #import "OFUnboundNamespaceException.h" #import "OFString.h" #import "OFXMLElement.h" #import "common.h" +#import "macros.h" @implementation OFUnboundNamespaceException + (instancetype)exceptionWithNamespace: (OFString*)namespace element: (OFXMLElement*)element { @@ -32,18 +31,11 @@ element: element] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithNamespace: (OFString*)namespace element: (OFXMLElement*)element { Index: src/exceptions/OFUnboundPrefixException.m ================================================================== --- src/exceptions/OFUnboundPrefixException.m +++ src/exceptions/OFUnboundPrefixException.m @@ -14,17 +14,16 @@ * file. */ #include "config.h" -#include - #import "OFUnboundPrefixException.h" #import "OFString.h" #import "OFXMLParser.h" #import "common.h" +#import "macros.h" @implementation OFUnboundPrefixException + (instancetype)exceptionWithPrefix: (OFString*)prefix parser: (OFXMLParser*)parser { @@ -32,18 +31,11 @@ parser: parser] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithPrefix: (OFString*)prefix parser: (OFXMLParser*)parser { Index: src/exceptions/OFUnsupportedProtocolException.m ================================================================== --- src/exceptions/OFUnsupportedProtocolException.m +++ src/exceptions/OFUnsupportedProtocolException.m @@ -14,34 +14,26 @@ * file. */ #include "config.h" -#include - #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]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithURL: (OFURL*)URL { self = [super init]; Index: src/exceptions/OFUnsupportedVersionException.m ================================================================== --- src/exceptions/OFUnsupportedVersionException.m +++ src/exceptions/OFUnsupportedVersionException.m @@ -14,33 +14,25 @@ * file. */ #include "config.h" -#include - #import "OFUnsupportedVersionException.h" #import "OFString.h" #import "common.h" +#import "macros.h" @implementation OFUnsupportedVersionException + (instancetype)exceptionWithVersion: (OFString*)version { return [[[self alloc] initWithVersion: version] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); + OF_INVALID_INIT_METHOD } - initWithVersion: (OFString*)version { self = [super init]; Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -129,10 +129,20 @@ #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); + +#define OF_INVALID_INIT_METHOD \ + @try { \ + [self doesNotRecognizeSelector: _cmd]; \ + } @catch (id e) { \ + [self release]; \ + @throw e; \ + } \ + \ + abort(); #ifdef OF_HAVE_CLASS_EXTENSIONS # define OF_PRIVATE_CATEGORY #else # define OF_PRIVATE_CATEGORY Private