How to export non virtual protected functions?
Good morning. I have a question regardless exposing protected functions. 1. What is the right way to export do_it function ? struct S1{ protected: void do_it(){} }; User should be able to derive in Python from S1 and to use do_it function. This is the code that pyplusplus generates right now. Pyste doesn't treat this use case too. ( So can't use it for solution ). namespace bp = boost::python; BOOST_PYTHON_MODULE(pyplusplus){ bp::class_< S1 >( "S1" ); bp::class_< S2, bp::bases< S1 > >( "S2" ); } There are a few possible solutions, also all of them includes creating wrapper class. I created this wrapper for S1. namespace bp = boost::python; struct S1_wrapper : S1, bp::wrapper< S1 > { void do_it( ){ if( bp::override do_it = this->get_override( "do_it" ) ) do_it( ); else S1::do_it( ); } void default_do_it( ){ S1::do_it( ); } }; solution 1: 1. S1_wrapper::do_it should be deleted 2. bp::class_< S1 >( "S1" ); becomes bp::class_< S1_wrapper >( "S1" ) .def( "do_it", &S1_wrapper::default_do_it ); solution 2: To treat do_it as virtual function. solution 3: Your solution comes here. Thanks for the help. Roman Yakovenko
participants (1)
-
Roman Yakovenko