Browse Source

ast parser, in FIELD_DECL only TYPE_REF allowed as children

master
heck 5 years ago
parent
commit
4e8ac205fb
  1. 9
      gen/ast_parser.py

9
gen/ast_parser.py

@ -29,7 +29,7 @@ class ASTParser:
else: else:
return [c for c in cursor.get_children() if c.location.file and c.location.file.name == path] return [c for c in cursor.get_children() if c.location.file and c.location.file.name == path]
def _parse(self, cursor, path, follow_includes=False): def _parse(self, cursor, path, follow_includes=False, parent_cursor=None):
item = None item = None
dont_recurse = False; dont_recurse = False;
# dont parse excluded CursorKinds # dont parse excluded CursorKinds
@ -99,6 +99,11 @@ class ASTParser:
if cursor.kind == CursorKind.TYPE_REF: if cursor.kind == CursorKind.TYPE_REF:
item["utypekind"] = cursor.type.kind.spelling item["utypekind"] = cursor.type.kind.spelling
if parent_cursor:
if( not cursor.kind == CursorKind.TYPE_REF
and parent_cursor.kind == CursorKind.FIELD_DECL):
return None
if not dont_recurse: if not dont_recurse:
# get direct children # get direct children
@ -106,7 +111,7 @@ class ASTParser:
if len(child_cursors) > 0: if len(child_cursors) > 0:
child_arr = [] child_arr = []
for child_cursor in child_cursors: for child_cursor in child_cursors:
child_result = self._parse(child_cursor, path, follow_includes=follow_includes) child_result = self._parse(child_cursor, path, follow_includes=follow_includes, parent_cursor=cursor)
if child_result: if child_result:
child_arr.append(child_result) child_arr.append(child_result)

Loading…
Cancel
Save