mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qapi: allow empty branches in flat unions
It often happens that just a few discriminator values imply extra data in a flat union. Existing checks did not make possible to leave other values uncovered. Such cases had to be worked around by either stating a dummy (empty) type or introducing another (subset) discriminator enumeration. Both options create redundant entities in qapi files for little profit. With this patch it is not necessary anymore to add designated union fields for every possible value of a discriminator enumeration. Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com> Message-Id: <1529311206-76847-2-git-send-email-anton.nefedov@virtuozzo.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
fe170d8bfa
commit
800877bb16
11 changed files with 35 additions and 30 deletions
|
@ -496,9 +496,11 @@ Resulting in these JSON objects:
|
|||
|
||||
Notice that in a flat union, the discriminator name is controlled by
|
||||
the user, but because it must map to a base member with enum type, the
|
||||
code generator can ensure that branches exist for all values of the
|
||||
enum (although the order of the keys need not match the declaration of
|
||||
the enum). In the resulting generated C data types, a flat union is
|
||||
code generator ensures that branches match the existing values of the
|
||||
enum. The order of the keys need not match the declaration of the enum.
|
||||
The keys need not cover all possible enum values. Omitted enum values
|
||||
are still valid branches that add no additional members to the data type.
|
||||
In the resulting generated C data types, a flat union is
|
||||
represented as a struct with the base members included directly, and
|
||||
then a union of structures for each branch of the struct.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue