More tweaks to +load. Now defers +load a little bit more.

This commit is contained in:
theraven 2010-07-20 10:53:53 +00:00
parent 378c7d3a6c
commit a75064866a
2 changed files with 15 additions and 3 deletions

View File

@ -34,7 +34,6 @@ static void load_category(struct objc_category *cat, struct objc_class *class)
cat->protocols->next = class->protocols;
class->protocols = cat->protocols;
}
objc_send_load_message(class);
}
static BOOL try_load_category(struct objc_category *cat)

View File

@ -16,6 +16,7 @@ void __objc_init_selector_tables(void);
void __objc_init_protocol_table(void);
void __objc_init_class_tables(void);
void __objc_init_dispatch_tables(void);
void objc_send_load_message(Class class);
/* Number of threads that are alive. */
int __objc_runtime_threads_alive = 1; /* !T:MUTEX */
@ -72,6 +73,7 @@ void __objc_exec_class(struct objc_module_abi_8 *module)
{
objc_load_class(symbols->definitions[defs++]);
}
unsigned int category_start = defs;
// Load the categories from this module
for (unsigned short i=0 ; i<symbols->category_count; i++)
{
@ -84,9 +86,20 @@ void __objc_exec_class(struct objc_module_abi_8 *module)
objc_init_statics(*(statics++));
}
// Fix up the class links for loaded classes.
objc_resolve_class_links();
// Load categories and statics that were deferred.
objc_load_buffered_categories();
objc_init_buffered_statics();
// Fix up the class links for loaded classes.
objc_resolve_class_links();
for (unsigned short i=0 ; i<symbols->category_count; i++)
{
struct objc_category *cat = (struct objc_category*)
symbols->definitions[category_start++];
Class class = (Class)objc_getClass(cat->class_name);
if ((Nil != class) &&
objc_test_class_flag(class, objc_class_flag_resolved))
{
objc_send_load_message(class);
}
}
}