pygccxml icon indicating copy to clipboard operation
pygccxml copied to clipboard

Loop over declarations inside a template

Open ombre5733 opened this issue 7 years ago • 1 comments

Is there a way to loop over the types defined inside a template? I'm currently testing the library with the following code:

namespace A {
struct B {
  struct D { bool d; };
};
struct D {};

template <typename T1, typename T2>
struct T {
  struct E { int e; };
};

T<B::D, bool> fun();
}

Starting with namespace A, I'm able to go to the template declaration but then I'm stuck.

>>> decls = pgx.parser.parse_string(cppsource, pgx_config)
>>> globalNamespace = pgx.declarations.get_global_namespace(decls)
>>> aNamespace = globalNamespace.namespace("A")

>>> x = aNamespace.declarations[2]
>>> x.decl_string
'::A::T<A::B::D, bool>'
>>> x.declarations
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'class_declaration_t' object has no attribute 'declarations'

Is there somewhere a link from class_declaration_t to the scope so that I can recurse into the template?

ombre5733 avatar Apr 15 '17 18:04 ombre5733