summaryrefslogtreecommitdiff
path: root/libobjc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-06 14:20:09 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-06 14:20:09 +0000
commit1db7b8a843e41f8e4858fbbdaac698e9f4ea371e (patch)
tree2eebcd872b6090c0533651d1c56a014d20130d9b /libobjc
parent0f4721f30396b56d99ec291495dd38dc1fe40aec (diff)
downloadgcc-1db7b8a843e41f8e4858fbbdaac698e9f4ea371e.tar.gz
In libobjc/:
2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/50002 * class.c (__objc_update_classes_with_methods): Iterate over meta classes as well as normal classes when refreshing the method implementations. This fixes replacing class methods. 2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> * class.c (class_getSuperclass): Fixed to work with meta classes still in construction too. In gcc/testsuite/: 2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/50002 * objc.dg/gnu-api-2-class.m: Updated comments. * obj-c++.dg/gnu-api-2-class.mm: Likewise. * objc.dg/gnu-api-2-class-meta.m: New test. * obj-c++.dg/gnu-api-2-class-meta.mm: Likewise. 2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> PR libobjc/49882 * obj-c++.dg/gnu-api-2-class.mm (main): Test class_getSuperclass() with classes that are in construction. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177510 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r--libobjc/ChangeLog12
-rw-r--r--libobjc/class.c69
2 files changed, 60 insertions, 21 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog
index a69e59032cc..b9f87fabec9 100644
--- a/libobjc/ChangeLog
+++ b/libobjc/ChangeLog
@@ -1,5 +1,17 @@
2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
+ PR libobjc/50002
+ * class.c (__objc_update_classes_with_methods): Iterate over meta
+ classes as well as normal classes when refreshing the method
+ implementations. This fixes replacing class methods.
+
+2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * class.c (class_getSuperclass): Fixed to work with meta classes
+ still in construction too.
+
+2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
+
* class.c (class_getSuperclass): Fixed typo in comment.
2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
diff --git a/libobjc/class.c b/libobjc/class.c
index fa21afc461d..edc56aa9ec4 100644
--- a/libobjc/class.c
+++ b/libobjc/class.c
@@ -781,35 +781,57 @@ __objc_update_classes_with_methods (struct objc_method *method_a, struct objc_me
while (node != NULL)
{
- /* Iterate over all methods in the class. */
- Class class = node->pointer;
- struct objc_method_list * method_list = class->methods;
-
- while (method_list)
+ /* We execute this loop twice: the first time, we iterate
+ over all methods in the class (instance methods), while
+ the second time we iterate over all methods in the meta
+ class (class methods). */
+ Class class = Nil;
+ BOOL done = NO;
+
+ while (done == NO)
{
- int i;
+ struct objc_method_list * method_list;
- for (i = 0; i < method_list->method_count; ++i)
+ if (class == Nil)
+ {
+ /* The first time, we work on the class. */
+ class = node->pointer;
+ }
+ else
{
- struct objc_method *method = &method_list->method_list[i];
+ /* The second time, we work on the meta class. */
+ class = class->class_pointer;
+ done = YES;
+ }
- /* If the method is one of the ones we are looking
- for, update the implementation. */
- if (method == method_a)
- sarray_at_put_safe (class->dtable,
- (sidx) method_a->method_name->sel_id,
- method_a->method_imp);
+ method_list = class->methods;
- if (method == method_b)
+ while (method_list)
+ {
+ int i;
+
+ for (i = 0; i < method_list->method_count; ++i)
{
- if (method_b != NULL)
+ struct objc_method *method = &method_list->method_list[i];
+
+ /* If the method is one of the ones we are
+ looking for, update the implementation. */
+ if (method == method_a)
sarray_at_put_safe (class->dtable,
- (sidx) method_b->method_name->sel_id,
- method_b->method_imp);
+ (sidx) method_a->method_name->sel_id,
+ method_a->method_imp);
+
+ if (method == method_b)
+ {
+ if (method_b != NULL)
+ sarray_at_put_safe (class->dtable,
+ (sidx) method_b->method_name->sel_id,
+ method_b->method_imp);
+ }
}
+
+ method_list = method_list->method_next;
}
-
- method_list = method_list->method_next;
}
node = node->next;
}
@@ -929,7 +951,12 @@ class_getSuperclass (Class class_)
superclass name to return the superclass. We can not resolve the
class until it is registered. */
if (CLS_IS_IN_CONSTRUCTION (class_))
- return objc_lookUpClass ((const char *)(class_->super_class));
+ {
+ if (CLS_ISMETA (class_))
+ return object_getClass ((id)objc_lookUpClass ((const char *)(class_->super_class)));
+ else
+ return objc_lookUpClass ((const char *)(class_->super_class));
+ }
/* If the class is not resolved yet, super_class would point to a
string (the name of the super class) as opposed to the actual