On 2011-07-29 13:29, Johan Råde wrote:
On 2011-07-27 11:06, Johan Råde wrote:
What is missing here is code that converts X*, Y* and Z* to PyObject*.
How do I write that?
I figured out the answer:
boost::python::api::object(...).ptr()
No, that did not work.
When I run the following code
C++:
#include
#include
using boost::noncopyable;
using namespace boost::python;
class X : noncopyable {};
PyObject* f()
{
return api::object(new X).ptr();
}
BOOST_PYTHON_MODULE(Foo)
{
class_("X");
def("f", &f);
}
Python:
import Foo
Foo.f()
then an exception, with the following error string, is thrown from the
api::object constructor:
TypeError: No to_python (by-value) converter found for C++ type:
class X
Am I using api::object incorrectly, or should I not use api::object at
all but do something completely different?
--Johan