Overview
Comment: | Nullability fixes for ObjFW runtime |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5882409fd0bd09e1536199603aad8acb |
User & Date: | js on 2017-10-01 09:54:52 |
Other Links: | manifest | tags |
Context
2017-10-01
| ||
13:43 | More nullability and style fixes check-in: 66c29a31f2 user: js tags: trunk | |
09:54 | Nullability fixes for ObjFW runtime check-in: 5882409fd0 user: js tags: trunk | |
09:28 | Nullability fixes for macOS High Sierra check-in: 166fd50e82 user: js tags: trunk | |
Changes
Modified src/OFIntrospection.m from [494b50aa22] to [b331601cc7].
︙ | ︙ | |||
146 147 148 149 150 151 152 | @try { _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = property->attributes | (property->extended_attributes << 8); if (property->getter.name != NULL) | | | | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | @try { _name = [[OFString alloc] initWithUTF8String: property->name]; _attributes = property->attributes | (property->extended_attributes << 8); if (property->getter.name != NULL) _getter = [[OFString alloc] initWithUTF8String: (const char *)property->getter.name]; if (property->setter.name != NULL) _setter = [[OFString alloc] initWithUTF8String: (const char *)property->setter.name]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
387 388 389 390 391 392 393 | self = [super init]; @try { const char *name = ivar_getName(ivar); if (name != NULL) _name = [[OFString alloc] initWithUTF8String: | | | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | self = [super init]; @try { const char *name = ivar_getName(ivar); if (name != NULL) _name = [[OFString alloc] initWithUTF8String: (const char *)ivar_getName(ivar)]; _typeEncoding = ivar_getTypeEncoding(ivar); _offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ |
Modified src/OFObject.m from [d1b883cd1d] to [b2d94e1a72].
︙ | ︙ | |||
293 294 295 296 297 298 299 | + (Class)class { return self; } + (OFString *)className { | | > | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | + (Class)class { return self; } + (OFString *)className { 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)) if (iter == class) return true; |
︙ | ︙ | |||
355 356 357 358 359 360 361 | withMethodFromClass: (Class)class { IMP method = [class methodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; | | < | > | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | withMethodFromClass: (Class)class { IMP method = [class methodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; return class_replaceMethod((Class)object_getClass(self), selector, (IMP)method, typeEncodingForSelector(object_getClass(class), selector)); } + (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class { IMP method = [class instanceMethodForSelector: selector]; if (method == NULL) @throw [OFInvalidArgumentException exception]; return class_replaceMethod(self, selector, (IMP)method, typeEncodingForSelector(class, selector)); } + (void)inheritMethodsFromClass: (Class)class { Class superclass = [self superclass]; |
︙ | ︙ | |||
481 482 483 484 485 486 487 | - init { return self; } - (Class)class { | | | > | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | - init { return self; } - (Class)class { return (Class)object_getClass(self); } - (Class)superclass { return class_getSuperclass(object_getClass(self)); } - (OFString *)className { 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; iter = class_getSuperclass(iter)) if (iter == class) |
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 | - (void *)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) | | | 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 | - (void *)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) return NULL; if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) @throw [OFOutOfRangeException exception]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: size]; |
︙ | ︙ |
Modified src/instance.m from [f080731090] to [ba0e2c91f2].
︙ | ︙ | |||
53 54 55 56 57 58 59 | objc_constructInstance(Class cls, void *bytes) { id obj = (id)bytes; if (cls == Nil || bytes == NULL) return nil; | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | objc_constructInstance(Class cls, void *bytes) { id obj = (id)bytes; if (cls == Nil || bytes == NULL) return nil; object_setClass(obj, (Class)cls); if (!callConstructors(cls, obj)) return nil; return obj; } |
︙ | ︙ |
Modified src/runtime/ObjFW-RT.h from [8577ac8d70] to [576d1fa9d6].
︙ | ︙ | |||
45 46 47 48 49 50 51 | # endif #endif #if !__has_feature(objc_arc) && !defined(__unsafe_unretained) # define __unsafe_unretained #endif | | | | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | # endif #endif #if !__has_feature(objc_arc) && !defined(__unsafe_unretained) # define __unsafe_unretained #endif #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; typedef const struct objc_selector *SEL; typedef signed char BOOL; typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...); typedef void (*objc_uncaught_exception_handler)(id _Nullable); typedef void (*objc_enumeration_mutation_handler)(id _Nonnull); struct objc_class { Class _Nonnull isa; Class _Nullable superclass; const char *_Nonnull name; unsigned long version; unsigned long info; long instance_size; struct objc_ivar_list *_Nullable ivars; struct objc_method_list *_Nullable methodlist; 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; struct objc_property_list *_Nullable properties; }; |
︙ | ︙ | |||
225 226 227 228 229 230 231 | SEL _Nonnull); extern bool class_addMethod(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, 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); | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | SEL _Nonnull); extern bool class_addMethod(Class _Nonnull, SEL _Nonnull, IMP _Nonnull, 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 *_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 objc_setUncaughtExceptionHandler( objc_uncaught_exception_handler _Nullable); |
︙ | ︙ |
Modified src/runtime/class.m from [d9200138d3] to [671f7fc3c1].
︙ | ︙ | |||
865 866 867 868 869 870 871 | rcls->info &= ~OBJC_CLASS_INFO_SETUP; } void objc_unregister_class(Class cls) { while (cls->subclass_list != NULL && cls->subclass_list[0] != Nil) | | | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | rcls->info &= ~OBJC_CLASS_INFO_SETUP; } void objc_unregister_class(Class cls) { while (cls->subclass_list != NULL && cls->subclass_list[0] != Nil) 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); if (strcmp(class_getName(cls), "Protocol") != 0) |
︙ | ︙ |
Modified src/runtime/protocol.m from [74d4f4e6fc] to [4d79da63d1].
︙ | ︙ | |||
63 64 65 66 67 68 69 | pl != NULL; pl = pl->next) for (long i = 0; i < pl->count; i++) if (protocol_conformsToProtocol(pl->list[i], p)) return true; objc_global_mutex_lock(); | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | pl != NULL; pl = pl->next) for (long i = 0; i < pl->count; i++) if (protocol_conformsToProtocol(pl->list[i], p)) return true; objc_global_mutex_lock(); if ((cats = objc_categories_for_class((Class)cls)) == NULL) { objc_global_mutex_unlock(); return false; } for (long i = 0; cats[i] != NULL; i++) { for (struct objc_protocol_list *pl = cats[i]->protocols; pl != NULL; pl = pl->next) { |
︙ | ︙ |
Modified src/runtime/selector.m from [1deeb73a3c] to [b4ebf0ad92].
︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | } SEL sel_registerName(const char *name) { const struct objc_abi_selector *rsel; struct objc_abi_selector *sel; objc_global_mutex_lock(); if (selectors != NULL && (rsel = objc_hashtable_get(selectors, name)) != NULL) { objc_global_mutex_unlock(); return (SEL)rsel; } if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); | > | > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | } 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) { objc_global_mutex_unlock(); return (SEL)rsel; } if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); 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!"); free_list[free_list_cnt++] = sel; |
︙ | ︙ |
Modified tests/ForwardingTests.m from [64bebc8dde] to [89ccb0a706].
︙ | ︙ | |||
69 70 71 72 73 74 75 | @implementation ForwardingTest + (BOOL)resolveClassMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | @implementation ForwardingTest + (BOOL)resolveClassMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { class_replaceMethod((Class)object_getClass(self), @selector(test), (IMP)test, "v#:"); return YES; } return NO; } + (BOOL)resolveInstanceMethod: (SEL)selector |
︙ | ︙ |