[Pyrex] Re: callback
Bryan Weingarten
bryan.weingarten at pobox.com
Mon Aug 18 16:35:41 CEST 2003
i'm not sure if it helps, but here is the declarations from the header i'm
using.
cdef extern from "../playif.h":
ctypedef int (*status)(void *, long, long)
void set_status_callback(int, status, void*)
> class Play
> def status_callback(self, callback, user_data):
> data = (callback, user_data)
> set_status_callback(self.ctx, _callback_wrapper, <void*>data)
>
> cdef int _callback_wrapper(void *data, long sec, long msec):
> callback, user_data = <object>data # this is line 56
> return callback(data, sec, msec)
>
> when i compile this i get the following error
> C:\src>mpgedit.pyx:56:20: Cannot convert 'void (*)' to Python object
>
> when i use the global variable technique as pedro suggested i get an
> additional error
> C:\src>mpgedit.pyx:49:8: '%s' redeclared
> C:\src>mpgedit.pyx:55:20: Cannot convert 'void (*)' to Python object
>
> line 49 is the "global data" line
>
>
> john,
>
> i would prefer to use your Py_INCREF and Py_DECREF since i'm used to using
> that when i write extesions manually. but i don't see how use it in my
> case. in my example, i don't see where to Py_INCREF or Py_DECREF.
>
>
> bryan
>
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
>
More information about the Pyrex
mailing list