rubicon-objc icon indicating copy to clipboard operation
rubicon-objc copied to clipboard

Should ObjCClass stay a subclass of type?

Open dgelessus opened this issue 6 years ago • 0 comments

At the moment ObjCClass extends ObjCInstance and type. As far as I can tell, the fact that it extends type is not used or needed for anything at the moment. A metaclass don't need to subclass type, it's enough to have its constructor accept the signature of type's constructor (name, bases, namespace).

It's also misleading, because users might expect to be able to define Python methods on Objective-C classes (by not decorating them with @objc_method). This is not possible at the moment, because instances of user-defined Objective-C classes are actually instances of ObjCInstance, and not of the user's ObjCClass subclass. We could theoretically support this though - similar to how an ObjC NSArray becomes a Python ObjCListInstance, we could make an ObjC UserSubclass become a Python UserSubclass too. (The logic in ObjCInstance._select_mixin would probably need to be optimized though, I don't think a chain of isKindOfClass: scales well.)

dgelessus avatar Sep 17 '17 00:09 dgelessus