diff options
author | Richard Stallman <rms@gnu.org> | 1993-05-06 02:42:55 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-05-06 02:42:55 +0000 |
commit | 4be7cc989c0a8c63660791479b6875cd0362fb3d (patch) | |
tree | c347a1855fc4c0bbb0e5f040f5ec24b5165e7f82 /gcc/objc | |
parent | bda63bf128168ac7c2b4ab65c92097a6ae533c95 (diff) | |
download | gcc-4be7cc989c0a8c63660791479b6875cd0362fb3d.zip gcc-4be7cc989c0a8c63660791479b6875cd0362fb3d.tar.gz gcc-4be7cc989c0a8c63660791479b6875cd0362fb3d.tar.bz2 |
(__objc_send_initialize, class_add_method_list):
Allow multiple +initialize methods per class.
From-SVN: r4349
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/sendmsg.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/gcc/objc/sendmsg.c b/gcc/objc/sendmsg.c index 3638c79..c7947ec 100644 --- a/gcc/objc/sendmsg.c +++ b/gcc/objc/sendmsg.c @@ -186,14 +186,31 @@ static void __objc_send_initialize(Class* class) if(class->super_class) __objc_send_initialize(class->super_class); - - m = search_for_method_in_list(class->class_pointer->methods, - sel_get_uid("initialize")); - if(m != NULL) - { - CLS_SETINITIALIZED(class); - (*m->method_imp) ((id) class, sel_get_uid("initialize")); - } + + { + MethodList_t method_list = class->class_pointer->methods; + SEL op = sel_register_name ("initialize"); + + /* If not found then we'll search the list. */ + while (method_list) + { + int i; + + /* Search the method list. */ + for (i = 0; i < method_list->method_count; ++i) + { + Method_t method = &method_list->method_list[i]; + + + if (method->method_name == op) + (*method->method_imp)((id) class, op); + } + + /* The method wasn't found. Follow the link to the next list of + methods. */ + method_list = method_list->method_next; + } + } } } @@ -268,6 +285,9 @@ void class_add_method_list (Class* class, MethodList_t list) { int i; + static SEL initialize_sel = 0; + if (!initialize_sel) + initialize_sel = sel_register_name ("initialize"); /* Passing of a linked list is not allowed. Do multiple calls. */ assert (!list->method_next); @@ -282,7 +302,8 @@ class_add_method_list (Class* class, MethodList_t list) /* This is where selector names are transmogriffed to SEL's */ method->method_name = sel_register_name ((char*)method->method_name); - if (search_for_method_in_list (class->methods, method->method_name)) + if (search_for_method_in_list (class->methods, method->method_name) + && method->method_name != initialize_sel) { /* Duplication. Print a error message an change the method name to NULL. */ |