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:40:39
|
Allen, there is no work around for this bug, so I work on it right now.
I believe you will have an answer pretty soon.
On 5/23/06, Allen Bierbaum <al...@vr...> wrote:
> I should also have mentioned that as of yet I have not found a work
> around for this bug.
>
> I tried to work around it by "finalizing" the Son class, but I can't
> find a reliable way to finalize a class with pyplusplus. Until then I
> think I am at an impass. :(
>
> -Allen
>
>
> Allen Bierbaum wrote:
>
> > I think I have found a bug in the handling of virtual methods with
> > pyplusplus.
> >
> > I have attached a set of test classes and the generated bindings.
> >
> > The problem seems to be that when you have 3 classes derived from each
> > other as:
> >
> > class Grandpa
> > class Father : public Grandpa
> > class Son : public Father
> >
> > And Grandpa declares a pure virtual method that is defined in Father
> > but just used in Son, the wrapper for Son still thinks it is a pure
> > virtual and doesn't know to generate code with the default
> > implementation in Father. (See the attached code, it really makes
> > more sense with an example)
> >
> > -Allen
> >
> >------------------------------------------------------------------------
> >
> >// This file has been generated by pyplusplus.
> >
> >#include "boost/python.hpp"
> >
> >#include "/home/allenb/temp/pypp_test/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 );
> > }
> >
> >};
> >
> >struct Son_wrapper : test_ns::Son, bp::wrapper< test_ns::Son > {
> >
> > Son_wrapper(test_ns::Son const & arg )
> > : test_ns::Son( arg )
> > , bp::wrapper< test_ns::Son >()
> > {}
> >
> > Son_wrapper()
> > : test_ns::Son()
> > , bp::wrapper< test_ns::Son >()
> > {}
> >
> > virtual int gp_pure( int i ){
> > bp::override func_gp_pure =3D this->get_override( "gp_pure" );
> > return func_gp_pure( i );
> > }
> >
> >};
> >
> >BOOST_PYTHON_MODULE(_test){
> > 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_< Son_wrapper, bp::bases< test_ns::Father > >( "Son" )
> > .def("gp_pure"
> > , bp::pure_virtual( &::test_ns::Grandpa::gp_pure )
> > , ( bp::arg("i") )
> > , bp::default_call_policies() );
> >}
> >
> >
> >------------------------------------------------------------------------
> >
> >
> >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
> >
> >
>
>
>
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> Fully trained technicians. The highest number of Red Hat certifications i=
n
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D107521&bid=3D248729&dat=
=3D121642
> _______________________________________________
> pygccxml-development mailing list
> pyg...@li...
> https://lists.sourceforge.net/lists/listinfo/pygccxml-development
>
--=20
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|