From 1b452adcc4879fe084b53cf9548a8fe87244ca6c Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 23 Jan 2021 13:22:44 +0100 Subject: [PATCH] Array Support added. --- pEpACIDgen/ast_2_acid.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pEpACIDgen/ast_2_acid.py b/pEpACIDgen/ast_2_acid.py index 1c342c1..26eacf5 100755 --- a/pEpACIDgen/ast_2_acid.py +++ b/pEpACIDgen/ast_2_acid.py @@ -129,7 +129,7 @@ def _extract_enum_decl(ast, name): def filter(data): if (data["kind"] == "CursorKind.ENUM_DECL" - and data["is_definition"] == True # no forward decl + and data["is_definition"] == True # no forward decl and data["type"] == name ): return True @@ -148,7 +148,7 @@ def _extract_struct_decl(ast, name): def filter(data): if (data["kind"] == "CursorKind.STRUCT_DECL" - and data["is_definition"] == True # no forward decl + and data["is_definition"] == True # no forward decl and data["type"] == name ): return True @@ -174,12 +174,20 @@ def _extract_typedef_decl(ast, name): res = utils.recursive_query(ast, filter) if res: ress = res.pop() - if ress["utypekind"] == "Typedef" or ress["utypekind"] == "Elaborated": - ret = _extract_enum_decl(ast, ress["utype"]) + if (ress["utypekind"] == "Typedef" + or ress["utypekind"] == "Elaborated" + or ress["utypekind"] == "ConstantArray" + or ress["utypekind"] == "Pointer"): + + type = ress["utype"] + if (ress["utypekind"] == "ConstantArray" or ress["utypekind"] == "Pointer"): + type = ress["utype"].split(' ')[0] + + ret = _extract_enum_decl(ast, type) if not ret: - ret = _extract_struct_decl(ast, ress["utype"]) + ret = _extract_struct_decl(ast, type) if not ret: - ret = _extract_typedef_decl(ast, ress["utype"]) + ret = _extract_typedef_decl(ast, type) else: ret = ress @@ -235,8 +243,8 @@ def _remove_typedefs_of_primitive(types): def extract_acid_selectively(ast, var_names, function_names): # ACID acid = {"functions": "", - "vars": "", - "types": ""} + "vars": "", + "types": ""} # stage 1: extract functions and vars (acid["functions"], acid["functions_notfound"]) = _extract_functions_named(ast, function_names)