c++ - Boost::Python bindings for classes with inheritance -
i'm trying figure whats wrong autogenerated (with pyste) boost::python code, have no luck far.
there c++ library, magick++, provides 2 classes, magick::drawable
, magick::drawablerectangle
:
https://www.imagemagick.org/subversion/imagemagick/trunk/magick++/lib/magick++/drawable.h
class magickdlldecl drawablebase: public std::unary_function<magickcore::drawingwand,void> {...} class magickdlldecl drawable { public: // constructor drawable ( void ); // construct drawablebase drawable ( const drawablebase& original_ ); ... } class magickdlldecl drawablerectangle : public drawablebase { ... }
these used arguments image.draw()
: https://www.imagemagick.org/subversion/imagemagick/trunk/magick++/lib/magick++/image.h
// draw on image using single drawable void draw ( const drawable &drawable_ ); // draw on image using drawable list void draw ( const std::list<magick::drawable> &drawable_ );
i'm trying make python bindings it, there autogenned wrappers classes,
http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_drawable.cpp
http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_drawablerectangle.cpp
http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_image.cpp
problem is, due indirect class casts drawablebase drawable, these wrappers not work:
>>> import pythonmagick >>> image = pythonmagick.image() >>> square = pythonmagick._pythonmagick.drawablerectangle(0,0,200,200) >>> image.draw(square) traceback (most recent call last): file "<stdin>", line 1, in <module> boost.python.argumenterror: python argument types in image.draw(image, drawablerectangle) did not match c++ signature: draw(magick::image {lvalue}, std::list<magick::drawable, std::allocator<magick::drawable> >) draw(magick::image {lvalue}, magick::drawable) # abstract drawable() work: >>> image.draw(pythonmagick._pythonmagick.drawable()) >>>
is there better way handle write own draw() wrapper in c++, cast pyobject drawable?
if want bp implicitly convert objects foy , must tell bp thay implicitly convertable. put in bp::code:
boost::python::implicitly_convertible<sourcetype,desttype>();
i not know how induce pyste this.
Comments
Post a Comment