@@ -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