bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: class initialization problem ?


From: David Ayers
Subject: Re: class initialization problem ?
Date: Mon, 25 Aug 2003 23:00:51 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

David Ayers wrote:

Manuel Guesdon wrote:

Hi David,

Thank you for the explanation.
At the begining my problem was with GSObjCIsKindOf wich wasn't returning YES when I didn't Log the class before (more precisely now with your help, when the class has not received a message before).

GSObjCIsKindOf use class_get_super_class and that's why I've got the problem.

So I think there's a bug in GSObjCIsKindOf as it doesn't return the good result under this case. Using GSObjCSuper doesn't seems t to be a solution as it call class_get_super_class

Is there a way to know if a class is initialized and force initialization in GSObjCSuper and GSObjCIsKindOf if it is not ?

Hmm. and class_superclass_of_class isn't public :-/, I don't have time right now, but I'll look into the runtime's as soon as I can, to see what we can do in GSObjCSuper to insure the reurn value is an intialized class. I've just posted a patch to make -base use many of our GSObjCRuntime functions. So if we can fix GSObjCSuper, the rest should fall into place.

I'm not sure if I really like this yet, but maybe it's just not a matter of liking but of correctness...
Try this:

Cheers,
David


Index: Headers/Additions/GNUstepBase/GSObjCRuntime.h
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Headers/Additions/GNUstepBase/GSObjCRuntime.h,v
retrieving revision 1.2
diff -u -r1.2 GSObjCRuntime.h
--- Headers/Additions/GNUstepBase/GSObjCRuntime.h       24 Aug 2003 23:07:40 
-0000      1.2
+++ Headers/Additions/GNUstepBase/GSObjCRuntime.h       25 Aug 2003 20:55:06 
-0000
@@ -139,9 +139,21 @@
  * Returns the superclass of this.
  */
 GS_STATIC_INLINE Class
-GSObjCSuper(Class this)
+GSObjCSuper(Class class)
 {
-  return class_get_super_class(this);
+#ifndef NeXT_RUNTIME
+  if (class != 0 && CLS_ISRESOLV (class) == NO)
+    {
+      const char *name;
+      name = (const char *)class->super_class;
+      if (name == NULL)
+       {
+         return 0;
+       }
+      return objc_lookup_class (name);
+    }
+#endif
+  return class_get_super_class(class);
 }
 
 /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]