[C++-sig] wrapping an abstract class with out parameters using boost.python

David Abrahams dave at boost-consulting.com
Mon Apr 17 00:09:23 CEST 2006


"Guillaume Desticourt" <guillaume.desticourt at gmail.com> writes:

> class DisplayDataWrap :
>   public DisplayData,
>   public wrapper<DisplayData>;
>
> to encapsulate the DisplayData::accept, i ve defined:
>
>   void DisplayDataWrap::accept(DisplayDataVisitor &visitor)
>   {
>     this->get_override("accept")(visitor);
>   }
>
> and in the module definition i do:
>  class_<DisplayDataWrap, boost::noncopyable>("PyDisplayData", no_init)
>     .def("accept", pure_virtual(&DisplayData::accept))
>     ;
>
> the problem is that i have no idea how to encapsulate:
> the DisplaData::getZone method...
> i tried
>   Zone getZone(void) const
>   {
>     Zone zone;
>     this->get_override("getZone")(zone);
>     return zone;
>   }
>
>  Zone (DisplayDataWrap::*getZone1)(void) const = &DisplayDataWrap::getZone;
>
>   class_<DisplayDataWrap, boost::noncopyable>("PyDisplayData", no_init)
>     .def("getZone", getZone1) ;
>
> and then i get the error messge
> RuntimeError: extension class wrapper for base class
> pimp::gfx2d::DisplayData has not been created yet
> and i am not even sure i ll be able to override the getZone in python...

Please post a minimal, reproducible testcase that shows your problem.
This should ideally be one C++ file (the extension module) and one
Python file that I can invoke to exercise it and demonstrate the problem.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list