qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RFC 03/10] qapi script: check correctness of dis


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH RFC 03/10] qapi script: check correctness of discriminator values in union
Date: Tue, 05 Nov 2013 06:25:57 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 11/04/2013 05:37 PM, Wenchao Xia wrote:
> It will check whether the values specfied are wrotten correctly when

s/specfied/specified/
s/wrotten/written/

> discriminator is a pre-defined enum type, which help check whether the
> schema is in good form.
> 
> It is allowed that, not every value in enum is used, so do not check

s/that,/that/

> that case.

Why do you allow partial coverage?  That feels like an accident waiting
to happen.  Does the user get a sane error message if they request an
enum value that wasn't mapped to a union branch?  I think it would be
wiser to mandate that if the discriminator is an enum, then the union
must cover all values of the enum.

> +
> +# Return the descriminator enum define, if discriminator is specified in

s/descriminator/discriminator/

> +# @expr and it is a pre-defined enum type
> +def descriminator_find_enum_define(expr):

s/descriminator/discriminator/ - and fix all callers

> +    discriminator = expr.get('discriminator')
> +    base = expr.get('base')
> +
> +    # Only support discriminator when base present
> +    if not (discriminator and base):
> +        return None
> +
> +    base_fields = find_base_fields(base)
> +
> +    if not base_fields:
> +        sys.stderr.write("Base '%s' is not a valid type\n"
> +                         % base)
> +        sys.exit(1)
> +
> +    descriminator_type = base_fields.get(discriminator)

s/descriminator/discriminator/

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