Browse Source

Array Support added.

master
heck 5 years ago
parent
commit
1b452adcc4
  1. 24
      pEpACIDgen/ast_2_acid.py

24
pEpACIDgen/ast_2_acid.py

@ -129,7 +129,7 @@ def _extract_enum_decl(ast, name):
def filter(data): def filter(data):
if (data["kind"] == "CursorKind.ENUM_DECL" 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 and data["type"] == name
): ):
return True return True
@ -148,7 +148,7 @@ def _extract_struct_decl(ast, name):
def filter(data): def filter(data):
if (data["kind"] == "CursorKind.STRUCT_DECL" 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 and data["type"] == name
): ):
return True return True
@ -174,12 +174,20 @@ def _extract_typedef_decl(ast, name):
res = utils.recursive_query(ast, filter) res = utils.recursive_query(ast, filter)
if res: if res:
ress = res.pop() ress = res.pop()
if ress["utypekind"] == "Typedef" or ress["utypekind"] == "Elaborated": if (ress["utypekind"] == "Typedef"
ret = _extract_enum_decl(ast, ress["utype"]) 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: if not ret:
ret = _extract_struct_decl(ast, ress["utype"]) ret = _extract_struct_decl(ast, type)
if not ret: if not ret:
ret = _extract_typedef_decl(ast, ress["utype"]) ret = _extract_typedef_decl(ast, type)
else: else:
ret = ress ret = ress
@ -235,8 +243,8 @@ def _remove_typedefs_of_primitive(types):
def extract_acid_selectively(ast, var_names, function_names): def extract_acid_selectively(ast, var_names, function_names):
# ACID # ACID
acid = {"functions": "", acid = {"functions": "",
"vars": "", "vars": "",
"types": ""} "types": ""}
# stage 1: extract functions and vars # stage 1: extract functions and vars
(acid["functions"], acid["functions_notfound"]) = _extract_functions_named(ast, function_names) (acid["functions"], acid["functions_notfound"]) = _extract_functions_named(ast, function_names)

Loading…
Cancel
Save