diff --git a/class_table.c b/class_table.c index d0eb7be..fa9a876 100644 --- a/class_table.c +++ b/class_table.c @@ -244,7 +244,10 @@ PRIVATE BOOL objc_resolve_class(Class cls) // Fix up the ivar offsets objc_compute_ivar_offsets(cls); // Send the +load message, if required - objc_send_load_message(cls); + if (!objc_test_class_flag(cls, objc_class_flag_user_created)) + { + objc_send_load_message(cls); + } if (_objc_load_callback) { _objc_load_callback(cls, 0); @@ -486,7 +489,7 @@ Class class_getSuperclass(Class cls) if (Nil == cls) { return Nil; } if (!objc_test_class_flag(cls, objc_class_flag_resolved)) { - return objc_getClass((const char*)cls->super_class); + objc_resolve_class(cls); } return cls->super_class; } diff --git a/runtime.c b/runtime.c index 197bcca..2355940 100644 --- a/runtime.c +++ b/runtime.c @@ -700,16 +700,8 @@ Class objc_allocateClassPair(Class superclass, const char *name, size_t extraByt // in objc_resolve_class(). // If the superclass is not yet resolved, then we need to look it up // via the class table. - if (!objc_test_class_flag(superclass, objc_class_flag_resolved)) - { - metaClass->super_class = (Class)objc_getClass((char*)superclass->super_class); - metaClass->isa = (Class)metaClass->super_class->isa->name; - } - else - { - metaClass->isa = (Class)superclass->isa->isa->name; - metaClass->super_class = superclass->isa; - } + metaClass->isa = (Class)superclass->isa->isa->name; + metaClass->super_class = superclass->isa; } metaClass->name = strdup(name); metaClass->info = objc_class_flag_meta | objc_class_flag_user_created | @@ -788,9 +780,12 @@ const char *object_getClassName(id obj) return class_getName(object_getClass(obj)); } +PRIVATE void objc_resolve_class(Class); + void objc_registerClassPair(Class cls) { LOCK_RUNTIME_FOR_SCOPE(); class_table_insert(cls); + objc_resolve_class(cls); }