On 03/08/2016 08:59 AM, Markus Armbruster wrote:
> Eric Blake <ebl...@redhat.com> 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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to