Let python call a C function pointer passed from the C Python API
hvictor at bluewin.ch
Mon Nov 16 14:04:48 CET 2009
I have C++ a void function pointer stored in a variable call. The
pointed function takes an int and a char* as arguments.
I have a python module containing this function:
return "pointer called"
As you can see I'm trying to use the argument x of the function like a
In the C++ side I'm doing following (note that I only paste relevant
parts of code because this system is working fine, C++ is able to call
function yeah and get its return value, but only with a string-
PyObject *pValue; // the argument for python
pValue = PyCObject_FromVoidPtr(call,destr); // destr is a void fctn
ptr, required from the api.
PyObject *pFunc = PyObject_GetAttrString(pModule, "yeah");
PyTuple_SetItem(pArgs, 0, pValue); // pArgs is a pyobject, the
arguments, I insert pValue in it.
pValue = PyObject_CallObject(pFunc, pArgs);
It does not work. can anyone help me please? I just want python to
call this function pointer.
More information about the Python-list