[Pyrex] pointer to function

Stefano Esposito stefano.esposito87 at gmail.com
Sat Sep 8 23:27:47 CEST 2007


Hi all,

i'm trying to wrap a function that takes as argument a pointer to function, my idea is to do something like this:

	ctypedef alpm_cb_download
	void alpm_option_set_dlcb (alpm_cb_download down)
	...
	
	global pydl_cb
	cdef void dl_cb(char *filename, int trans, int tot):
		pydl_cb (filename, trans, tot)
	
	...
	def init ([...]):
		...
		alpm_set_dlcb (dl_cb) <-- failing here
		...
	def set_dlcb (down):
		pydl_cb = down
	...

where down is a python function. That way the user could define a python function and the library could use a C function. However this is failing at pyrexc with
alpm.pyx:27:26: Cannot convert 'void ((char (*),int ,int ))' to Python object. Where's my error? :)

-- 
Stefano Esposito <stefano.esposito87 at gmail.com>



More information about the Pyrex mailing list