[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 07/10] qapi: Don't special-case simple union
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 07/10] qapi: Don't special-case simple union wrappers |
Date: |
Tue, 8 Mar 2016 09:16:35 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
On 03/08/2016 08:59 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> Simple unions were carrying a special case that hid their 'data'
>> QMP member from the resulting C struct, via the hack method
>> QAPISchemaObjectTypeVariant.simple_union_type(). But by using
>> the work we started by unboxing flat union and alternate
>> branches, coupled with the ability to visit the members of an
>> implicit type, we can now expose the simple union's implicit
>> type in qapi-types.h:
>>
>> +++ b/scripts/qapi.py
>> @@ -1006,7 +1006,6 @@ class QAPISchemaObjectType(QAPISchemaType):
>> return c_name(self.name) + pointer_suffix
>>
>> def c_unboxed_type(self):
>> - assert not self.is_implicit()
>
> Doesn't this belong into PATCH 04?
>
>> return c_name(self.name)
Maybe. Patch 3 kept the assertion out of straight code refactoring, and
patch 4 didn't use c_unboxed_type(), so this was the first place where I
had to weaken the assertion. But moving it into patch 4 doesn't seem
like it would hurt, as it is still semantically related to the fact that
we are planning on allowing an unboxed implicit type.
>> - visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err);
>> -''',
>> - c_type=var.type.c_name(),
>> - c_name=c_name(var.name))
>> - ret += mcgen('''
>> - break;
>> -''')
>> + variants.tag_member.type.prefix),
>> + c_type=var.type.c_name(), c_name=c_name(var.name))
>>
>> ret += mcgen('''
>> default:
>
> This stupid special case has given us enough trouble, good to see it
> gone!
Yeah, it was a nice feeling to get to this point!
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v4 08/10] qapi: Allow anonymous base for flat union, (continued)
[Qemu-devel] [PATCH v4 10/10] qapi: Populate info['name'] for each entity, Eric Blake, 2016/03/05
[Qemu-devel] [PATCH v4 09/10] qapi: Use anonymous bases in QMP flat unions, Eric Blake, 2016/03/05
[Qemu-devel] [PATCH v4 07/10] qapi: Don't special-case simple union wrappers, Eric Blake, 2016/03/05