As Francesco noted, you can skip the elements. The above code example does not work anymore due to changes in the latest version of cindex.py.
The following is a minimal example of getting specific nodes from AST.
example.cpp file:
int i; char var[10]; double tmp; int add (int a, int b) { int r; r=a+b; return (r); }
Python code example:
import sys from clang.cindex import * index = Index.create() tu = index.parse('example.cpp') root_node = tu.cursor
if you want the type of each element of the array u to go through:
result[1].type.element_type.kind #######OUTPUT###### >>> TypeKind.CHAR_S
since modul cindex.py is well documented, it should not be difficult to find how to get the necessary information.
source share