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: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collisions
Date: Wed, 23 Sep 2015 06:45:56 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

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

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

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