I'm trying to figure whats wrong with some autogenerated (with Pyste) boost::python code, but have no luck so far.
There is C++ library, Magick++, which provides two classes, Magick::Drawable and 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 from DrawableBase
Drawable ( const DrawableBase& original_ );
...
}
class MagickDLLDecl DrawableRectangle : public DrawableBase
{ ... }
These are used as arguments for Image.draw():
https://www.imagemagick.org/subversion/ImageMagick/trunk/Magick++/lib/Magick++/Image.h
// Draw on image using a single drawable
void draw ( const Drawable &drawable_ );
// Draw on image using a drawable list
void draw ( const std::list<Magick::Drawable> &drawable_ );
I'm trying to make python bindings for it, there are autogenned wrappers for all the 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 to indirect class casts from DrawableBase to Drawable, these wrappers do 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)
# But abstract Drawable() does work:
>>> image.draw(PythonMagick._PythonMagick.Drawable())
>>>
Is there any better way to handle this than write my own draw() wrapper in C++, which would cast PyObject into Drawable?