Re: [pygccxml-development] Bug in virtual function wrapping with pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-05-23 19:51:11
|
> > Allen Bierbaum wrote: > > > > > > > > >namespace test_ns > > >{ > > >class Grandpa > > >{ > > >public: > > > virtual int gp_pure(int i) =3D 0; > > >}; > > > > > >class Father : public Grandpa > > >{ > > >public: > > > virtual int gp_pure(int i); > > >}; > > > > > >class Son : public Father > > >{ > > >public: > > >}; > > > > > >} // namespace test_ns You need to check out module_creator/creator.py file: Here is the code generated after I fixed the bug: #include "boost/python.hpp" #include "Classes.h" namespace bp =3D boost::python; struct Grandpa_wrapper : test_ns::Grandpa, bp::wrapper< test_ns::Grandpa > = { Grandpa_wrapper() : test_ns::Grandpa() , bp::wrapper< test_ns::Grandpa >() {} virtual int gp_pure( int i ){ bp::override func_gp_pure =3D this->get_override( "gp_pure" ); return func_gp_pure( i ); } }; struct Father_wrapper : test_ns::Father, bp::wrapper< test_ns::Father > { Father_wrapper(test_ns::Father const & arg ) : test_ns::Father( arg ) , bp::wrapper< test_ns::Father >() {} Father_wrapper() : test_ns::Father() , bp::wrapper< test_ns::Father >() {} virtual int gp_pure( int i ) { if( bp::override func_gp_pure =3D this->get_override( "gp_pure" ) ) return func_gp_pure( i ); else return test_ns::Father::gp_pure( i ); } virtual int default_gp_pure( int i ) { return test_ns::Father::gp_pure( i ); } }; BOOST_PYTHON_MODULE(pyplusplus){ bp::class_< Grandpa_wrapper, boost::noncopyable >( "Grandpa" ) .def("gp_pure" , bp::pure_virtual( &::test_ns::Grandpa::gp_pure ) , ( bp::arg("i") ) , bp::default_call_policies() ); bp::class_< Father_wrapper, bp::bases< test_ns::Grandpa > >( "Father" ) .def("gp_pure" , &::test_ns::Father::gp_pure , &Father_wrapper::default_gp_pure , ( bp::arg("i") ) , bp::default_call_policies() ); bp::class_< test_ns::Son, bp::bases< test_ns::Father > >( "Son" ); } Enjoy. --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |