I figured out how to deal w/(void *) in the context of NSData. It is
simply a matter of using Ronald's most excellent method bridging
mechanism to create a bridge for the various methods that convert void*
into bufferobjects and vice-versa.
I am committing working code -- see unit test. Working, with caveats.
It spews a warning because I have *no clue* what to do for calls to
super and because the code may not actually be working (additional unit
tests appreciated).
Also, note that -initWithBytes:length: fails for larger hunks o' data.
Probably alloc hack related????
[bumbox:~/bbum-developer/sourceforge/pyobjc] 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 NSData
>>> def newData(s):
... return NSData.alloc().initWithBytes_length_(s, len(s))
...
>>> newData("asdfasdf")
<61736466 61736466 >
>>> newData("asdfasdfasdfasdfasdfasdf")
<61736466 61736466 61736466 61736466 61736466 61736466 >
>>>
newData("asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd
fasdfasdfasdfasdfasdfasdf")
Segmentation fault
In any case, this lays the foundation for fully supporting
NSBitmapImageRep and anything else that uses pointers to big hunks of
memory-- whether or not that memory is generated within Cocoa or within
Python can be made irrelevant outside of the normal lifespan issues.
b.bum
|