Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -148,15 +148,15 @@ _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = property->attributes | (property->extended_attributes << 8); if (property->getter.name != NULL) - _getter = [[OFString alloc] - initWithUTF8String: property->getter.name]; + _getter = [[OFString alloc] initWithUTF8String: + (const char *)property->getter.name]; if (property->setter.name != NULL) - _setter = [[OFString alloc] - initWithUTF8String: property->setter.name]; + _setter = [[OFString alloc] initWithUTF8String: + (const char *)property->setter.name]; } @catch (id e) { [self release]; @throw e; } @@ -389,11 +389,11 @@ @try { const char *name = ivar_getName(ivar); if (name != NULL) _name = [[OFString alloc] initWithUTF8String: - (const char *_Nonnull)ivar_getName(ivar)]; + (const char *)ivar_getName(ivar)]; _typeEncoding = ivar_getTypeEncoding(ivar); _offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -295,12 +295,13 @@ return self; } + (OFString *)className { - return [OFString stringWithCString: class_getName(self) - encoding: OF_STRING_ENCODING_ASCII]; + return [OFString + stringWithCString: (const char *)class_getName(self) + encoding: OF_STRING_ENCODING_ASCII]; } + (bool)isSubclassOfClass: (Class)class { for (Class iter = self; iter != Nil; iter = class_getSuperclass(iter)) @@ -357,13 +358,13 @@ IMP method = [class methodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; - return class_replaceMethod(object_getClass(self), selector, - (IMP _Nonnull)method, - typeEncodingForSelector(object_getClass(class), selector)); + return class_replaceMethod((Class)object_getClass(self), selector, + (IMP)method, typeEncodingForSelector(object_getClass(class), + selector)); } + (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class { @@ -370,11 +371,11 @@ IMP method = [class instanceMethodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; - return class_replaceMethod(self, selector, (IMP _Nonnull)method, + return class_replaceMethod(self, selector, (IMP)method, typeEncodingForSelector(class, selector)); } + (void)inheritMethodsFromClass: (Class)class { @@ -483,22 +484,23 @@ return self; } - (Class)class { - return (Class _Nonnull)object_getClass(self); + return (Class)object_getClass(self); } - (Class)superclass { return class_getSuperclass(object_getClass(self)); } - (OFString *)className { - return [OFString stringWithCString: object_getClassName(self) - encoding: OF_STRING_ENCODING_ASCII]; + return [OFString + stringWithCString: (const char *)object_getClassName(self) + encoding: OF_STRING_ENCODING_ASCII]; } - (bool)isKindOfClass: (Class)class { for (Class iter = object_getClass(self); iter != Nil; @@ -1026,11 +1028,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/instance.m ================================================================== --- src/instance.m +++ src/instance.m @@ -55,11 +55,11 @@ id obj = (id)bytes; if (cls == Nil || bytes == NULL) return nil; - object_setClass(obj, (Class _Nonnull)cls); + object_setClass(obj, (Class)cls); if (!callConstructors(cls, obj)) return nil; return obj; 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; @@ -227,11 +227,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 Index: src/runtime/class.m ================================================================== --- src/runtime/class.m +++ src/runtime/class.m @@ -867,11 +867,11 @@ void objc_unregister_class(Class cls) { while (cls->subclass_list != NULL && cls->subclass_list[0] != Nil) - objc_unregister_class(cls->subclass_list[0]); + objc_unregister_class((Class)cls->subclass_list[0]); if (cls->info & OBJC_CLASS_INFO_LOADED) call_method(cls, "unload"); objc_hashtable_delete(classes, cls->name); Index: src/runtime/protocol.m ================================================================== --- src/runtime/protocol.m +++ src/runtime/protocol.m @@ -65,11 +65,11 @@ if (protocol_conformsToProtocol(pl->list[i], p)) return true; objc_global_mutex_lock(); - if ((cats = objc_categories_for_class(cls)) == NULL) { + if ((cats = objc_categories_for_class((Class)cls)) == NULL) { objc_global_mutex_unlock(); return false; } for (long i = 0; cats[i] != NULL; i++) { Index: src/runtime/selector.m ================================================================== --- src/runtime/selector.m +++ src/runtime/selector.m @@ -70,10 +70,11 @@ SEL sel_registerName(const char *name) { const struct objc_abi_selector *rsel; struct objc_abi_selector *sel; + char *name_copy; objc_global_mutex_lock(); if (selectors != NULL && (rsel = objc_hashtable_get(selectors, name)) != NULL) { @@ -82,13 +83,14 @@ } if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); - if ((sel->name = of_strdup(name)) == NULL) + if ((name_copy = of_strdup(name)) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); + sel->name = name_copy; sel->types = NULL; if ((free_list = realloc(free_list, sizeof(void *) * (free_list_cnt + 2))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); Index: tests/ForwardingTests.m ================================================================== --- tests/ForwardingTests.m +++ tests/ForwardingTests.m @@ -71,12 +71,12 @@ + (BOOL)resolveClassMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { - class_replaceMethod(object_getClass(self), @selector(test), - (IMP)test, "v#:"); + class_replaceMethod((Class)object_getClass(self), + @selector(test), (IMP)test, "v#:"); return YES; } return NO; }