summaryrefslogtreecommitdiff
path: root/libobjc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-16 14:03:42 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-16 14:03:42 +0000
commit63edd4793c007093d00b73c58761ee516004e544 (patch)
treeb7ad195618cdca2ff18a0a9236f8926331622f27 /libobjc
parent0a5dd1a5aa5e923702f39d0c25212a65455778e0 (diff)
downloadgcc-63edd4793c007093d00b73c58761ee516004e544.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165542 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r--libobjc/ChangeLog6
-rw-r--r--libobjc/class.c14
-rw-r--r--libobjc/ivars.c2
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);
}