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)

> 
> I was looking at the approach taken for windows, but it is not clear to me 
> where the fundamental structures for windows lie outside of the win32 
> specific bits in pypy.rpython.lltypesystem.module.ll_os. For the most part 
> they seem to be defined in the modules where they will be used, so it is 
> difficult for me to understand how it all fits together. In general, a higher 
> level description of how to handle data types which you cannot openly declare 
> would be very helpful. 
> 
> Thanks in advance.
> 
> -- Dan
> 
> 
> _______________________________________________
> [email protected]
> http://codespeak.net/mailman/listinfo/pypy-dev

_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to