[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: |
Thu, 21 Aug 2003 18:54:30 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507 |
Hi Manual,
the unintilized pointer is actually the class name as a c string. From:
init.c
/* This function is used when building the class tree used to send
ordinately the +load message to all classes needing it. The tree
is really needed so that superclasses will get the message before
subclasses.
This tree will contain classes which are being loaded (or have just
being loaded), and whose super_class pointers have not yet been
resolved. This implies that their super_class pointers point to a
string with the name of the superclass; when the first message is
sent to the class (/an object of that class) the class links will
be resolved, which will replace the super_class pointers with
pointers to the actual superclasses.
Unfortunately, the tree might also contain classes which had been
loaded previously, and whose class links have already been
resolved.
This function returns the superclass of a class in both cases, and
can be used to build the determine the class relationships while
building the tree.
*/
static Class class_superclass_of_class (Class class)
...
Maybe you could rely on GSObjCRuntime functions (GSObjCSuper) that try
handle these oddities.
Cheers,
David
Manuel Guesdon wrote:
Hi,
I've found a very very stange thing:
I wanted to find if class aClass inherit from another class bClass.
When NSLog-ing class, this works, without it doesn't !
Here are some traces:
aClass=0x4156e320
(aClass address)
class_get_super_class(aClass)=0x4156d782 (aClass
superclass adress)
class_get_super_class(class_get_super_class(aClass))=(null) (aClass
superclass superclass adress. It shouldn't
be null !!!!)
aClass=MyClassName (result of NSLog(@"aClass=%@",aClass))
aClass=0x4156e320
(aClass address; same as 1st time)
class_get_super_class(aClass)=0x41487400 (aClass
superclass adress. It has changed !!)
class_get_super_class(class_get_super_class(aClass))=0x406fcf40 (aClass
superclass superclass adress. It's now correct !)!)
Any idea ?
Manuels