[pypy-dev] Newb questions about ext module writing
len-l at telus.net
Sat Jul 22 03:24:19 CEST 2006
On 21 Jul 2006 at 20:31, Scott Dial wrote:
> Furthermore, my callback functions from readline will not be passed any
> sort of "state", so how do I get that from within my callback function?
> Again, I thought a poor kludge was to tag reference to "state" onto the
> function during setup_readline.
> def setup_readline(state, w_module):
> cfunc = CFUNCTYPE(POINTER(c_char_p), c_char_p, c_int, c_int)
> c_rl_attempted_completion_function = cfunc(space.flex_complete)
> space.flex_complete.space = space
> def flex_complete(text, start, end):
> from pypy.module.readline.interp_readline import getstate
> getstate(flex_complete).begidx = start
> getstate(flex_complete).endidx = end
In ctypes that is easy: use a bound method as the callback. Does that
even work in rctypes?
<len-l at telus.net>
More information about the Pypy-dev