I have a C header with:
typedef struct
{
<normal members>
void (*cb_func)(glp_tree *T, void *info);
void *cb_info;
<normal members>
} glp_iocp;
Currently, in my pxd file:
ctypedef struct IntOptCP "glp_iocp":
<normal members>
int out_dly # mip.out_dly (milliseconds)
#void (*cb_func)(Tree* tree, void* info)
# mip.cb_func
#void* cb_info # mip.cb_info
<normal members>
In a pyx file, at some point, I do (essentially):
cdef class MyClass:
IntOptCP _iocp
<__cintit__ and the like>
def some_method(self):
<manipulation of self._iocp>
controls = dict()
controls = self._iocp
return controls
This works nicely. However, now I also wish to expose cb_func
and cb_info
. This then breaks the assignment to controls. What I would like to have is two python object types (classes?), one for cb_func
and one for cb_info
, instances of which can be passed through to cb_func
and cb_info
arguments of the glp_iocp
struct.
I have read https://github.com/cython/cython/tree/master/Demos/callback (and have used pycapsule), but nevertheless, I am too inexperienced/unfamiliar with Cython to see how I can use that information for my specific case.
So, any help and pointers on how to (best) expose cb_func
and cb_info
are welcome.