Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @@ -131,11 +133,11 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, copy, nonatomic) OFString *programName; @property (readonly, copy, nonatomic) OFArray OF_GENERIC(OFString*) *arguments; @property (readonly, copy, nonatomic) OFDictionary OF_GENERIC(OFString*, OFString*) *environment; -@property (assign) id delegate; +@property (assign, nullable) id delegate; #endif /*! * @brief Returns the only OFApplication instance in the application. * @@ -180,12 +182,12 @@ * @brief Gets args and argv. * * @param argc A pointer where a pointer to argc should be stored * @param argv A pointer where a pointer to argv should be stored */ -- (void)getArgumentCount: (int**)argc - andArgumentValues: (char***[])argv; +- (void)getArgumentCount: (__nonnull int **__nonnull)argc + andArgumentValues: (__nonnull char **__nonnull *__nonnull[])argv; /*! * @brief Returns the name of the program (argv[0]). * * @return The name of the program (argv[0]) @@ -209,18 +211,18 @@ /*! * @brief Returns the delegate of the application. * * @return The delegate of the application */ -- (id )delegate; +- (nullable id )delegate; /*! * @brief Sets the delegate of the application. * * @param delegate The delegate for the application */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; /*! * @brief Terminates the application. */ - (void)terminate OF_NO_RETURN; @@ -237,9 +239,12 @@ @end #ifdef __cplusplus extern "C" { #endif -extern int of_application_main(int*, char**[], Class); +extern int of_application_main(__nonnull int*, __nonnull char **__nonnull[], + Class); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -28,10 +28,12 @@ #import "OFEnumerator.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFString; enum { @@ -65,20 +67,20 @@ * * @param object The object to map * @param index The index of the object to map * @return The object to map to */ -typedef id (^of_array_map_block_t)(id object, size_t index); +typedef __nonnull id (^of_array_map_block_t)(id object, size_t index); /*! * @brief A block for folding an OFArray. * * @param left The object to which the object has been folded so far * @param right The object that should be added to the left object * @return The left and right side folded into one object */ -typedef id (^of_array_fold_block_t)(id left, id right); +typedef __nullable id (^of_array_fold_block_t)(__nullable id left, id right); #endif /*! * @class OFArray OFArray.h ObjFW/OFArray.h * @@ -135,11 +137,11 @@ * * @param objects A C array of objects * @param count The length of the C array * @return A new autoreleased OFArray */ -+ (instancetype)arrayWithObjects: (ObjectType const*)objects ++ (instancetype)arrayWithObjects: (__nonnull ObjectType const *__nonnull)objects count: (size_t)count; /*! * @brief Initializes an OFArray with the specified object. * @@ -180,11 +182,11 @@ * * @param objects A C array of objects * @param count The length of the C array * @return An initialized OFArray */ -- initWithObjects: (ObjectType const*)objects +- initWithObjects: (__nonnull ObjectType const *__nonnull)objects count: (size_t)count; /*! * @brief Returns the object at the specified index in the array. * @@ -201,19 +203,19 @@ * @brief Copies the objects at the specified range to the specified buffer. * * @param buffer The buffer to copy the objects to * @param range The range to copy */ -- (void)getObjects: (__unsafe_unretained ObjectType*)buffer +- (void)getObjects: (__unsafe_unretained __nonnull ObjectType *__nonnull)buffer inRange: (of_range_t)range; /*! * @brief Returns the objects of the array as a C array. * * @return The objects of the array as a C array */ -- (ObjectType const*)objects; +- (__nonnull ObjectType const *__nonnull)objects; /*! * @brief Returns the index of the first object that is equivalent to the * specified object or `OF_NOT_FOUND` if it was not found. * @@ -238,41 +240,41 @@ * object. * * @param object The object which is checked for being in the array * @return A boolean whether the array contains the specified object */ -- (bool)containsObject: (ObjectType)object; +- (bool)containsObject: (nullable ObjectType)object; /*! * @brief Checks whether the array contains an object with the specified * address. * * @param object The object which is checked for being in the array * @return A boolean whether the array contains an object with the specified * address */ -- (bool)containsObjectIdenticalTo: (ObjectType)object; +- (bool)containsObjectIdenticalTo: (nullable ObjectType)object; /*! * @brief Returns the first object of the array or nil. * * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The first object of the array or nil */ -- (ObjectType)firstObject; +- (nullable ObjectType)firstObject; /*! * @brief Returns the last object of the array or nil. * * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The last object of the array or nil */ -- (ObjectType)lastObject; +- (nullable ObjectType)lastObject; /*! * @brief Returns the objects in the specified range as a new OFArray. * * @param range The range for the subarray @@ -344,11 +346,11 @@ * @param selector The selector to perform on all objects in the array * @param object The object to perform the selector with on all objects in the * array */ - (void)makeObjectsPerformSelector: (SEL)selector - withObject: (id)object; + withObject: (nullable id)object; /*! * @brief Returns a sorted copy of the array. * * @return A sorted copy of the array @@ -448,11 +450,11 @@ * * @param block A block which folds two objects into one, which is called for * all objects except the first * @return The array folded to a single object */ -- (id)foldUsingBlock: (of_array_fold_block_t)block; +- (nullable id)foldUsingBlock: (of_array_fold_block_t)block; #endif @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @@ -465,14 +467,16 @@ unsigned long *_mutationsPtr; size_t _position; } - initWithArray: (OFArray*)data - mutationsPtr: (unsigned long*)mutationsPtr; + mutationsPtr: (__nullable unsigned long*)mutationsPtr; @end + +OF_ASSUME_NONNULL_END #import "OFMutableArray.h" #ifndef NSINTEGER_DEFINED /* Required for array literals to work */ @compatibility_alias NSArray OFArray; #endif Index: src/OFArray_adjacent.h ================================================================== --- src/OFArray_adjacent.h +++ src/OFArray_adjacent.h @@ -14,12 +14,16 @@ * file. */ #import "OFArray.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; @interface OFArray_adjacent: OFArray { OFDataArray *_array; } @end + +OF_ASSUME_NONNULL_END Index: src/OFArray_adjacentSubarray.h ================================================================== --- src/OFArray_adjacentSubarray.h +++ src/OFArray_adjacentSubarray.h @@ -13,8 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFArray_subarray.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFArray_adjacentSubarray: OFArray_subarray @end + +OF_ASSUME_NONNULL_END Index: src/OFArray_subarray.h ================================================================== --- src/OFArray_subarray.h +++ src/OFArray_subarray.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFArray.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFArray_subarray: OFArray { OFArray *_array; of_range_t _range; @@ -25,5 +27,7 @@ + (instancetype)arrayWithArray: (OFArray*)array range: (of_range_t)range; - initWithArray: (OFArray*)array range: (of_range_t)range; @end + +OF_ASSUME_NONNULL_END Index: src/OFAutoreleasePool+Private.h ================================================================== --- src/OFAutoreleasePool+Private.h +++ src/OFAutoreleasePool+Private.h @@ -13,10 +13,14 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFAutoreleasePool.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFAutoreleasePool (OF_PRIVATE_CATEGORY) + (void)OF_handleThreadTermination; - (void)OF_super_dealloc; @end + +OF_ASSUME_NONNULL_END Index: src/OFAutoreleasePool.h ================================================================== --- src/OFAutoreleasePool.h +++ src/OFAutoreleasePool.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFAutoreleasePool OFAutoreleasePool.h ObjFW/OFAutoreleasePool.h * * @brief A pool that keeps track of objects to release. * @@ -74,5 +76,7 @@ #endif extern id of_autorelease(id); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFBigDataArray.h ================================================================== --- src/OFBigDataArray.h +++ src/OFBigDataArray.h @@ -14,10 +14,12 @@ * file. */ #import "OFDataArray.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFBigDataArray OFBigDataArray.h ObjFW/OFBigDataArray.h * * @brief A class for storing arbitrary big data in an array. * @@ -28,5 +30,7 @@ @interface OFBigDataArray: OFDataArray { size_t _size; } @end + +OF_ASSUME_NONNULL_END Index: src/OFBlock.h ================================================================== --- src/OFBlock.h +++ src/OFBlock.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "block.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFBlock OFBlock.h ObjFW/OFBlock.h * * @brief The class for all blocks, since all blocks are also objects. */ @@ -32,5 +34,7 @@ @interface OFGlobalBlock: OFBlock @end @interface OFMallocBlock: OFBlock @end + +OF_ASSUME_NONNULL_END Index: src/OFCollection.h ================================================================== --- src/OFCollection.h +++ src/OFCollection.h @@ -14,10 +14,12 @@ * file. */ #import "OFEnumerator.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @protocol OFCollection OFCollection.h ObjFW/OFCollection.h * * @brief A protocol with methods common for all collections. */ @@ -38,7 +40,9 @@ * specified object. * * @param object The object which is checked for being in the collection * @return A boolean whether the collection contains the specified object */ -- (bool)containsObject: (id)object; +- (bool)containsObject: (nullable id)object; @end + +OF_ASSUME_NONNULL_END Index: src/OFCondition.h ================================================================== --- src/OFCondition.h +++ src/OFCondition.h @@ -14,10 +14,12 @@ * file. */ #import "OFMutex.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDate; /*! * @class OFCondition OFCondition.h ObjFW/OFCondition.h * @@ -68,5 +70,7 @@ /*! * @brief Signals all threads to continue. */ - (void)broadcast; @end + +OF_ASSUME_NONNULL_END Index: src/OFConstantString.h ================================================================== --- src/OFConstantString.h +++ src/OFConstantString.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFString.h" + +OF_ASSUME_NONNULL_BEGIN #if !defined(OF_CONSTANT_STRING_M) && \ defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) # ifdef __cplusplus extern "C" { @@ -36,5 +38,7 @@ { char *_cString; unsigned int _cStringLength; } @end + +OF_ASSUME_NONNULL_END Index: src/OFCountedSet.h ================================================================== --- src/OFCountedSet.h +++ src/OFCountedSet.h @@ -14,10 +14,12 @@ * file. */ #import "OFSet.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef OF_HAVE_BLOCKS /*! * @brief A block for enumerating an OFCountedSet. @@ -63,5 +65,7 @@ #endif @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif + +OF_ASSUME_NONNULL_END Index: src/OFCountedSet_hashtable.h ================================================================== --- src/OFCountedSet_hashtable.h +++ src/OFCountedSet_hashtable.h @@ -14,12 +14,16 @@ * file. */ #import "OFCountedSet.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @interface OFCountedSet_hashtable: OFCountedSet { OFMapTable *_mapTable; } @end + +OF_ASSUME_NONNULL_END Index: src/OFDataArray+Hashing.h ================================================================== --- src/OFDataArray+Hashing.h +++ src/OFDataArray+Hashing.h @@ -14,10 +14,12 @@ * file. */ #import "OFDataArray.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifdef __cplusplus extern "C" { #endif @@ -79,5 +81,7 @@ * * @return The SHA-512 hash of the data array as an autoreleased OFString */ - (OFString*)SHA512Hash; @end + +OF_ASSUME_NONNULL_END Index: src/OFDataArray+MessagePackValue.h ================================================================== --- src/OFDataArray+MessagePackValue.h +++ src/OFDataArray+MessagePackValue.h @@ -14,10 +14,12 @@ * file. */ #import "OFDataArray.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFDataArray_MessagePackValue_reference; #ifdef __cplusplus @@ -30,5 +32,7 @@ * * @return The MessagePack representation as an object */ - (id)messagePackValue; @end + +OF_ASSUME_NONNULL_END Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "OFSerialization.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFURL; /*! * @class OFDataArray OFDataArray.h ObjFW/OFDataArray.h @@ -228,18 +230,18 @@ /*! * @brief Returns the first item of the OFDataArray. * * @return The first item of the OFDataArray or NULL */ -- (void*)firstItem OF_RETURNS_INNER_POINTER; +- (nullable void*)firstItem OF_RETURNS_INNER_POINTER; /*! * @brief Returns the last item of the OFDataArray. * * @return The last item of the OFDataArray or NULL */ -- (void*)lastItem OF_RETURNS_INNER_POINTER; +- (nullable void*)lastItem OF_RETURNS_INNER_POINTER; /*! * @brief Adds an item to the OFDataArray. * * @param item A pointer to an arbitrary item @@ -323,8 +325,10 @@ * @param path The path of the file to write to */ - (void)writeToFile: (OFString*)path; #endif @end + +OF_ASSUME_NONNULL_END #import "OFDataArray+Hashing.h" #import "OFDataArray+MessagePackValue.h" Index: src/OFDate.h ================================================================== --- src/OFDate.h +++ src/OFDate.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFSerialization.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFConstantString; /*! * @class OFDate OFDate.h ObjFW/OFDate.h @@ -336,5 +338,7 @@ * @param seconds The seconds after the date * @return A new, autoreleased OFDate */ - (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds; @end + +OF_ASSUME_NONNULL_END Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -27,18 +27,20 @@ #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" + +OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); #ifdef OF_HAVE_BLOCKS typedef void (^of_dictionary_enumeration_block_t)(id key, id object, bool *stop); typedef bool (^of_dictionary_filter_block_t)(id key, id object); -typedef id (^of_dictionary_map_block_t)(id key, id object); +typedef __nonnull id (^of_dictionary_map_block_t)(id key, id object); #endif /*! * @class OFDictionary OFDictionary.h ObjFW/OFDictionary.h * @@ -103,13 +105,14 @@ * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return A new autoreleased OFDictionary */ -+ (instancetype)dictionaryWithObjects: (ObjectType const*)objects - forKeys: (KeyType const*)keys - count: (size_t)count; ++ (instancetype) + dictionaryWithObjects: (__nonnull ObjectType const *__nonnull)objects + forKeys: (__nonnull KeyType const *__nonnull)keys + count: (size_t)count; /*! * @brief Creates a new OFDictionary with the specified keys objects. * * @param firstKey The first key @@ -156,12 +159,12 @@ * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ -- initWithObjects: (ObjectType const*)objects - forKeys: (KeyType const*)keys +- initWithObjects: (__nonnull ObjectType const *__nonnull)objects + forKeys: (__nonnull KeyType const *__nonnull)keys count: (size_t)count; /*! * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. @@ -189,31 +192,31 @@ * performance reasons! * * @param key The key whose object should be returned * @return The object for the given key or nil if the key was not found */ -- (ObjectType)objectForKey: (KeyType)key; -- (ObjectType)objectForKeyedSubscript: (KeyType)key; +- (nullable ObjectType)objectForKey: (KeyType)key; +- (nullable ObjectType)objectForKeyedSubscript: (KeyType)key; /*! * @brief Checks whether the dictionary contains an object equal to the * specified object. * * @param object The object which is checked for being in the dictionary * @return A boolean whether the dictionary contains the specified object */ -- (bool)containsObject: (ObjectType)object; +- (bool)containsObject: (nullable ObjectType)object; /*! * @brief Checks whether the dictionary contains an object with the specified * address. * * @param object The object which is checked for being in the dictionary * @return A boolean whether the dictionary contains an object with the * specified address */ -- (bool)containsObjectIdenticalTo: (ObjectType)object; +- (bool)containsObjectIdenticalTo: (nullable ObjectType)object; /*! * @brief Returns an array of all keys. * * @return An array of all keys @@ -274,12 +277,14 @@ @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef KeyType # undef ObjectType #endif + +OF_ASSUME_NONNULL_END #import "OFMutableDictionary.h" #ifndef NSINTEGER_DEFINED /* Required for dictionary literals to work */ @compatibility_alias NSDictionary OFDictionary; #endif Index: src/OFDictionary_hashtable.h ================================================================== --- src/OFDictionary_hashtable.h +++ src/OFDictionary_hashtable.h @@ -14,10 +14,12 @@ * file. */ #import "OFDictionary.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @class OFMapTableEnumerator; @interface OFDictionary_hashtable: OFDictionary { @@ -24,5 +26,7 @@ OFMapTable *_mapTable; } - initWithCapacity: (size_t)capacity; @end + +OF_ASSUME_NONNULL_END Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + #ifndef DOXYGEN @class OFEnumerator OF_GENERIC(ObjectType); @class OFArray OF_GENERIC(ObjectType); #endif @@ -48,15 +50,15 @@ # define ObjectType id # endif @interface OFEnumerator: OFObject #endif /*! - * @brief Returns the next object. + * @brief Returns the next object or nil if there is none left. * - * @return The next object + * @return The next object or nil if there is none left */ -- (ObjectType)nextObject; +- (nullable ObjectType)nextObject; /*! * @brief Returns an array of all remaining objects in the collection. * * @return An array of all remaining objects in the collection @@ -88,13 +90,13 @@ #ifndef NSINTEGER_DEFINED typedef struct { /// Arbitrary state information for the enumeration unsigned long state; /// Pointer to a C array of objects to return - __unsafe_unretained id *itemsPtr; + __unsafe_unretained __nullable id *__nullable itemsPtr; /// Arbitrary state information to detect mutations - unsigned long *mutationsPtr; + __nullable unsigned long *mutationsPtr; /// Additional arbitrary state information unsigned long extra[5]; } of_fast_enumeration_state_t; #endif @@ -116,8 +118,11 @@ * @param count The number of objects that can be stored at objects * @return The number of objects returned in objects or 0 when the enumeration * finished. */ - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state - objects: (__unsafe_unretained id*)objects + objects: (__unsafe_unretained __nonnull id + *__nonnull)objects count: (int)count; @end + +OF_ASSUME_NONNULL_END Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -23,10 +23,12 @@ #include #include #import "OFSeekableStream.h" + +OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDate; #if defined(_WIN32) @@ -327,5 +329,7 @@ extern int of_stat(OFString *path, of_stat_t *buffer); extern int of_lstat(OFString *path, of_stat_t *buffer); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -18,10 +18,12 @@ #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif +OF_ASSUME_NONNULL_BEGIN + @class OFHTTPClient; @class OFHTTPRequest; @class OFHTTPResponse; @class OFURL; @class OFTCPSocket; @@ -106,11 +108,11 @@ bool _lastWasHEAD; OFHTTPResponse *_lastResponse; } #ifdef OF_HAVE_PROPERTIES -@property (assign) id delegate; +@property (assign, nullable) id delegate; @property bool insecureRedirectsAllowed; #endif /*! * @brief Creates a new OFHTTPClient. @@ -122,18 +124,18 @@ /*! * @brief Sets the delegate of the HTTP request. * * @param delegate The delegate of the HTTP request */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; /*! * @brief Returns the delegate of the HTTP reqeust. * * @return The delegate of the HTTP request */ -- (id )delegate; +- (nullable id )delegate; /*! * @brief Sets whether redirects from HTTPS to HTTP are allowed. * * @param allowed Whether redirects from HTTPS to HTTP are allowed @@ -172,5 +174,7 @@ - (void)close; @end @interface OFObject (OFHTTPClientDelegate) @end + +OF_ASSUME_NONNULL_END Index: src/OFHTTPRequest.h ================================================================== --- src/OFHTTPRequest.h +++ src/OFHTTPRequest.h @@ -19,10 +19,12 @@ #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif +OF_ASSUME_NONNULL_BEGIN + @class OFURL; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFDataArray; @class OFString; @@ -80,13 +82,14 @@ #ifdef OF_HAVE_PROPERTIES @property (copy) OFURL *URL; @property of_http_request_method_t method; @property of_http_request_protocol_version_t protocolVersion; -@property (copy) OFDictionary OF_GENERIC(OFString*, OFString*) *headers; -@property (retain) OFDataArray *body; -@property (copy) OFString *remoteAddress; +@property (copy, nullable) OFDictionary OF_GENERIC(OFString*, OFString*) + *headers; +@property (retain, nullable) OFDataArray *body; +@property (copy, nullable) OFString *remoteAddress; #endif /*! * @brief Creates a new OFHTTPRequest. * @@ -170,64 +173,65 @@ /*! * @brief Sets a dictionary with headers for the HTTP request. * * @param headers A dictionary with headers for the HTTP request */ -- (void)setHeaders: (OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; +- (void)setHeaders: + (nullable OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; /*! * @brief Returns a dictionary with headers for the HTTP request. * * @return A dictionary with headers for the HTTP request. */ -- (OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; +- (nullable OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; /*! * @brief Sets the entity body of the HTTP request. * * @param body The entity body of the HTTP request */ -- (void)setBody: (OFDataArray*)body; +- (void)setBody: (nullable OFDataArray*)body; /*! * @brief Sets the entity body of the HTTP request to the specified string * encoded in UTF-8. * * @param string The string to use for the entity body */ -- (void)setBodyFromString: (OFString*)string; +- (void)setBodyFromString: (nullable OFString*)string; /*! * @brief Sets the entity body of the HTTP request to the specified string * encoded in the specified encoding. * * @param string The string to use for the entity body * @param encoding The encoding to encode the string with */ -- (void)setBodyFromString: (OFString*)string +- (void)setBodyFromString: (nullable OFString*)string encoding: (of_string_encoding_t)encoding; /*! * @brief Returns the entity body of the HTTP request. * * @return The entity body of the HTTP request */ -- (OFDataArray*)body; +- (nullable OFDataArray*)body; /*! * @brief Sets the remote address from which the request originates. * * @param remoteAddress The remote address from which the request originates */ -- (void)setRemoteAddress: (OFString*)remoteAddress; +- (void)setRemoteAddress: (nullable OFString*)remoteAddress; /*! * @brief Returns the remote address from which the request originates. * * @return The remote address from which the request originates */ -- (OFString*)remoteAddress; +- (nullable OFString*)remoteAddress; @end #ifdef __cplusplus extern "C" { #endif @@ -235,11 +239,11 @@ * @brief Returns a C string describing the specified request method. * * @param method The request method which should be described as a C string * @return A C string describing the specified request method */ -extern const char* of_http_request_method_to_string( +extern __nullable const char* of_http_request_method_to_string( of_http_request_method_t method); /*! * @brief Returns the request method for the specified string. * @@ -249,5 +253,7 @@ extern of_http_request_method_t of_http_request_method_from_string( const char *string); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFHTTPResponse.h ================================================================== --- src/OFHTTPResponse.h +++ src/OFHTTPResponse.h @@ -14,10 +14,12 @@ * file. */ #import "OFStream.h" #import "OFHTTPRequest.h" + +OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); /*! * @class OFHTTPResponse OFHTTPResponse.h ObjFW/OFHTTPResponse.h @@ -32,11 +34,12 @@ } #ifdef OF_HAVE_PROPERTIES @property of_http_request_protocol_version_t protocolVersion; @property short statusCode; -@property (copy) OFDictionary OF_GENERIC(OFString*, OFString*) *headers; +@property (copy, nullable) OFDictionary OF_GENERIC(OFString*, OFString*) + *headers; #endif /*! * @brief Sets the protocol version of the HTTP request reply. * @@ -83,18 +86,19 @@ /*! * @brief Returns the headers of the reply to the HTTP request. * * @return The headers of the reply to the HTTP request */ -- (OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; +- (nullable OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; /*! * @brief Returns the headers of the reply to the HTTP request. * * @param headers The headers of the reply to the HTTP request */ -- (void)setHeaders: (OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; +- (void)setHeaders: + (nullable OFDictionary OF_GENERIC(OFString*, OFString*)*)headers; /*! * @brief Returns the reply as a string, trying to detect the encoding. * * @return The reply as a string @@ -107,5 +111,7 @@ * * @return The reply as a string */ - (OFString*)stringWithEncoding: (of_string_encoding_t)encoding; @end + +OF_ASSUME_NONNULL_END Index: src/OFHTTPServer.h ================================================================== --- src/OFHTTPServer.h +++ src/OFHTTPServer.h @@ -18,10 +18,12 @@ #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif +OF_ASSUME_NONNULL_BEGIN + @class OFHTTPServer; @class OFHTTPRequest; @class OFHTTPResponse; @class OFTCPSocket; @class OFException; @@ -75,14 +77,14 @@ OFString *_name; OFTCPSocket *_listeningSocket; } #ifdef OF_HAVE_PROPERTIES -@property (copy) OFString *host; +@property (copy, nullable) OFString *host; @property uint16_t port; -@property (assign) id delegate; -@property (copy) OFString *name; +@property (assign, nullable) id delegate; +@property (copy, nullable) OFString *name; #endif /*! * @brief Creates a new HTTP server. * @@ -93,18 +95,18 @@ /*! * @brief Sets the host on which the HTTP server will listen. * * @param host The host to listen on */ -- (void)setHost: (OFString*)host; +- (void)setHost: (nullable OFString*)host; /*! * @brief Returns the host on which the HTTP server will listen. * * @return The host on which the HTTP server will listen */ -- (OFString*)host; +- (nullable OFString*)host; /*! * @brief Sets the port on which the HTTP server will listen. * * @param port The port to listen on @@ -121,32 +123,32 @@ /*! * @brief Sets the delegate for the HTTP server. * * @param delegate The delegate for the HTTP server */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; /*! * @brief Returns the delegate for the HTTP server. * * @return The delegate for the HTTP server */ -- (id )delegate; +- (nullable id )delegate; /*! * @brief Sets the server name the server presents to clients. * * @param name The server name to present to clients */ -- (void)setName: (OFString*)name; +- (void)setName: (nullable OFString*)name; /*! * @brief Returns the server name the server presents to clients. * * @return The server name the server presents to clients */ -- (OFString*)name; +- (nullable OFString*)name; /*! * @brief Starts the HTTP server in the current thread's runloop. */ - (void)start; @@ -159,5 +161,7 @@ - (void)stop; @end @interface OFObject (OFHTTPServerDelegate) @end + +OF_ASSUME_NONNULL_END Index: src/OFHash.h ================================================================== --- src/OFHash.h +++ src/OFHash.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @protocol OFHash OFHash.h ObjFW/OFHash.h * * @brief A protocol for classes providing hash functions. */ @@ -80,5 +82,7 @@ * you are still interested in the previous digest, you need to memcpy * it yourself before calling @ref reset! */ - (void)reset; @end + +OF_ASSUME_NONNULL_END Index: src/OFINICategory+Private.h ================================================================== --- src/OFINICategory+Private.h +++ src/OFINICategory+Private.h @@ -15,14 +15,18 @@ */ #import "OFINICategory.h" #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + @class OFStream; @interface OFINICategory (OF_PRIVATE_CATEGORY) - (instancetype)OF_init; - (void)OF_parseLine: (OFString*)line; - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first; @end + +OF_ASSUME_NONNULL_END Index: src/OFINICategory.h ================================================================== --- src/OFINICategory.h +++ src/OFINICategory.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); #endif @@ -59,11 +61,11 @@ * the first key/value pair found is returned. * * @param key The key for which the string value should be returned * @return The string value for the specified key, or nil if it does not exist */ -- (OFString*)stringForKey: (OFString*)key; +- (nullable OFString*)stringForKey: (OFString*)key; /*! * @brief Returns the string value for the specified key or the specified * default value if it does not exist. * @@ -73,12 +75,12 @@ * @param key The key for which the string value should be returned * @param defaultValue The value to return if the key does not exist * @return The string value for the specified key or the specified default * value if it does not exist */ -- (OFString*)stringForKey: (OFString*)key - defaultValue: (OFString*)defaultValue; +- (nullable OFString*)stringForKey: (OFString*)key + defaultValue: (nullable OFString*)defaultValue; /*! * @brief Returns the integer value for the specified key or the specified * default value if it does not exist. * @@ -234,5 +236,7 @@ * * @param key The key of the value to remove */ - (void)removeValueForKey: (OFString*)key; @end + +OF_ASSUME_NONNULL_END Index: src/OFINIFile.h ================================================================== --- src/OFINIFile.h +++ src/OFINIFile.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFString.h" #import "OFINICategory.h" + +OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); /*! * @class OFINIFile OFINIFile.h ObjFW/OFINIFile.h @@ -99,5 +101,7 @@ * @param encoding The encoding to use */ - (void)writeToFile: (OFString*)path encoding: (of_string_encoding_t)encoding; @end + +OF_ASSUME_NONNULL_END Index: src/OFInflate64Stream.h ================================================================== --- src/OFInflate64Stream.h +++ src/OFInflate64Stream.h @@ -14,13 +14,17 @@ * file. */ #import "OFInflateStream.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFInflate64Stream OFInflate64Stream.h ObjFW/OFInflate64Stream.h * * @brief A class that handles Deflate64 decompression transparently for an * underlying stream. */ @interface OFInflate64Stream: OFInflateStream @end + +OF_ASSUME_NONNULL_END Index: src/OFInflateStream.h ================================================================== --- src/OFInflateStream.h +++ src/OFInflateStream.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFStream.h" + +OF_ASSUME_NONNULL_BEGIN #define OF_INFLATE_STREAM_BUFFER_SIZE 4096 /*! * @class OFInflateStream OFInflateStream.h ObjFW/OFInflateStream.h @@ -95,5 +97,7 @@ * from which compressed data is read * @return A initialized OFInflateStream */ - initWithStream: (OFStream*)stream; @end + +OF_ASSUME_NONNULL_END Index: src/OFIntrospection.h ================================================================== --- src/OFIntrospection.h +++ src/OFIntrospection.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); #endif @@ -48,11 +50,11 @@ } #ifdef OF_HAVE_PROPERTIES @property (readonly) SEL selector; @property (readonly, copy) OFString *name; -@property (readonly) const char *typeEncoding; +@property (assign, readonly, nullable) const char *typeEncoding; #endif /*! * @brief Returns the selector of the method. * @@ -70,11 +72,11 @@ /*! * @brief Returns the type encoding for the method. * * @return The type encoding for the method */ -- (const char*)typeEncoding; +- (nullable const char*)typeEncoding; @end /*! * @class OFProperty OFIntrospection.h ObjFW/OFIntrospection.h * @@ -88,11 +90,11 @@ } #ifdef OF_HAVE_PROPERTIES @property (readonly, copy) OFString *name; @property (readonly) unsigned attributes; -@property (readonly, copy) OFString *getter, *setter; +@property (copy, readonly, nullable) OFString *getter, *setter; #endif /*! * @brief Returns the name of the property. * @@ -124,18 +126,18 @@ /*! * @brief Returns the name of the getter. * * @return The name of the getter */ -- (OFString*)getter; +- (nullable OFString*)getter; /*! * @brief Returns the name of the setter. * * @return The name of the setter */ -- (OFString*)setter; +- (nullable OFString*)setter; @end /*! * @class OFInstanceVariable OFIntrospection.h ObjFW/OFIntrospection.h * @@ -149,11 +151,11 @@ } #ifdef OF_HAVE_PROPERTIES @property (readonly, copy) OFString *name; @property (readonly) ptrdiff_t offset; -@property (readonly) const char *typeEncoding; +@property (assign, readonly, nullable) const char *typeEncoding; #endif /*! * @brief Returns the name of the instance variable. * @@ -171,11 +173,11 @@ /*! * @brief Returns the type encoding for the instance variable. * * @return The type encoding for the instance variable */ -- (const char*)typeEncoding; +- (nullable const char*)typeEncoding; @end /*! * @class OFIntrospection OFIntrospection.h ObjFW/OFIntrospection.h * @@ -257,5 +259,7 @@ */ - (OFArray OF_GENERIC(OFInstanceVariable*)*)instanceVariables; /* TODO: protocols */ @end + +OF_ASSUME_NONNULL_END Index: src/OFJSONRepresentation.h ================================================================== --- src/OFJSONRepresentation.h +++ src/OFJSONRepresentation.h @@ -14,10 +14,12 @@ * file. */ @class OFString; +OF_ASSUME_NONNULL_BEGIN + enum { OF_JSON_REPRESENTATION_PRETTY = 0x01, OF_JSON_REPRESENTATION_JSON5 = 0x02, OF_JSON_REPRESENTATION_IDENTIFIER = 0x10 }; @@ -53,5 +55,7 @@ * * @return The JSON representation of the object as a string */ - (OFString*)JSONRepresentationWithOptions: (int)options; @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver+Private.h ================================================================== --- src/OFKernelEventObserver+Private.h +++ src/OFKernelEventObserver+Private.h @@ -13,14 +13,18 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFKernelEventObserver.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFKernelEventObserver (OF_PRIVATE_CATEGORY) - (void)OF_addObjectForReading: (id)object; - (void)OF_addObjectForWriting: (id)object; - (void)OF_removeObjectForReading: (id)object; - (void)OF_removeObjectForWriting: (id)object; -- (void)OF_processQueueAndStoreRemovedIn: (OFMutableArray*)removed; +- (void)OF_processQueueAndStoreRemovedIn: (nullable OFMutableArray*)removed; - (void)OF_processReadBuffers; @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver.h ================================================================== --- src/OFKernelEventObserver.h +++ src/OFKernelEventObserver.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "socket.h" + +OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFDataArray; #ifdef OF_HAVE_THREADS @@ -125,11 +127,11 @@ OFMutex *_mutex; #endif } #ifdef OF_HAVE_PROPERTIES -@property (assign) id delegate; +@property (assign, nullable) id delegate; #endif /*! * @brief Creates a new OFKernelEventObserver. * @@ -140,18 +142,18 @@ /*! * @brief Returns the delegate for the OFKernelEventObserver. * * @return The delegate for the OFKernelEventObserver */ -- (id )delegate; +- (nullable id )delegate; /*! * @brief Sets the delegate for the OFKernelEventObserver. * * @param delegate The delegate for the OFKernelEventObserver */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; /*! * @brief Adds an object to observe for reading. * * This is also used to observe a listening socket for incoming connections, @@ -226,5 +228,7 @@ @end @interface OFObject (OFKernelEventObserverDelegate) @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver_epoll.h ================================================================== --- src/OFKernelEventObserver_epoll.h +++ src/OFKernelEventObserver_epoll.h @@ -14,13 +14,17 @@ * file. */ #import "OFKernelEventObserver.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @interface OFKernelEventObserver_epoll: OFKernelEventObserver { int _epfd; OFMapTable *_FDToEvents; } @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver_kqueue.h ================================================================== --- src/OFKernelEventObserver_kqueue.h +++ src/OFKernelEventObserver_kqueue.h @@ -14,10 +14,12 @@ * file. */ #import "OFKernelEventObserver.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; @class OFMutableArray OF_GENERIC(ObjectType); @interface OFKernelEventObserver_kqueue: OFKernelEventObserver { @@ -24,5 +26,7 @@ int _kernelQueue; OFDataArray *_changeList; OFMutableArray *_removedArray; } @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver_poll.h ================================================================== --- src/OFKernelEventObserver_poll.h +++ src/OFKernelEventObserver_poll.h @@ -14,14 +14,18 @@ * file. */ #import "OFKernelEventObserver.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; @interface OFKernelEventObserver_poll: OFKernelEventObserver { OFDataArray *_FDs; size_t _maxFD; __unsafe_unretained id *_FDToObject; } @end + +OF_ASSUME_NONNULL_END Index: src/OFKernelEventObserver_select.h ================================================================== --- src/OFKernelEventObserver_select.h +++ src/OFKernelEventObserver_select.h @@ -24,12 +24,16 @@ #ifdef HAVE_SYS_SELECT_H # include #endif #import "OFKernelEventObserver.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFKernelEventObserver_select: OFKernelEventObserver { fd_set _readFDs, _writeFDs; int _maxFD; } @end + +OF_ASSUME_NONNULL_END Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" + +OF_ASSUME_NONNULL_BEGIN typedef struct of_list_object_t of_list_object_t; /*! * @struct of_list_object_t OFList.h ObjFW/OFList.h * @@ -57,12 +59,12 @@ size_t _count; unsigned long _mutations; } #ifdef OF_HAVE_PROPERTIES -@property (readonly) of_list_object_t *firstListObject; -@property (readonly) of_list_object_t *lastListObject; +@property (readonly, nullable) of_list_object_t *firstListObject; +@property (readonly, nullable) of_list_object_t *lastListObject; #endif /*! * @brief Creates a new OFList. * @@ -73,18 +75,18 @@ /*! * @brief Returns the first list object of the list. * * @return The first list object of the list */ -- (of_list_object_t*)firstListObject; +- (nullable of_list_object_t*)firstListObject; /*! * @brief Returns the last list object of the list. * * @return The last list object of the list */ -- (of_list_object_t*)lastListObject; +- (nullable of_list_object_t*)lastListObject; /*! * @brief Appends an object to the list. * * @param object The object to append @@ -142,20 +144,20 @@ * object. * * @param object The object which is checked for being in the list * @return A boolean whether the list contains the specified object */ -- (bool)containsObject: (ObjectType)object; +- (bool)containsObject: (nullable ObjectType)object; /*! * @brief Checks whether the list contains an object with the specified address. * * @param object The object which is checked for being in the list * @return A boolean whether the list contains an object with the specified * address */ -- (bool)containsObjectIdenticalTo: (ObjectType)object; +- (bool)containsObjectIdenticalTo: (nullable ObjectType)object; /*! * @brief Returns an OFEnumerator to enumerate through all objects of the list. * * @returns An OFEnumerator to enumerate through all objects of the list @@ -168,21 +170,21 @@ * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The first object of the list or nil */ -- (ObjectType)firstObject; +- (nullable ObjectType)firstObject; /*! * @brief Returns the last object of the list or nil. * * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The last object of the list or nil */ -- (ObjectType)lastObject; +- (nullable ObjectType)lastObject; /*! * @brief Removes all objects from the list. */ - (void)removeAllObjects; @@ -200,5 +202,7 @@ } - initWithList: (OFList*)list mutationsPointer: (unsigned long*)mutationsPtr; @end + +OF_ASSUME_NONNULL_END Index: src/OFLocking.h ================================================================== --- src/OFLocking.h +++ src/OFLocking.h @@ -14,18 +14,20 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @protocol OFLocking OFLocking.h ObjFW/OFLocking.h * * @brief A protocol for locks. */ @protocol OFLocking #ifdef OF_HAVE_PROPERTIES -@property (copy) OFString *name; +@property (copy, nullable) OFString *name; #endif /*! * @brief Locks the lock. */ @@ -46,14 +48,16 @@ /*! * @brief Sets a name for the lock. * * @param name The name for the lock */ -- (void)setName: (OFString*)name; +- (void)setName: (nullable OFString*)name; /*! * @brief Returns the name for the lock. * * @return The name for the lock */ -- (OFString*)name; +- (nullable OFString*)name; @end + +OF_ASSUME_NONNULL_END Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -14,10 +14,12 @@ * file. */ #import "OFHash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFMD5Hash OFMD5Hash.h ObjFW/OFMD5Hash.h * * @brief A class which provides functions to create an MD5 hash. */ @@ -33,5 +35,7 @@ bool _calculated; } - (void)OF_resetState; @end + +OF_ASSUME_NONNULL_END Index: src/OFMapTable+Private.h ================================================================== --- src/OFMapTable+Private.h +++ src/OFMapTable+Private.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFMapTable.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFMapTable_EnumeratorWrapper: OFEnumerator { OFMapTableEnumerator *_enumerator; id _object; @@ -23,5 +25,7 @@ } - initWithEnumerator: (OFMapTableEnumerator*)enumerator object: (id)object; @end + +OF_ASSUME_NONNULL_END Index: src/OFMapTable.h ================================================================== --- src/OFMapTable.h +++ src/OFMapTable.h @@ -15,26 +15,29 @@ */ #import "OFObject.h" #import "OFEnumerator.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ /*! * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h * * @brief A struct describing the functions to be used by the map table. */ typedef struct { /// The function to retain keys / values - void* (*retain)(void *value); + __nonnull void* (*__nullable retain)(__nonnull void *value); /// The function to release keys / values - void (*release)(void *value); + void (*__nullable release)(__nonnull void *value); /// The function to hash keys - uint32_t (*hash)(void *value); + uint32_t (*__nullable hash)(__nonnull void *value); /// The function to compare keys / values - bool (*equal)(void *value1, void *value2); + bool (*__nullable equal)(__nonnull void *value1, + __nonnull void *value2); } of_map_table_functions_t; #ifdef OF_HAVE_BLOCKS /*! * @brief A block for enumerating an OFMapTable. @@ -52,11 +55,11 @@ * * @param key The key of the value to replace * @param value The value to replace * @return The value to replace the value with */ -typedef void* (^of_map_table_replace_block_t)(void *key, void *value); +typedef __nonnull void* (^of_map_table_replace_block_t)(void *key, void *value); #endif @class OFMapTableEnumerator; /*! @@ -131,16 +134,16 @@ * @return The number of objects in the map table */ - (size_t)count; /*! - * @brief Returns the value for the given key or nil if the key was not found. + * @brief Returns the value for the given key or NULL if the key was not found. * * @param key The key whose object should be returned - * @return The value for the given key or nil if the key was not found + * @return The value for the given key or NULL if the key was not found */ -- (void*)valueForKey: (void*)key; +- (nullable void*)valueForKey: (void*)key; /*! * @brief Sets a value for a key. * * @param key The key to set @@ -166,21 +169,21 @@ * value. * * @param value The value which is checked for being in the map table * @return A boolean whether the map table contains the specified value */ -- (bool)containsValue: (void*)value; +- (bool)containsValue: (nullable void*)value; /*! * @brief Checks whether the map table contains a value with the specified * address. * * @param value The value which is checked for being in the map table * @return A boolean whether the map table contains a value with the specified * address. */ -- (bool)containsValueIdenticalTo: (void*)value; +- (bool)containsValueIdenticalTo: (nullable void*)value; /*! * @brief Returns an OFMapTableEnumerator to enumerate through the map table's * keys. * @@ -255,5 +258,7 @@ * @brief Resets the enumerator, so the next call to nextKey returns the first * key again. */ - (void)reset; @end + +OF_ASSUME_NONNULL_END Index: src/OFMessagePackExtension.h ================================================================== --- src/OFMessagePackExtension.h +++ src/OFMessagePackExtension.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; /*! * @class OFMessagePackExtension \ * OFMessagePackExtension.h ObjFW/OFMessagePackExtension.h @@ -71,5 +73,7 @@ * * @return The data of the extension */ - (OFDataArray*)data; @end + +OF_ASSUME_NONNULL_END Index: src/OFMessagePackRepresentation.h ================================================================== --- src/OFMessagePackRepresentation.h +++ src/OFMessagePackRepresentation.h @@ -12,10 +12,14 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ +#import "OFObject.h" + +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; /*! * @protocol OFMessagePackRepresentation * OFMessagePackRepresentation.h ObjFW/OFMessagePackRepresentation.h @@ -30,5 +34,7 @@ * * @return The MessagePack representation of the object as an OFDataArray. */ - (OFDataArray*)messagePackRepresentation; @end + +OF_ASSUME_NONNULL_END Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -14,10 +14,12 @@ * file. */ #import "OFArray.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef OF_HAVE_BLOCKS /*! * @brief A block for replacing values in an OFMutableArray. @@ -24,11 +26,11 @@ * * @param object The object to replace * @param index The index of the object to replace * @return The object to replace the object with */ -typedef id (^of_array_replace_block_t)(id object, size_t index); +typedef __nonnull id (^of_array_replace_block_t)(id object, size_t index); #endif /*! * @class OFMutableArray OFArray.h ObjFW/OFArray.h * @@ -208,5 +210,7 @@ - (void)makeImmutable; @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif + +OF_ASSUME_NONNULL_END Index: src/OFMutableArray_adjacent.h ================================================================== --- src/OFMutableArray_adjacent.h +++ src/OFMutableArray_adjacent.h @@ -14,13 +14,17 @@ * file. */ #import "OFArray.h" +OF_ASSUME_NONNULL_BEGIN + @class OFDataArray; @interface OFMutableArray_adjacent: OFMutableArray { OFDataArray *_array; unsigned long _mutations; } @end + +OF_ASSUME_NONNULL_END Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -14,10 +14,12 @@ * file. */ #import "OFDictionary.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef OF_HAVE_BLOCKS /*! * @brief A block for replacing objects in an OFMutableDictionary. @@ -24,11 +26,11 @@ * * @param key The key of the object to replace * @param object The object to replace * @return The object to replace the object with */ -typedef id (^of_dictionary_replace_block_t)(id key, id object); +typedef __nonnull id (^of_dictionary_replace_block_t)(id key, id object); #endif /*! * @class OFMutableDictionary OFDictionary.h ObjFW/OFDictionary.h * @@ -103,5 +105,7 @@ @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef KeyType # undef ObjectType #endif + +OF_ASSUME_NONNULL_END Index: src/OFMutableDictionary_hashtable.h ================================================================== --- src/OFMutableDictionary_hashtable.h +++ src/OFMutableDictionary_hashtable.h @@ -14,12 +14,16 @@ * file. */ #import "OFDictionary.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @interface OFMutableDictionary_hashtable: OFMutableDictionary { OFMapTable *_mapTable; } @end + +OF_ASSUME_NONNULL_END Index: src/OFMutableSet.h ================================================================== --- src/OFMutableSet.h +++ src/OFMutableSet.h @@ -14,10 +14,12 @@ * file. */ #import "OFSet.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFMutableSet OFSet.h ObjFW/OFSet.h * * @brief An abstract class for a mutable unordered set of unique objects. */ @@ -71,5 +73,7 @@ - (void)makeImmutable; @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif + +OF_ASSUME_NONNULL_END Index: src/OFMutableSet_hashtable.h ================================================================== --- src/OFMutableSet_hashtable.h +++ src/OFMutableSet_hashtable.h @@ -14,12 +14,16 @@ * file. */ #import "OFMutableSet.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @interface OFMutableSet_hashtable: OFMutableSet { OFMapTable *_mapTable; } @end + +OF_ASSUME_NONNULL_END Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFMutableString OFString.h ObjFW/OFString.h * * @brief A class for storing and modifying strings. */ @@ -205,5 +207,7 @@ /*! * @brief Converts the mutable string to an immutable string. */ - (void)makeImmutable; @end + +OF_ASSUME_NONNULL_END Index: src/OFMutableString_UTF8.h ================================================================== --- src/OFMutableString_UTF8.h +++ src/OFMutableString_UTF8.h @@ -14,13 +14,17 @@ * file. */ #import "OFMutableString.h" #import "OFString_UTF8.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFMutableString_UTF8: OFMutableString { @public struct of_string_utf8_ivars *restrict _s; struct of_string_utf8_ivars _storage; } @end + +OF_ASSUME_NONNULL_END Index: src/OFMutex.h ================================================================== --- src/OFMutex.h +++ src/OFMutex.h @@ -17,10 +17,12 @@ #import "OFObject.h" #import "OFLocking.h" #import "threading.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFMutex OFMutex.h ObjFW/OFMutex.h * * @brief A class for creating mutual exclusions. */ @@ -36,5 +38,7 @@ * * @return A new autoreleased mutex. */ + (instancetype)mutex; @end + +OF_ASSUME_NONNULL_END Index: src/OFNull.h ================================================================== --- src/OFNull.h +++ src/OFNull.h @@ -17,10 +17,12 @@ #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFNull OFNull.h ObjFW/OFNull.h * * @brief A class for representing null values in collections. */ @@ -31,5 +33,7 @@ * * @return An OFNull singleton */ + (OFNull*)null; @end + +OF_ASSUME_NONNULL_END Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -26,10 +26,12 @@ #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ /*! * @brief The C type of a number stored in an OFNumber. */ @@ -811,10 +813,12 @@ * * @return The OFNumber as a double */ - (double)doubleValue; @end + +OF_ASSUME_NONNULL_END #ifndef NSINTEGER_DEFINED /* Required for number literals to work */ @compatibility_alias NSNumber OFNumber; #endif Index: src/OFObject+Serialization.h ================================================================== --- src/OFObject+Serialization.h +++ src/OFObject+Serialization.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifdef __cplusplus extern "C" { #endif @@ -32,5 +34,7 @@ * * @return The object serialized as a string */ - (OFString*)stringBySerializing; @end + +OF_ASSUME_NONNULL_END Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -29,10 +29,12 @@ #include #import "macros.h" #import "autorelease.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ /*! * @brief A result of a comparison. */ @@ -234,38 +236,38 @@ * @brief Returns the implementation for the specified selector. * * @param selector The selector for which the method should be returned * @return The implementation for the specified selector */ -- (IMP)methodForSelector: (SEL)selector; +- (nullable IMP)methodForSelector: (SEL)selector; /*! * @brief Returns the type encoding for the specified selector. * * @param selector The selector for which the type encoding should be returned * @return The type encoding for the specified selector */ -- (const char*)typeEncodingForSelector: (SEL)selector; +- (nullable const char*)typeEncodingForSelector: (SEL)selector; /*! * @brief Performs the specified selector. * * @param selector The selector to perform * @return The object returned by the method specified by the selector */ -- (id)performSelector: (SEL)selector; +- (nullable id)performSelector: (SEL)selector; /*! * @brief Performs the specified selector with the specified object. * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @return The object returned by the method specified by the selector */ -- (id)performSelector: (SEL)selector - withObject: (id)object; +- (nullable id)performSelector: (SEL)selector + withObject: (nullable id)object; /*! * @brief Performs the specified selector with the specified objects. * * @param selector The selector to perform @@ -273,13 +275,13 @@ * selector * @param object2 The second object that is passed to the method specified by * the selector * @return The object returned by the method specified by the selector */ -- (id)performSelector: (SEL)selector - withObject: (id)object1 - withObject: (id)object2; +- (nullable id)performSelector: (SEL)selector + withObject: (nullable id)object1 + withObject: (nullable id)object2; /*! * @brief Checks two objects for equality. * * Classes containing data (like strings, arrays, lists etc.) should reimplement @@ -289,11 +291,11 @@ * return the same hash for objects which are equal! * * @param object The object which should be tested for equality * @return A boolean whether the object is equal to the specified object */ -- (bool)isEqual: (id)object; +- (bool)isEqual: (nullable id)object; /*! * @brief Calculates a hash for the object. * * Classes containing data (like strings, arrays, lists etc.) should reimplement @@ -469,20 +471,20 @@ * * @param selector The selector for which the method should be returned * @return The implementation of the instance method for the specified selector * or nil if it isn't implemented */ -+ (IMP)instanceMethodForSelector: (SEL)selector; ++ (nullable IMP)instanceMethodForSelector: (SEL)selector; /*! * @brief Returns the type encoding of the instance method for the specified * selector. * * @param selector The selector for which the type encoding should be returned * @return The type encoding of the instance method for the specified selector */ -+ (const char*)typeEncodingForInstanceSelector: (SEL)selector; ++ (nullable const char*)typeEncodingForInstanceSelector: (SEL)selector; /*! * @brief Returns a description for the class, which is usually the class name. * * This is mostly for debugging purposes. @@ -496,23 +498,23 @@ * * @param selector The selector of the class method to replace * @param class_ The class from which the new class method should be taken * @return The old implementation */ -+ (IMP)replaceClassMethod: (SEL)selector - withMethodFromClass: (Class)class_; ++ (nullable IMP)replaceClassMethod: (SEL)selector + withMethodFromClass: (Class)class_; /*! * @brief Replaces an instance method with an instance method from another * class. * * @param selector The selector of the instance method to replace * @param class_ The class from which the new instance method should be taken * @return The old implementation */ -+ (IMP)replaceInstanceMethod: (SEL)selector - withMethodFromClass: (Class)class_; ++ (nullable IMP)replaceInstanceMethod: (SEL)selector + withMethodFromClass: (Class)class_; /*! * @brief Replaces or adds a class method. * * If the method already exists, it is replaced and the old implementation @@ -522,13 +524,13 @@ * @param selector The selector for the new method * @param implementation The implementation for the new method * @param typeEncoding The type encoding for the new method * @return The old implementation or nil if the method was added */ -+ (IMP)replaceClassMethod: (SEL)selector - withImplementation: (IMP)implementation - typeEncoding: (const char*)typeEncoding; ++ (nullable IMP)replaceClassMethod: (SEL)selector + withImplementation: (IMP)implementation + typeEncoding: (const char*)typeEncoding; /*! * @brief Replaces or adds an instance method. * * If the method already exists, it is replaced and the old implementation @@ -538,13 +540,13 @@ * @param selector The selector for the new method * @param implementation The implementation for the new method * @param typeEncoding The type encoding for the new method * @return The old implementation or nil if the method was added */ -+ (IMP)replaceInstanceMethod: (SEL)selector - withImplementation: (IMP)implementation - typeEncoding: (const char*)typeEncoding; ++ (nullable IMP)replaceInstanceMethod: (SEL)selector + withImplementation: (IMP)implementation + typeEncoding: (const char*)typeEncoding; /*! * @brief Adds all methods from the specified class to the class that is the * receiver. * @@ -656,12 +658,12 @@ * * @param pointer A pointer to the already allocated memory * @param size The new size for the memory chunk * @return A pointer to the resized memory chunk */ -- (void*)resizeMemory: (void*)pointer - size: (size_t)size; +- (nullable void*)resizeMemory: (nullable void*)pointer + size: (size_t)size; /*! * @brief Resizes memory in the object's memory pool to the specific number of * items of the specified size. * @@ -671,22 +673,22 @@ * @param pointer A pointer to the already allocated memory * @param size The size of each item to resize to * @param count The number of items to resize to * @return A pointer to the resized memory chunk */ -- (void*)resizeMemory: (void*)pointer - size: (size_t)size - count: (size_t)count; +- (nullable void*)resizeMemory: (nullable void*)pointer + size: (size_t)size + count: (size_t)count; /*! * @brief Frees allocated memory and removes it from the object's memory pool. * * Does nothing if the pointer is NULL. * * @param pointer A pointer to the allocated memory */ -- (void)freeMemory: (void*)pointer; +- (void)freeMemory: (nullable void*)pointer; /*! * @brief Deallocates the object. * * It is automatically called when the retain count reaches zero. @@ -712,11 +714,11 @@ * @param object The object that is passed to the method specified by the * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector - withObject: (id)object + withObject: (nullable id)object afterDelay: (of_time_interval_t)delay; /*! * @brief Performs the specified selector with the specified objects after the * specified delay. @@ -727,12 +729,12 @@ * @param object2 The second object that is passed to the method specified by * the selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector - withObject: (id)object1 - withObject: (id)object2 + withObject: (nullable id)object1 + withObject: (nullable id)object2 afterDelay: (of_time_interval_t)delay; #ifdef OF_HAVE_THREADS /*! * @brief Performs the specified selector on the specified thread. @@ -755,11 +757,11 @@ * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread - withObject: (id)object + withObject: (nullable id)object waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the specified thread with the * specified objects. @@ -772,12 +774,12 @@ * the selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread - withObject: (id)object1 - withObject: (id)object2 + withObject: (nullable id)object1 + withObject: (nullable id)object2 waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the main thread. * @@ -795,11 +797,11 @@ * @param object The object that is passed to the method specified by the * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelectorOnMainThread: (SEL)selector - withObject: (id)object + withObject: (nullable id)object waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the main thread with the specified * objects. @@ -810,12 +812,12 @@ * @param object2 The second object that is passed to the method specified by * the selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelectorOnMainThread: (SEL)selector - withObject: (id)object1 - withObject: (id)object2 + withObject: (nullable id)object1 + withObject: (nullable id)object2 waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the specified thread after the * specified delay. @@ -838,11 +840,11 @@ * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread - withObject: (id)object + withObject: (nullable id)object afterDelay: (of_time_interval_t)delay; /*! * @brief Performs the specified selector on the specified thread with the * specified objects after the specified delay. @@ -855,12 +857,12 @@ * the selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread - withObject: (id)object1 - withObject: (id)object2 + withObject: (nullable id)object1 + withObject: (nullable id)object2 afterDelay: (of_time_interval_t)delay; #endif /*! * @brief This method is called when @ref resolveClassMethod: or @@ -870,11 +872,11 @@ * @note When the message should not be forwarded, you should not return nil, * but instead return the result of the superclass! * * @return The target to forward the message to */ -- (id)forwardingTargetForSelector: (SEL)selector; +- (nullable id)forwardingTargetForSelector: (SEL)selector; /*! * @brief Handles messages which are not understood by the receiver. * * @warning If you override this method, you must make sure that it never @@ -935,17 +937,19 @@ * @return The result of the comparison */ - (of_comparison_result_t)compare: (id )object; @end -#import "OFObject+Serialization.h" - #ifdef __cplusplus extern "C" { #endif -extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, - void **extra); +extern id of_alloc_object(Class class_, size_t extraSize, + size_t extraAlignment, __nonnull void **__nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END + +#import "OFObject+Serialization.h" Index: src/OFOptionsParser.h ================================================================== --- src/OFOptionsParser.h +++ src/OFOptionsParser.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFConstantString.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFOptionsParser OFOptionsParser.h ObjFW/OFOptionsParser.h * * @brief A class for parsing the program options specified on the command line. */ @@ -80,14 +82,16 @@ * @brief Returns the argument for the last parsed option, or nil if the last * parsed option takes no argument. * * @return The argument for the last parsed option */ -- (OFString*)argument; +- (nullable OFString*)argument; /*! * @brief Returns the arguments following the last option. * * @return The arguments following the last option */ - (OFArray OF_GENERIC(OFString*)*)remainingArguments; @end + +OF_ASSUME_NONNULL_END Index: src/OFPlugin.h ================================================================== --- src/OFPlugin.h +++ src/OFPlugin.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; #ifndef _WIN32 typedef void* of_plugin_handle_t; #else @@ -39,7 +41,9 @@ * @brief Loads a plugin from a file. * * @param path Path to the plugin file. The suffix is appended automatically. * @return The loaded plugin */ -+ (id)pluginFromFile: (OFString*)path; ++ (OF_KINDOF(OFPlugin*))pluginFromFile: (OFString*)path; @end + +OF_ASSUME_NONNULL_END Index: src/OFProcess.h ================================================================== --- src/OFProcess.h +++ src/OFProcess.h @@ -27,10 +27,12 @@ #import "OFString.h" #ifdef _WIN32 # include #endif + +OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); /*! @@ -67,12 +69,13 @@ * @param program The program to execute. If it does not start with a slash, the * search path specified in PATH is used. * @param arguments The arguments to pass to the program, or nil * @return A new, autoreleased OFProcess. */ -+ (instancetype)processWithProgram: (OFString*)program - arguments: (OFArray OF_GENERIC(OFString*)*)arguments; ++ (instancetype) + processWithProgram: (OFString*)program + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments; /*! * @brief Creates a new OFProcess with the specified program, program name and * arguments and invokes the program. * @@ -81,13 +84,14 @@ * @param programName The program name for the program to invoke (argv[0]). * Usually, this is equal to program. * @param arguments The arguments to pass to the program, or nil * @return A new, autoreleased OFProcess. */ -+ (instancetype)processWithProgram: (OFString*)program - programName: (OFString*)programName - arguments: (OFArray OF_GENERIC(OFString*)*)arguments; ++ (instancetype) + processWithProgram: (OFString*)program + programName: (OFString*)programName + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments; /*! * @brief Creates a new OFProcess with the specified program, program name, * arguments and environment and invokes the program. * @@ -101,15 +105,16 @@ * the environment. If you want to add to the existing * environment, you need to get the existing environment * first, copy it, modify it and then pass it. * @return A new, autoreleased OFProcess. */ -+ (instancetype)processWithProgram: (OFString*)program - programName: (OFString*)programName - arguments: (OFArray OF_GENERIC(OFString*)*)arguments - environment: (OFDictionary OF_GENERIC(OFString*, - OFString*)*)environment; ++ (instancetype) + processWithProgram: (OFString*)program + programName: (OFString*)programName + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments + environment: (nullable OFDictionary + OF_GENERIC(OFString*, OFString*)*)environment; /*! * @brief Initializes an already allocated OFProcess with the specified program * and invokes the program. * @@ -127,11 +132,11 @@ * search path specified in PATH is used. * @param arguments The arguments to pass to the program, or nil * @return An initialized OFProcess. */ - initWithProgram: (OFString*)program - arguments: (OFArray OF_GENERIC(OFString*)*)arguments; + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments; /*! * @brief Initializes an already allocated OFProcess with the specified program, * program name and arguments and invokes the program. * @@ -142,11 +147,11 @@ * @param arguments The arguments to pass to the program, or nil * @return An initialized OFProcess. */ - initWithProgram: (OFString*)program programName: (OFString*)programName - arguments: (OFArray OF_GENERIC(OFString*)*)arguments; + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments; /*! * @brief Initializes an already allocated OFProcess with the specified program, * program name, arguments and environment and invokes the program. * @@ -162,12 +167,13 @@ * first, copy it, modify it and then pass it. * @return An initialized OFProcess. */ - initWithProgram: (OFString*)program programName: (OFString*)programName - arguments: (OFArray OF_GENERIC(OFString*)*)arguments - environment: (OFDictionary OF_GENERIC(OFString*, OFString*)*)environment; + arguments: (nullable OFArray OF_GENERIC(OFString*)*)arguments + environment: (nullable OFDictionary + OF_GENERIC(OFString*, OFString*)*)environment; /*! * @brief Closes the write direction of the process. * * This method needs to be called for some programs before data can be read, @@ -174,5 +180,7 @@ * since some programs don't start processing before the write direction is * closed. */ - (void)closeForWriting; @end + +OF_ASSUME_NONNULL_END Index: src/OFRIPEMD160Hash.h ================================================================== --- src/OFRIPEMD160Hash.h +++ src/OFRIPEMD160Hash.h @@ -14,10 +14,12 @@ * file. */ #import "OFHash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFRIPEMD160Hash OFRIPEMD160Hash.h ObjFW/OFRIPEMD160Hash.h * * @brief A class which provides functions to create a RIPEMD-160 hash. */ @@ -33,5 +35,7 @@ bool _calculated; } - (void)OF_resetState; @end + +OF_ASSUME_NONNULL_END Index: src/OFRecursiveMutex.h ================================================================== --- src/OFRecursiveMutex.h +++ src/OFRecursiveMutex.h @@ -17,10 +17,12 @@ #import "OFObject.h" #import "OFLocking.h" #import "threading.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFRecursiveMutex OFRecursiveMutex.h ObjFW/OFRecursiveMutex.h * * @brief A class for creating mutual exclusions which can be entered * recursively. @@ -37,5 +39,7 @@ * * @return A new autoreleased recursive mutex. */ + (instancetype)mutex; @end + +OF_ASSUME_NONNULL_END Index: src/OFRunLoop+Private.h ================================================================== --- src/OFRunLoop+Private.h +++ src/OFRunLoop+Private.h @@ -17,10 +17,12 @@ #import "OFRunLoop.h" #import "OFStream.h" #ifdef OF_HAVE_SOCKETS # import "OFUDPSocket.h" #endif + +OF_ASSUME_NONNULL_BEGIN @interface OFRunLoop (OF_PRIVATE_CATEGORY) + (void)OF_setMainRunLoop: (OFRunLoop*)runLoop; #ifdef OF_HAVE_SOCKETS + (void)OF_addAsyncReadForStream: (OFStream*)stream @@ -68,5 +70,7 @@ # endif + (void)OF_cancelAsyncRequestsForObject: (id)object; #endif - (void)OF_removeTimer: (OFTimer*)timer; @end + +OF_ASSUME_NONNULL_END Index: src/OFRunLoop.h ================================================================== --- src/OFRunLoop.h +++ src/OFRunLoop.h @@ -16,10 +16,12 @@ #import "OFObject.h" #ifdef OF_HAVE_SOCKETS # import "OFTCPSocket.h" #endif + +OF_ASSUME_NONNULL_BEGIN @class OFSortedList OF_GENERIC(ObjectType); #ifdef OF_HAVE_THREADS @class OFMutex; @class OFCondition; @@ -80,5 +82,7 @@ * @brief Stops the run loop. If there is still an operation being executed, it * is finished before the run loop stops. */ - (void)stop; @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA1Hash.h ================================================================== --- src/OFSHA1Hash.h +++ src/OFSHA1Hash.h @@ -14,10 +14,12 @@ * file. */ #import "OFHash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA1Hash OFSHA1Hash.h ObjFW/OFSHA1Hash.h * * @brief A class which provides functions to create an SHA-1 hash. */ @@ -33,5 +35,7 @@ bool _calculated; } - (void)OF_resetState; @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA224Hash.h ================================================================== --- src/OFSHA224Hash.h +++ src/OFSHA224Hash.h @@ -14,12 +14,16 @@ * file. */ #import "OFSHA224Or256Hash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA224Hash OFSHA224Hash.h ObjFW/OFSHA224Hash.h * * @brief A class which provides functions to create an SHA-224 hash. */ @interface OFSHA224Hash: OFSHA224Or256Hash @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA224Or256Hash.h ================================================================== --- src/OFSHA224Or256Hash.h +++ src/OFSHA224Or256Hash.h @@ -14,10 +14,12 @@ * file. */ #import "OFHash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA224Or256Hash OFSHA224Or256Hash.h ObjFW/OFSHA224Or256Hash.h * * @brief A base class for SHA-224 and SHA-256. */ @@ -33,5 +35,7 @@ bool _calculated; } - (void)OF_resetState; @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA256Hash.h ================================================================== --- src/OFSHA256Hash.h +++ src/OFSHA256Hash.h @@ -14,12 +14,16 @@ * file. */ #import "OFSHA224Or256Hash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA256Hash OFSHA256Hash.h ObjFW/OFSHA256Hash.h * * @brief A class which provides functions to create an SHA-256 hash. */ @interface OFSHA256Hash: OFSHA224Or256Hash @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA384Hash.h ================================================================== --- src/OFSHA384Hash.h +++ src/OFSHA384Hash.h @@ -14,12 +14,16 @@ * file. */ #import "OFSHA384Or512Hash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA384Hash OFSHA384Hash.h ObjFW/OFSHA384Hash.h * * @brief A class which provides functions to create an SHA-384 hash. */ @interface OFSHA384Hash: OFSHA384Or512Hash @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA384Or512Hash.h ================================================================== --- src/OFSHA384Or512Hash.h +++ src/OFSHA384Or512Hash.h @@ -14,10 +14,12 @@ * file. */ #import "OFHash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA384Or512Hash OFSHA384Or512Hash.h ObjFW/OFSHA384Or512Hash.h * * @brief A base class for SHA-384 and SHA-512. */ @@ -33,5 +35,7 @@ bool _calculated; } - (void)OF_resetState; @end + +OF_ASSUME_NONNULL_END Index: src/OFSHA512Hash.h ================================================================== --- src/OFSHA512Hash.h +++ src/OFSHA512Hash.h @@ -14,12 +14,16 @@ * file. */ #import "OFSHA384Or512Hash.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSHA512Hash OFSHA512Hash.h ObjFW/OFSHA512Hash.h * * @brief A class which provides functions to create an SHA-512 hash. */ @interface OFSHA512Hash: OFSHA384Or512Hash @end + +OF_ASSUME_NONNULL_END Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -23,10 +23,12 @@ #include #import "OFStream.h" +OF_ASSUME_NONNULL_BEGIN + #if defined(_WIN32) typedef __int64 of_offset_t; #elif defined(__ANDROID__) typedef long long of_offset_t; #elif defined(OF_HAVE_OFF64_T) @@ -82,5 +84,7 @@ * @return The new offset from the start of the file */ - (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence; @end + +OF_ASSUME_NONNULL_END Index: src/OFSerialization.h ================================================================== --- src/OFSerialization.h +++ src/OFSerialization.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" + +OF_ASSUME_NONNULL_BEGIN #define OF_SERIALIZATION_NS @"https://webkeks.org/objfw/serialization" @class OFXMLElement; @@ -39,5 +41,7 @@ * * @return The object serialized into an XML element */ - (OFXMLElement*)XMLElementBySerializing; @end + +OF_ASSUME_NONNULL_END Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -25,10 +25,12 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFSerialization.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFArray OF_GENERIC(ObjectType); #ifdef OF_HAVE_BLOCKS @@ -103,11 +105,11 @@ * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return A new, autoreleased set with the specified objects */ -+ (instancetype)setWithObjects: (ObjectType const*)objects ++ (instancetype)setWithObjects: (__nonnull ObjectType const *__nonnull)objects count: (size_t)count; /*! * @brief Initializes an already allocated set with the specified set. * @@ -137,11 +139,11 @@ * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return An initialized set with the specified objects */ -- initWithObjects: (ObjectType const*)objects +- initWithObjects: (__nonnull ObjectType const *__nonnull)objects count: (size_t)count; /*! * @brief Initializes an already allocated set with the specified object and * va_list. @@ -215,11 +217,11 @@ * object. * * @param object The object which is checked for being in the set * @return A boolean whether the set contains the specified object */ -- (bool)containsObject: (ObjectType)object; +- (bool)containsObject: (nullable ObjectType)object; /*! * @brief Returns an OFEnumerator to enumerate through all objects of the set. * * @returns An OFEnumerator to enumerate through all objects of the set @@ -246,7 +248,9 @@ #endif @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif + +OF_ASSUME_NONNULL_END #import "OFMutableSet.h" Index: src/OFSet_hashtable.h ================================================================== --- src/OFSet_hashtable.h +++ src/OFSet_hashtable.h @@ -14,14 +14,18 @@ * file. */ #import "OFSet.h" +OF_ASSUME_NONNULL_BEGIN + @class OFMapTable; @interface OFSet_hashtable: OFSet { OFMapTable *_mapTable; } - initWithCapacity: (size_t)capacity; @end + +OF_ASSUME_NONNULL_END Index: src/OFSettings.h ================================================================== --- src/OFSettings.h +++ src/OFSettings.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFArray OF_GENERIC(ObjectType); /*! * @class OFSettings OFSettings.h ObjFW/OFSettings.h @@ -127,22 +129,22 @@ * not exist. * * @param path The path for which the string value should be returned * @return The string value of the specified path */ -- (OFString*)stringForPath: (OFString*)path; +- (nullable OFString*)stringForPath: (OFString*)path; /*! * @brief Returns the string for the specified path, or the default value if * the path does not exist. * * @param path The path for which the string value should be returned * @param defaultValue The default value to return if the path does not exist * @return The string value of the specified path */ -- (OFString*)stringForPath: (OFString*)path - defaultValue: (OFString*)defaultValue; +- (nullable OFString*)stringForPath: (OFString*)path + defaultValue: (nullable OFString*)defaultValue; /*! * @brief Returns the integer for the specified path, or the default value if * the path does not exist. * @@ -210,5 +212,7 @@ * should always call this method after doing a bunch of changes, no * matter which backend is used! */ - (void)save; @end + +OF_ASSUME_NONNULL_END Index: src/OFSettings_INIFile.h ================================================================== --- src/OFSettings_INIFile.h +++ src/OFSettings_INIFile.h @@ -14,14 +14,18 @@ * file. */ #import "OFSettings.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFINIFile; @interface OFSettings_INIFile: OFSettings { OFString *_filePath; OFINIFile *_INIFile; } @end + +OF_ASSUME_NONNULL_END Index: src/OFSortedList.h ================================================================== --- src/OFSortedList.h +++ src/OFSortedList.h @@ -14,10 +14,12 @@ * file. */ #import "OFList.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSortedList OFSortedList.h ObjFW/OFSortedList.h * * @brief A class which provides easy to use sorted double-linked lists. * @@ -41,5 +43,7 @@ - (of_list_object_t*)insertObject: (ObjectType )object; @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif + +OF_ASSUME_NONNULL_END Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -14,10 +14,12 @@ * file. */ #import "OFStream.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFStdIOStream OFStdIOStream.h ObjFW/OFStdIOStream.h * * @brief A class for providing standard input, output and error as OFStream. * @@ -37,21 +39,23 @@ /*! @file */ /*! * @brief The standard input as an OFStream. */ -extern OFStdIOStream *of_stdin; +extern __nullable OFStdIOStream *of_stdin; /*! * @brief The standard output as an OFStream. */ -extern OFStdIOStream *of_stdout; +extern __nullable OFStdIOStream *of_stdout; /*! * @brief The standard error as an OFStream. */ -extern OFStdIOStream *of_stderr; +extern __nullable OFStdIOStream *of_stderr; extern void of_log(OFConstantString*, ...); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFStream+Private.h ================================================================== --- src/OFStream+Private.h +++ src/OFStream+Private.h @@ -13,9 +13,13 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFStream.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFStream (OF_PRIVATE_CATEGORY) - (bool)OF_isWaitingForDelimiter; @end + +OF_ASSUME_NONNULL_END Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -27,10 +27,12 @@ #import "OFString.h" #ifdef OF_HAVE_SOCKETS # import "OFKernelEventObserver.h" #endif +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFStream; @class OFDataArray; @class OFException; @@ -44,22 +46,23 @@ * @param length The length of the data that has been read * @param exception An exception which occurred while reading or nil on success * @return A bool whether the same block should be used for the next read */ typedef bool (^of_stream_async_read_block_t)(OFStream *stream, void *buffer, - size_t length, OFException *exception); + size_t length, __nullable OFException *exception); /*! * @brief A block which is called when a line was read from the stream. * * @param stream The stream on which a line was read - * @param line The line which has been read + * @param line The line which has been read or nil when the end of stream + * occurred * @param exception An exception which occurred while reading or nil on success * @return A bool whether the same block should be used for the next read */ typedef bool (^of_stream_async_read_line_block_t)(OFStream *stream, - OFString *line, OFException *exception); + __nullable OFString *line, __nullable OFException *exception); #endif /*! * @class OFStream OFStream.h ObjFW/OFStream.h * @@ -200,14 +203,14 @@ * false from the method. * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, void *buffer, size_t size, * OFException *exception)`. */ - - (void)asyncReadIntoBuffer: (void*)buffer - exactLength: (size_t)length - target: (id)target - selector: (SEL)selector; +- (void)asyncReadIntoBuffer: (void*)buffer + exactLength: (size_t)length + target: (id)target + selector: (SEL)selector; # ifdef OF_HAVE_BLOCKS /*! * @brief Asyncronously reads *at most* ref size bytes from the stream into a * buffer. @@ -594,21 +597,21 @@ * @brief Reads until a newline, \\0 or end of stream occurs. * * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readLine; +- (nullable OFString*)readLine; /*! * @brief Reads with the specified encoding until a newline, \\0 or end of * stream occurs. * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; +- (nullable OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; #ifdef OF_HAVE_SOCKETS /*! * @brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. @@ -689,11 +692,11 @@ * no complete line has been received yet. * * @return The line that was read, autoreleased, or nil if the line is not * complete yet */ -- (OFString*)tryReadLine; +- (nullable OFString*)tryReadLine; /*! * @brief Tries to read a line from the stream with the specified encoding (see * @ref readLineWithEncoding:) and returns nil if no complete line has * been received yet. @@ -700,21 +703,21 @@ * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or nil if the line is not * complete yet */ -- (OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding; +- (nullable OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding; /*! * @brief Reads until the specified string or \\0 is found or the end of stream * occurs. * * @param delimiter The delimiter * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readTillDelimiter: (OFString*)delimiter; +- (nullable OFString*)readTillDelimiter: (OFString*)delimiter; /*! * @brief Reads until the specified string or \\0 is found or the end of stream * occurs. * @@ -721,12 +724,12 @@ * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readTillDelimiter: (OFString*)delimiter - encoding: (of_string_encoding_t)encoding; +- (nullable OFString*)readTillDelimiter: (OFString*)delimiter + encoding: (of_string_encoding_t)encoding; /*! * @brief Tries to reads until the specified string or \\0 is found or the end * of stream (see @ref readTillDelimiter:) and returns nil if not enough * data has been received yet. @@ -733,11 +736,11 @@ * * @param delimiter The delimiter * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)tryReadTillDelimiter: (OFString*)delimiter; +- (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter; /*! * @brief Tries to read until the specified string or \\0 is found or the end * of stream occurs (see @ref readTillDelimiter:encoding:) and * returns nil if not enough data has been received yet. @@ -745,12 +748,12 @@ * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)tryReadTillDelimiter: (OFString*)delimiter - encoding: (of_string_encoding_t)encoding; +- (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter + encoding: (of_string_encoding_t)encoding; /*! * @brief Returns a boolen whether writes are buffered. * * @return A boolean whether writes are buffered @@ -1162,5 +1165,7 @@ * * @return Whether the lowlevel is at the end of the stream */ - (bool)lowlevelIsAtEndOfStream; @end + +OF_ASSUME_NONNULL_END Index: src/OFStreamSocket.h ================================================================== --- src/OFStreamSocket.h +++ src/OFStreamSocket.h @@ -16,10 +16,12 @@ #import "OFStream.h" #import "socket.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFStreamSocket OFStreamSocket.h ObjFW/OFStreamSocket.h * * @brief A class which provides functions to create and use stream sockets. */ @@ -34,5 +36,7 @@ * * @return A new, autoreleased OFTCPSocket */ + (instancetype)socket; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+Hashing.h ================================================================== --- src/OFString+Hashing.h +++ src/OFString+Hashing.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFString_Hashing_reference; #ifdef __cplusplus @@ -72,5 +74,7 @@ * * @return The SHA-512 hash of the string as an autoreleased OFString */ - (OFString*)SHA512Hash; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+JSONValue.h ================================================================== --- src/OFString+JSONValue.h +++ src/OFString+JSONValue.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFString_JSONValue_reference; #ifdef __cplusplus @@ -64,5 +66,7 @@ * * @return An object */ - (id)JSONValueWithDepthLimit: (size_t)depthLimit; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+Serialization.h ================================================================== --- src/OFString+Serialization.h +++ src/OFString+Serialization.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFString_Serialization_reference; #ifdef __cplusplus @@ -30,5 +32,7 @@ * * @return The deserialized object */ - (id)objectByDeserializing; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+URLEncoding.h ================================================================== --- src/OFString+URLEncoding.h +++ src/OFString+URLEncoding.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFString_URLEncoding_reference; #ifdef __cplusplus @@ -37,5 +39,7 @@ * * @return A new autoreleased string */ - (OFString*)stringByURLDecoding; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+XMLEscaping.h ================================================================== --- src/OFString+XMLEscaping.h +++ src/OFString+XMLEscaping.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFString_XMLEscaping_reference; #ifdef __cplusplus @@ -30,5 +32,7 @@ * * @return A new autoreleased string */ - (OFString*)stringByXMLEscaping; @end + +OF_ASSUME_NONNULL_END Index: src/OFString+XMLUnescaping.h ================================================================== --- src/OFString+XMLUnescaping.h +++ src/OFString+XMLUnescaping.h @@ -14,10 +14,12 @@ * file. */ #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef __cplusplus extern "C" { #endif @@ -33,12 +35,12 @@ * * @param string The XML string which contains an unknown entity * @param entity The XML entity which is unknown * @return A replacement string for the unknown entity */ -typedef OFString* (^of_string_xml_unescaping_block_t)(OFString *string, - OFString *entity); +typedef __nullable OFString* (^of_string_xml_unescaping_block_t)( + OFString *string, OFString *entity); #endif /*! * @protocol OFStringXMLUnescapingDelegate OFString.h ObjFW/OFString.h * @@ -73,11 +75,11 @@ * unknown entities. * * @param delegate An OFXMLUnescapingDelegate as a handler for unknown entities */ - (OFString*)stringByXMLUnescapingWithDelegate: - (id )delegate; + (nullable id )delegate; #ifdef OF_HAVE_BLOCKS /*! * @brief Unescapes XML in the string and uses the specified block for unknown * entities. @@ -86,5 +88,7 @@ */ - (OFString*)stringByXMLUnescapingWithBlock: (of_string_xml_unescaping_block_t)block; #endif @end + +OF_ASSUME_NONNULL_END Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -27,10 +27,12 @@ #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFConstantString; #if defined(__cplusplus) && __cplusplus >= 201103L @@ -1096,10 +1098,23 @@ */ - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; #endif @end +#ifdef __cplusplus +extern "C" { +#endif +extern size_t of_string_utf8_encode(of_unichar_t, char*); +extern size_t of_string_utf8_decode(const char*, size_t, of_unichar_t*); +extern size_t of_string_utf16_length(const of_char16_t*); +extern size_t of_string_utf32_length(const of_char32_t*); +#ifdef __cplusplus +} +#endif + +OF_ASSUME_NONNULL_END + #import "OFConstantString.h" #import "OFMutableString.h" #import "OFString+Hashing.h" #import "OFString+JSONValue.h" #import "OFString+Serialization.h" @@ -1120,17 +1135,6 @@ * * TODO: Submit a patch for Clang that makes the boxing classes configurable! */ @interface NSString: OFString @end -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern size_t of_string_utf8_encode(of_unichar_t, char*); -extern size_t of_string_utf8_decode(const char*, size_t, of_unichar_t*); -extern size_t of_string_utf16_length(const of_char16_t*); -extern size_t of_string_utf32_length(const of_char32_t*); -#ifdef __cplusplus -} #endif Index: src/OFString_UTF8+Private.h ================================================================== --- src/OFString_UTF8+Private.h +++ src/OFString_UTF8+Private.h @@ -13,11 +13,15 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFString_UTF8.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFString_UTF8 (OF_PRIVATE_CATEGORY) - (instancetype)OF_initWithUTF8String: (const char*)UTF8String length: (size_t)UTF8StringLength storage: (char*)storage; @end + +OF_ASSUME_NONNULL_END Index: src/OFString_UTF8.h ================================================================== --- src/OFString_UTF8.h +++ src/OFString_UTF8.h @@ -13,10 +13,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFString.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFString_UTF8: OFString { @public /* @@ -46,5 +48,7 @@ extern size_t of_string_utf8_get_index(const char*, size_t); extern size_t of_string_utf8_get_position(const char*, size_t, size_t); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFString.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ @@ -80,11 +82,11 @@ * * If the vendor could not be determined, nil is returned instead. * * @return The vendor of the CPU */ -+ (OFString*)CPUVendor; ++ (nullable OFString*)CPUVendor; /*! * @brief Returns whether the CPU supports MMX. * * @return Whether the CPU supports MMX @@ -145,5 +147,7 @@ * * @return Whether the CPU supports AVX2 */ + (bool)supportsAVX2; @end + +OF_ASSUME_NONNULL_END Index: src/OFTCPSocket+SOCKS5.h ================================================================== --- src/OFTCPSocket+SOCKS5.h +++ src/OFTCPSocket+SOCKS5.h @@ -14,10 +14,12 @@ * file. */ #import "OFTCPSocket.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFTCPSocket_SOCKS5_reference; #ifdef __cplusplus @@ -26,5 +28,7 @@ @interface OFTCPSocket (SOCKS5) - (void)OF_SOCKS5ConnectToHost: (OFString*)host port: (uint16_t)port; @end + +OF_ASSUME_NONNULL_END Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -16,10 +16,12 @@ #import "OFStreamSocket.h" #import "socket.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFTCPSocket; @class OFString; @@ -30,11 +32,11 @@ * @param socket The socket which connected * @param exception An exception which occurred while connecting the socket or * nil on success */ typedef void (^of_tcp_socket_async_connect_block_t)(OFTCPSocket *socket, - OFException *exception); + __nullable OFException *exception); /*! * @brief A block which is called when the socket accepted a connection. * * @param socket The socket which accepted the connection @@ -43,11 +45,11 @@ * nil on success * @return A bool whether the same block should be used for the next incoming * connection */ typedef bool (^of_tcp_socket_async_accept_block_t)(OFTCPSocket *socket, - OFTCPSocket *acceptedSocket, OFException *exception); + OFTCPSocket *acceptedSocket, __nullable OFException *exception); #endif /*! * @class OFTCPSocket OFTCPSocket.h ObjFW/OFTCPSocket.h * @@ -65,11 +67,11 @@ uint16_t _SOCKS5Port; } #ifdef OF_HAVE_PROPERTIES @property (readonly, getter=isListening) bool listening; -@property (copy) OFString *SOCKS5Host; +@property (copy, nullable) OFString *SOCKS5Host; @property uint16_t SOCKS5Port; @property (getter=isKeepAliveEnabled) bool keepAliveEnabled; @property (getter=isTCPNoDelayEnabled) bool TCPNoDelayEnabled; #endif @@ -77,18 +79,18 @@ * @brief Sets the global SOCKS5 proxy host to use when creating a new socket * * @param SOCKS5Host The host to use as a SOCKS5 proxy when creating a new * socket */ -+ (void)setSOCKS5Host: (OFString*)SOCKS5Host; ++ (void)setSOCKS5Host: (nullable OFString*)SOCKS5Host; /*! * @brief Returns the host to use as a SOCKS5 proxy when creating a new socket * * @return The host to use as a SOCKS5 proxy when creating a new socket */ -+ (OFString*)SOCKS5Host; ++ (nullable OFString*)SOCKS5Host; /*! * @brief Sets the global SOCKS5 proxy port to use when creating a new socket * * @param SOCKS5Port The port to use as a SOCKS5 proxy when creating a new socket @@ -105,18 +107,18 @@ /*! * @brief Sets the host to use as a SOCKS5 proxy. * * @param host The host to use as a SOCKS5 proxy */ -- (void)setSOCKS5Host: (OFString*)host; +- (void)setSOCKS5Host: (nullable OFString*)host; /*! * @brief Returns the host to use as a SOCKS5 proxy. * * @return The host to use as a SOCKS5 proxy */ -- (OFString*)SOCKS5Host; +- (nullable OFString*)SOCKS5Host; /*! * @brief Sets the port to use on the SOCKS5 proxy. * * The default port is 1080. @@ -232,11 +234,11 @@ * * Only works with accepted sockets! * * @return The remote address as a string */ -- (OFString*)remoteAddress; +- (nullable OFString*)remoteAddress; /*! * @brief Returns whether the socket is a listening socket. * * @return Whether the socket is a listening socket @@ -273,9 +275,11 @@ @end #ifdef __cplusplus extern "C" { #endif -extern Class of_tls_socket_class; +extern __nullable Class of_tls_socket_class; #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFTLSSocket.h ================================================================== --- src/OFTLSSocket.h +++ src/OFTLSSocket.h @@ -12,11 +12,13 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#import "objfw-defs.h" +#import "OFObject.h" + +OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @protocol OFTLSSocket; @@ -53,13 +55,13 @@ * @brief A protocol that should be implemented by 3rd-party libraries * implementing TLS. */ @protocol OFTLSSocket #ifdef OF_HAVE_PROPERTIES -@property (assign) id delegate; -@property (copy) OFString *certificateFile, *privateKeyFile; -@property const char *privateKeyPassphrase; +@property (assign, nullable) id delegate; +@property (copy, nullable) OFString *certificateFile, *privateKeyFile; +@property (assign, nullable) const char *privateKeyPassphrase; @property (getter=isCertificateVerificationEnabled) bool certificateVerificationEnabled; #endif /*! @@ -84,25 +86,25 @@ /*! * @brief Sets a delegate for the TLS socket. * * @param delegate The delegate to use */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; /*! * @brief Returns the delegate used by the TLS socket. * * @return The delegate used by the TLS socket */ -- (id )delegate; +- (nullable id )delegate; /*! * @brief Sets the path to the X.509 certificate file to use. * * @param certificateFile The path to the X.509 certificate file */ -- (void)setCertificateFile: (OFString*)certificateFile; +- (void)setCertificateFile: (nullable OFString*)certificateFile; /*! * @brief Sets the path to the X.509 certificate file to use for the specified * SNI host. * @@ -117,11 +119,11 @@ /*! * @brief Returns the path of the X.509 certificate file used by the TLS socket. * * @return The path of the X.509 certificate file used by the TLS socket */ -- (OFString*)certificateFile; +- (nullable OFString*)certificateFile; /*! * @brief Returns the path of the X.509 certificate file used by the TLS socket * for the specified SNI host. * @@ -129,18 +131,18 @@ * should be returned * * @return The path of the X.509 certificate file used by the TLS socket for * the specified SNI host */ -- (OFString*)certificateFileForSNIHost: (OFString*)SNIHost; +- (nullable OFString*)certificateFileForSNIHost: (OFString*)SNIHost; /*! * @brief Sets the path to the PKCS#8 private key file to use. * * @param privateKeyFile The path to the PKCS#8 private key file */ -- (void)setPrivateKeyFile: (OFString*)privateKeyFile; +- (void)setPrivateKeyFile: (nullable OFString*)privateKeyFile; /*! * @brief Sets the path to the PKCS#8 private key file to use for the specified * SNI host. * @@ -155,11 +157,11 @@ * @brief Returns the path of the PKCS#8 private key file used by the TLS * socket. * * @return The path of the PKCS#8 private key file used by the TLS socket */ -- (OFString*)privateKeyFile; +- (nullable OFString*)privateKeyFile; /*! * @brief Returns the path of the PKCS#8 private key file used by the TLS * socket for the specified SNI host. * @@ -167,11 +169,11 @@ * file should be returned * * @return The path of the PKCS#8 private key file used by the TLS socket for * the specified SNI host */ -- (OFString*)privateKeyFileForSNIHost: (OFString*)SNIHost; +- (nullable OFString*)privateKeyFileForSNIHost: (OFString*)SNIHost; /*! * @brief Sets the passphrase to decrypt the PKCS#8 private key file. * * @warning You have to ensure that this is in secure memory protected from @@ -178,11 +180,11 @@ * swapping! This is also the reason why this is not an OFString. * * @param privateKeyPassphrase The passphrase to decrypt the PKCS#8 private * key file */ -- (void)setPrivateKeyPassphrase: (const char*)privateKeyPassphrase; +- (void)setPrivateKeyPassphrase: (nullable const char*)privateKeyPassphrase; /*! * @brief Sets the passphrase to decrypt the PKCS#8 private key file for the * specified SNI host. * @@ -202,11 +204,11 @@ * * @warning You should not copy this to insecure memory which is swappable! * * @return The passphrase to decrypt the PKCS#8 private key file */ -- (const char*)privateKeyPassphrase; +- (nullable const char*)privateKeyPassphrase; /*! * @brief Returns the passphrase to decrypt the PKCS#8 private key file for the * specified SNI host. * @@ -216,11 +218,11 @@ * private key file should be returned * * @return The passphrase to decrypt the PKCS#8 private key file for the * specified SNI host */ -- (const char*)privateKeyPassphraseForSNIHost: (OFString*)SNIHost; +- (nullable const char*)privateKeyPassphraseForSNIHost: (OFString*)SNIHost; /** * @brief Enable or disable certificate verification. * * The default is enabled. @@ -234,5 +236,7 @@ * * @return Whether certificate verification is enabled */ - (bool)isCertificateVerificationEnabled; @end + +OF_ASSUME_NONNULL_END Index: src/OFThread+Private.h ================================================================== --- src/OFThread+Private.h +++ src/OFThread+Private.h @@ -14,10 +14,14 @@ * file. */ #import "OFThread.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef OF_HAVE_THREADS @interface OFThread (OF_PRIVATE_CATEGORY) + (void)OF_createMainThread; @end #endif + +OF_ASSUME_NONNULL_END Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -18,10 +18,12 @@ #ifdef OF_HAVE_THREADS # import "threading.h" #endif +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFDate; @class OFRunLoop; @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @@ -30,11 +32,11 @@ /*! * @brief A block to be executed in a new thread. * * @return The object which should be returned when the thread is joined */ -typedef id (^of_thread_block_t)(void); +typedef __nullable id (^of_thread_block_t)(void); #endif /*! * @class OFThread OFThread.h ObjFW/OFThread.h * @@ -154,11 +156,11 @@ /*! * @brief Terminates the current thread, letting it return the specified object. * * @param object The object which the terminated thread will return */ -+ (void)terminateWithObject: (id)object OF_NO_RETURN; ++ (void)terminateWithObject: (nullable id)object OF_NO_RETURN; # ifdef OF_HAVE_BLOCKS /*! * @brief Initializes an already allocated thread with the specified block. * @@ -174,11 +176,11 @@ * It can access the object passed to the threadWithObject or initWithObject * method using the instance variable named object. * * @return The object the join method should return when called for this thread */ -- (id)main; +- (nullable id)main; /*! * @brief This routine is exectued when the thread's main method has finished * executing or terminate has been called. * @@ -208,18 +210,18 @@ /*! * @brief Returns the name of the thread or nil if none has been set. * * @return The name of the thread or nik if none has been set */ -- (OFString*)name; +- (nullable OFString*)name; /*! * @brief Sets the name for the thread. * * @param name The name for the thread */ -- (void)setName: (OFString*)name; +- (void)setName: (nullable OFString*)name; /*! * @brief Returns the priority of the thread. * * @return The priority of the thread @@ -251,5 +253,7 @@ * @param stackSize The stack size for the thread */ - (void)setStackSize: (size_t)stackSize; #endif @end + +OF_ASSUME_NONNULL_END Index: src/OFThreadPool.h ================================================================== --- src/OFThreadPool.h +++ src/OFThreadPool.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef OF_HAVE_BLOCKS /*! * @brief A block for a job which should be executed in a thread pool. @@ -93,11 +95,11 @@ * @param selector The selector to perform on the target * @param object THe object with which the selector is performed on the target */ - (void)dispatchWithTarget: (id)target selector: (SEL)selector - object: (id)object; + object: (nullable id)object; #ifdef OF_HAVE_BLOCKS /*! * @brief Executes the specified block as soon as a thread is ready. * @@ -116,5 +118,7 @@ * * @return The size of the thread pool */ - (size_t)size; @end + +OF_ASSUME_NONNULL_END Index: src/OFTimer+Private.h ================================================================== --- src/OFTimer+Private.h +++ src/OFTimer+Private.h @@ -13,9 +13,13 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFTimer.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFTimer (OF_PRIVATE_CATEGORY) -- (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop; +- (void)OF_setInRunLoop: (nullable OFRunLoop*)inRunLoop; @end + +OF_ASSUME_NONNULL_END Index: src/OFTimer.h ================================================================== --- src/OFTimer.h +++ src/OFTimer.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFTimer; @class OFDate; @class OFRunLoop; @@ -87,11 +89,11 @@ * @return A new, autoreleased timer */ + (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector - object: (id)object + object: (nullable id)object repeats: (bool)repeats; /*! * @brief Creates and schedules a new timer with the specified time interval. * @@ -106,12 +108,12 @@ * @return A new, autoreleased timer */ + (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector - object: (id)object1 - object: (id)object2 + object: (nullable id)object1 + object: (nullable id)object2 repeats: (bool)repeats; #ifdef OF_HAVE_BLOCKS /*! * @brief Creates and schedules a new timer with the specified time interval. @@ -151,11 +153,11 @@ * @return A new, autoreleased timer */ + (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector - object: (id)object + object: (nullable id)object repeats: (bool)repeats; /*! * @brief Creates a new timer with the specified time interval. * @@ -170,12 +172,12 @@ * @return A new, autoreleased timer */ + (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval target: (id)target selector: (SEL)selector - object: (id)object1 - object: (id)object2 + object: (nullable id)object1 + object: (nullable id)object2 repeats: (bool)repeats; #ifdef OF_HAVE_BLOCKS /*! * @brief Creates a new timer with the specified time interval. @@ -223,11 +225,11 @@ */ - initWithFireDate: (OFDate*)fireDate interval: (of_time_interval_t)interval target: (id)target selector: (SEL)selector - object: (id)object + object: (nullable id)object repeats: (bool)repeats; /*! * @brief Initializes an already allocated timer with the specified time * interval. @@ -246,12 +248,12 @@ */ - initWithFireDate: (OFDate*)fireDate interval: (of_time_interval_t)interval target: (id)target selector: (SEL)selector - object: (id)object1 - object: (id)object2 + object: (nullable id)object1 + object: (nullable id)object2 repeats: (bool)repeats; #ifdef OF_HAVE_BLOCKS /*! * @brief Initializes an already allocated timer with the specified time @@ -321,5 +323,7 @@ * @brief Waits until the timer fired. */ - (void)waitUntilDone; #endif @end + +OF_ASSUME_NONNULL_END Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -17,10 +17,12 @@ #import "OFObject.h" #import "OFKernelEventObserver.h" #import "socket.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFUDPSocket; @class OFException; @@ -44,11 +46,12 @@ * @param address The address of the resolved host / port pair * @param exception An exception which occurred while resolving or nil on * success */ typedef void (^of_udp_socket_async_resolve_block_t)(OFString *host, - uint16_t port, of_udp_socket_address_t address, OFException *exception); + uint16_t port, of_udp_socket_address_t address, + __nullable OFException *exception); /*! * @brief A block which is called when a packet has been received. * * @param socket The UDP which received a packet @@ -59,11 +62,11 @@ * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_udp_socket_async_receive_block_t)(OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t sender, - OFException *exception); + __nullable OFException *exception); #endif /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * @@ -72,12 +75,11 @@ * Addresses are of type @ref of_udp_socket_address_t. You can use @ref * getHost:andPort:forAddress: to create an address for a host / port pair and * @ref getHost:andPort:forAddress: to get the host / port pair for an address. * If you want to compare two addresses, you can use * @ref of_udp_socket_address_equal and you can use - * @ref of_udp_socket_address_hash to get a hash to use in e.g. - * @ref OFMapTable. + * @ref of_udp_socket_address_hash to get a hash to use in e.g. @ref OFMapTable. * * @warning Even though the OFCopying protocol is implemented, it does *not* * return an independent copy of the socket, but instead retains it. * This is so that the socket can be used as a key for a dictionary, * so context can be associated with a socket. Using a socket in more @@ -150,12 +152,12 @@ * the host of the host / port pair. * @param port A pointer to an uint16_t. If it is not NULL, the port of the * host / port pair will be written to it. * @param address The address for which the host and port should be retrieved */ -+ (void)getHost: (OFString *__autoreleasing*)host - andPort: (uint16_t*)port ++ (void)getHost: (__nonnull OFString *__autoreleasing *__nullable)host + andPort: (__nullable uint16_t*)port forAddress: (of_udp_socket_address_t*)address; /*! * @brief Binds the socket to the specified host and port. * @@ -278,5 +280,7 @@ */ extern uint32_t of_udp_socket_address_hash(of_udp_socket_address_t *address); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/OFURL.h ================================================================== --- src/OFURL.h +++ src/OFURL.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFSerialization.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; /*! * @class OFURL OFURL.h ObjFW/OFURL.h * @@ -33,16 +35,16 @@ #ifdef OF_HAVE_PROPERTIES @property (copy) OFString *scheme; @property (copy) OFString *host; @property uint16_t port; -@property (copy) OFString *user; -@property (copy) OFString *password; +@property (copy, nullable) OFString *user; +@property (copy, nullable) OFString *password; @property (copy) OFString *path; -@property (copy) OFString *parameters; -@property (copy) OFString *query; -@property (copy) OFString *fragment; +@property (copy, nullable) OFString *parameters; +@property (copy, nullable) OFString *query; +@property (copy, nullable) OFString *fragment; #endif /*! * Creates a new URL. * @@ -132,32 +134,32 @@ /*! * @brief Returns the user part of the URL. * * @return The user part of the URL */ -- (OFString*)user; +- (nullable OFString*)user; /*! * @brief Set the user part of the URL. * * @param user The user part of the URL to set */ -- (void)setUser: (OFString*)user; +- (void)setUser: (nullable OFString*)user; /*! * @brief Returns the password part of the URL. * * @return The password part of the URL */ -- (OFString*)password; +- (nullable OFString*)password; /*! * @brief Set the password part of the URL. * * @param password The password part of the URL to set */ -- (void)setPassword: (OFString*)password; +- (void)setPassword: (nullable OFString*)password; /*! * @brief Returns the path part of the URL. * * @return The path part of the URL @@ -174,49 +176,51 @@ /*! * @brief Returns the parameters part of the URL. * * @return The parameters part of the URL */ -- (OFString*)parameters; +- (nullable OFString*)parameters; /*! * @brief Set the parameters part of the URL. * * @param parameters The parameters part of the URL to set */ -- (void)setParameters: (OFString*)parameters; +- (void)setParameters: (nullable OFString*)parameters; /*! * @brief Returns the query part of the URL. * * @return The query part of the URL */ -- (OFString*)query; +- (nullable OFString*)query; /*! * @brief Set the query part of the URL. * * @param query The query part of the URL to set */ -- (void)setQuery: (OFString*)query; +- (void)setQuery: (nullable OFString*)query; /*! * @brief Returns the fragment part of the URL. * * @return The fragment part of the URL */ -- (OFString*)fragment; +- (nullable OFString*)fragment; /*! * @brief Set the fragment part of the URL. * * @param fragment The fragment part of the URL to set */ -- (void)setFragment: (OFString*)fragment; +- (void)setFragment: (nullable OFString*)fragment; /*! * @brief Returns the URL as a string. * * @return The URL as a string */ - (OFString*)string; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLAttribute.h ================================================================== --- src/OFXMLAttribute.h +++ src/OFXMLAttribute.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; /*! * @class OFXMLAttribute OFXMLAttribute.h ObjFW/OFXMLAttribute.h * @@ -30,13 +32,13 @@ } #ifdef OF_HAVE_PROPERTIES @property (readonly, copy) OFString *name; # ifdef __cplusplus -@property (readonly, copy, getter=namespace) OFString *namespace_; +@property (readonly, copy, getter=namespace, nullable) OFString *namespace_; # else -@property (readonly, copy) OFString *namespace; +@property (readonly, copy, nullable) OFString *namespace; # endif #endif /*! * @brief Creates a new XML attribute. @@ -55,11 +57,11 @@ * @param namespace_ The namespace of the attribute * @param stringValue The string value of the attribute * @return A new autoreleased OFXMLAttribute with the specified parameters */ + (instancetype)attributeWithName: (OFString*)name - namespace: (OFString*)namespace_ + namespace: (nullable OFString*)namespace_ stringValue: (OFString*)stringValue; /*! * @brief Initializes an already allocated OFXMLAttribute. * @@ -77,11 +79,11 @@ * @param namespace_ The namespace of the attribute * @param stringValue The string value of the attribute * @return An initialized OFXMLAttribute with the specified parameters */ - initWithName: (OFString*)name - namespace: (OFString*)namespace_ + namespace: (nullable OFString*)namespace_ stringValue: (OFString*)stringValue; /*! * @brief Returns the name of the attribute as an autoreleased OFString. * @@ -92,7 +94,9 @@ /*! * @brief Returns the namespace of the attribute as an autoreleased OFString. * * @return The namespace of the attribute as an autoreleased OFString */ -- (OFString*)namespace; +- (nullable OFString*)namespace; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLCDATA.h ================================================================== --- src/OFXMLCDATA.h +++ src/OFXMLCDATA.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFXMLCDATA OFXMLCDATA.h ObjFW/OFXMLCDATA.h * * @brief A class representing XML CDATA. */ @@ -40,5 +42,7 @@ * @param string The string value for the CDATA * @return An initialized OFXMLCDATA */ - initWithString: (OFString*)string; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLCharacters.h ================================================================== --- src/OFXMLCharacters.h +++ src/OFXMLCharacters.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFXMLCharacters OFXMLCharacters.h ObjFW/OFXMLCharacters.h * * @brief A class representing XML characters. */ @@ -41,5 +43,7 @@ * @param string The string value for the characters * @return An initialized OFXMLCharacters */ - initWithString: (OFString*)string; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLComment.h ================================================================== --- src/OFXMLComment.h +++ src/OFXMLComment.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFXMLComment OFXMLComment.h ObjFW/OFXMLComment.h * * @brief A class for representing XML comments. */ @@ -41,5 +43,7 @@ * @param string The string for the comment * @return An initialized OFXMLComment */ - initWithString: (OFString*)string; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLElement+Serialization.h ================================================================== --- src/OFXMLElement+Serialization.h +++ src/OFXMLElement+Serialization.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLElement.h" +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern int _OFXMLElement_Serialization_reference; #ifdef __cplusplus @@ -30,5 +32,7 @@ * * @return The deserialized object */ - (id)objectByDeserializing; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFMutableString; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @@ -39,17 +41,19 @@ } #ifdef OF_HAVE_PROPERTIES @property (copy) OFString *name; # ifdef __cplusplus -@property (copy, getter=namespace, setter=setNamespace:) OFString *namespace_; +@property (copy, getter=namespace, setter=setNamespace:, nullable) + OFString *namespace_; # else -@property (copy) OFString *namespace; +@property (copy, nullable) OFString *namespace; # endif -@property (copy) OFString *defaultNamespace; -@property (readonly, copy) OFArray OF_GENERIC(OFXMLAttribute*) *attributes; -@property (copy) OFArray OF_GENERIC(OFXMLNode*) *children; +@property (copy, nullable) OFString *defaultNamespace; +@property (copy, readonly, nullable) OFArray OF_GENERIC(OFXMLAttribute*) + *attributes; +@property (copy, nullable) OFArray OF_GENERIC(OFXMLNode*) *children; #endif /*! * @brief Creates a new XML element with the specified name. * @@ -65,11 +69,11 @@ * @param stringValue The value for the element * @return A new autoreleased OFXMLElement with the specified element name and * value */ + (instancetype)elementWithName: (OFString*)name - stringValue: (OFString*)stringValue; + stringValue: (nullable OFString*)stringValue; /*! * @brief Creates a new XML element with the specified name and namespace. * * @param name The name for the element @@ -76,11 +80,11 @@ * @param namespace_ The namespace for the element * @return A new autoreleased OFXMLElement with the specified element name and * namespace */ + (instancetype)elementWithName: (OFString*)name - namespace: (OFString*)namespace_; + namespace: (nullable OFString*)namespace_; /*! * @brief Creates a new XML element with the specified name, namespace and * string value. * @@ -89,12 +93,12 @@ * @param stringValue The value for the element * @return A new autoreleased OFXMLElement with the specified element name, * namespace and value */ + (instancetype)elementWithName: (OFString*)name - namespace: (OFString*)namespace_ - stringValue: (OFString*)stringValue; + namespace: (nullable OFString*)namespace_ + stringValue: (nullable OFString*)stringValue; /*! * @brief Creates a new element with the specified element. * * @param element An OFXMLElement to initialize the OFXMLElement with @@ -138,11 +142,11 @@ * @param stringValue The value for the element * @return An initialized OFXMLElement with the specified element name and * value */ - initWithName: (OFString*)name - stringValue: (OFString*)stringValue; + stringValue: (nullable OFString*)stringValue; /*! * @brief Initializes an already allocated OFXMLElement with the specified name * and namespace. * @@ -150,11 +154,11 @@ * @param namespace_ The namespace for the element * @return An initialized OFXMLElement with the specified element name and * namespace */ - initWithName: (OFString*)name - namespace: (OFString*)namespace_; + namespace: (nullable OFString*)namespace_; /*! * @brief Initializes an already allocated OFXMLElement with the specified name, * namespace and value. * @@ -163,12 +167,12 @@ * @param stringValue The value for the element * @return An initialized OFXMLElement with the specified element name, * namespace and value */ - initWithName: (OFString*)name - namespace: (OFString*)namespace_ - stringValue: (OFString*)stringValue; + namespace: (nullable OFString*)namespace_ + stringValue: (nullable OFString*)stringValue; /*! * @brief Initializes an already allocated OFXMLElement with the specified * element. * @@ -215,39 +219,51 @@ /*! * @brief Sets the namespace of the element. * * @param namespace_ The new namespace */ -- (void)setNamespace: (OFString*)namespace_; +- (void)setNamespace: (nullable OFString*)namespace_; /*! * @brief Returns the namespace of the element. * * @return The namespace of the element */ -- (OFString*)namespace; +- (nullable OFString*)namespace; + +/*! + * @brief Sets a prefix for a namespace. + * + * @param prefix The prefix for the namespace + * @param namespace_ The namespace for which the prefix is set + */ +- (void)setPrefix: (OFString*)prefix + forNamespace: (OFString*)namespace_; + +/*! + * @brief Binds a prefix for a namespace. + * + * @param prefix The prefix for the namespace + * @param namespace_ The namespace for which the prefix is bound + */ +- (void)bindPrefix: (OFString*)prefix + forNamespace: (OFString*)namespace_; + +/*! + * @brief Sets the default namespace for the element to be used if there is no + * parent. + * + * @param defaultNamespace The default namespace for the element + */ +- (void)setDefaultNamespace: (nullable OFString*)defaultNamespace; /*! * @brief Returns an OFArray with the attributes of the element. * * @return An OFArray with the attributes of the element */ -- (OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; - -/*! - * @brief Removes all children and adds the children from the specified array. - * - * @param children The new children to add - */ -- (void)setChildren: (OFArray OF_GENERIC(OFXMLNode*)*)children; - -/*! - * @brief Returns an array of OFXMLNodes with all children of the element. - * - * @return An array of OFXMLNodes with all children of the element - */ -- (OFArray OF_GENERIC(OFXMLNode*)*)children; +- (nullable OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; /*! * @brief Adds the specified attribute. * * If an attribute with the same name and namespace already exists, it is not @@ -279,11 +295,11 @@ * @param name The name of the attribute * @param namespace_ The namespace of the attribute * @param stringValue The value of the attribute */ - (void)addAttributeWithName: (OFString*)name - namespace: (OFString*)namespace_ + namespace: (nullable OFString*)namespace_ stringValue: (OFString*)stringValue; /*! * @brief Returns the attribute with the specified name. * @@ -298,11 +314,11 @@ * @param attributeName The name of the attribute * @param attributeNS The namespace of the attribute * @return The attribute with the specified name and namespace */ - (OFXMLAttribute*)attributeForName: (OFString*)attributeName - namespace: (OFString*)attributeNS; + namespace: (nullable OFString*)attributeNS; /*! * @brief Removes the attribute with the specified name. * * @param attributeName The name of the attribute @@ -314,37 +330,25 @@ * * @param attributeName The name of the attribute * @param attributeNS The namespace of the attribute */ - (void)removeAttributeForName: (OFString*)attributeName - namespace: (OFString*)attributeNS; - -/*! - * @brief Sets a prefix for a namespace. - * - * @param prefix The prefix for the namespace - * @param namespace_ The namespace for which the prefix is set - */ -- (void)setPrefix: (OFString*)prefix - forNamespace: (OFString*)namespace_; - -/*! - * @brief Binds a prefix for a namespace. - * - * @param prefix The prefix for the namespace - * @param namespace_ The namespace for which the prefix is bound - */ -- (void)bindPrefix: (OFString*)prefix - forNamespace: (OFString*)namespace_; - -/*! - * @brief Sets the default namespace for the element to be used if there is no - * parent. - * - * @param defaultNamespace The default namespace for the element - */ -- (void)setDefaultNamespace: (OFString*)defaultNamespace; + namespace: (nullable OFString*)attributeNS; + +/*! + * @brief Removes all children and adds the children from the specified array. + * + * @param children The new children to add + */ +- (void)setChildren: (nullable OFArray OF_GENERIC(OFXMLNode*)*)children; + +/*! + * @brief Returns an array of OFXMLNodes with all children of the element. + * + * @return An array of OFXMLNodes with all children of the element + */ +- (nullable OFArray OF_GENERIC(OFXMLNode*)*)children; /*! * @brief Adds a child to the OFXMLElement. * * @param child An OFXMLNode which is added as a child @@ -413,11 +417,11 @@ * @brief Returns all children that have the specified namespace. * * @return All children that have the specified namespace */ - (OFArray OF_GENERIC(OFXMLElement*)*)elementsForNamespace: - (OFString*)elementNS; + (nullable OFString*)elementNS; /*! * @brief Returns the first child element with the specified name. * * @param elementName The name of the element @@ -439,19 +443,22 @@ * @param elementName The name of the element * @param elementNS The namespace of the element * @return The first child element with the specified name and namespace */ - (OFXMLElement*)elementForName: (OFString*)elementName - namespace: (OFString*)elementNS; + namespace: (nullable OFString*)elementNS; /*! * @brief Returns the child elements with the specified name and namespace. * * @param elementName The name of the elements * @param elementNS The namespace of the elements * @return The child elements with the specified name and namespace */ -- (OFArray OF_GENERIC(OFXMLElement*)*)elementsForName: (OFString*)elementName - namespace: (OFString*)elementNS; +- (OFArray OF_GENERIC(OFXMLElement*)*) + elementsForName: (OFString*)elementName + namespace: (nullable OFString*)elementNS; @end + +OF_ASSUME_NONNULL_END #import "OFXMLElement+Serialization.h" Index: src/OFXMLElementBuilder.h ================================================================== --- src/OFXMLElementBuilder.h +++ src/OFXMLElementBuilder.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" #import "OFXMLParser.h" + +OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); @class OFXMLElement; @class OFXMLElementBuilder; @@ -77,12 +79,12 @@ * @param prefix The prefix of the close tag * @param namespace_ The namespace of the close tag */ - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name - prefix: (OFString*)prefix - namespace: (OFString*)namespace_; + prefix: (nullable OFString*)prefix + namespace: (nullable OFString*)namespace_; /*! * @brief This callback is called when the XML parser for the element builder * found an unknown entity. * @@ -109,32 +111,34 @@ OFMutableArray OF_GENERIC(OFXMLElement*) *_stack; id _delegate; } #ifdef OF_HAVE_PROPERTIES -@property (assign) id delegate; +@property (assign, nullable) id delegate; #endif /*! * @brief Creates a new element builder. * * @return A new, autoreleased OFXMLElementBuilder */ + (instancetype)elementBuilder; -/*! - * @brief Returns the delegate for the OFXMLElementBuilder. - * - * @return The delegate for the OFXMLElementBuilder - */ -- (id )delegate; - /*! * @brief Sets the delegate for the OFXMLElementBuilder. * * @param delegate The delegate for the OFXMLElementBuilder */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; + +/*! + * @brief Returns the delegate for the OFXMLElementBuilder. + * + * @return The delegate for the OFXMLElementBuilder + */ +- (nullable id )delegate; @end @interface OFObject (OFXMLElementBuilderDelegate) @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLNode.h ================================================================== --- src/OFXMLNode.h +++ src/OFXMLNode.h @@ -15,10 +15,12 @@ */ #import "OFObject.h" #import "OFSerialization.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFXMLNode OFXMLNode.h ObjFW/OFXMLNode.h * * @brief A class which stores an XML element. */ @@ -95,5 +97,7 @@ * indentation */ - (OFString*)XMLStringWithIndentation: (unsigned int)indentation level: (unsigned int)level; @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLParser.h ================================================================== --- src/OFXMLParser.h +++ src/OFXMLParser.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "OFString.h" #import "OFXMLAttribute.h" +OF_ASSUME_NONNULL_BEGIN + @class OFXMLParser; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @@ -57,13 +59,13 @@ * @param attributes The attributes included in the tag which just started or * nil */ - (void)parser: (OFXMLParser*)parser didStartElement: (OFString*)name - prefix: (OFString*)prefix - namespace: (OFString*)ns - attributes: (OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; + prefix: (nullable OFString*)prefix + namespace: (nullable OFString*)ns + attributes: (nullable OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; /*! * @brief This callback is called when the XML parser found the end of a tag. * * @param parser The parser which found the end of a tag @@ -71,12 +73,12 @@ * @param prefix The prefix of the tag which just ended or nil * @param ns The namespace of the tag which just ended or nil */ - (void)parser: (OFXMLParser*)parser didEndElement: (OFString*)name - prefix: (OFString*)prefix - namespace: (OFString*)ns; + prefix: (nullable OFString*)prefix + namespace: (nullable OFString*)ns; /*! * @brief This callback is called when the XML parser found characters. * * In case there are comments or CDATA, it is possible that this callback is @@ -174,11 +176,11 @@ of_string_encoding_t _encoding; size_t _depthLimit; } #ifdef OF_HAVE_PROPERTIES -@property (assign) id delegate; +@property (assign, nullable) id delegate; @property size_t depthLimit; #endif /*! * @brief Creates a new XML parser. @@ -185,23 +187,23 @@ * * @return A new, autoreleased OFXMLParser */ + (instancetype)parser; -/*! - * @brief Returns the delegate that is used by the XML parser. - * - * @return The delegate that is used by the XML parser - */ -- (id )delegate; - /*! * @brief Sets the delegate the XML parser should use. * * @param delegate The delegate to use */ -- (void)setDelegate: (id )delegate; +- (void)setDelegate: (nullable id )delegate; + +/*! + * @brief Returns the delegate that is used by the XML parser. + * + * @return The delegate that is used by the XML parser + */ +- (nullable id )delegate; /*! * @brief Returns the depth limit for the XML parser. * * @return The depth limit for the XML parser @@ -266,5 +268,7 @@ - (bool)finishedParsing; @end @interface OFObject (OFXMLParserDelegate) @end + +OF_ASSUME_NONNULL_END Index: src/OFXMLProcessingInstructions.h ================================================================== --- src/OFXMLProcessingInstructions.h +++ src/OFXMLProcessingInstructions.h @@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + /*! * @class OFXMLProcessingInstructions \ * OFXMLProcessingInstructions.h ObjFW/OFXMLProcessingInstructions.h * * @brief A class for representing XML processing instructions. @@ -42,5 +44,7 @@ * @param string The string for the processing instructions * @return An initialized OFXMLProcessingInstructions */ - initWithString: (OFString*)string; @end + +OF_ASSUME_NONNULL_END Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "OFString.h" #import "OFZIPArchiveEntry.h" +OF_ASSUME_NONNULL_BEGIN + #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); #endif @@ -112,5 +114,7 @@ * @param path The path to the file inside the archive * @return A stream for reading the specified file form the archive */ - (OFStream*)streamForReadingFile: (OFString*)path; @end + +OF_ASSUME_NONNULL_END Index: src/OFZIPArchiveEntry+Private.h ================================================================== --- src/OFZIPArchiveEntry+Private.h +++ src/OFZIPArchiveEntry+Private.h @@ -13,13 +13,17 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFZIPArchive.h" + +OF_ASSUME_NONNULL_BEGIN @interface OFZIPArchiveEntry (OF_PRIVATE_CATEGORY) - (instancetype)OF_initWithStream: (OFStream*)stream; - (uint16_t)OF_generalPurposeBitFlag; - (uint16_t)OF_lastModifiedFileTime; - (uint16_t)OF_lastModifiedFileDate; - (uint64_t)OF_localFileHeaderOffset; @end + +OF_ASSUME_NONNULL_END Index: src/OFZIPArchiveEntry.h ================================================================== --- src/OFZIPArchiveEntry.h +++ src/OFZIPArchiveEntry.h @@ -14,10 +14,12 @@ * file. */ #import "OFObject.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ enum { OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE = 0, OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE = 8, @@ -231,9 +233,11 @@ * @param data A pointer to a pointer that should be set to the start of the * extra field with the specified tag * @param size A pointer to an uint16_t that should be set to the size */ extern void of_zip_archive_entry_extra_field_find(OFDataArray *extraField, - uint16_t tag, uint8_t **data, uint16_t *size); + uint16_t tag, __nonnull uint8_t **__nonnull data, __nonnull uint16_t *size); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -26,12 +26,14 @@ #ifdef OF_HAVE_OSATOMIC # include #endif +OF_ASSUME_NONNULL_BEGIN + static OF_INLINE int -of_atomic_int_add(volatile int *p, int i) +of_atomic_int_add(volatile __nonnull int *p, int i) { #if !defined(OF_HAVE_THREADS) return (*p += i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, i); @@ -76,11 +78,11 @@ # error of_atomic_int_add not implemented! #endif } static OF_INLINE int32_t -of_atomic_int32_add(volatile int32_t *p, int32_t i) +of_atomic_int32_add(volatile __nonnull int32_t *p, int32_t i) { #if !defined(OF_HAVE_THREADS) return (*p += i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, i); @@ -112,11 +114,11 @@ # error of_atomic_int32_add not implemented! #endif } static OF_INLINE void* -of_atomic_ptr_add(void* volatile *p, intptr_t i) +of_atomic_ptr_add(__nullable void *volatile *__nonnull p, intptr_t i) { #if !defined(OF_HAVE_THREADS) return (*(char* volatile*)p += i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, (void*)i); @@ -162,11 +164,11 @@ # error of_atomic_ptr_add not implemented! #endif } static OF_INLINE int -of_atomic_int_sub(volatile int *p, int i) +of_atomic_int_sub(volatile __nonnull int *p, int i) { #if !defined(OF_HAVE_THREADS) return (*p -= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, i); @@ -213,11 +215,11 @@ # error of_atomic_int_sub not implemented! #endif } static OF_INLINE int32_t -of_atomic_int32_sub(volatile int32_t *p, int32_t i) +of_atomic_int32_sub(volatile __nonnull int32_t *p, int32_t i) { #if !defined(OF_HAVE_THREADS) return (*p -= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, i); @@ -250,11 +252,11 @@ # error of_atomic_int32_sub not implemented! #endif } static OF_INLINE void* -of_atomic_ptr_sub(void* volatile *p, intptr_t i) +of_atomic_ptr_sub(__nullable void *volatile *__nonnull p, intptr_t i) { #if !defined(OF_HAVE_THREADS) return (*(char* volatile*)p -= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, (void*)i); @@ -302,11 +304,11 @@ # error of_atomic_ptr_sub not implemented! #endif } static OF_INLINE int -of_atomic_int_inc(volatile int *p) +of_atomic_int_inc(volatile __nonnull int *p) { #if !defined(OF_HAVE_THREADS) return ++*p; #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, 1); @@ -359,11 +361,11 @@ # error of_atomic_int_inc not implemented! #endif } static OF_INLINE int32_t -of_atomic_int32_inc(volatile int32_t *p) +of_atomic_int32_inc(volatile __nonnull int32_t *p) { #if !defined(OF_HAVE_THREADS) return ++*p; #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, 1); @@ -401,11 +403,11 @@ # error of_atomic_int32_inc not implemented! #endif } static OF_INLINE int -of_atomic_int_dec(volatile int *p) +of_atomic_int_dec(volatile __nonnull int *p) { #if !defined(OF_HAVE_THREADS) return --*p; #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, 1); @@ -458,11 +460,11 @@ # error of_atomic_int_dec not implemented! #endif } static OF_INLINE int32_t -of_atomic_int32_dec(volatile int32_t *p) +of_atomic_int32_dec(volatile __nonnull int32_t *p) { #if !defined(OF_HAVE_THREADS) return --*p; #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, 1); @@ -500,11 +502,11 @@ # error of_atomic_int32_dec not implemented! #endif } static OF_INLINE unsigned int -of_atomic_int_or(volatile unsigned int *p, unsigned int i) +of_atomic_int_or(volatile __nonnull unsigned int *p, unsigned int i) { #if !defined(OF_HAVE_THREADS) return (*p |= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_or_and_fetch(p, i); @@ -559,11 +561,11 @@ # error of_atomic_int_or not implemented! #endif } static OF_INLINE uint32_t -of_atomic_int32_or(volatile uint32_t *p, uint32_t i) +of_atomic_int32_or(volatile __nonnull uint32_t *p, uint32_t i) { #if !defined(OF_HAVE_THREADS) return (*p |= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_or_and_fetch(p, i); @@ -600,11 +602,11 @@ # error of_atomic_int32_or not implemented! #endif } static OF_INLINE unsigned int -of_atomic_int_and(volatile unsigned int *p, unsigned int i) +of_atomic_int_and(volatile __nonnull unsigned int *p, unsigned int i) { #if !defined(OF_HAVE_THREADS) return (*p &= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_and_and_fetch(p, i); @@ -659,11 +661,11 @@ # error of_atomic_int_and not implemented! #endif } static OF_INLINE uint32_t -of_atomic_int32_and(volatile uint32_t *p, uint32_t i) +of_atomic_int32_and(volatile __nonnull uint32_t *p, uint32_t i) { #if !defined(OF_HAVE_THREADS) return (*p &= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_and_and_fetch(p, i); @@ -700,11 +702,11 @@ # error of_atomic_int32_and not implemented! #endif } static OF_INLINE unsigned int -of_atomic_int_xor(volatile unsigned int *p, unsigned int i) +of_atomic_int_xor(volatile __nonnull unsigned int *p, unsigned int i) { #if !defined(OF_HAVE_THREADS) return (*p ^= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_xor_and_fetch(p, i); @@ -759,11 +761,11 @@ # error of_atomic_int_xor not implemented! #endif } static OF_INLINE uint32_t -of_atomic_int32_xor(volatile uint32_t *p, uint32_t i) +of_atomic_int32_xor(volatile __nonnull uint32_t *p, uint32_t i) { #if !defined(OF_HAVE_THREADS) return (*p ^= i); #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_xor_and_fetch(p, i); @@ -800,11 +802,11 @@ # error of_atomic_int32_xor not implemented! #endif } static OF_INLINE bool -of_atomic_int_cmpswap(volatile int *p, int o, int n) +of_atomic_int_cmpswap(volatile __nonnull int *p, int o, int n) { #if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return true; @@ -855,11 +857,11 @@ # error of_atomic_int_cmpswap not implemented! #endif } static OF_INLINE bool -of_atomic_int32_cmpswap(volatile int32_t *p, int32_t o, int32_t n) +of_atomic_int32_cmpswap(volatile __nonnull int32_t *p, int32_t o, int32_t n) { #if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return true; @@ -910,11 +912,12 @@ # error of_atomic_int32_cmpswap not implemented! #endif } static OF_INLINE bool -of_atomic_ptr_cmpswap(void* volatile *p, void *o, void *n) +of_atomic_ptr_cmpswap(__nullable void *volatile *__nonnull p, + __nullable void *o, __nullable void *n) { #if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return true; @@ -1010,5 +1013,7 @@ ); #else of_memory_barrier(); #endif } + +OF_ASSUME_NONNULL_END Index: src/autorelease.h ================================================================== --- src/autorelease.h +++ src/autorelease.h @@ -12,10 +12,14 @@ * 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 "macros.h" + +OF_ASSUME_NONNULL_BEGIN + /*! @file */ #ifdef __cplusplus extern "C" { #endif @@ -41,5 +45,7 @@ */ extern id _objc_rootAutorelease(id object); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/base64.h ================================================================== --- src/base64.h +++ src/base64.h @@ -21,15 +21,13 @@ #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif -#ifdef OF_OBJFW_RUNTIME -# import "runtime.h" -#else -# import -#endif +#import "macros.h" + +OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFDataArray; #ifdef __cplusplus @@ -39,5 +37,7 @@ extern OFString *of_base64_encode(const void*, size_t); extern bool of_base64_decode(OFDataArray*, const char*, size_t); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/block.h ================================================================== --- src/block.h +++ src/block.h @@ -12,10 +12,14 @@ * 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 "macros.h" + +OF_ASSUME_NONNULL_BEGIN + typedef struct of_block_literal_t { #ifdef __OBJC__ Class isa; #else void *isa; @@ -46,5 +50,7 @@ ((__typeof__(__VA_ARGS__))_Block_copy((const void*)(__VA_ARGS__))) #endif #ifndef Block_release # define Block_release(...) _Block_release((const void*)(__VA_ARGS__)) #endif + +OF_ASSUME_NONNULL_END Index: src/instance.h ================================================================== --- src/instance.h +++ src/instance.h @@ -12,13 +12,19 @@ * 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 "macros.h" + +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif -extern id objc_constructInstance(Class, void*); +extern id objc_constructInstance(__nullable Class, __nullable void*); extern void* objc_destructInstance(id); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -171,10 +171,22 @@ # define OF_HAVE_GENERICS # define OF_GENERIC(...) <__VA_ARGS__> #else # define OF_GENERIC(...) #endif + +#if __has_feature(nullability) +# define OF_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +# define OF_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +# define OF_ASSUME_NONNULL_BEGIN +# define OF_ASSUME_NONNULL_END +# define __nonnull +# define __nullable +# define nonnull +# define nullable +#endif #if __has_feature(objc_kindof) # define OF_KINDOF(cls) __kindof cls #else # define OF_KINDOF(cls) id Index: src/of_asprintf.h ================================================================== --- src/of_asprintf.h +++ src/of_asprintf.h @@ -21,13 +21,20 @@ # define __STDC_CONSTANT_MACROS #endif #include +#import "macros.h" + +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif -extern int of_asprintf(char**, const char*, ...); -extern int of_vasprintf(char**, const char*, va_list); +extern int of_asprintf(__nullable char **__nonnull, const __nonnull char*, ...); +extern int of_vasprintf(__nullable char **__nonnull, const __nonnull char*, + va_list); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/of_strptime.h ================================================================== --- src/of_strptime.h +++ src/of_strptime.h @@ -21,12 +21,18 @@ # define __STDC_CONSTANT_MACROS #endif #include +#import "macros.h" + +OF_ASSUME_NONNULL_BEGIN + #ifdef __cplusplus extern "C" { #endif extern const char* of_strptime(const char*, const char*, struct tm *tm); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/resolver.h ================================================================== --- src/resolver.h +++ src/resolver.h @@ -16,10 +16,12 @@ #import "OFString.h" #import "socket.h" +OF_ASSUME_NONNULL_BEGIN + /*! @file */ /*! * @struct of_resolver_result_t resolver.h ObjFW/resolver.h * @@ -45,12 +47,12 @@ * address struct * * @return An array of results. The list is terminated by NULL and should be * free'd after use. */ -extern of_resolver_result_t** of_resolve_host(OFString *host, uint16_t port, - int protocol); +extern __nullable of_resolver_result_t **__nonnull + of_resolve_host(OFString *host, uint16_t port, int protocol); /*! * @brief Converts the specified address to a string and port pair. * * @param address The address to convert to a string @@ -59,16 +61,21 @@ * address or NULL if the host is not needed * @param port A pointer to an uint16_t which should be set to the port of the * address or NULL if the port is not needed */ extern void of_address_to_string_and_port(struct sockaddr *address, - socklen_t addressLength, OFString *__autoreleasing *host, uint16_t *port); + socklen_t addressLength, + __nonnull OFString *__autoreleasing *__nullable host, + __nullable uint16_t *port); /*! * @brief Frees the results returned by @ref of_resolve_host. * * @param results The results returned by @ref of_resolve_host */ -extern void of_resolver_free(of_resolver_result_t **results); +extern void of_resolver_free( + __nullable of_resolver_result_t **__nonnull results); #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -65,10 +65,14 @@ struct in_addr ss_data2; int8_t ss_data3[8]; }; #endif +#import "macros.h" + +OF_ASSUME_NONNULL_BEGIN + #ifndef _WIN32 typedef int of_socket_t; #else typedef SOCKET of_socket_t; #endif @@ -83,5 +87,7 @@ socklen_t *restrict address_len); # endif #ifdef __cplusplus } #endif + +OF_ASSUME_NONNULL_END Index: tests/OFDataArrayTests.m ================================================================== --- tests/OFDataArrayTests.m +++ tests/OFDataArrayTests.m @@ -133,11 +133,11 @@ EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]", OFOutOfRangeException, [array[0] itemAtIndex: [array[0] count]]) EXPECT_EXCEPTION(@"Detect out of range in -[addItems:count:]", - OFOutOfRangeException, [array[0] addItems: NULL + OFOutOfRangeException, [array[0] addItems: data[0] count: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]", OFOutOfRangeException, [array[0] removeItemsInRange: of_range([array[0] count], 1)])