Re: [pygccxml-development] Incorrect code due to parameter default values
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2008-10-27 12:24:49
|
On Mon, Oct 27, 2008 at 12:39 PM, Paul Melis <pa...@sc...> wrote: > Hello, > > Py++ generates incorrect code for me that won't compile, this is with > the svn version of yesterday. > The real problem is gccxml's stupid handling of parameter default > values, where it > only stores the argument value literally found during parsing, which is > obviously dependent on context. > > I.e. when gccxml parses > > namespace doh { > enum E { ONE, TWO, THREE }; > void f(int a, int b = THREE); > } > > it stores for the default value of parameter b "THREE", instead of > "doh::THREE". > Py++ then generates code that isn't put inside namespace doh, but DOES > use the value THREE. Which won't compile... > > I seem to recall there was a patch for this some time ago for Py++. > Should that patch have solved all instances of this problem? > If not, would patching the gccxml output be an appropriate way of > working around this? (I.e. replacing THEE with doh::THREE). The long version: http://language-binding.net/pygccxml/upgrade_issues.html#free-and-member-function-default-arguments The short version: there is nothing I can do about this and you will have to replace default value from the script: #f is "calldef_t" instance for arg in f.arguments: arg.default_value = <<<new default value or None>>> Another approach is described here: http://language-binding.net/pyplusplus/documentation/functions/default_args.html HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |