|
@ -173,17 +173,15 @@ def _extract_typedef_decl(ast, name): |
|
|
|
|
|
|
|
|
res = utils.recursive_query(ast, filter) |
|
|
res = utils.recursive_query(ast, filter) |
|
|
if res: |
|
|
if res: |
|
|
ret = res.pop() |
|
|
ress = res.pop() |
|
|
|
|
|
if ress["utypekind"] == "Typedef" or ress["utypekind"] == "Elaborated": |
|
|
if ret["utypekind"] == "Typedef": |
|
|
ret = _extract_enum_decl(ast, ress["utype"]) |
|
|
ret = _extract_typedef_decl(ast, ret["utype"]) |
|
|
if not ret: |
|
|
elif ret["utypekind"] == "Elaborated": |
|
|
ret = _extract_struct_decl(ast, ress["utype"]) |
|
|
enum_decl = _extract_enum_decl(ast, ret["utype"]) |
|
|
if not ret: |
|
|
struct_decl = _extract_struct_decl(ast, ret["utype"]) |
|
|
ret = _extract_typedef_decl(ast, ress["utype"]) |
|
|
if enum_decl and struct_decl: |
|
|
else: |
|
|
assert False, "duplicate types" |
|
|
ret = ress |
|
|
else: |
|
|
|
|
|
ret = enum_decl or struct_decl |
|
|
|
|
|
|
|
|
|
|
|
return ret |
|
|
return ret |
|
|
|
|
|
|
|
@ -206,16 +204,32 @@ def _find_dup_types(data): |
|
|
return (all_types, list(dups)) |
|
|
return (all_types, list(dups)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_dup_types(types): |
|
|
|
|
|
ret = [] |
|
|
|
|
|
|
|
|
|
|
|
for type in types: |
|
|
|
|
|
dup = False |
|
|
|
|
|
for i in ret: |
|
|
|
|
|
if i["type"] == type["type"]: |
|
|
|
|
|
dup = True |
|
|
|
|
|
|
|
|
|
|
|
if not dup: |
|
|
|
|
|
ret.append(type) |
|
|
|
|
|
|
|
|
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Check for primitive type |
|
|
# TODO: Check for primitive type |
|
|
def _remove_typedefs_of_primitive(types): |
|
|
def _remove_typedefs_of_primitive(types): |
|
|
types_struct_enum = [] |
|
|
types_struct_enum = [] |
|
|
|
|
|
types_removed = [] |
|
|
for type in types: |
|
|
for type in types: |
|
|
if (type["kind"] == "CursorKind.TYPEDEF_DECL"): |
|
|
if (type["kind"] == "CursorKind.TYPEDEF_DECL"): |
|
|
pass |
|
|
types_removed.append(type) |
|
|
else: |
|
|
else: |
|
|
types_struct_enum.append(type) |
|
|
types_struct_enum.append(type) |
|
|
|
|
|
|
|
|
return types_struct_enum |
|
|
return (types_struct_enum, types_removed) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def extract_acid_selectively(ast, var_names, function_names): |
|
|
def extract_acid_selectively(ast, var_names, function_names): |
|
@ -246,7 +260,10 @@ def extract_acid_selectively(ast, var_names, function_names): |
|
|
acid["typerefs_notfound"] += notfound |
|
|
acid["typerefs_notfound"] += notfound |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acid["types"] = _remove_typedefs_of_primitive(acid["types"]) |
|
|
(struct_enum_types, types_removed) = _remove_typedefs_of_primitive(acid["types"]) |
|
|
|
|
|
acid["types"] = struct_enum_types |
|
|
|
|
|
acid["types_removed"] = types_removed |
|
|
|
|
|
acid["types"] = remove_dup_types(acid["types"]) |
|
|
acid["type_names"] = _extract_type_names(acid["types"]) |
|
|
acid["type_names"] = _extract_type_names(acid["types"]) |
|
|
|
|
|
|
|
|
return acid |
|
|
return acid |
|
|