[C++-sig] Converintg C++ object to python object
Jadhav, Alok
alok.jadhav at credit-suisse.com
Wed Dec 9 02:13:04 CET 2009
In my C++ callback function below
[code]
static void PythonCallBack(RFAMessage *msg, void *clientdata)
{
PyObject *func, *arglist;
PyGILState_STATE state;
state = PyGILState_Ensure();
func = (PyObject *) clientdata; // Get Python function
RFAMessageWrapper msg2(msg);
PyObject *argobj = SWIG_NewPointerObj(SWIG_as_voidptr(&msg2),
SWIGTYPE_p_RFAMessageWrapper , SWIG_POINTER_NEW | 0 );
arglist = Py_BuildValue("(O)",argobj); // Build argument
list
PyEval_CallObject(func,arglist); // Call Python
Py_XDECREF(arglist); // Trash arglist
//SWIG_PYTHON_THREAD_END_BLOCK;
PyGILState_Release(state);
}
[/code]
Can you tell me if the usage of SWIG_NewPointerObj is correct? I want
to convert a C++ class object into python equivalent object. In the
python code, the passed object is identified as SwigPyObject and not
RFAMessageWrapper which I am expecting.
How can I convert RFAMessageWrapper object into its Python equivalent to
that in my Python function I can use the passed object as
RFAMessageWrapper.
Regards,
Alok
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================
More information about the Cplusplus-sig
mailing list