diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-07-08 16:14:21 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-07-26 21:10:11 +0200 |
commit | 69dd62dfd60631ba69201d8a197fde1ece4b4df3 (patch) | |
tree | 9963bd4874919f3a53e0cc2aab0550385fd3ff79 /scripts/qapi.py | |
parent | ea66c6d8819c8fc5f73a28554992be64e5399fed (diff) | |
download | qemu-69dd62dfd60631ba69201d8a197fde1ece4b4df3.tar.gz qemu-69dd62dfd60631ba69201d8a197fde1ece4b4df3.tar.bz2 qemu-69dd62dfd60631ba69201d8a197fde1ece4b4df3.zip |
qapi: Anonymous unions
The discriminator for anonymous unions is the data type. This allows to
have a union type that allows both of these:
{ 'file': 'my_existing_block_device_id' }
{ 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } }
Unions like this are specified in the schema with an empty dict as
discriminator. For this example you could take:
{ 'union': 'BlockRef',
'discriminator': {},
'data': { 'definition': 'BlockOptions',
'reference': 'str' } }
{ 'type': 'ExampleObject',
'data: { 'file': 'BlockRef' } }
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r-- | scripts/qapi.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py index 3a54c7fc7c..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] |