diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-10-16 14:03:42 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-10-16 14:03:42 +0000 |
commit | 1cde73d75d94428876d2924763acd292b2f4b632 (patch) | |
tree | b7ad195618cdca2ff18a0a9236f8926331622f27 /libobjc | |
parent | 4b0b4ab069cd49638ab3c09d427d00180ce60691 (diff) | |
download | gcc-1cde73d75d94428876d2924763acd292b2f4b632.zip gcc-1cde73d75d94428876d2924763acd292b2f4b632.tar.gz gcc-1cde73d75d94428876d2924763acd292b2f4b632.tar.bz2 |
class.c (class_getSuperclass): Call __objc_resolve_class_links if the class is not resolved yet.
2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com>
* class.c (class_getSuperclass): Call __objc_resolve_class_links
if the class is not resolved yet.
* ivars.c (class_getInstanceVariable): Use class_getSuperclass.
From-SVN: r165542
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 6 | ||||
-rw-r--r-- | libobjc/class.c | 14 | ||||
-rw-r--r-- | libobjc/ivars.c | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 569b628..2142b89 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,11 @@ 2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com> + * class.c (class_getSuperclass): Call __objc_resolve_class_links + if the class is not resolved yet. + * ivars.c (class_getInstanceVariable): Use class_getSuperclass. + +2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com> + * objc/runtime.h (class_getIvarLayout): New. (class_getWeakIvarLayout): New. (class_setIvarLayout): New. diff --git a/libobjc/class.c b/libobjc/class.c index 8c6f989..7148345 100644 --- a/libobjc/class.c +++ b/libobjc/class.c @@ -500,7 +500,7 @@ objc_getClass (const char *name) if (class) return class; - + if (__objc_get_unknown_class_handler) return (*__objc_get_unknown_class_handler) (name); @@ -796,12 +796,24 @@ class_isMetaClass (Class class_) return CLS_ISMETA (class_); } +/* Even inside libobjc it may be worth using class_getSuperclass + instead of accessing class_->super_class directly because it + resolves the class links if needed. If you access + class_->super_class directly, make sure to deal with the situation + where the class is not resolved yet! */ Class class_getSuperclass (Class class_) { if (class_ == Nil) return Nil; + /* 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 + super class. In that case, we need to resolve the class links + before we can return super_class. */ + if (! CLS_ISRESOLV (class_)) + __objc_resolve_class_links (); + return class_->super_class; } diff --git a/libobjc/ivars.c b/libobjc/ivars.c index 827243a..9e9a84b 100644 --- a/libobjc/ivars.c +++ b/libobjc/ivars.c @@ -53,7 +53,7 @@ class_getInstanceVariable (Class class_, const char *name) } } } - class_ = class_->super_class; + class_ = class_getSuperclass (class_); } objc_mutex_unlock (__objc_runtime_mutex); } |