[pypy-dev] Newb questions about ext module writing

Scott Dial scott+pypy-dev at scottdial.com
Sat Jul 22 13:39:27 CEST 2006


Armin Rigo wrote:
> On Fri, Jul 21, 2006 at 06:24:19PM -0700, Lenard Lindstrom wrote:
>> In ctypes that is easy: use a bound method as the callback. Does that 
>> even work in rctypes?
> 
> I'm afraid not, and it's not obvious how this would be compiled to C
> code, given that there is no kind of closure in ANSI C.
> 
> I don't see how to do that at all, actually :-(  It's somehow a design
> problem of the readline lib, which should in theory always pass an extra
> void* "closure" arguments to callbacks...
> 
> It might be necessary to use hacks like a single global State instance,
> storing the "space" the readline lib was initialized with, instead of
> one State per space.

I am admittedly ignorant of rctypes capabilities, but I can appreciate
the conversion in C code being awkward. Reading around more, I see in
rctypes.implementation where an attempt for CALLBACK_FUNCTYPE was
droppped. Seems like I have bitten off more than I can chew here.

I think you understate the issue by saying it's "a design problem of the
readline lib" because many, many C libraries are going to need callback
functionality. If I have evaluated the project's current state
correctly, then I realize this is more-or-less not the current focus of
development. So, no biggie.

I just figured it would something I could just go through the motions on
to become familiar. I am open to other suggestions. I can comeback to
this when I have a better understanding of everything.

-- 
Scott Dial
scott at scottdial.com
scodial at indiana.edu




More information about the Pypy-dev mailing list