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