diff --git a/gen/ast_parser.py b/gen/ast_parser.py index 8edbd12..1944c74 100644 --- a/gen/ast_parser.py +++ b/gen/ast_parser.py @@ -29,19 +29,19 @@ class ASTParser: else: 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 dont_recurse = False; # dont parse excluded CursorKinds excluded_cursortypes = [CursorKind.INTEGER_LITERAL] if not cursor.kind in excluded_cursortypes: item = {"" - "tokens" : "", - "kind" : "", - "name" : "", - "type" : "", - "file" : "", - "is_definition" : "", + "tokens": "", + "kind": "", + "name": "", + "type": "", + "file": "", + "is_definition": "", } # generic info for all CursorKinds @@ -99,6 +99,11 @@ class ASTParser: if cursor.kind == CursorKind.TYPE_REF: 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: # get direct children @@ -106,7 +111,7 @@ class ASTParser: if len(child_cursors) > 0: child_arr = [] 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: child_arr.append(child_result)