Ian already mentioned the possibility of writing your own type extension. Building on that notion... Ephi Dror writes:
1. At this point we are trying to wrap the C++ class as C, but our problem is, how do we pass a pointer from Python to C++ so we can keep the pointer to the class.
You can arrange that the methods of your type extension downcast the "self" pointer passed to them, to make it a pointer to your object, and then invoke member functions on it. Something like this: static PyObject * myext_meth1( PyObject *self, PyObject *args ) { MyObject *myo = static_cast<MyObject *>(self); return myo->meth1( args ); }
2. Is there any easer way to call the functions of C++ classes from python instead of wrapping them with C functions.
You can write scripts to automate the production of wrappers like that shown above. Or you can use CXX, as Ian mentioned. Some formalization of the techniques exhibited in CXX is what several of us regard as the end goal deliverable for this SIG. But it is proving challenging to do this, given the constraints of personal time and effort, as well as standards conformance. -- Geoffrey Furnish Actel Corporation furnish@actel.com Senior Staff Engineer 955 East Arques Ave voice: 408-522-7528 Placement & Routing Sunnyvale, CA 94086-4533 fax: 408-328-2303 "... because only those who write the code truly control the project." -- Jamie Zawinski