[C++-sig] pyplusplus tutorials & GUI wizard

Roman Yakovenko roman.yakovenko at gmail.com
Thu Feb 9 12:45:54 CET 2006


On 2/9/06, Matthias Baas <baas at ira.uka.de> wrote:
> Roman Yakovenko wrote:
> Sorry, the example in my previous mail was not the original example. I
> left away the actual default argument that I deemed only to be a minor
> detail, but as it turned out it's actually the key to produce the
> failure. Now here's another (verified!) example:
>
> enum spam { eggs };
> void foo(unsigned int v=eggs);
>
> If I wrap this code pyplusplus generates:
>
>      bp::def( "foo"
>              , &foo
>              , ( bp::arg("arg0")=unsigned int( ::::eggs ) )
>              , bp::default_call_policies() );
>
> This code generates a compile error (using gcc 3.3.4). You have to
> replace "unsigned int" with "(unsigned int)".

Now you are talking :-).

First of all the bug has been fixed. You can check out only pygccxml package.
Second. There are few things happen here. GCC-XML sometimes generates
invalid default argument string. pygccxml tries to fix it. So the
exact case\source
is important.

> This example even reveals two more bugs that my original code doesn't
> show. The four colons before "eggs" also produce a compile error, this
> should only be two colons.
> And then, for some reason, pyplusplus doesn't see the correct name ("v")
> of the argument and just calls it "arg0" in the bindings.

There is nothing I can do. GCC-XML does not report argument name :-(.
I have to find time and to submit few bugs to GCC-XML.

Any way, :-), if the name of argument is important to you, there is
something you can do:
you can find relevant function, and then you can rename arguments.
Relevant classes are:
    pygccxml.declarations.calldef_t -
        it contains "arguments" property - list of all function arguments.
    pygccxml.declarations.argument_t - class that defines argument
:-)

> - Matthias -

Thanks for bug reporting.

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list