[Pyobjc-dev] Re: [Pythonmac-SIG] pyobjc / cocoa

Jack Jansen Jack.Jansen@oratrix.com
Thu, 17 Oct 2002 22:06:35 +0200


On donderdag, oktober 17, 2002, at 06:24 , Bill Bumgarner wrote:
> Convenience wrappers are in the works.  Instead of wrapping, we 
> are thinking of simply providing a subclass of NSDictionary and 
> NSArray that can encapsulate DictType and Array/TupleTypes 
> respectively.   That way, Python arrays and dicts will behave 
> like normal NSArray / NSDictionary instances on the ObjC side 
> of the bridge.   (The other direction has already been bridged).

I think we should again combine forces here. At the moment we 
have two bridges that make the NS-objects or the CoreFoundation 
alter-ego's available to Python, and half a bridge the other way.

The Carbon.CF module (a misnomer, it isn't Carbon-dependent, 
that'll be fixed) exports most of CoreFoundation's objects to 
Python, but at the moment it isn't complete in that you can't 
say obj[12] if obj as a CFArray, i.e. it just exports method 
calls. It does have a nifty toCF() method that takes any 
supported Python object (a recursive combination of 
dict/list/string/scalar/CFObject) and returns its CF equivalent, 
and each CFObject has a toPython() method that does the reverse. 
And due to the way Carbon.CF works you hardly ever have to call 
toCF(), usually if a conversion from a Python object is needed 
it is done automatically.

Most of this module is automatically generated, so as Apple 
comes up with more CF objects, or these objects grow new 
methods, that'll be automatically incorporated.

And in PyObjC we have support for using NS objects in a way that 
is natural to Python, i.e. you can say obj[12] here. But when I 
last looked PyObjC didn't handle all object types, and handled 
some in a slightly funny way (strings, scalars). Note that 
"slightly funny" is meant derogatory here, doing automatic 
conversion for these types is often a good idea, but may come 
back to haunt us now that unicode is more important, and now 
that a Python program may have obtained a CFString object from 
another source.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- 
Emma Goldman -