Commit 1cde73d7 by Nicola Pero Committed by Nicola Pero

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
parent 4b0b4ab0
2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com> 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. * objc/runtime.h (class_getIvarLayout): New.
(class_getWeakIvarLayout): New. (class_getWeakIvarLayout): New.
(class_setIvarLayout): New. (class_setIvarLayout): New.
......
...@@ -500,7 +500,7 @@ objc_getClass (const char *name) ...@@ -500,7 +500,7 @@ objc_getClass (const char *name)
if (class) if (class)
return class; return class;
if (__objc_get_unknown_class_handler) if (__objc_get_unknown_class_handler)
return (*__objc_get_unknown_class_handler) (name); return (*__objc_get_unknown_class_handler) (name);
...@@ -796,12 +796,24 @@ class_isMetaClass (Class class_) ...@@ -796,12 +796,24 @@ class_isMetaClass (Class class_)
return CLS_ISMETA (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
class_getSuperclass (Class class_) class_getSuperclass (Class class_)
{ {
if (class_ == Nil) if (class_ == Nil)
return 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; return class_->super_class;
} }
......
...@@ -53,7 +53,7 @@ class_getInstanceVariable (Class class_, const char *name) ...@@ -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); objc_mutex_unlock (__objc_runtime_mutex);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment