I'm trying to pass a proxy class instance (SWIG generated) of CClass,
to a python callback function from C++. The proxy class instance of
CClass is created from a pointer to the C++ class CClass.
Using the code below, I receive the error message:
"AttributeError : 'PySwigObject' object has no attribute 'GetName'"
The python callback function is being passed in through the clientdata
pointer, and the CClass *class pointer is what's being converted to an
instance of the SWIG proxy class and passed to the python callback
function as an argument.
static void PythonCallBack( CClass *class,void *clientdata)
{
PyObject *func, *arglist,*obj;
PyObject *result;
func = (PyObject *) clientdata; // Get Python function
obj = SWIG_NewPointer Obj((void*) cmd, SWIGTYPE_p_CSCS ICommand, 1);
//create instance of python proxy class from c++ pointer
arglist=Py_Buil dValue("(O)",*o bj); //convert to tuple
result = PyEval_CallObje ct(func,arglist ); // Call Python
Py_XDECREF(resu lt);
return;
}
Any input would greatly appreciated. Thanks,
Jeff
to a python callback function from C++. The proxy class instance of
CClass is created from a pointer to the C++ class CClass.
Using the code below, I receive the error message:
"AttributeError : 'PySwigObject' object has no attribute 'GetName'"
The python callback function is being passed in through the clientdata
pointer, and the CClass *class pointer is what's being converted to an
instance of the SWIG proxy class and passed to the python callback
function as an argument.
static void PythonCallBack( CClass *class,void *clientdata)
{
PyObject *func, *arglist,*obj;
PyObject *result;
func = (PyObject *) clientdata; // Get Python function
obj = SWIG_NewPointer Obj((void*) cmd, SWIGTYPE_p_CSCS ICommand, 1);
//create instance of python proxy class from c++ pointer
arglist=Py_Buil dValue("(O)",*o bj); //convert to tuple
result = PyEval_CallObje ct(func,arglist ); // Call Python
Py_XDECREF(resu lt);
return;
}
Any input would greatly appreciated. Thanks,
Jeff