Boost logo

Boost Users :

From: Fredrik Wikström (fredrik.wikstrom_at_[hidden])
Date: 2006-01-16 15:40:20


Hi!

I have a polymorphic class in c++ like:

class Example
{
  public:
    void do_something() = 0;
    void do_something_more {}
}

This is wrap like:

#include <boost/python.hpp>
using namespace boost::python;

struct ExampleWrap : Example, wrapper<Example>
{
    void do_something()
    {
        this->get_override("do_something")();
    }
};

and finally:

BOOST_PYTHON_MODULE(test)
{
    class_<ExampleWrap, boost::noncopyable>("Example")
        .def("do_something", pure_virtual(&Window::do_something))
        .def("do_something_more", &Window::do_something_more)
    ;
}

This compiles fine, the python code that work looks like:

class Example(test.Example)
  def do_something(self):
    ...some code...

e = Example()
e.do_something_more()

The python code that doesn't work looks like:

class Example(test.Example)
  def __init__(self):
    ..some code...

  def do_something(self):
    ...some code...

e = Example()
e.do_something_more()

This generates the error:

e.do_something_more()
Boost.Python.ArgumentError: Python argument types in
    Example.do_something_more(Example)
did not match C++ signature:
    do_something_more(Example {lvalue})

How can I fix this? I really need to define a constructor in python class that
inherit from the c++ Example class.

/Fredrik

-----------------------------------------------
This mail was sent through www.lulea.cc


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net