Re: [Pyobjc-dev] Re: Making List<->Array bridging transparent
Brought to you by:
ronaldoussoren
From: Peter M. <zig...@po...> - 2002-11-09 14:42:52
|
On Sunday, November 10, 2002, at 01:11 AM, Ronald Oussoren wrote: > > On Saturday, Nov 9, 2002, at 11:31 Europe/Amsterdam, Peter Montagner > wrote: > >> Bill Bumgarner wrote: >> >>> ... is true, then we add <type 'list'> to the bases for the newly >>> created Python class object? Assuming a complete implementation of >>> convenience methods, this would allow bridged instances of NSArray to >>> function fully on the Python side of the bridge [i.e. work in >>> contexts >>> like the above where the runtime is testing for a particular type and >>> not just a set of methods]. >>> >>> As an experiment, I tried-- naively-- to add this to the function >>> that >>> bridges classes to Python... it doesn't work. >> >> So you can't do it by adding list as a base but could you instead >> just not use ObjCObject to do the wrapping? What if you created >> another class with list as the only base? You can't slam PyListObject >> and ObjCObject together but could you subclass list and add >> real_object as another variable? Or will python not even let you >> subclass compiled classes in C? > > That would work, but then NSArray would no longer by a subclass of > NSObject. This will probably cause subtle bugs and won't buy us much > in the long run. Especially because this will be a non-issue in Python > 2.3: I filed a bug-report related to this and the bug was fixed within > a day :-) Great! But why wouldn't NSArray be a subclass of NSObject under my scheme? ObjCObject isn't an NSObject is it? I though it was a proxy, passing method calls to an encapsulated id. I was thinking a list based NSArray wrapper would act the same: answering any sequence methods by translating them into NSArray methods and passing any non sequence methods (ie. native NSArray methods) on to the encapsulated NSArray. This way, any NSArray instances would look like sequences to pure python code but would still respond to all the Cocoa methods as per normal. Of course, I'm still pretty new to the inner workings of PyObjC so I could be completely mistaken. And I have absolutely no idea how hard that would be. How is either method going to solve the splice problem if the splice code is trying to access the list directly? Did I understand that correctly? BTW, how long do you think it will take Apple to include Python 2.3 in the default install? Peter |