[Pyobjc-dev] DictType -> ObjC
Brought to you by:
ronaldoussoren
|
From: Bill B. <bb...@co...> - 2002-10-16 23:12:52
|
Ronald,
How hard would it be to proxy DictType, ArrayType, and TupleType
into Obj-C such that they look/feel/act/behave/are subclasses of
NSDictionary and NSArray?
That is, such that they implement the primitive methods of the
NSDictionary/NSArray class clusters and internally use the Py* APIs to
retrieve/set values [converting as necessary]?
This would be significantly valuable in that it doesn't imply a
conversion as the objects come across the bridge from Python->ObjC, yet
they would be compatible with NSDictionary/NSArray and friends.
Also-- should the following slice fail in the way that it does? (I
included the last two lines only because it raises the question as to
whether or not NSNumber/NSValue should be converted across the bridge
-- I'm not sure that there is a really clear answer).
[bumbox:IssueCenter/V3/Python] bbum% python
Python 2.2 (#1, 07/14/02, 23:25:09)
[GCC Apple cpp-precomp 6.14] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Foundation import *
>>> x = NSMutableArray.array()
>>> x.addObject_(1)
>>> x.addObject_(2)
>>> x.addObject_(3)
>>> x.addObject_(4)
>>> x.addObject_(5)
>>> y = [1,2,3,4,5]
>>> y[2:4]
[3, 4]
>>> x[2:4]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/objc/__init__.py", line 152,
in <lambda>
CONVENIENCE_METHODS['objectAtIndex:'] = ('__getitem__', lambda
self, arg: self.objectAtIndex_(arg))
TypeError: expected an integer for argument 1: its typespec is 'I'
>>> y[0]
1
>>> x[0]
<NSCFNumber objective-c instance 0xc1a7c0>
>>>
b.bum
|