Re: [pygccxml-development] Function adaptors
Brought to you by:
mbaas,
roman_yakovenko
|
From: Berserker <ber...@ho...> - 2009-08-20 08:15:48
|
> >> ::boost::python::class_< Foo_wrapper, ::boost::noncopyable >( "Foo",
> >> ::boost::python::init< >() )
> >> .def(
> >> "public_virtual"
> >> , (void ( ::Foo::* )( ) )(&::Foo::public_virtual)
> >> , (void ( Foo_wrapper::* )( )
> >> )(&Foo_wrapper::default_public_virtual) )
> >> .def(
> >> "protected_virtual"
> >> , (void ( ::Foo::* )( ) )(&::Foo_wrapper::protected_virtual)
> >> , (void ( Foo_wrapper::* )( )
> >> )(&Foo_wrapper::default_protected_virtual) ) );
> >
> > The only "hack" is the bad cast in the line "(void ( ::Foo::* )( )
> > )(&::Foo_wrapper::protected_virtual)"
> > but I tested the code from Python to C++ and from C++ to Python and now it
> > works as I expected!
>
> I am pretty sure this is illegal. Today, Py++ generates valid code for
> wide range of compilers and os. I think this change will break some of
> them.
I made some other tests :)
If I simply declare (assuming that we always have a wrapper class):
> ::boost::python::class_< Foo_wrapper, ::boost::noncopyable >( "Foo",
> ::boost::python::init< >() )
> .def(
> "public_virtual"
> , (void ( Foo_wrapper::* )( )) (&Foo_wrapper::default_public_virtual) )
> .def(
> "protected_virtual"
> , (void ( Foo_wrapper::* )( )(&Foo_wrapper::default_protected_virtual) ) );
virtual public/protected functions (with "base" call from Python) works as expected
with no "hacks" (tested from Python<->C++).
Why Py++ declares virtual public/protected functions as:
> .def("public_virtual", (void ( ::Foo::* )( ) )(&::Foo::public_virtual),
> (void ( Foo_wrapper::* )( )(&Foo_wrapper::default_public_virtual) )
insted of simply:
> .def("public_virtual", (void ( Foo_wrapper::* )( )(&Foo_wrapper::default_public_virtual) )
when we have a wrapper class?
I hope that this change seems reasonable to you.
P.S.: Thanks for your patience :D :D :D
_________________________________________________________________
Scarica i nuovi gadget per personalizzare Messenger!
http://www.messenger.it/home_gadget.aspx |