qapi: Assert in places where variants are not handled

We are getting closer to the point where we could use one union
as the base or variant type within another union type (as long
as there are no collisions between any possible combination of
member names allowed across all discriminator choices). But
until we get to that point, it is worth asserting that variants
are not present in places where we are not prepared to handle
them: when exploding a type into a parameter list, we do not
expect variants. The qapi.py code is already checking this,
via the older check_type() method; but someday we hope to get
rid of that and move checking into QAPISchema*.check(). The
two asserts added here make sure any refactoring still catches
problems, and makes it locally obvious why we can iterate over
only type.members without worrying about type.variants.

Backports commit 29f6bd15eb8a55ed37b2a443f7275b3d134eb2b2 from qemu
This commit is contained in:
Eric Blake 2018-02-21 21:58:21 -05:00 committed by Lioncash
parent 1cfdf802a9
commit a7713451d9
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -39,6 +39,7 @@ def gen_event_send(name, arg_type):
proto=gen_event_send_proto(name, arg_type))
if arg_type and arg_type.members:
assert not arg_type.variants
ret += mcgen('''
QmpOutputVisitor *qov;
Visitor *v;