Python: class hierarchies; return pointer to base

Hi, I'm trying to use Boost.Python to create an extension module based on some existing code. Therein I have a class hierarchy which I would like to expose in a way that would make it possible to subclass any of its classes in python. I run into a problem when I try to expose C++ functions which return pointers to the base class of the hierarchy. In the minimal example I am using for testing purposes I have: // An abstract base class class abstract { ... virtual void thing() const = 0; }; // A conctrete subclass implemented in C++ class concrete : public abstract { ... virtual void thing const { ... } }; // Callback to allow happy subclassing of abstract in python class abstract_callback : public abstract { ... }; // Callback to allow happy subclassing of concrete in python class concrete_callback : public abstract { ... }; BOOST_PYTHON_MODULE_INIT(abstract) { ... python::class_builder<abstract, abstract_callback> abs_class(this_module, "abstract"); ... python::class_builder<concrete, concrete_callback> con_class(this_module, "concrete"); con_class.declare_base(abs_class); ... } This all works fine, until I try to expose to python a function such as abstract* ret_p_abs( ... ); When compiling (gcc 2.95.2) the module, I get the error no matching function for call to `py_extension_class_converters (boost::python::type<abstract *>)' I infer from comments in the source code that this is to be expected if the class in question has not been wrapped as an extension class. This makes sense, as abstract has, indeed, not been wrapped ... but I don't think that it should be; abstract_callback was created for that purpose. How should I proceed ? Thanks,
participants (1)
-
Jacek Generowicz