qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collision


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collisions
Date: Wed, 23 Sep 2015 16:02:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 09/23/2015 03:43 AM, Markus Armbruster wrote:
>
>>> Commit 1e6c1616 was where we quit burning the C member name 'base'.
>>> Prior to that time, members of base classes did not clash with variant
>>> names because of the C boxing.
>> 
>> For union types.  For struct types, we still box the base.  I'd like to
>> get rid of that.
>
> Patch 34/46 :)

Okay :)

>> Even when the base is boxed, the members still clash in QMP.
>> 
>> We also box the variants (e.g. UserDefA *value1 in the example above).
>> Would be nice to get rid of that, too.
>
> What do you mean? Here's an example of current boxed code:
>
> enum EnumType {
>     ENUM_TYPE_ONE,
>     ENUM_TYPE_TWO,
> };
> struct One {
>     int a;
> };
> struct Two {
>     char *a;
> };
> struct Union {
>     EnumType type;
>     /* union tag is @type */
>     union {
>         One *one;
>         Two *two;
>     };
> };
>
> Is this what you envision for unboxed? Note that we still have to
> namespace things properly (we have to have union.one.a and union.two.a,
> and not a direct union.a), so all we'd be saving is the additional
> allocation of the variant pointers.
>
> struct Union {
>     EnumType type;
>     /* union tag is @type */
>     union {
>         struct {
>             int a;
>         } one;
>         struct {
>             char *a;
>         } two;
>     };
> };
>
> However, I'm not sure it would always help.  The conversion of
> netdev_add to full qapi relies on being able to access the variant
> through a named struct (such as NetdevTapOptions); unboxing the variant
> would get rid of the convenient access to these named sub-structs.

struct Union {
    EnumType type;
    /* union tag is @type */
    union {
        One one;
        Two two;
    };
};

For base, we go one step further and peel off the struct, to save some
notational overhead.  Pointless for unions.



reply via email to

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