diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2011-08-06 09:49:30 +0000 |
---|---|---|
committer | Nicola Pero <nicola.pero@meta-innovation.com> | 2011-08-06 09:49:30 +0000 |
commit | 76c638a82099b37ef2dc2dd6c1e9000c82be9f0a (patch) | |
tree | 1e7b3a8bb4d030cf3d96c14215b779ba1938243f | |
parent | 6ebfa40bcdf7ffaacd4e7897132680e795e837a5 (diff) |
In libobjc/:
2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
PR libobjc/49882
* class.c (class_getSuperclass): Return the superclass if the
class is in construction.
* objc/runtime.h (class_getSuperclass): Updated documentation.
In gcc/testsuite/:
2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com>
PR libobjc/49882
* objc.dg/gnu-api-2-class.m (main): Test class_getSuperclass()
with classes that are in construction.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@177505 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/gnu-api-2-class.m | 8 | ||||
-rw-r--r-- | libobjc/ChangeLog | 7 | ||||
-rw-r--r-- | libobjc/class.c | 9 | ||||
-rw-r--r-- | libobjc/objc/runtime.h | 8 |
5 files changed, 31 insertions, 7 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bdfacbf796e..cb5adfe815f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> + + PR libobjc/49882 + * objc.dg/gnu-api-2-class.m (main): Test class_getSuperclass() + with classes that are in construction. + 2011-08-05 Jason Merrill <jason@redhat.com> PR c++/48993 diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class.m b/gcc/testsuite/objc.dg/gnu-api-2-class.m index f396a09fad8..d69f8eba20f 100644 --- a/gcc/testsuite/objc.dg/gnu-api-2-class.m +++ b/gcc/testsuite/objc.dg/gnu-api-2-class.m @@ -394,6 +394,14 @@ int main(int argc, void **args) MySubClass *object = [[MySubClass alloc] init]; if (class_getSuperclass (object_getClass (object)) != objc_getClass ("MyRootClass")) abort (); + + /* Test that it works on a newly created, but not registered, class. */ + { + Class new_class = objc_allocateClassPair (objc_getClass ("MyRootClass"), "MySubClass3", 0); + + if (class_getSuperclass (new_class) != objc_getClass ("MyRootClass")) + abort (); + } } printf ("Testing class_getVersion ()...\n"); diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 61d4ac335d7..978878e2701 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,10 @@ +2011-08-06 Nicola Pero <nicola.pero@meta-innovation.com> + + PR libobjc/49882 + * class.c (class_getSuperclass): Return the superclass if the + class is in construction. + * objc/runtime.h (class_getSuperclass): Updated documentation. + 2011-08-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * Makefile.in (INCLUDES): Search diff --git a/libobjc/class.c b/libobjc/class.c index 3fe3561d2ac..5df70508691 100644 --- a/libobjc/class.c +++ b/libobjc/class.c @@ -923,10 +923,13 @@ class_getSuperclass (Class class_) if (class_ == Nil) return Nil; - /* Classes that are in construction are not resolved and can not be - resolved! */ + /* Classes that are in construction are not resolved, and still have + the class name (instead of a class pointer) in the + class_->superclass field. In that case we need to lookup the + superclass name to return the superclass. We can not resolve the + class until it is registered. */ if (CLS_IS_IN_CONSTRUCTION (class_)) - return Nil; + 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 diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index ab9926e9b6d..c649e239d9e 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -497,10 +497,10 @@ objc_EXPORT const char * class_getName (Class class_); objc_EXPORT BOOL class_isMetaClass (Class class_); /* Return the superclass of 'class_'. If 'class_' is Nil, or it is a - root class, return Nil. If 'class_' is a class being constructed, - that is, a class returned by objc_allocateClassPair() but before it - has been registered with the runtime using - objc_registerClassPair(), return Nil. */ + root class, return Nil. This function also works if 'class_' is a + class being constructed, that is, a class returned by + objc_allocateClassPair() but before it has been registered with the + runtime using objc_registerClassPair(). */ objc_EXPORT Class class_getSuperclass (Class class_); /* Return the 'version' number of the class, which is an integer that |