Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -218,11 +218,11 @@ * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value +- (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Copies the objects at the specified range to the specified buffer. * Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -317,13 +317,10 @@ objc_autoreleasePoolPop(pool); return; } - if (value == [OFNull null]) - value = nil; - for (id object in self) [object setValue: value forKey: key]; } @@ -450,21 +447,32 @@ if (separator == nil) @throw [OFInvalidArgumentException exception]; if ([self count] == 0) return @""; - if ([self count] == 1) - return [[self firstObject] performSelector: selector]; + + if ([self count] == 1) { + OFString *component = + [[self firstObject] performSelector: selector]; + + if (component == nil) + @throw [OFInvalidArgumentException exception]; + + return component; + } ret = [OFMutableString string]; if (options & OF_ARRAY_SKIP_EMPTY) { for (id object in self) { void *pool = objc_autoreleasePoolPush(); OFString *component = [object performSelector: selector]; + if (component == nil) + @throw [OFInvalidArgumentException exception]; + if ([component length] > 0) { if ([ret length] > 0) [ret appendString: separator]; [ret appendString: component]; } @@ -474,17 +482,22 @@ } else { bool first = true; for (id object in self) { void *pool = objc_autoreleasePoolPush(); + OFString *component = + [object performSelector: selector]; + + if (component == nil) + @throw [OFInvalidArgumentException exception]; if OF_UNLIKELY (first) first = false; else [ret appendString: separator]; - [ret appendString: [object performSelector: selector]]; + [ret appendString: component]; objc_autoreleasePoolPop(pool); } } Index: src/OFData.h ================================================================== --- src/OFData.h +++ src/OFData.h @@ -32,11 +32,11 @@ * for OFData with item size 1. */ @interface OFData: OFObject { - unsigned char *_Nullable _items; + unsigned char *_items; size_t _count, _itemSize; bool _freeWhenDone; } /*! Index: src/OFDate.h ================================================================== --- src/OFDate.h +++ src/OFDate.h @@ -305,21 +305,21 @@ * If the argument is `nil`, it returns the receiver. * * @param otherDate Another date * @return The earlier date of the two dates */ -- (OFDate *)earlierDate: (OFDate *)otherDate; +- (OFDate *)earlierDate: (nullable OFDate *)otherDate; /*! * @brief Returns the later of the two dates. * * If the argument is `nil`, it returns the receiver. * * @param otherDate Another date * @return The later date of the two dates */ -- (OFDate *)laterDate: (OFDate *)otherDate; +- (OFDate *)laterDate: (nullable OFDate *)otherDate; /*! * @brief Returns the seconds since 1970-01-01T00:00:00Z. * * @return The seconds since 1970-01-01T00:00:00Z Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -219,11 +219,11 @@ * @ref OFUndefinedKeyException is thrown. * * @param key The key to set * @param value The value to set the key to */ -- (void)setValue: (nullable id)value +- (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Checks whether the dictionary contains an object equal to the * specified object. Index: src/OFKeyValueCoding.h ================================================================== --- src/OFKeyValueCoding.h +++ src/OFKeyValueCoding.h @@ -52,11 +52,11 @@ * @brief Set the value for the specified key * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value +- (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief This is called by @ref setValue:forKey: if the specified key does not * exist. Index: src/OFMapTable.h ================================================================== --- src/OFMapTable.h +++ src/OFMapTable.h @@ -25,18 +25,19 @@ * @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 / objects - void *_Nonnull (*_Nullable retain)(void *object); - /// The function to release keys / objects - void (*_Nullable release)(void *object); - /// The function to hash keys - uint32_t (*_Nullable hash)(void *object); - /// The function to compare keys / objects - bool (*_Nullable equal)(void *object1, void *object2); + /*! The function to retain keys / objects */ + void *_Nullable (*_Nullable retain)(void *_Nullable object); + /*! The function to release keys / objects */ + void (*_Nullable release)(void *_Nullable object); + /*! The function to hash keys */ + uint32_t (*_Nullable hash)(void *_Nullable object); + /*! The function to compare keys / objects */ + bool (*_Nullable equal)(void *_Nullable object1, + void *_Nullable object2); } of_map_table_functions_t; #ifdef OF_HAVE_BLOCKS /*! * @brief A block for enumerating an OFMapTable. Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -649,11 +649,11 @@ * * @param size The size of the memory to allocate * @return A pointer to the allocated memory. May return NULL if the specified * size is 0. */ -- (nullable void *)allocMemoryWithSize: (size_t)size; +- (void *)allocMemoryWithSize: (size_t)size; /*! * @brief Allocates memory for the specified number of items and stores it in * the object's memory pool. * @@ -662,12 +662,12 @@ * @param size The size of each item to allocate * @param count The number of items to allocate * @return A pointer to the allocated memory. May return NULL if the specified * size or count is 0. */ -- (nullable void *)allocMemoryWithSize: (size_t)size - count: (size_t)count; +- (void *)allocMemoryWithSize: (size_t)size + count: (size_t)count; /*! * @brief Resizes memory in the object's memory pool to the specified size. * * If the pointer is NULL, this is equivalent to allocating memory. Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -828,11 +828,11 @@ { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) - return NULL; + return (void *_Nonnull)NULL; if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) @throw [OFOutOfRangeException exception]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) Index: src/OFSet.h ================================================================== --- src/OFSet.h +++ src/OFSet.h @@ -243,11 +243,11 @@ * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ -- (void)setValue: (nullable id)value +- (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Returns an OFEnumerator to enumerate through all objects of the set. * Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -253,13 +253,10 @@ objc_autoreleasePoolPop(pool); return; } - if (value == [OFNull null]) - value = nil; - for (id object in self) [object setValue: value forKey: key]; } Index: src/exceptions/OFMemoryNotPartOfObjectException.h ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.h +++ src/exceptions/OFMemoryNotPartOfObjectException.h @@ -25,18 +25,18 @@ * * @brief An exception indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { - void *_pointer; + void *_Nullable _pointer; id _object; } /*! * A pointer to the memory which is not part of the object. */ -@property (readonly, nonatomic) void *pointer; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *pointer; /*! * The object which the memory is not part of. */ @property (readonly, nonatomic) id object; @@ -48,11 +48,11 @@ * * @param pointer A pointer to the memory that is not part of the object * @param object The object which the memory is not part of * @return A new, autoreleased memory not part of object exception */ -+ (instancetype)exceptionWithPointer: (void *)pointer ++ (instancetype)exceptionWithPointer: (nullable void *)pointer object: (id)object; - init OF_UNAVAILABLE; /*! @@ -60,10 +60,10 @@ * * @param pointer A pointer to the memory that is not part of the object * @param object The object which the memory is not part of * @return An initialized memory not part of object exception */ -- initWithPointer: (void *)pointer +- initWithPointer: (nullable void *)pointer object: (id)object OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -253,11 +253,11 @@ [m unsignedLongLongValue] == 100 && [m floatValue] == 110 && [m doubleValue] == 120) EXPECT_EXCEPTION(@"Catch -[setValue:forKey:] with nil key for scalar", - OFInvalidArgumentException, [m setValue: nil + OFInvalidArgumentException, [m setValue: (id _Nonnull)nil forKey: @"intValue"]) [pool drain]; } @end