[C++-sig] Converintg C++ object to python object
Jadhav, Alok
alok.jadhav at credit-suisse.com
Wed Dec 9 05:54:53 CET 2009
When I pass a C++ object to Python function, I want to be able to use
that object using its Proxy class in the python code. How can I achieve
that?
Regards, Alok
-----Original Message-----
From: cplusplus-sig-bounces+alok.jadhav=credit-suisse.com at python.org
[mailto:cplusplus-sig-bounces+alok.jadhav=credit-suisse.com at python.org]
On Behalf Of Jadhav, Alok
Sent: Wednesday, December 09, 2009 10:13 AM
To: Development of Python/C++ integration
Subject: [C++-sig] Converintg C++ object to python object
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
========================================================================
=======
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
===============================================================================
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