// This file has been generated by Py++. // Copyright 2004-2008 Roman Yakovenko. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "boost/python.hpp" #include "virtual_inheritance_to_be_exported.hpp" namespace bp = boost::python; struct base_wrapper : base, bp::wrapper< base > { base_wrapper(base const & arg ) : base( arg ) , bp::wrapper< base >(){ // copy constructor } base_wrapper() : base() , bp::wrapper< base >(){ // null constructor } virtual void do_smth( ) { if( bp::override func_do_smth = this->get_override( "do_smth" ) ) func_do_smth( ); else this->base::do_smth( ); } void default_do_smth( ) { base::do_smth( ); } }; struct derived_wrapper : derived, bp::wrapper< derived > { derived_wrapper(derived const & arg ) : derived( arg ) , bp::wrapper< derived >(){ // copy constructor } derived_wrapper() : derived() , bp::wrapper< derived >(){ // null constructor } virtual void do_smth( ) { if( bp::override func_do_smth = this->get_override( "do_smth" ) ) func_do_smth( ); else this->base::do_smth( ); } void default_do_smth( ) { base::do_smth( ); } }; BOOST_PYTHON_MODULE(virtual_inheritance){ bp::class_< base_wrapper >( "base", "documentation" ) .def( "do_smth" , (void ( ::base::* )( ) )(&::base::do_smth) , (void ( base_wrapper::* )( ) )(&base_wrapper::default_do_smth) ); bp::class_< derived_wrapper, bp::bases< base > >( "derived", "documentation" ) .def( "do_smth" , (void ( ::base::* )( ) )(&::base::do_smth) , (void ( derived_wrapper::* )( ) )(&derived_wrapper::default_do_smth) ); }