[Pyrex] callback
Bryan Weingarten
bryan.weingarten at pobox.com
Mon Aug 18 05:04:40 CEST 2003
i currently have a callback similar to the cheese demo. but i have a
problem i hope someone can help me resolve.
the following code works correctly... it's basically the "cheese" code:
class Play:
def status_callback(self, callback):
set_status_callback(self.ctx, _callback_wrapper, <void*>callback)
cdef int _callback_wrapper(void *callback, long sec, long msec):
return (<object>callback)(sec, msec)
my problem is that the i need user data to be passed into status_callback
which gets passed back to the python callback. the "cheese" way of doing
this is to cast the python callback function to a void* and pass it into the
user data field of the c function. unfortunately, this takes up the one and
only user data field and doesn't allow for the python user to pass in user
data. i tried to add the _callback_wrapper as a method of the class so i
could save the data as instance data, but pyrex complained about that... so
i'm at a loss now... can someone help me?
thanks,
bryan
More information about the Pyrex
mailing list