Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-31 Thread Markus Armbruster
Eric Blake writes: > On 07/29/2015 01:33 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> On 07/01/2015 02:21 PM, Markus Armbruster wrote: 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 renamed to >>>

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-31 Thread Markus Armbruster
Markus Armbruster writes: > Eric Blake writes: > >> On 07/01/2015 02:21 PM, Markus Armbruster wrote: >>> 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 renamed to >>> 'kind' and put at the beginning. >> >> The renami

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-30 Thread Eric Blake
On 07/30/2015 09:44 AM, Markus Armbruster wrote: which means that if we name any of the branches 'data' (that is, if 'data' is a member of the enum discriminator), things fail to compile. We could probably fix that by naming our dummy branch '_data'. >>> >>> I wonder whether member

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-30 Thread Markus Armbruster
Eric Blake writes: > On 07/30/2015 01:11 AM, Markus Armbruster wrote: > >>> Another name collision bug: our code generates flat unions as: >>> >>> struct BlockdevOptions { >>> BlockdevDriver driver; >>> ... >>> /* End fields inherited from BlockdevOptionsBase. */ >>> /* union tag is B

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-30 Thread Eric Blake
On 07/30/2015 01:11 AM, Markus Armbruster wrote: >> Another name collision bug: our code generates flat unions as: >> >> struct BlockdevOptions { >> BlockdevDriver driver; >> ... >> /* End fields inherited from BlockdevOptionsBase. */ >> /* union tag is BlockdevDriver driver */ >>

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-30 Thread Markus Armbruster
Eric Blake writes: > On 07/29/2015 01:33 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> On 07/01/2015 02:21 PM, Markus Armbruster wrote: 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 renamed to >>>

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-29 Thread Eric Blake
On 07/29/2015 01:33 AM, Markus Armbruster wrote: > Eric Blake writes: > >> On 07/01/2015 02:21 PM, Markus Armbruster wrote: >>> 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 renamed to >>> 'kind' and put at the begin

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-29 Thread Markus Armbruster
Eric Blake writes: > On 07/01/2015 02:21 PM, Markus Armbruster wrote: >> 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 renamed to >> 'kind' and put at the beginning. > > The renaming to 'kind' was a bug waiting to hap

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-28 Thread Eric Blake
On 07/01/2015 02:21 PM, Markus Armbruster wrote: > 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 renamed to > 'kind' and put at the beginning. The renaming to 'kind' was a bug waiting to happen. Consider this example,

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-27 Thread Markus Armbruster
Eric Blake writes: > On 07/24/2015 06:01 AM, Markus Armbruster wrote: > >>> It might be worth tweaking the generator to output a C comment either >>> here (at the start of the larger struct)... >>> char *string; EnumOne enum1; >>> >>> ...or here (at the end of the base s

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-27 Thread Eric Blake
On 07/24/2015 06:01 AM, Markus Armbruster wrote: >> It might be worth tweaking the generator to output a C comment either >> here (at the start of the larger struct)... >> >>> char *string; >>> EnumOne enum1; >> >> ...or here (at the end of the base struct) mentioning that >> UserD

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-24 Thread Markus Armbruster
Eric Blake writes: > On 07/01/2015 02:21 PM, Markus Armbruster wrote: >> 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 renamed to >> 'kind' and put at the beginning. >> > >> Change to put all base members at the begi

Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-20 Thread Eric Blake
On 07/01/2015 02:21 PM, Markus Armbruster wrote: > 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 renamed to > 'kind' and put at the beginning. > > Change to put all base members at the beginning, unadulterated. Not >

[Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions

2015-07-01 Thread Markus Armbruster
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 renamed to 'kind' and put at the beginning. Example: qapi-schema-test.json has { 'struct': 'UserDefUnionBase', 'data': { 'string': 'str', 'enum1': 'EnumOne' } }