On Sun, 2012-06-03 at 21:25 -0700, Matt Rice wrote:
this patch allows you to loop over gdb.NamespaceDecl's from the
global_namespace,
and get at declarations, and some various things needed along the way.
Thanks! I haven't looked much at C++ support, so any help here is
welcome.
I've pushed your patch as 6aa5979fe81194a1a962fa6007930cafda268605 (plus
a subsequent fix for a missing Py_INCREF I spotted in
gcc_NamespaceDecl_unalias - functions return a new reference on their
return value, if not NULL).
I wasn't quite sure on where to put the functions i added to
gcc-python-tree.c
or if they are named inappropriately.
They look reasonable, so I didn't change
your patch. Please try to
stick to 4-space indentation though.
one strange thing i suppose is the alias_of/unalias duality,
in gccint it says:
Do not attempt to use `cp_namespace_decls' for a namespace which is
an alias. Instead, follow `DECL_NAMESPACE_ALIAS' links until you
reach an ordinary, non-alias, namespace, and call
`cp_namespace_decls' there.
Note to self: this is in:
http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gccint/Namespaces.html
alias_of calls DECL_NAMESPACE_ALIAS once, and returns None if not an
alias
while unalias does the looping, and returns self if not an alias.
turns out DECL_NAMESPACE_ALIAS seems to always return the same alias
as looping over it.
rather than the actual alias (in alias of alias cases),
thus the looping doesn't seem to be doing much,
but I kept both around for the None vs Self behaviour.
if this behaves differently on various gcc's i'll have to do something
about the test.
though, now that I think about it maybe I should get rid of alias_of,
and turn it into is_alias returning a BOOL, let me know what you prefer.
couldn't think of a better name than unalias, but didn't particularly like it.
Well, we're not API frozen at this stage of the plugin's development, so
you can always change it, I guess. I'm not doing much C++, so I don't
have a strong opinion here.
Thanks again for the patch!
Dave