Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -156,32 +156,32 @@ /*! * @brief Returns the only OFApplication instance in the application. * * @return The only OFApplication instance in the application */ -+ (OFApplication *)sharedApplication; ++ (nullable OFApplication *)sharedApplication; /*! * @brief Returns the name of the program (argv[0]). * * @return The name of the program (argv[0]) */ -+ (OFString *)programName; ++ (nullable OFString *)programName; /*! * @brief Returns the arguments passed to the application. * * @return The arguments passed to the application */ -+ (OFArray OF_GENERIC(OFString *) *)arguments; ++ (nullable OFArray OF_GENERIC(OFString *) *)arguments; /*! * @brief Returns the environment of the application. * * @return The environment of the application */ -+ (OFDictionary OF_GENERIC(OFString *, OFString *) *)environment; ++ (nullable OFDictionary OF_GENERIC(OFString *, OFString *) *)environment; /*! * @brief Terminates the application with the EXIT_SUCCESS status. */ + (void)terminate OF_NO_RETURN; Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -491,11 +491,11 @@ unsigned long *_Nullable _mutationsPtr; size_t _position; } - initWithArray: (OFArray *)data - mutationsPtr: (unsigned long *_Nullable)mutationsPtr; + mutationsPtr: (nullable unsigned long *)mutationsPtr; @end OF_ASSUME_NONNULL_END #import "OFMutableArray.h" Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -113,11 +113,11 @@ { #if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) /* * objc_setFutureClass suddenly stopped working as OFConstantString * became more complex. So the only solution is to make - * _OFConstantStringClassRerence the actual class, but there is no + * _OFConstantStringClassReference the actual class, but there is no * objc_initializeClassPair in 10.5. However, objc_allocateClassPair * does not register the new class with the subclass in the ObjC1 * runtime like the ObjC2 runtime does, so this workaround should be * fine. */ Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -229,21 +229,21 @@ * 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: (nullable ObjectType)object; +- (bool)containsObject: (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: (nullable ObjectType)object; +- (bool)containsObjectIdenticalTo: (ObjectType)object; /*! * @brief Returns an array of all keys. * * @return An array of all keys Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -385,12 +385,15 @@ - (instancetype)of_initWithIvar: (Ivar)ivar { self = [super init]; @try { - _name = [[OFString alloc] - initWithUTF8String: ivar_getName(ivar)]; + const char *name = ivar_getName(ivar); + + if (name != NULL) + _name = [[OFString alloc] initWithUTF8String: name]; + _typeEncoding = ivar_getTypeEncoding(ivar); _offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -133,20 +133,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: (nullable ObjectType)object; +- (bool)containsObject: (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: (nullable ObjectType)object; +- (bool)containsObjectIdenticalTo: (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 Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -195,11 +195,11 @@ /*! * @brief Returns the superclass of the object. * * @return The superclass of the object */ -- (Class)superclass; +- (nullable Class)superclass; /*! * @brief Returns a boolean whether the object of the specified kind. * * @param class_ The class whose kind is checked @@ -459,11 +459,11 @@ /*! * @brief Returns the superclass of the class. * * @return The superclass of the class */ -+ (Class)superclass; ++ (nullable Class)superclass; /*! * @brief Checks whether instances of the class respond to a given selector. * * @param selector The selector which should be checked for respondence @@ -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. */ -- (void *)allocMemoryWithSize: (size_t)size; +- (nullable 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. */ -- (void *)allocMemoryWithSize: (size_t)size - count: (size_t)count; +- (nullable 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 @@ -470,11 +470,11 @@ } @finally { free(methodList); } #endif - [self inheritMethodsFromClass: [class superclass]]; + [self inheritMethodsFromClass: superclass]; } + (BOOL)resolveClassMethod: (SEL)selector { return NO; @@ -828,11 +828,11 @@ { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) - return (void *_Nonnull)NULL; + return 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 @@ -204,20 +204,20 @@ /*! * @brief Returns an arbitrary object in the set. * * @return An arbitrary object in the set */ -- (ObjectType)anyObject; +- (nullable ObjectType)anyObject; /*! * @brief Checks whether the set contains an object equal to the specified * 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: (nullable ObjectType)object; +- (bool)containsObject: (ObjectType)object; /*! * @brief Returns the value for the specified key * * If the key starts with an `@`, the `@` is stripped and Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -157,11 +157,11 @@ * @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 _Nonnull *_Nullable)host - andPort: (uint16_t *_Nullable)port + andPort: (nullable uint16_t *)port forAddress: (of_udp_socket_address_t *)address; /*! * @brief Binds the socket to the specified host and port. * Index: src/bridge/OFString+NSObject.m ================================================================== --- src/bridge/OFString+NSObject.m +++ src/bridge/OFString+NSObject.m @@ -16,11 +16,19 @@ #import #import "OFString+NSObject.h" +#import "OFInitializationFailedException.h" + @implementation OFString (NSObject) - (id)NSObject { - return [NSString stringWithUTF8String: [self UTF8String]]; + NSString *string = [NSString stringWithUTF8String: [self UTF8String]]; + + if (string == nil) + @throw [OFInitializationFailedException + exceptionWithClass: [NSString class]]; + + return string; } @end Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -602,29 +602,29 @@ OF_HASH_ADD(hash, (otherCopy >> 8) & 0xFF); \ OF_HASH_ADD(hash, otherCopy & 0xFF); \ } static OF_INLINE bool -of_bitset_isset(uint8_t *storage, size_t index) +of_bitset_isset(uint8_t *_Nonnull storage, size_t index) { return storage[index / 8] & (1 << (index % 8)); } static OF_INLINE void -of_bitset_set(uint8_t *storage, size_t index) +of_bitset_set(uint8_t *_Nonnull storage, size_t index) { storage[index / 8] |= (1 << (index % 8)); } static OF_INLINE void -of_bitset_clear(uint8_t *storage, size_t index) +of_bitset_clear(uint8_t *_Nonnull storage, size_t index) { storage[index / 8] &= ~(1 << (index % 8)); } -static OF_INLINE char * -of_strdup(const char *string) +static OF_INLINE char *_Nullable +of_strdup(const char *_Nonnull string) { char *copy; size_t length = strlen(string); if ((copy = (char *)malloc(length + 1)) == NULL) @@ -634,11 +634,11 @@ return copy; } static OF_INLINE void -of_explicit_memset(void *buffer_, int character, size_t length) +of_explicit_memset(void *_Nonnull buffer_, int character, size_t length) { volatile unsigned char *buffer = (volatile unsigned char *)buffer_; while (buffer < (unsigned char *)buffer_ + length) *buffer++ = character; Index: src/runtime/ObjFW-RT.h ================================================================== --- src/runtime/ObjFW-RT.h +++ src/runtime/ObjFW-RT.h @@ -47,12 +47,12 @@ #if !__has_feature(objc_arc) && !defined(__unsafe_unretained) # define __unsafe_unretained #endif -#define Nil (Class)0 -#define nil (id)0 +#define Nil (Class _Null_unspecified)0 +#define nil (id _Null_unspecified)0 #define YES (BOOL)1 #define NO (BOOL)0 typedef struct objc_class *Class; typedef struct objc_object *id; @@ -69,12 +69,12 @@ unsigned long version; unsigned long info; long instance_size; struct objc_ivar_list *_Nullable ivars; struct objc_method_list *_Nullable methodlist; - struct objc_dtable *_Nullable dtable; - Class _Nonnull *_Nullable subclass_list; + struct objc_dtable *_Nonnull dtable; + Class _Nullable *_Nullable subclass_list; void *_Nullable sibling_class; struct objc_protocol_list *_Nullable protocols; void *_Nullable gc_object_type; unsigned long abi_version; int32_t *_Nonnull *_Nullable ivar_offsets; @@ -226,11 +226,11 @@ const char *_Nullable); extern IMP _Nullable class_replaceMethod(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, const char *_Nullable); extern Class _Nullable object_getClass(id _Nullable); extern Class _Nullable object_setClass(id _Nullable, Class _Nonnull); -extern const char *_Nonnull object_getClassName(id _Nullable); +extern const char *_Nullable object_getClassName(id _Nullable); extern const char *_Nonnull protocol_getName(Protocol *_Nonnull); extern bool protocol_isEqual(Protocol *_Nonnull, Protocol *_Nonnull); extern bool protocol_conformsToProtocol(Protocol *_Nonnull, Protocol *_Nonnull); extern void objc_exit(void); extern _Nullable objc_uncaught_exception_handler