[pypy-dev] Writing Mixed Modules for MacOS
dcolish at gmail.com
Wed Feb 23 19:48:46 CET 2011
On Wednesday, February 23, 2011 at 10:04 AM, Henry Mason wrote:
> On Feb 23, 2011, at 8:29 AM, Dan Colish wrote:
> > I've been working on porting the OSX specific libraries in CPython to PyPy and I'm running into issues. The shape of many fundamental data structures used in the CoreFoundation libraries are not available to me. I was hoping to just fudge it by using a ptr to that structure, but it is not working out as I had hoped. Here is a terribly incorrect sample of what I've been hacking on: http://paste.pocoo.org/show/yENK4gE11yRM9i6p46Ra and here is the corresponding osx documentation: http://goo.gl/i6mYD.
> Are you saying you don't know the shape of the opaque CFTypes, like CFNumber? Pointers to forward-declared structures is a pretty pervasive pattern in C API. For example, I see the FILE* returned by fopen() declared like this:
> FILEP = rffi.COpaquePtr('FILE')
> fopen = rffi.llexternal('fopen', [rffi.CCHARP, rffi.CCHARP], FILEP)
> fclose = rffi.llexternal('fclose', [FILEP], rffi.INT)
> in pypy/rpython/lltypesystem/test/test_ll2ctypes.py, so I imagine you'd be able to do the same for CFTypes:
> CFAllocatorRef = rffi.COpaquePtr('__ CFAllocator')
> CFNumberRef = rffi.COpaquePtr('__CFNumber')
> CFNumberCreateInt = rffi.llexternal('CFNumberCreate', [CFAllocatorRef, rffi.INT, rffi.VOIDP], CFNumberRef)
This is exactly what I was looking for, thank you!
More information about the Pypy-dev