2008/6/29 Roman Yakovenko <rom...@gm...>:
> On Sun, Jun 29, 2008 at 7:03 PM, Gustavo Carneiro <gjc...@gm...>
> wrote:
> > I have a function[1] that extracts properties from a type, using
> > pygccxml.declarations.type_traits
> >
> > For a simple type, it does nothing, and the type name is unchanged. All
> is
> > well here:
> >
> > ***** type traits for '::uint64_t'
> > *** > return ('uint64_t', False, 0, False)
> >
> >
> > In the following case, I call type_traits.remove_const and
> > type_traits.remove_reference, and the resulting type then appears
> different:
> >
> > ***** type traits for '::uint64_t const &'
> > *** > return ('long unsigned int', True, 0, True)
> >
> > Yes, I know that in this system "long unsigned int" is the same as
> > uint64_t. But I would rather work with uint64_t, due to LLP/LP platform
> > differences.
> >
> > Any hints on how to work around this?
>
> Yes. You can improve the function. The first thing the current
> implementation does - it removes "typedef"'s, it simplifies a lot.
> Almost all functions in type_traits implemented this way.
>
> I am a little bit busy these days, if you can wait, I will take a look
> on it. If not the patch is welcome.
What I did was the obvious thing. Removed the remove_alias call, and it now
works perfectly for me :-)
I honestly don't understand why remove_alias is needed here :-/
Index: pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml/declarations/type_traits.py (revision 1362)
+++ pygccxml/declarations/type_traits.py (working copy)
@@ -171,7 +171,8 @@
If type is not pointer type, it will be returned as is.
"""
- nake_type = remove_alias( type )
+ #nake_type = remove_alias( type )
+ nake_type = type
if not is_pointer( nake_type ):
return type
elif isinstance( nake_type, cpptypes.volatile_t ) and isinstance(
nake_type.base, cpptypes.pointer_t ):
@@ -219,7 +220,8 @@
If type is not reference type, it will be returned as is.
"""
- nake_type = remove_alias( type )
+ #nake_type = remove_alias( type )
+ nake_type = type
if not is_reference( nake_type ):
return type
else:
@@ -236,7 +238,8 @@
If type is not const type, it will be returned as is
"""
- nake_type = remove_alias( type )
+ #nake_type = remove_alias( type )
+ nake_type = type
if not is_const( nake_type ):
return type
else:
>
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
>
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
|