[C++-sig] Calling member function of object created in C++ via embedded Python
Ron Brown, Jr.
rbrown at gamry.com
Wed Apr 18 19:31:14 CEST 2007
Thanks John, I'll give that a shot!
John Reid wrote:
> If I have you right you might try this:
> typedef boost::shared_ptr< World > world_ptr;
> world_ptr worldObject( new World ), worldObject2;
> worldObject2 = extract<world_ptr>(resultObject);
> If you pass pointers to objects around instead of objects by value you
> will probably have more luck. The following line as it stands forces use
> of the copy constructor (if worldObject is of type World)
> dictionary["pyWorldObject"] = worldObject
> For boost.python to work with world_ptrs you will need to tell it about
> them, so add this to the BOOST_PYTHON_MODULE:
> register_ptr_to_python( world_ptr );
> There may be typos in the above but I think this is along the right sort
> of lines....
More information about the Cplusplus-sig