Hi David,

Le 6 janv. 2010 à 23:29, David Chisnall a écrit :

> On 6 Jan 2010, at 15:06, 荒田 実樹 wrote:
>
>> - class_getSuperclass directly refer to cls->super_class
>> (class_get_super_class doesn't work on metaclass).

class_getSuperclass() seems to be correctly implemented in  
ObjectiveC2.framework but not in libobjc2.
In libobjc2, it calls class_get_super_class() which doesn't work with  
a metaclass as argument.

I think several similar new libobjc2 functions are currently broken  
when you pass a metaclass because they call the old libobjc1 API which  
doesn't accept metaclasses as classes.
Unless libobjc2 has changed the semantic of CLS_ISCLASS, CLS_ISCLASS 
(aMetaclass) counterintuitively returns false. Since the old libobjc1  
API checks the argument with CLS_ISCLASS in functions such as  
class_get_super_class() or class_get_instance_size(), new APIs such as  
class_getSuperclass() and class_getInstanceSize() are not equivalent.

This problem probably exists with few other functions in addition the  
two I mentionned.

On Mac OS X, the following is valid and returns two different class  
objects:
class_getSuperclass(objc_getClass("NSCountedSet"));
class_getSuperclass(objc_getMetaClass("NSCountedSet"));

Similarly:
class_getInstanceSize(objc_getClass("NSCountedSet")); // returns 12
class_getInstanceSize(objc_getMetaClass("NSCountedSet")); // returns 48

> Hmm.  For Apple-compatibility we should be setting it to NSObject.  I
> wonder if that would break GNUstep...
>
> By the way, if you've got a decent set of tests for this API then they
> would be very helpful...

May be you can adapt the Apple test suite: 
http://www.opensource.apple.com/source/objc4/objc4-437.1/test/

Cheers,
Quentin.


_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à