Original Post
I'm having troubles using inheritance with Boost.Python. The documentation only gives examples for half of the inheritance tree if you've got virtual functions: the base class. It has no information on derived classes that have virtual functions. I've tried all the logic combinations, but it still doesn't work. Either I get an error that it can't convert a Derived into a Base, or I get an error that I'm calling a pure virtual function. The comments basically sum it up. Draw is pure virtual in Renderable, and it is implemented in Quad. I want to be able to make a quad inside a Python script and pass it to a C++ function that takes a Renderable* and then calls renderable->Draw(). Depending on what I use, I get either an error that it can't convert a Quad into a Renderable* or that I'm calling a pure virtual function. Any help would be appreciated!
struct RenderableWrap : Renderable, wrapper<Renderable>
{
public:
void Draw()
{
this->get_override("Draw")();
}
};
...
//This part I think is right
class_<RenderableWrap, boost::noncopyable>("Renderable")
.def("Draw",pure_virtual(&Renderable::Draw))
;
//This part I haven't the slightest clue
//Should it inherit from Renderable? Should it Use it's own wrapper class?
//Should it inherit from BOTH Renderable and RenderableWrap?
//Should it's wrapper inherit from Renderable or Quad or RenderableWrap or some combination there-of?
class_<Quad, bases<RenderableWrap> >("Quad",init<float, float, float, float>())
.def("SetColor",&Quad::SetColor)
.def("Draw",&Quad::Draw)
;