On Thu, Apr 30, 2009 at 9:45 AM, Germán Diago
Hello. After much googling I didn't find anything useful. My problem is:
I have a virtual function like this
class MyClass {
void monitor(Object * o); }
I have wrapped another class, which inherits from Object:
class Character : public Object {...};
which is also exposed to python.
I register my virtual function as the documentation says I have to do:
class_
("MyClass"). def("monitor", &MyClass::monitor); When I try to call it from python, I get the following error:
a = MyClass() b = Character(....) a.monitor(b)
MyClass.monitor(MyClass, Character) did not match C++ signature: monitorizar(MyClass {lvalue}, Object *)
For it to be able to convert, two things need to be true. 1) Object needs to be exposed to Python as well (although you might want to use another word, 'object' is a keyword in Python and 'Object' is awfully close to that). 2) Character needs to be exposed to Python with Object being specified as a baseclass in the class_ definition. I noticed that MyClass did not specify Object as its baseclass either, so if you intend to pass things around as their subclass type (Object), you should tell Python that Object is its baseclass too.