On 4/21/06, Rodrigue Cloutier <rod...@ho...> wrote:
>
> Hi Roman,
>
> It seems I have found a bug with typedefs. When using typedef types in
> default arguments, the namespace qualifier gets lost on the default
> argument.
I am aware of this kinds of bugs. pyplusplus just assigns default value, th=
at
GCC-XML reported. So, basically this is not py++ bug, but GCC-XML.
Also, you are not the first person who failed on this bug. So
pygccxml, the front-end
to GCC-XML, makes an attempt to fix this situation. It seems that you find =
new
use case, I will try to fix it, based on your example. Also, if you
can not wait or just
curious, or may be you want to contribute ( :-) ) you can take a look on
pygccxml/parser/patcher.py file
> The following code will produce the error:
>
> namespace core {
> struct foo {
> foo(){}
> };
> typedef foo fooType;
> }
>
> void* func( const core::fooType& position =3D core::fooType() );
> Will produce the following. Notice that fooType should be core::fooType()=
.
>
>
> bp::def( "func"
> , &func
> , ( bp::arg("arg0")=3DfooType() )
> , bp::return_value_policy< bp::return_opaque_pointer,
> bp::default_call_policies >() );
>
>
> Not using the typedef produces the correct output.
>
>
> void* func2( const core::foo& position =3D core::foo() );
>
> bp::def( "func2"
> , &func2
> , ( bp::arg("arg0")=3D::core::foo( ) )
> , bp::return_value_policy< bp::return_opaque_pointer,
> bp::default_call_policies >() );
>
> I will look on my side to see if I can fix it but I am still learning the
> library :)
Basically, if you have only few places you can fix them using next code:
mb =3D module_builder_t( ... )
func2 =3D mb.free_function( 'func2', arg_types=3D[None] )
#arg_types=3D[None] makes query more specific. It says function with one
argument of
#any type
func2.arguments[0].default_value =3D 'core::foo()'
> Thanks for the great work.
Enjoy.
> Rod
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|