diff options
-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 569b6289515..2142b893c18 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 8c6f989a8e9..71483457e25 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 827243a6c71..9e9a84b068e 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); } |