summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorWenchao Xia2014-03-05 03:44:31 +0100
committerLuiz Capitulino2014-03-11 14:07:41 +0100
commitdad1fcab91bf101a02151069036d416367b59c5c (patch)
tree876b69f56572ed1ea2214840729540989b8dc4d5 /scripts
parentMerge remote-tracking branch 'remotes/kraxel/tags/pull-input-5' into staging (diff)
downloadqemu-dad1fcab91bf101a02151069036d416367b59c5c.tar.gz
qemu-dad1fcab91bf101a02151069036d416367b59c5c.tar.xz
qemu-dad1fcab91bf101a02151069036d416367b59c5c.zip
qapi script: remember explicitly defined enum values
Later other scripts will need to check the enum values. Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index f3c2a2037a..023930ea0c 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -169,7 +169,7 @@ def parse_schema(fp):
for expr in schema.exprs:
if expr.has_key('enum'):
- add_enum(expr['enum'])
+ add_enum(expr['enum'], expr['data'])
elif expr.has_key('union'):
add_union(expr)
add_enum('%sKind' % expr['union'])
@@ -289,13 +289,19 @@ def find_union(name):
return union
return None
-def add_enum(name):
+def add_enum(name, enum_values = None):
global enum_types
- enum_types.append(name)
+ enum_types.append({"enum_name": name, "enum_values": enum_values})
-def is_enum(name):
+def find_enum(name):
global enum_types
- return (name in enum_types)
+ for enum in enum_types:
+ if enum['enum_name'] == name:
+ return enum
+ return None
+
+def is_enum(name):
+ return find_enum(name) != None
def c_type(name):
if name == 'str':