From 69dd62dfd60631ba69201d8a197fde1ece4b4df3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 8 Jul 2013 16:14:21 +0200 Subject: 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 Reviewed-by: Eric Blake --- qobject/qjson.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qobject') diff --git a/qobject/qjson.c b/qobject/qjson.c index 19085a1bb7..6cf2511580 100644 --- a/qobject/qjson.c +++ b/qobject/qjson.c @@ -260,6 +260,8 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) /* XXX: should QError be emitted? */ case QTYPE_NONE: break; + case QTYPE_MAX: + abort(); } } -- cgit v1.2.3