qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 46/46] qapi: Allow anonymous base for flat un


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 46/46] qapi: Allow anonymous base for flat union
Date: Wed, 23 Sep 2015 14:59:26 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 09/21/2015 03:58 PM, Eric Blake wrote:
> Rather than requiring all flat unions to explicitly create
> a separate base struct, we want to allow the qapi schema
> to specify the common fields via an inline dictionary. This
> is similar to how commands can specify inline types for the
> arguments.
> 
> Now that the feature is legal, we can drop the former
> flat-union-bad-base negative test, and instead change the
> positive tests in qapi-schema-test to use it.
> 
> Signed-off-by: Eric Blake <address@hidden>
> ---

> +++ b/scripts/qapi-visit.py

> @@ -272,10 +272,17 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s 
> **obj, const char *name, Error
> 
>      tag_key = variants.tag_member.name
>      if base:
> -        ret += mcgen('''
> +        if not base.is_implicit():
> +            ret += mcgen('''
>      visit_type_%(c_name)s_fields(v, (%(c_name)s **)obj, &err);
>  ''',
> -                     c_name=c_name(base.name))
> +                         c_name=c_name(base.name))
> +        else:
> +            push_indent()
> +            ret += gen_visit_fields(base.members, '(*obj)->', False,
> +                                    'err', 'out_obj')
> +            pop_indent()
> +        tag_key = variants.tag_member.name
>      else:
>          ret += mcgen('''
>      visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err);
>  ''',
>                      c_type=variants.tag_member.type.c_name(),
>                      c_name=c_name(tag_key), name=tag_key)
>     ret += mcgen('''
>         if (err) {
>             goto out_obj;
>         }

Whoops - this results in two back-to-back 'if (err)' clauses in the
generated output when an implicit base is used (harmless, other than
wasted effort). I'll avoid the duplication in v6.

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