Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -798,10 +798,12 @@ 4B837D7A16829C5F007A3E83 /* instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B837D7816829C5F007A3E83 /* instance.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8385161951BF9500D5358A /* OFSettings_INIFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8385121951BF9500D5358A /* OFSettings_INIFile.h */; }; 4B8385171951BF9500D5358A /* OFSettings_INIFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8385131951BF9500D5358A /* OFSettings_INIFile.m */; }; 4B8385181951BF9500D5358A /* OFSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8385141951BF9500D5358A /* OFSettings.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8385191951BF9500D5358A /* OFSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8385151951BF9500D5358A /* OFSettings.m */; }; + 4B853CEB1EBFDEB000A4B2C4 /* OFXMLNode+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B853CEA1EBFDEB000A4B2C4 /* OFXMLNode+Private.h */; }; + 4B853CEC1EBFDEB000A4B2C4 /* OFXMLNode+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B853CEA1EBFDEB000A4B2C4 /* OFXMLNode+Private.h */; }; 4B879A8C177231F000EBCEA4 /* OFDataArray+MessagePackValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B879A8D177231F000EBCEA4 /* OFDataArray+MessagePackValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */; }; 4B879A8E177231F000EBCEA4 /* OFMessagePackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B879A8B177231F000EBCEA4 /* OFMessagePackRepresentation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B881D3C1CCBFE2600E2F7D8 /* crc32.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B881D391CCBFE0700E2F7D8 /* crc32.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B881D3D1CCBFE2A00E2F7D8 /* crc32.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B881D3A1CCBFE0700E2F7D8 /* crc32.m */; }; @@ -1456,10 +1458,11 @@ 4B837D7816829C5F007A3E83 /* instance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instance.h; path = src/instance.h; sourceTree = ""; }; 4B8385121951BF9500D5358A /* OFSettings_INIFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSettings_INIFile.h; path = src/OFSettings_INIFile.h; sourceTree = ""; }; 4B8385131951BF9500D5358A /* OFSettings_INIFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSettings_INIFile.m; path = src/OFSettings_INIFile.m; sourceTree = ""; }; 4B8385141951BF9500D5358A /* OFSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSettings.h; path = src/OFSettings.h; sourceTree = ""; }; 4B8385151951BF9500D5358A /* OFSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSettings.m; path = src/OFSettings.m; sourceTree = ""; }; + 4B853CEA1EBFDEB000A4B2C4 /* OFXMLNode+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFXMLNode+Private.h"; path = "src/OFXMLNode+Private.h"; sourceTree = ""; }; 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+MessagePackValue.h"; path = "src/OFDataArray+MessagePackValue.h"; sourceTree = ""; }; 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+MessagePackValue.m"; path = "src/OFDataArray+MessagePackValue.m"; sourceTree = ""; }; 4B879A8B177231F000EBCEA4 /* OFMessagePackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMessagePackRepresentation.h; path = src/OFMessagePackRepresentation.h; sourceTree = ""; }; 4B881D391CCBFE0700E2F7D8 /* crc32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = crc32.h; path = src/crc32.h; sourceTree = ""; }; 4B881D3A1CCBFE0700E2F7D8 /* crc32.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = crc32.m; path = src/crc32.m; sourceTree = ""; }; @@ -2184,10 +2187,11 @@ 4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.m */, 4B0D249411DFAA3D00ED6FFC /* OFXMLElementBuilder.h */, 4B0D249511DFAA3D00ED6FFC /* OFXMLElementBuilder.m */, 4B11005A14329B9A003A45D8 /* OFXMLNode.h */, 4B11005B14329B9A003A45D8 /* OFXMLNode.m */, + 4B853CEA1EBFDEB000A4B2C4 /* OFXMLNode+Private.h */, 4B6799891099E7C50041064A /* OFXMLParser.h */, 4B67998A1099E7C50041064A /* OFXMLParser.m */, 4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */, 4B48B95314DC23B100546D39 /* OFXMLProcessingInstructions.m */, 4BE52D1F17B990B4005958D1 /* OFZIPArchive.h */, @@ -2587,10 +2591,11 @@ 4B2C22A31DA292BE00735907 /* OFString_UTF8+Private.h in Headers */, 4B2C22A41DA292BE00735907 /* OFTarArchiveEntry+Private.h in Headers */, 4B2C22A51DA292BE00735907 /* OFTCPSocket+SOCKS5.h in Headers */, 4B2C22A61DA292BE00735907 /* OFThread+Private.h in Headers */, 4B2C22A71DA292BE00735907 /* OFTimer+Private.h in Headers */, + 4B853CEC1EBFDEB000A4B2C4 /* OFXMLNode+Private.h in Headers */, 4B2C22A81DA292BE00735907 /* OFZIPArchiveEntry+Private.h in Headers */, 4B2C22AA1DA292BE00735907 /* socket_helpers.h in Headers */, 4BFC37BE1E50E11C00EE1269 /* common.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2809,10 +2814,11 @@ 4B6C8ADB17BD5C2E00B194F2 /* OFString_UTF8+Private.h in Headers */, 4BC176361D04963000C32718 /* OFTarArchiveEntry+Private.h in Headers */, 4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */, 4B6C8ADC17BD5C2E00B194F2 /* OFThread+Private.h in Headers */, 4B6C8ADD17BD5C2E00B194F2 /* OFTimer+Private.h in Headers */, + 4B853CEB1EBFDEB000A4B2C4 /* OFXMLNode+Private.h in Headers */, 4B6C8ADE17BD5C2E00B194F2 /* OFZIPArchiveEntry+Private.h in Headers */, 4B7DD58218942FE200990FD6 /* socket_helpers.h in Headers */, 4BFC37BD1E50E11C00EE1269 /* common.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; Index: src/OFBlock.h ================================================================== --- src/OFBlock.h +++ src/OFBlock.h @@ -24,10 +24,12 @@ * @class OFBlock OFBlock.h ObjFW/OFBlock.h * * @brief The class for all blocks, since all blocks are also objects. */ @interface OFBlock: OFObject ++ alloc OF_UNAVAILABLE; +- init OF_UNAVAILABLE; @end @interface OFStackBlock: OFBlock @end Index: src/OFDeflateStream.h ================================================================== --- src/OFDeflateStream.h +++ src/OFDeflateStream.h @@ -75,10 +75,12 @@ * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFDeflateStream */ + (instancetype)streamWithStream: (OFStream *)stream; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFDeflateStream with the specified * underlying stream. * Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -78,10 +78,12 @@ * @param fd A file descriptor, returned from for example open(). * It is not closed when the OFFile object is deallocated! * @return A new autoreleased OFFile */ + (instancetype)fileWithFileDescriptor: (int)fd; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFFile. * * @param path The path to the file to open as a string Index: src/OFHTTPCookie.h ================================================================== --- src/OFHTTPCookie.h +++ src/OFHTTPCookie.h @@ -89,10 +89,12 @@ * * @param string The cookie string to parse * @return An array of cookies */ + (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForString: (OFString *)string; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated new cookie with the specified name * and value. * Index: src/OFHTTPCookie.m ================================================================== --- src/OFHTTPCookie.m +++ src/OFHTTPCookie.m @@ -326,21 +326,20 @@ return hash; } - copy { - OFHTTPCookie *copy = [[OFHTTPCookie alloc] init]; + OFHTTPCookie *copy = [[OFHTTPCookie alloc] initWithName: _name + value: _value]; @try { - copy->_name = [_name copy]; - copy->_value = [_value copy]; copy->_expires = [_expires copy]; copy->_domain = [_domain copy]; copy->_path = [_path copy]; copy->_secure = _secure; copy->_HTTPOnly = _HTTPOnly; - copy->_extensions = [_extensions mutableCopy]; + [copy->_extensions addObjectsFromArray: _extensions]; } @catch (id e) { [copy release]; @throw e; } Index: src/OFINICategory.h ================================================================== --- src/OFINICategory.h +++ src/OFINICategory.h @@ -37,10 +37,12 @@ /*! * The name of the INI category */ @property (nonatomic, copy) OFString *name; + +- init OF_UNAVAILABLE; /*! * @brief Returns the string value for the specified key, or `nil` if it does * not exist. * Index: src/OFINIFile.h ================================================================== --- src/OFINIFile.h +++ src/OFINIFile.h @@ -50,10 +50,12 @@ * * @return A new, autoreleased OFINIFile with the contents of the specified file */ + (instancetype)fileWithPath: (OFString *)path encoding: (of_string_encoding_t)encoding; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFINIFile with the contents of the * specified file. * Index: src/OFIntrospection.h ================================================================== --- src/OFIntrospection.h +++ src/OFIntrospection.h @@ -61,10 +61,12 @@ /*! * The type encoding for the method. */ @property OF_NULLABLE_PROPERTY (readonly) const char *typeEncoding; + +- init OF_UNAVAILABLE; @end /*! * @class OFProperty OFIntrospection.h ObjFW/OFIntrospection.h * @@ -108,10 +110,12 @@ /*! * @return The name of the setter. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *setter; + +- init OF_UNAVAILABLE; @end /*! * @class OFInstanceVariable OFIntrospection.h ObjFW/OFIntrospection.h * @@ -136,10 +140,12 @@ /*! * The type encoding for the instance variable. */ @property OF_NULLABLE_PROPERTY (readonly) const char *typeEncoding; + +- init OF_UNAVAILABLE; @end /*! * @class OFIntrospection OFIntrospection.h ObjFW/OFIntrospection.h * @@ -197,10 +203,12 @@ * @brief Creates a new introspection for the specified class. * * @return A new, autoreleased introspection for the specified class */ + (instancetype)introspectionWithClass: (Class)class_; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFIntrospection with the specified * class. * Index: src/OFMapTable.h ================================================================== --- src/OFMapTable.h +++ src/OFMapTable.h @@ -110,10 +110,12 @@ + (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions objectFunctions: (of_map_table_functions_t) objectFunctions capacity: (size_t)capacity; +- init OF_UNAVAILABLE; + /*! * @brief Initializes an already allocated OFMapTable with the specified key * and object functions. * * @param keyFunctions A structure of functions for handling keys @@ -239,10 +241,12 @@ uint32_t _capacity; unsigned long _mutations; unsigned long *_mutationsPtr; uint32_t _position; } + +- init OF_UNAVAILABLE; /*! * @brief Returns the next object. * * @return The next object Index: src/OFMessagePackExtension.h ================================================================== --- src/OFMessagePackExtension.h +++ src/OFMessagePackExtension.h @@ -52,10 +52,12 @@ * @param data The data for the extension * @return A new, autoreleased OFMessagePackRepresentation */ + (instancetype)extensionWithType: (int8_t)type data: (OFDataArray *)data; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFMessagePackRepresentation with the * specified type and data. * Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -373,10 +373,12 @@ * * @param double_ A double which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithDouble: (double)double_; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFNumber with the specified bool. * * @param bool_ A bool which the OFNumber should contain Index: src/OFOptionsParser.h ================================================================== --- src/OFOptionsParser.h +++ src/OFOptionsParser.h @@ -117,10 +117,12 @@ * option is `\0` and long option is `nil`. * * @return A new, autoreleased OFOptionsParser */ + (instancetype)parserWithOptions: (const of_options_parser_option_t *)options; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFOptionsParser so that it accepts * the specified options. * Index: src/OFProcess.h ================================================================== --- src/OFProcess.h +++ src/OFProcess.h @@ -111,10 +111,12 @@ processWithProgram: (OFString *)program programName: (OFString *)programName arguments: (nullable OFArray OF_GENERIC(OFString *) *)arguments environment: (nullable OFDictionary OF_GENERIC(OFString *, OFString *) *)environment; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFProcess with the specified program * and invokes the program. * Index: src/OFSettings.h ================================================================== --- src/OFSettings.h +++ src/OFSettings.h @@ -49,10 +49,12 @@ * @param applicationName The name of the application whose settings should be * accessed * @return A new, autoreleased OFSettings instance */ + (instancetype)settingsWithApplicationName: (OFString *)applicationName; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFSettings instance with the * specified application name. * Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -32,10 +32,12 @@ @interface OFStdIOStream: OFStream { int _fd; bool _atEndOfStream; } + +- init OF_UNAVAILABLE; /*! * @brief Query the underlying terminal for the number of columns. * * @return The number of columns, or -1 if there is no underlying terminal or Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1011,11 +1011,11 @@ response: response]; self = [[response string] retain]; } else # endif - @throw [OFUnsupportedProtocolException exception]; + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; objc_autoreleasePoolPop(pool); return self; } Index: src/OFTimer.h ================================================================== --- src/OFTimer.h +++ src/OFTimer.h @@ -201,10 +201,12 @@ */ + (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval repeats: (bool)repeats block: (of_timer_block_t)block; #endif + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated timer with the specified time * interval. * Index: src/OFXMLAttribute.h ================================================================== --- src/OFXMLAttribute.h +++ src/OFXMLAttribute.h @@ -87,8 +87,10 @@ * @return An initialized OFXMLAttribute with the specified parameters */ - initWithName: (OFString *)name namespace: (nullable OFString *)namespace_ stringValue: (OFString *)stringValue; + +- initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -15,10 +15,11 @@ */ #include "config.h" #import "OFXMLAttribute.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFDictionary.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @@ -52,11 +53,11 @@ - initWithName: (OFString *)name namespace: (OFString *)namespace stringValue: (OFString *)stringValue { - self = [super init]; + self = [super OF_init]; @try { _name = [name copy]; _namespace = [namespace copy]; _stringValue = [stringValue copy]; @@ -68,11 +69,11 @@ return self; } - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || Index: src/OFXMLCDATA.h ================================================================== --- src/OFXMLCDATA.h +++ src/OFXMLCDATA.h @@ -41,8 +41,10 @@ * * @param string The string value for the CDATA * @return An initialized OFXMLCDATA */ - initWithString: (OFString *)string; + +- initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLCDATA.m ================================================================== --- src/OFXMLCDATA.m +++ src/OFXMLCDATA.m @@ -15,10 +15,11 @@ */ #include "config.h" #import "OFXMLCDATA.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @@ -28,11 +29,11 @@ return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString *)string { - self = [super init]; + self = [super OF_init]; @try { _CDATA = [string copy]; } @catch (id e) { [self release]; @@ -42,11 +43,11 @@ return self; } - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || Index: src/OFXMLCharacters.h ================================================================== --- src/OFXMLCharacters.h +++ src/OFXMLCharacters.h @@ -42,8 +42,10 @@ * * @param string The string value for the characters * @return An initialized OFXMLCharacters */ - initWithString: (OFString *)string; + +- initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLCharacters.m ================================================================== --- src/OFXMLCharacters.m +++ src/OFXMLCharacters.m @@ -15,10 +15,11 @@ */ #include "config.h" #import "OFXMLCharacters.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @@ -28,11 +29,11 @@ return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString *)string { - self = [super init]; + self = [super OF_init]; @try { _characters = [string copy]; } @catch (id e) { [self release]; @@ -42,11 +43,11 @@ return self; } - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || Index: src/OFXMLComment.h ================================================================== --- src/OFXMLComment.h +++ src/OFXMLComment.h @@ -42,8 +42,10 @@ * * @param string The string for the comment * @return An initialized OFXMLComment */ - initWithString: (OFString *)string; + +- initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -17,10 +17,11 @@ #include "config.h" #include #import "OFXMLComment.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @@ -30,11 +31,11 @@ return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString *)string { - self = [super init]; + self = [super OF_init]; @try { _comment = [string copy]; } @catch (id e) { [self release]; @@ -44,11 +45,11 @@ return self; } - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -130,10 +130,12 @@ * file */ + (instancetype)elementWithFile: (OFString *)path; #endif +- init OF_UNAVAILABLE; + /*! * @brief Initializes an already allocated OFXMLElement with the specified name. * * @param name The name for the element * @return An initialized OFXMLElement with the specified element name @@ -205,10 +207,12 @@ * @param path The path to the file * @return An initialized OFXMLElement with the contents of the specified file */ - initWithFile: (OFString *)path; #endif + +- initWithSerialization: (OFXMLElement *)element; /*! * @brief Sets a prefix for a namespace. * * @param prefix The prefix for the namespace Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -20,10 +20,11 @@ #include #include #import "OFXMLElement.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFXMLAttribute.h" @@ -158,11 +159,11 @@ - initWithName: (OFString *)name namespace: (OFString *)namespace stringValue: (OFString *)stringValue { - self = [super init]; + self = [super OF_init]; @try { if (name == nil) @throw [OFInvalidArgumentException exception]; @@ -184,11 +185,11 @@ return self; } - initWithElement: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { if (element == nil) @throw [OFInvalidArgumentException exception]; @@ -273,11 +274,11 @@ } #endif - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); OFXMLElement *attributesElement, *namespacesElement; OFXMLElement *childrenElement; ADDED src/OFXMLNode+Private.h Index: src/OFXMLNode+Private.h ================================================================== --- src/OFXMLNode+Private.h +++ src/OFXMLNode+Private.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFXMLNode.h" + +OF_ASSUME_NONNULL_BEGIN + +@interface OFXMLNode () +- (instancetype)OF_init; +@end + +OF_ASSUME_NONNULL_END Index: src/OFXMLNode.h ================================================================== --- src/OFXMLNode.h +++ src/OFXMLNode.h @@ -17,16 +17,21 @@ #import "OFObject.h" #import "OFSerialization.h" OF_ASSUME_NONNULL_BEGIN +@class OFXMLElement; + /*! * @class OFXMLNode OFXMLNode.h ObjFW/OFXMLNode.h * * @brief A class which stores an XML element. */ @interface OFXMLNode: OFObject +- init OF_UNAVAILABLE; +- initWithSerialization: (OFXMLElement *)element OF_UNAVAILABLE; + /*! * @brief Returns the contents of the receiver as a string value. * * @return A string with the string value */ Index: src/OFXMLNode.m ================================================================== --- src/OFXMLNode.m +++ src/OFXMLNode.m @@ -18,10 +18,20 @@ #import "OFXMLNode.h" #import "OFString.h" @implementation OFXMLNode +- (instancetype)OF_init +{ + return [super init]; +} + +- init +{ + OF_INVALID_INIT_METHOD +} + - initWithSerialization: (OFXMLElement *)element { OF_INVALID_INIT_METHOD } Index: src/OFXMLProcessingInstructions.h ================================================================== --- src/OFXMLProcessingInstructions.h +++ src/OFXMLProcessingInstructions.h @@ -43,8 +43,10 @@ * * @param string The string for the processing instructions * @return An initialized OFXMLProcessingInstructions */ - initWithString: (OFString *)string; + +- initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLProcessingInstructions.m ================================================================== --- src/OFXMLProcessingInstructions.m +++ src/OFXMLProcessingInstructions.m @@ -17,10 +17,11 @@ #include "config.h" #include #import "OFXMLProcessingInstructions.h" +#import "OFXMLNode+Private.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @@ -30,11 +31,11 @@ return [[[self alloc] initWithString: string] autorelease]; } - initWithString: (OFString *)string { - self = [super init]; + self = [super OF_init]; @try { _processingInstructions = [string copy]; } @catch (id e) { [self release]; @@ -44,11 +45,11 @@ return self; } - initWithSerialization: (OFXMLElement *)element { - self = [super init]; + self = [super OF_init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -67,10 +67,12 @@ * @param path The path to the ZIP file * @return A new, autoreleased OFZIPArchive */ + (instancetype)archiveWithPath: (OFString *)path; #endif + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFZIPArchive object with the * specified seekable stream. * Index: src/exceptions/OFAcceptFailedException.h ================================================================== --- src/exceptions/OFAcceptFailedException.h +++ src/exceptions/OFAcceptFailedException.h @@ -42,19 +42,23 @@ /*! * @return The errno from when the exception was created. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased accept failed exception. * * @param socket The socket which could not accept a connection * @param errNo The errno for the error * @return A new, autoreleased accept failed exception */ + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated accept failed exception. * * @param socket The socket which could not accept a connection Index: src/exceptions/OFAllocFailedException.h ================================================================== --- src/exceptions/OFAllocFailedException.h +++ src/exceptions/OFAllocFailedException.h @@ -34,14 +34,17 @@ * does not know for which class allocation failed and it should not be handled * like other exceptions, as the exception handling code is not allowed to * allocate *any* memory. */ @interface OFAllocFailedException: OFObject ++ (instancetype)exception OF_UNAVAILABLE; +- init OF_UNAVAILABLE; + /*! * @brief Returns a description of the exception. * * @return A description of the exception */ - (OFString *)description; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFBindFailedException.h ================================================================== --- src/exceptions/OFBindFailedException.h +++ src/exceptions/OFBindFailedException.h @@ -54,10 +54,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased bind failed exception. * * @param host The host on which binding failed * @param port The port on which binding failed @@ -67,10 +69,12 @@ */ + (instancetype)exceptionWithHost: (OFString *)host port: (uint16_t)port socket: (id)socket errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated bind failed exception. * * @param host The host on which binding failed Index: src/exceptions/OFChangeCurrentDirectoryPathFailedException.h ================================================================== --- src/exceptions/OFChangeCurrentDirectoryPathFailedException.h +++ src/exceptions/OFChangeCurrentDirectoryPathFailedException.h @@ -40,10 +40,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased change current directory path failed * exception. * * @param path The path of the directory to which the current path could not be @@ -51,10 +53,12 @@ * @param errNo The errno of the error that occurred * @return A new, autoreleased change current directory path failed exception */ + (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated change directory failed exception. * * @param path The path of the directory to which the current path could not be Index: src/exceptions/OFChangeOwnerFailedException.h ================================================================== --- src/exceptions/OFChangeOwnerFailedException.h +++ src/exceptions/OFChangeOwnerFailedException.h @@ -48,10 +48,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased change owner failed exception. * * @param path The path of the item * @param owner The new owner for the item @@ -61,10 +63,12 @@ */ + (instancetype)exceptionWithPath: (OFString *)path owner: (nullable OFString *)owner group: (nullable OFString *)group errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated change owner failed exception. * * @param path The path of the item Index: src/exceptions/OFChangePermissionsFailedException.h ================================================================== --- src/exceptions/OFChangePermissionsFailedException.h +++ src/exceptions/OFChangePermissionsFailedException.h @@ -48,10 +48,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased change permissions failed exception. * * @param path The path of the item * @param permissions The new permissions for the item @@ -59,10 +61,12 @@ * @return A new, autoreleased change permissions failed exception */ + (instancetype)exceptionWithPath: (OFString *)path permissions: (mode_t)permissions errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated change permissions failed exception. * * @param path The path of the item Index: src/exceptions/OFConnectionFailedException.h ================================================================== --- src/exceptions/OFConnectionFailedException.h +++ src/exceptions/OFConnectionFailedException.h @@ -54,10 +54,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased connection failed exception. * * @param host The host to which the connection failed * @param port The port on the host to which the connection failed @@ -79,10 +81,12 @@ */ + (instancetype)exceptionWithHost: (OFString *)host port: (uint16_t)port socket: (id)socket errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated connection failed exception. * * @param host The host to which the connection failed Index: src/exceptions/OFCopyItemFailedException.h ================================================================== --- src/exceptions/OFCopyItemFailedException.h +++ src/exceptions/OFCopyItemFailedException.h @@ -43,10 +43,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased copy item failed exception. * * @param sourcePath The original path * @param destinationPath The new path @@ -54,10 +56,12 @@ * @return A new, autoreleased copy item failed exception */ + (instancetype)exceptionWithSourcePath: (OFString *)sourcePath destinationPath: (OFString *)destinationPath errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated copy item failed exception. * * @param sourcePath The original path Index: src/exceptions/OFCreateDirectoryFailedException.h ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.h +++ src/exceptions/OFCreateDirectoryFailedException.h @@ -39,10 +39,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased create directory failed exception. * * @param path A string with the path of the directory which could not be * created @@ -49,10 +51,12 @@ * @param errNo The errno of the error that occurred * @return A new, autoreleased create directory failed exception */ + (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated create directory failed exception. * * @param path A string with the path of the directory which could not be Index: src/exceptions/OFCreateSymbolicLinkFailedException.h ================================================================== --- src/exceptions/OFCreateSymbolicLinkFailedException.h +++ src/exceptions/OFCreateSymbolicLinkFailedException.h @@ -44,10 +44,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased create symbolic link failed exception. * * @param sourcePath The source for the symbolic link * @param destinationPath The destination for the symbolic link @@ -65,10 +67,12 @@ * @return A new, autoreleased create symbolic link failed exception */ + (instancetype)exceptionWithSourcePath: (OFString *)sourcePath destinationPath: (OFString *)destinationPath errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated create symbolic link failed * exception. * Index: src/exceptions/OFEnumerationMutationException.h ================================================================== --- src/exceptions/OFEnumerationMutationException.h +++ src/exceptions/OFEnumerationMutationException.h @@ -34,17 +34,21 @@ /*! * The object which was mutated during enumeration. */ @property (readonly, nonatomic) id object; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased enumeration mutation exception. * * @param object The object which was mutated during enumeration * @return A new, autoreleased enumeration mutation exception */ + (instancetype)exceptionWithObject: (id)object; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated enumeration mutation exception. * * @param object The object which was mutated during enumeration Index: src/exceptions/OFGetOptionFailedException.h ================================================================== --- src/exceptions/OFGetOptionFailedException.h +++ src/exceptions/OFGetOptionFailedException.h @@ -40,19 +40,23 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased get option failed exception. * * @param stream The stream for which the option could not be gotten * @param errNo The errno of the error that occurred * @return A new, autoreleased get option failed exception */ + (instancetype)exceptionWithStream: (OFStream *)stream errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated get option failed exception. * * @param stream The stream for which the option could not be gotten Index: src/exceptions/OFHTTPRequestFailedException.h ================================================================== --- src/exceptions/OFHTTPRequestFailedException.h +++ src/exceptions/OFHTTPRequestFailedException.h @@ -46,19 +46,23 @@ /*! * The response for the failed HTTP request. */ @property (readonly, nonatomic) OFHTTPResponse *response; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased HTTP request failed exception. * * @param request The HTTP request which failed * @param response The response for the failed HTTP request * @return A new, autoreleased HTTP request failed exception */ + (instancetype)exceptionWithRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated HTTP request failed exception. * * @param request The HTTP request which failed Index: src/exceptions/OFHashAlreadyCalculatedException.h ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.h +++ src/exceptions/OFHashAlreadyCalculatedException.h @@ -33,17 +33,21 @@ /*! * The hash which has already been calculated. */ @property (readonly, nonatomic) id object; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased hash already calculated exception. * * @param object The hash which has already been calculated * @return A new, autoreleased hash already calculated exception */ + (instancetype)exceptionWithObject: (id)object; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated hash already calculated exception. * * @param object The hash which has already been calculated Index: src/exceptions/OFInvalidJSONException.h ================================================================== --- src/exceptions/OFInvalidJSONException.h +++ src/exceptions/OFInvalidJSONException.h @@ -31,34 +31,38 @@ } /*! * The string containing the invalid JSON representation. */ -@property (readonly, nonatomic) OFString *string; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *string; /*! * The line in which parsing the JSON representation failed. */ @property (readonly) size_t line; + ++ (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased invalid JSON exception. * * @param string The string containing the invalid JSON representation * @param line The line in which the parsing error was encountered * @return A new, autoreleased invalid JSON exception */ -+ (instancetype)exceptionWithString: (OFString *)string ++ (instancetype)exceptionWithString: (nullable OFString *)string line: (size_t)line; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated invalid JSON exception. * * @param string The string containing the invalid JSON representation * @param line The line in which the parsing error was encountered * @return An initialized invalid JSON exception */ -- initWithString: (OFString *)string +- initWithString: (nullable OFString *)string line: (size_t)line; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFLinkFailedException.h ================================================================== --- src/exceptions/OFLinkFailedException.h +++ src/exceptions/OFLinkFailedException.h @@ -43,10 +43,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased link failed exception. * * @param sourcePath The source for the link * @param destinationPath The destination for the link @@ -64,10 +66,12 @@ * @return A new, autoreleased link failed exception */ + (instancetype)exceptionWithSourcePath: (OFString *)sourcePath destinationPath: (OFString *)destinationPath errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated link failed exception. * * @param sourcePath The source for the link Index: src/exceptions/OFListenFailedException.h ================================================================== --- src/exceptions/OFListenFailedException.h +++ src/exceptions/OFListenFailedException.h @@ -47,10 +47,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased listen failed exception. * * @param socket The socket which failed to listen * @param backLog The requested size of the back log @@ -58,10 +60,12 @@ * @return A new, autoreleased listen failed exception */ + (instancetype)exceptionWithSocket: (id)socket backLog: (int)backLog errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated listen failed exception * * @param socket The socket which failed to listen Index: src/exceptions/OFMemoryNotPartOfObjectException.h ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.h +++ src/exceptions/OFMemoryNotPartOfObjectException.h @@ -39,19 +39,23 @@ /*! * The object which the memory is not part of. */ @property (readonly, nonatomic) id object; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased memory not part of object exception. * * @param pointer A pointer to the memory that is not part of the object * @param object The object which the memory is not part of * @return A new, autoreleased memory not part of object exception */ + (instancetype)exceptionWithPointer: (void *)pointer object: (id)object; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated memory not part of object exception. * * @param pointer A pointer to the memory that is not part of the object Index: src/exceptions/OFMoveItemFailedException.h ================================================================== --- src/exceptions/OFMoveItemFailedException.h +++ src/exceptions/OFMoveItemFailedException.h @@ -43,10 +43,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased move item failed exception. * * @param sourcePath The original path * @param destinationPath The new path @@ -54,10 +56,12 @@ * @return A new, autoreleased move item failed exception */ + (instancetype)exceptionWithSourcePath: (OFString *)sourcePath destinationPath: (OFString *)destinationPath errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated move item failed exception. * * @param sourcePath The original path Index: src/exceptions/OFNotImplementedException.h ================================================================== --- src/exceptions/OFNotImplementedException.h +++ src/exceptions/OFNotImplementedException.h @@ -39,19 +39,23 @@ /*! * The object which does not (fully) implement the selector. */ @property (readonly, nonatomic) id object; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased not implemented exception. * * @param selector The selector which is not or not fully implemented * @param object The object which does not (fully) implement the selector * @return A new, autoreleased not implemented exception */ + (instancetype)exceptionWithSelector: (SEL)selector object: (id)object; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated not implemented exception. * * @param selector The selector which is not or not fully implemented Index: src/exceptions/OFNotOpenException.h ================================================================== --- src/exceptions/OFNotOpenException.h +++ src/exceptions/OFNotOpenException.h @@ -31,17 +31,21 @@ /*! * The object which is not open, connected or bound. */ @property (readonly, nonatomic) id object; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased not open exception. * * @param object The object which is not open, connected or bound * @return A new, autoreleased not open exception */ + (instancetype)exceptionWithObject: (id)object; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated not open exception. * * @param object The object which is not open, connected or bound Index: src/exceptions/OFObserveFailedException.h ================================================================== --- src/exceptions/OFObserveFailedException.h +++ src/exceptions/OFObserveFailedException.h @@ -40,19 +40,23 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased observe failed exception. * * @param observer The observer which failed to observe * @param errNo The errno of the error that occurred * @return A new, autoreleased observe failed exception */ + (instancetype)exceptionWithObserver: (OFKernelEventObserver *)observer errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated observe failed exception. * * @param observer The observer which failed to observe Index: src/exceptions/OFOpenItemFailedException.h ================================================================== --- src/exceptions/OFOpenItemFailedException.h +++ src/exceptions/OFOpenItemFailedException.h @@ -43,10 +43,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased open item failed exception. * * @param path A string with the path of the item tried to open * @return A new, autoreleased open item failed exception @@ -82,10 +84,12 @@ * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithPath: (OFString *)path mode: (nullable OFString *)mode errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated open item failed exception. * * @param path A string with the path of the item which could not be opened Index: src/exceptions/OFReadOrWriteFailedException.h ================================================================== --- src/exceptions/OFReadOrWriteFailedException.h +++ src/exceptions/OFReadOrWriteFailedException.h @@ -45,10 +45,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased read or write failed exception. * * @param object The object from which reading or to which writing failed * @param requestedLength The requested length of the data that could not be @@ -68,10 +70,12 @@ * @return A new, autoreleased read or write failed exception */ + (instancetype)exceptionWithObject: (id)object requestedLength: (size_t)requestedLength errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated read or write failed exception. * * @param object The object from which reading or to which writing failed Index: src/exceptions/OFRemoveItemFailedException.h ================================================================== --- src/exceptions/OFRemoveItemFailedException.h +++ src/exceptions/OFRemoveItemFailedException.h @@ -38,19 +38,23 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased remove failed exception. * * @param path The path of the item which could not be removed * @param errNo The errno of the error that occurred * @return A new, autoreleased remove item failed exception */ + (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated remove failed exception. * * @param path The path of the item which could not be removed Index: src/exceptions/OFSandboxActivationFailedException.h ================================================================== --- src/exceptions/OFSandboxActivationFailedException.h +++ src/exceptions/OFSandboxActivationFailedException.h @@ -41,19 +41,23 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased sandboxing failed exception. * * @param sandbox The sandbox which could not be activated * @param errNo The errno of the error that occurred * @return A new, autoreleased sandboxing failed exception */ + (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated sandboxing failed exception. * * @param sandbox The sandbox which could not be activated Index: src/exceptions/OFSeekFailedException.h ================================================================== --- src/exceptions/OFSeekFailedException.h +++ src/exceptions/OFSeekFailedException.h @@ -50,10 +50,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased seek failed exception. * * @param stream The stream for which seeking failed * @param offset The offset to which seeking failed @@ -63,10 +65,12 @@ */ + (instancetype)exceptionWithStream: (OFSeekableStream *)stream offset: (of_offset_t)offset whence: (int)whence errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated seek failed exception. * * @param stream The stream for which seeking failed Index: src/exceptions/OFSetOptionFailedException.h ================================================================== --- src/exceptions/OFSetOptionFailedException.h +++ src/exceptions/OFSetOptionFailedException.h @@ -40,19 +40,23 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased set option failed exception. * * @param stream The stream for which the option could not be set * @param errNo The errno of the error that occurred * @return A new, autoreleased set option failed exception */ + (instancetype)exceptionWithStream: (OFStream *)stream errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated set option failed exception. * * @param stream The stream for which the option could not be set Index: src/exceptions/OFStatItemFailedException.h ================================================================== --- src/exceptions/OFStatItemFailedException.h +++ src/exceptions/OFStatItemFailedException.h @@ -38,10 +38,12 @@ /*! * The errno of the error that occurred. */ @property (readonly) int errNo; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased stat item failed exception. * * @param path A string with the path of the item whose status could not be * retrieved @@ -57,10 +59,12 @@ * @param errNo The errno of the error that occurred * @return A new, autoreleased stat item failed exception */ + (instancetype)exceptionWithPath: (OFString *)path errNo: (int)errNo; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated stat item failed exception. * * @param path A string with the path of the item whose status could not be Index: src/exceptions/OFUnboundNamespaceException.h ================================================================== --- src/exceptions/OFUnboundNamespaceException.h +++ src/exceptions/OFUnboundNamespaceException.h @@ -44,19 +44,23 @@ /*! * The element in which the namespace was not bound. */ @property (readonly, nonatomic) OFXMLElement *element; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased unbound namespace exception. * * @param namespace_ The namespace which is unbound * @param element The element in which the namespace was not bound * @return A new, autoreleased unbound namespace exception */ + (instancetype)exceptionWithNamespace: (OFString *)namespace_ element: (OFXMLElement *)element; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated unbound namespace exception. * * @param namespace_ The namespace which is unbound Index: src/exceptions/OFUnboundPrefixException.h ================================================================== --- src/exceptions/OFUnboundPrefixException.h +++ src/exceptions/OFUnboundPrefixException.h @@ -40,19 +40,23 @@ /*! * The parser which encountered the unbound prefix. */ @property (readonly, nonatomic) OFXMLParser *parser; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased unbound prefix exception. * * @param prefix The prefix which is unbound * @param parser The parser which encountered the unbound prefix * @return A new, autoreleased unbound prefix exception */ + (instancetype)exceptionWithPrefix: (OFString *)prefix parser: (OFXMLParser *)parser; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated unbound prefix exception. * * @param prefix The prefix which is unbound Index: src/exceptions/OFUndefinedKeyException.h ================================================================== --- src/exceptions/OFUndefinedKeyException.h +++ src/exceptions/OFUndefinedKeyException.h @@ -44,10 +44,12 @@ /*! * The value for the undefined key */ @property (readonly, nonatomic) id value; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased undefined key exception. * * @param object The object on which the key is undefined * @param key The key which is undefined @@ -67,10 +69,12 @@ * @return A new, autoreleased undefined key exception */ + (instancetype)exceptionWithObject: (id)object key: (OFString *)key value: (id)value; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated undefined key exception. * * @param object The object on which the key is undefined Index: src/exceptions/OFUnsupportedProtocolException.h ================================================================== --- src/exceptions/OFUnsupportedProtocolException.h +++ src/exceptions/OFUnsupportedProtocolException.h @@ -36,17 +36,21 @@ /*! * The URL whose protocol is unsupported. */ @property (readonly, nonatomic) OFURL *URL; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased unsupported protocol exception. * * @param URL The URL whose protocol is unsupported * @return A new, autoreleased unsupported protocol exception */ + (instancetype)exceptionWithURL: (OFURL*)URL; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated unsupported protocol exception * * @param URL The URL whose protocol is unsupported Index: src/exceptions/OFUnsupportedVersionException.h ================================================================== --- src/exceptions/OFUnsupportedVersionException.h +++ src/exceptions/OFUnsupportedVersionException.h @@ -33,17 +33,21 @@ /*! * The version which is unsupported. */ @property (readonly, nonatomic) OFString *version; ++ (instancetype)exception OF_UNAVAILABLE; + /*! * @brief Creates a new, autoreleased unsupported version exception. * * @param version The version which is unsupported * @return A new, autoreleased unsupported version exception */ + (instancetype)exceptionWithVersion: (OFString *)version; + +- init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated unsupported protocol exception. * * @param version The version which is unsupported Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -66,17 +66,19 @@ #ifdef __GNUC__ # define OF_INLINE inline __attribute__((__always_inline__)) # define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1)) # define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0)) +# define OF_UNAVAILABLE __attribute__((__unavailable__)) # define OF_CONST_FUNC __attribute__((__const__)) # define OF_NO_RETURN_FUNC __attribute__((__noreturn__)) # define OF_WEAK_REF(sym) __attribute__((__weakref__(sym))) #else # define OF_INLINE inline # define OF_LIKELY(cond) cond # define OF_UNLIKELY(cond) cond +# define OF_UNAVAILABLE # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC # define OF_WEAK_REF(sym) #endif