[C++-sig] Creating python objects from C++

tom tom at muzzylane.com
Mon Oct 28 23:03:15 CET 2002


Hi
 
I'm embedding a Python interpreter in a C++ application and am trying to
use Boost.Python to connect the two.  I've got it hooked up and can
access my application from Python, and subclass C++ objects inside the
interpreter and it works perfectly!
 
The tricky part is that I need to drive this process from the C++ side,
instead of the Python side.  I need the ability to extend C++ objects
with Python methods, but to create and maintain those objects from C++.
I haven't seen anything in the mailing list or the docs about how to do
this.
 
I've been trying to pass back the PyTypeObject* for a given class back
to C++ and create the objects using the _PyObject_New function described
in the Python documentation, but I haven't been able to pass it back to
C++.  I get 
 
"TypeError: No registered converter was able to extract a C++ reference
to type struct _typeobject from this Python object of type
Boost.Python.class."
 
Is there a better way to do this? Or if not, what's the best way to
write a converter to pull out the PyTypeObject information?
 
Thanks
Tom McCormack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20021028/d1a44fe5/attachment.htm>


More information about the Cplusplus-sig mailing list