Re: [pygccxml-development] py++ generating invalid default args code
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2008-01-15 06:39:10
|
On Jan 15, 2008 1:02 AM, Allen Bierbaum <al...@vr...> wrote:
> I am wrapping a method that looks something like this:
>
> class MyClass
> {
> public:
> void init(const unsigned value=0,
> const ClassB valueb=ClassB(-10.0, 11.0),
> const float other_val=2.0);
> };
>
> When py++ wraps this it creates code like this:
>
> { //::MyClass::init
>
> typedef void ( ::MyClass::*init_function_type )( ::unsigned
> const,::ClassB const,::float const ) ;
>
> MyClass_exposer.def( "init"
> , init_function_type( &::MyClass::init )
> , ( bp::arg("value")=(unsigned char const)(0)
> , bp::arg("valueb")=::ClassB( (&-1.0e+1), (&1.1e+1)
> , bp::arg("other_val")=2.0e+0 ) );
> }
>
> As you can see the "&-1.0e+1" style values are invalid code and the
> compiler fails to build the code. Is this a know issue and is there a
> simple work around or way to prevent py++ from generating code that
> won't compile?
Yes, this is a known issue -
http://language-binding.net/pygccxml/design.html#patchers
You have few ways to fix the problem:
http://language-binding.net/pyplusplus/documentation/functions/default_args.html
or
mb = module_builder_t(...)
mb.mem_fun( '::MyClass::init' ).arguments[1].default_value =
'ClassB(-10.0, 11.0)'
Choose the one you like
HTH
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|