|
|
@ -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) |
|
|
|