aboutsummaryrefslogtreecommitdiff
path: root/libobjc/sendmsg.c
diff options
context:
space:
mode:
authorNicola Pero <nicola@gcc.gnu.org>2011-10-08 17:52:06 +0000
committerNicola Pero <nicola@gcc.gnu.org>2011-10-08 17:52:06 +0000
commit0ea39696e441675fa9c8d2e7dafd5ff6782e241d (patch)
treec87aa33515b54b89054895be5d96b1b5bee58c6b /libobjc/sendmsg.c
parent30a390c8104f9530cd8721e699deecd823fc4e9c (diff)
In libobjc/: 2011-10-08 Richard Frith-Macdonald <rfm@gnu.org> Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/: 2011-10-08 Richard Frith-Macdonald <rfm@gnu.org> Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/50428 * sendmsg.c (__objc_send_initialize): If a class does not have an +initialize method, search for an +initialize method in the superclass and in the ancestor classes and execute the first one that is found. This makes the GNU runtime behave in the same way as the Apple/NeXT runtime with respect to +initialize methods and subclassing. In gcc/: 2011-10-08 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/50428 * doc/objc.texi (Garbage Collection): Updated example to protect +initialize against execution in subclasses. In gcc/testsuite/: 2011-10-08 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/50428 * objc/execute/initialize-1.m: New test. From-SVN: r179711
Diffstat (limited to 'libobjc/sendmsg.c')
-rw-r--r--libobjc/sendmsg.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/libobjc/sendmsg.c b/libobjc/sendmsg.c
index 8aa266dd11f..ea8ea970262 100644
--- a/libobjc/sendmsg.c
+++ b/libobjc/sendmsg.c
@@ -516,34 +516,13 @@ __objc_send_initialize (Class class)
{
SEL op = sel_registerName ("initialize");
- IMP imp = 0;
- struct objc_method_list * method_list = class->class_pointer->methods;
-
- while (method_list)
- {
- int i;
- struct objc_method * method;
-
- for (i = 0; i < method_list->method_count; i++)
- {
- method = &(method_list->method_list[i]);
- if (method->method_name
- && method->method_name->sel_id == op->sel_id)
- {
- imp = method->method_imp;
- break;
- }
- }
-
- if (imp)
- break;
-
- method_list = method_list->method_next;
- }
- if (imp)
+ struct objc_method *method = search_for_method_in_hierarchy (class->class_pointer,
+ op);
+
+ if (method)
{
DEBUG_PRINTF (" begin of [%s +initialize]\n", class->name);
- (*imp) ((id) class, op);
+ (*method->method_imp) ((id)class, op);
DEBUG_PRINTF (" end of [%s +initialize]\n", class->name);
}
#ifdef DEBUG