aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorWenchao Xia <wenchaoqemu@gmail.com>2014-03-04 18:44:31 -0800
committerLuiz Capitulino <lcapitulino@redhat.com>2014-03-11 09:07:41 -0400
commitdad1fcab91bf101a02151069036d416367b59c5c (patch)
tree876b69f56572ed1ea2214840729540989b8dc4d5 /scripts/qapi.py
parentc57ec3249e9839c7ea2e3789f6e40f9ec1c92f55 (diff)
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/qapi.py')
-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':