qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 25/30] qapi: Hoist tag collision check to Va


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v10 25/30] qapi: Hoist tag collision check to Variants.check()
Date: Mon, 9 Nov 2015 22:33:44 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/09/2015 06:07 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
> 
>> Checking that a given QAPISchemaObjectTypeVariant.name is a
>> member of the corresponding QAPISchemaEnumType of the owning
>> QAPISchemaObjectTypeVariants.tag_member ensures that there are
>> no collisions in the generated C union for those tag values
>> (since the enum itself should have no collisions).
>>
>> However, this check was the only thing that Variant.check() was
>> doing beyond the work of the superclass ObjectTypeMember.check(),
>> and resulted in a difference of the .check() signatures just to
>> pass the enum type down.
>>
>> Simplify things by instead doing the tag name check as part of
>> Variants.check(), at which point we can rely on inheritance
>> instead of overriding Variant.check().
>>
>> Signed-off-by: Eric Blake <address@hidden>
>>
>> ---

>> -        assert isinstance(self.tag_member.type, QAPISchemaEnumType)
>> +        tag_type = self.tag_member.type
>> +        assert isinstance(tag_type, QAPISchemaEnumType)
>>          for v in self.variants:
>> -            v.check(schema, self.tag_member.type)
>> +            v.check(schema)
>> +            assert v.name in tag_type.values
> 
> Two changes squashed together:
> 
> * Move the assertion from QAPISchemaObjectTypeVariant.check(),
> 
> * Capture self.tag_member.type in tag_type
> 
> The second part makes the patch slightly less obvious.  Matter of taste.

I'm dropping the tag_type temporary member.  Once I played more with
making qtype_code a qapi builtin type, it became much more elegant to
revisit this code (the use of tag_type here was for when my later
patches were trying to key off of tag_type==None as a witness of
alternates).

-- 
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

[Prev in Thread] Current Thread [Next in Thread]