mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-29 05:13:54 -06:00
qapi: add QAPISchemaIfCond.is_present()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210804083105.97531-4-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
f17539c80d
commit
33aa3267ba
4 changed files with 12 additions and 9 deletions
|
@ -29,6 +29,9 @@ class QAPISchemaIfCond:
|
|||
def __init__(self, ifcond=None):
|
||||
self.ifcond = ifcond or []
|
||||
|
||||
def is_present(self):
|
||||
return bool(self.ifcond)
|
||||
|
||||
|
||||
class QAPISchemaEntity:
|
||||
meta: Optional[str] = None
|
||||
|
@ -598,7 +601,7 @@ class QAPISchemaVariants:
|
|||
self.info,
|
||||
"discriminator member '%s' of %s must not be optional"
|
||||
% (self._tag_name, base))
|
||||
if self.tag_member.ifcond.ifcond:
|
||||
if self.tag_member.ifcond.is_present():
|
||||
raise QAPISemError(
|
||||
self.info,
|
||||
"discriminator member '%s' of %s must not be conditional"
|
||||
|
@ -606,7 +609,7 @@ class QAPISchemaVariants:
|
|||
else: # simple union
|
||||
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
|
||||
assert not self.tag_member.optional
|
||||
assert self.tag_member.ifcond.ifcond == []
|
||||
assert not self.tag_member.ifcond.is_present()
|
||||
if self._tag_name: # flat union
|
||||
# branches that are not explicitly covered get an empty type
|
||||
cases = {v.name for v in self.variants}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue