From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adM6B-0002df-Du for qemu-devel@nongnu.org; Tue, 08 Mar 2016 13:11:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adM6A-0005a7-HP for qemu-devel@nongnu.org; Tue, 08 Mar 2016 13:11:11 -0500 From: Markus Armbruster References: <1457194595-16189-1-git-send-email-eblake@redhat.com> <1457194595-16189-8-git-send-email-eblake@redhat.com> <87y49t55ae.fsf@blackfin.pond.sub.org> <56DEFAE3.7040704@redhat.com> Date: Tue, 08 Mar 2016 19:10:59 +0100 In-Reply-To: <56DEFAE3.7040704@redhat.com> (Eric Blake's message of "Tue, 8 Mar 2016 09:16:35 -0700") Message-ID: <87si003kng.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 07/10] qapi: Don't special-case simple union wrappers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , "open list:Block layer core" , "Michael S. Tsirkin" , Jan Kiszka , Jason Wang , Michael Roth , Vincenzo Maffione , qemu-devel@nongnu.org, Gerd Hoffmann , Igor Mammedov , Paolo Bonzini , Giuseppe Lettieri , Luiz Capitulino , Luigi Rizzo , Samuel Thibault Eric Blake writes: > On 03/08/2016 08:59 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> Simple unions were carrying a special case that hid their 'data' >>> QMP member from the resulting C struct, via the hack method >>> QAPISchemaObjectTypeVariant.simple_union_type(). But by using >>> the work we started by unboxing flat union and alternate >>> branches, coupled with the ability to visit the members of an >>> implicit type, we can now expose the simple union's implicit >>> type in qapi-types.h: >>> > >>> +++ b/scripts/qapi.py >>> @@ -1006,7 +1006,6 @@ class QAPISchemaObjectType(QAPISchemaType): >>> return c_name(self.name) + pointer_suffix >>> >>> def c_unboxed_type(self): >>> - assert not self.is_implicit() >> >> Doesn't this belong into PATCH 04? >> >>> return c_name(self.name) > > Maybe. Patch 3 kept the assertion out of straight code refactoring, and > patch 4 didn't use c_unboxed_type(), so this was the first place where I > had to weaken the assertion. But moving it into patch 4 doesn't seem > like it would hurt, as it is still semantically related to the fact that > we are planning on allowing an unboxed implicit type. PATCH 04 drops the assertion from c_name(). Let's keep the two consistent. >>> - visit_type_%(c_type)s_members(v, &obj->u.%(c_name)s, &err); >>> -''', >>> - c_type=var.type.c_name(), >>> - c_name=c_name(var.name)) >>> - ret += mcgen(''' >>> - break; >>> -''') >>> + variants.tag_member.type.prefix), >>> + c_type=var.type.c_name(), c_name=c_name(var.name)) >>> >>> ret += mcgen(''' >>> default: >> >> This stupid special case has given us enough trouble, good to see it >> gone! > > Yeah, it was a nice feeling to get to this point!