mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: allow unions to contain further unions
This extends the QAPI schema validation to permit unions inside unions, provided the checks for clashing fields pass. Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230420102619.348173-4-berrange@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
1e148b545f
commit
a17dbc4b79
12 changed files with 234 additions and 3 deletions
|
@ -465,9 +465,10 @@ class QAPISchemaObjectType(QAPISchemaType):
|
|||
# on behalf of info, which is not necessarily self.info
|
||||
def check_clash(self, info, seen):
|
||||
assert self._checked
|
||||
assert not self.variants # not implemented
|
||||
for m in self.members:
|
||||
m.check_clash(info, seen)
|
||||
if self.variants:
|
||||
self.variants.check_clash(info, seen)
|
||||
|
||||
def connect_doc(self, doc=None):
|
||||
super().connect_doc(doc)
|
||||
|
@ -656,8 +657,7 @@ class QAPISchemaVariants:
|
|||
self.info,
|
||||
"branch '%s' is not a value of %s"
|
||||
% (v.name, self.tag_member.type.describe()))
|
||||
if (not isinstance(v.type, QAPISchemaObjectType)
|
||||
or v.type.variants):
|
||||
if not isinstance(v.type, QAPISchemaObjectType):
|
||||
raise QAPISemError(
|
||||
self.info,
|
||||
"%s cannot use %s"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue