summaryrefslogtreecommitdiffstats
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorAnthony Liguori2013-07-26 23:54:19 +0200
committerAnthony Liguori2013-07-26 23:54:19 +0200
commit405c97c3a5950d8a49b90cb977e33b6b3f9a8f95 (patch)
tree0ea08a86ce91960577be3b720de34a0dddfe7623 /scripts/qapi.py
parentseccomp: removing unused syscalls gtom whitelist (diff)
parentAdd tests for sync modes 'TOP' and 'NONE' (diff)
downloadqemu-405c97c3a5950d8a49b90cb977e33b6b3f9a8f95.tar.gz
qemu-405c97c3a5950d8a49b90cb977e33b6b3f9a8f95.tar.xz
qemu-405c97c3a5950d8a49b90cb977e33b6b3f9a8f95.zip
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# By Kevin Wolf (16) and Ian Main (2) # Via Kevin Wolf * kwolf/for-anthony: Add tests for sync modes 'TOP' and 'NONE' Implement sync modes for drive-backup. Implement qdict_flatten() blockdev: Split up 'cache' option blockdev: Rename 'readonly' option to 'read-only' qcow2: Use dashes instead of underscores in options blockdev: Rename I/O throttling options for QMP QemuOpts: Add qemu_opt_unset() block: Allow "driver" option on the top level qapi: Anonymous unions qapi.py: Maintain a list of union types qapi: Add consume argument to qmp_input_get_object() qapi: Flat unions with arbitrary discriminator qapi: Add visitor for implicit structs docs: Document QAPI union types qapi-visit.py: Implement 'base' for unions qapi-visit.py: Split off generate_visit_struct_fields() qapi-types.py: Implement 'base' for unions Message-id: 1374870032-31672-1-git-send-email-kwolf@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r--scripts/qapi.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index baf13213a9..38c808e256 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -17,6 +17,21 @@ builtin_types = [
'uint8', 'uint16', 'uint32', 'uint64'
]
+builtin_type_qtypes = {
+ 'str': 'QTYPE_QSTRING',
+ 'int': 'QTYPE_QINT',
+ 'number': 'QTYPE_QFLOAT',
+ 'bool': 'QTYPE_QBOOL',
+ 'int8': 'QTYPE_QINT',
+ 'int16': 'QTYPE_QINT',
+ 'int32': 'QTYPE_QINT',
+ 'int64': 'QTYPE_QINT',
+ 'uint8': 'QTYPE_QINT',
+ 'uint16': 'QTYPE_QINT',
+ 'uint32': 'QTYPE_QINT',
+ 'uint64': 'QTYPE_QINT',
+}
+
def tokenize(data):
while len(data):
ch = data[0]
@@ -105,6 +120,7 @@ def parse_schema(fp):
if expr_eval.has_key('enum'):
add_enum(expr_eval['enum'])
elif expr_eval.has_key('union'):
+ add_union(expr_eval)
add_enum('%sKind' % expr_eval['union'])
elif expr_eval.has_key('type'):
add_struct(expr_eval)
@@ -188,6 +204,7 @@ def type_name(name):
enum_types = []
struct_types = []
+union_types = []
def add_struct(definition):
global struct_types
@@ -200,6 +217,17 @@ def find_struct(name):
return struct
return None
+def add_union(definition):
+ global union_types
+ union_types.append(definition)
+
+def find_union(name):
+ global union_types
+ for union in union_types:
+ if union['union'] == name:
+ return union
+ return None
+
def add_enum(name):
global enum_types
enum_types.append(name)