Signed-off-by: Markus Armbruster <arm...@redhat.com> Reviewed-by: Eric Blake <ebl...@redhat.com> Message-Id: <1489582656-31133-44-git-send-email-arm...@redhat.com> --- scripts/qapi.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py index 735ddaa..f4d1a48 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -47,7 +47,7 @@ returns_whitelist = [] name_case_whitelist = [] enum_types = {} -struct_types = [] +struct_types = {} union_types = [] all_names = {} @@ -555,7 +555,7 @@ class QAPISchemaParser(object): def find_base_members(base): if isinstance(base, dict): return base - base_struct_define = find_struct(base) + base_struct_define = struct_types.get(base) if not base_struct_define: return None return base_struct_define['data'] @@ -565,7 +565,7 @@ def find_base_members(base): def find_alternate_member_qtype(qapi_type): if qapi_type in builtin_types: return builtin_types[qapi_type] - elif find_struct(qapi_type): + elif qapi_type in struct_types: return 'QTYPE_QDICT' elif qapi_type in enum_types: return 'QTYPE_QSTRING' @@ -638,19 +638,6 @@ def add_name(name, info, meta, implicit=False): all_names[name] = meta -def add_struct(definition, info): - global struct_types - struct_types.append(definition) - - -def find_struct(name): - global struct_types - for struct in struct_types: - if struct['struct'] == name: - return struct - return None - - def add_union(definition, info): global union_types union_types.append(definition) @@ -928,7 +915,7 @@ def check_exprs(exprs): elif 'struct' in expr: meta = 'struct' check_keys(expr_elem, 'struct', ['data'], ['base']) - add_struct(expr, info) + struct_types[expr[meta]] = expr elif 'command' in expr: meta = 'command' check_keys(expr_elem, 'command', [], -- 2.7.4