Received: from eggs.gnu.org ([2001:4830:134:3::10]:55673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zekcz-00022u-K3 for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zekct-00011X-Gc for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:02:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zekct-00011F-Bc for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:02:27 -0400 From: Markus Armbruster References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-4-git-send-email-eblake@redhat.com> <87h9mmfpf7.fsf@blackfin.pond.sub.org> <5601955B.4050109@redhat.com> <87a8sda2t8.fsf@blackfin.pond.sub.org> <56029F04.3040407@redhat.com> Date: Wed, 23 Sep 2015 16:02:24 +0200 In-Reply-To: <56029F04.3040407@redhat.com> (Eric Blake's message of "Wed, 23 Sep 2015 06:45:56 -0600") Message-ID: <87r3lp5j4f.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 03/46] qapi: Test for C member name collisions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, DirtY.iCE.hu@gmail.com, Michael Roth , ehabkost@redhat.com, qemu-devel@nongnu.org Eric Blake 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.