[C++-sig] Re: Returning shared_ptr<boost::python::obj> to Python

David Abrahams dave at boost-consulting.com
Sat Sep 4 15:54:39 CEST 2004


"Jim" <jmastro at rochester.rr.com> writes:

>> I need to return the Python object to Python, and have the Python scripts
> call arbitrary methods
>> in them.
>
> I also need to pass the PyObject* I pulled out of the boost::python::object
> back to the C++ code. I have no clue how to do this. Trying to call a C++
> function expecting a shared_ptr<boost::python::object> and a Point results
> in this output:
>
> Boost.Python.ArgumentError: Python argument types in
>     MyClass.MyMethod(MyClass, instance, Point)
> did not match C++ signature:
>     MyMethod(class Module::Class {lvalue}, class boost::shared_ptr<class
> boost::python::api::object> {lvalue}, class Point)
>
> and unfortunately I'm not sure what to do to pass the object back to C++. I
> _must_ be going about this all wrong. Help?

Well, you could register a from-python conversion for
boost::shared_ptr<boost::python::object>, but my sense is that you're
going to drop the use of shared_ptr... or
boost::python::object... pretty soon.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list