diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-06-28 20:05:53 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2015-09-04 15:47:13 +0200 |
commit | 1e6c1616a91cdcbe9a8387541f7689b8c11632aa (patch) | |
tree | 077667234523416e849d7f185a6b77edaee0864c /tests/qapi-schema/qapi-schema-test.out | |
parent | 0f61af3eb396ae163cd1572ce12e05f5d08d7c15 (diff) |
qapi: Generate a nicer struct for flat unions
The struct generated for a flat union is weird: the members of its
base are at the end, except for the union tag, which is at the
beginning.
Example: qapi-schema-test.json has
{ 'struct': 'UserDefUnionBase',
'data': { 'string': 'str', 'enum1': 'EnumOne' } }
{ 'union': 'UserDefFlatUnion',
'base': 'UserDefUnionBase',
'discriminator': 'enum1',
'data': { 'value1' : 'UserDefA',
'value2' : 'UserDefB',
'value3' : 'UserDefB' } }
We generate:
struct UserDefFlatUnion
{
EnumOne enum1;
union {
void *data;
UserDefA *value1;
UserDefB *value2;
UserDefB *value3;
};
char *string;
};
Change to put all base members at the beginning, unadulterated. Not
only is this easier to understand, it also permits casting the flat
union to its base, if that should become useful.
We now generate:
struct UserDefFlatUnion
{
/* Members inherited from UserDefUnionBase: */
char *string;
EnumOne enum1;
/* Own members: */
union { /* union tag is @enum1 */
void *data;
UserDefA *value1;
UserDefB *value2;
UserDefB *value3;
};
};
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qapi-schema/qapi-schema-test.out')
0 files changed, 0 insertions, 0 deletions