aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/schema.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-03-21 17:42:41 +0100
committerMarkus Armbruster <armbru@redhat.com>2022-04-21 10:11:25 +0200
commita58069494ded1282c36b7fca8d67bf487c160983 (patch)
treec6de12c9b556a9b22d3d2bad9d99c6057402daa5 /scripts/qapi/schema.py
parent9c125d17e9402c232c46610802e5931b3639d77b (diff)
downloadqemu-a58069494ded1282c36b7fca8d67bf487c160983.zip
qemu-a58069494ded1282c36b7fca8d67bf487c160983.tar.gz
qemu-a58069494ded1282c36b7fca8d67bf487c160983.tar.bz2
qapi-schema: support alternates with array type
Detect array types as alternate branches, and turn the JSON list into a QAPISchemaArrayType. Array types in an alternate are represented with QTYPE_QLIST in the type field. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20220321164243.200569-2-pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi/schema.py')
-rw-r--r--scripts/qapi/schema.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index b7b3fc0..3728340 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -243,6 +243,7 @@ class QAPISchemaType(QAPISchemaEntity):
'number': 'QTYPE_QNUM',
'int': 'QTYPE_QNUM',
'boolean': 'QTYPE_QBOOL',
+ 'array': 'QTYPE_QLIST',
'object': 'QTYPE_QDICT'
}
return json2qtype.get(self.json_type())
@@ -1069,6 +1070,9 @@ class QAPISchema:
None))
def _make_variant(self, case, typ, ifcond, info):
+ if isinstance(typ, list):
+ assert len(typ) == 1
+ typ = self._make_array_type(typ[0], info)
return QAPISchemaVariant(case, info, typ, ifcond)
def _def_union_type(self, expr, info, doc):