[C++-sig] Another bug in pyplusplus
Niall Douglas
s_sourceforge at nedprod.com
Sun Jun 18 05:14:40 CEST 2006
If you disable use of keywords using
mb.calldefs().use_keywords=False, pyplusplus also stops inserting
default argument values into its wrappers eg;
int FXDialogBox::execute(int placement=DEFAULT)
... should become
virtual ::FX::FXuint execute( ::FX::FXuint placement =
FX::DEFAULT ) {
if( bp::override func_execute = this->get_override( "execute"
) )
return func_execute( placement );
else
return FX::FXDialogBox::execute( placement );
}
Unfortunately, it's missing the default argument. To fix this,
replace calldef_wrapper_t.args_declaration() with:
def args_declaration( self ):
args = []
boost_obj = algorithm.create_identifier( self,
'::boost::python::object' )
for index, arg in enumerate( self.declaration.arguments ):
result = arg.type.decl_string + ' ' +
self.argument_name(index)
if arg.default_value:
if not declarations.is_pointer( arg.type ) or
arg.default_value != '0':
result += '=%s' % arg.default_value
else:
result += '=%s()' % boost_obj
args.append( result )
if len( args ) == 1:
return args[ 0 ]
return ', '.join( args )
Another point - I believe the default_X function doesn't need to be
virtual. By making it so, you're introducing an unnecessary
inefficiency:
virtual ::FX::FXuint default_execute( ::FX::FXuint placement ) {
return FX::FXDialogBox::execute( placement );
}
Cheers,
Niall
More information about the Cplusplus-sig
mailing list