diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-03-15 13:57:32 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-03-16 07:13:04 +0100 |
commit | ed285bf821eeb5d82bb2777707cc02b11194b7b1 (patch) | |
tree | e30987c1a9ba5fec66a65491651877d633085d65 /scripts/qapi.py | |
parent | 5f018446fe69ec85711db364e8d1f4c4de372bf5 (diff) |
qapi: struct_types is a list used like a dict, make it one
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1489582656-31133-44-git-send-email-armbru@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r-- | scripts/qapi.py | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py index 735ddaa605..f4d1a483e5 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', [], |