I SOLVED IT ... thanks for people who provided me help .. but i believe solved it myself. .haha .. took me long time..
so .. the solution is something like this.. in my c function ..which calls python call .. [code] PyObject *argobj = SWIG_NewPointerObj(SWIG_as_voidptr(&msg2), SWIGTYPE_p_RFAMessageWrapper, SWIG_POINTER_NEW | 0 ); try { arglist = Py_BuildValue("(O)",argobj); // Build argument list PyEval_CallObject(func,arglist); // Call Python } catch (...) { cout<<"Unknown exception..."<<endl; } [\code] I am using PyObject *argobj = SWIG_NewPointerObj(SWIG_as_voidptr(&msg2), SWIGTYPE_p_RFAMessageWrapper, SWIG_POINTER_NEW | 0 ); This was incorrect... i guess SWIG_POINTER_NEW is used to create pointer to the actual c++ object where as if I pass 0 PyObject *argobj = SWIG_NewPointerObj(SWIG_as_voidptr(&msg2), SWIGTYPE_p_RFAMessageWrapper, 0 | 0 ); This actually creates a pointer to the wrapped python object :) I could access my object in my python code now. I had to include std_string.i to enable string typemaps :) Thanks, Alok -----Original Message----- From: cplusplus-sig-bounces+alok.jadhav=credit-suisse....@python.org [mailto:cplusplus-sig-bounces+alok.jadhav=credit-suisse....@python.org] On Behalf Of Jadhav, Alok Sent: Wednesday, December 09, 2009 1:55 PM To: Development of Python/C++ integration Subject: Re: [C++-sig] Converintg C++ object to python object 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....@python.org [mailto:cplusplus-sig-bounces+alok.jadhav=credit-suisse....@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@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 ======================================================================== ======= _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@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 =============================================================================== _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig