Re: [pygccxml-development] py++ generating invalid default args code
Brought to you by:
mbaas,
roman_yakovenko
|
From: Allen B. <al...@vr...> - 2008-01-15 14:14:51
|
Is there a way to detect this problem is happening and output an error
with a link to the documentation? The way it works now where it
generates code that doesn't compile seems a bit problematic to me. I
don't think a new user would be able to decipher what is going on and
determine what they need to fix.
-Allen
Roman Yakovenko wrote:
> 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
>
|