On 06/12/2012 01:17, Jaedyn K. Draper wrote:
Hello everyone!
So I'm working on a little project in which I'm using Python as an embedded
scripting engine. So far I've not had much trouble with it using boost.python,
but there's something I'd like to do with it if it's possible.
Basically, Python can be used to extend my C++ classes by adding functions and
even data values to the class. I'd like to be able to have these persist in
the C++ side, so one python function can add data members to a class, and then
later the same instance passed to a different function will still have them.
The goal here being to write a generic core engine in C++, and let users
extend it in Python in any way they need without ever having to touch the C++.
So what I thought would work was that I would store a |boost::python::object|
in the C++ class as a value |self|, and when calling the python from the C++,
I'd send that python object through |boost::python::ptr()|, so that
modifications on the python side would persist back to the C++ class.
Unfortunately when I try this, I get the following error:
|TypeError: No to_python (by-value) converter found for C++ type:
boost::python::api::object|
Is there any way of passing an object directly to a python function like that,
or any other way I can go about this to achieve my desired result?
Please post some example code. Is it an option to aggregate a std::map<string,
bpy::object*> into the C++ class? It would serve somehow like a "__dict__" on
the C++ side.
--
Giuseppe Corbelli
WASP Software Engineer, Copan Italia S.p.A
Phone: +390303666318 Fax: +390302659932
E-mail: giuseppe.corbe...@copanitalia.com
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig