Received: from eggs.gnu.org ([2001:4830:134:3::10]:45950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWS7E-0003g1-Ur for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:11:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWS7B-0001ie-N8 for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:11:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWS7B-0001iT-HP for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:11:41 -0500 From: Markus Armbruster References: <1455582057-27565-1-git-send-email-eblake@redhat.com> <1455582057-27565-12-git-send-email-eblake@redhat.com> <877fi3s03p.fsf@blackfin.pond.sub.org> <56C4DDDC.5070408@redhat.com> <87h9h6l7uz.fsf@blackfin.pond.sub.org> <56C5F6A7.5050102@redhat.com> Date: Thu, 18 Feb 2016 18:11:39 +0100 In-Reply-To: <56C5F6A7.5050102@redhat.com> (Eric Blake's message of "Thu, 18 Feb 2016 09:51:51 -0700") Message-ID: <8760xm6j04.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v10 11/13] qapi: Don't box branches of flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Peter Crosthwaite , qemu-devel@nongnu.org, Michael Roth , Luiz Capitulino , Paolo Bonzini , Richard Henderson Eric Blake writes: > On 02/18/2016 01:51 AM, Markus Armbruster wrote: > >>> It gets renamed to is_unboxed after the review on 10/13. But even after >>> my patch to convert simple unions, this code will still be >>> c_type=typ.c_type(is_unboxed=True), unless I figure out a way to rework >>> .c_type() to not need two separate boolean flags for the three different >>> contexts in which we use a type name (declaring an unboxed member to a >>> struct, declaring a local variable, and declaring a const parameter). >> >> A possible alternative to a single c_type() with flags for context would >> be separate c_CONTEXT_type(). >> >> In QAPISchemaType: >> >> def c_type(self): >> pass >> >> def c_param_type(self): >> return self.c_type() > > and > > def c_unboxed_type(self): > return self.c_type() > > so that c_unboxed_type() is callable on all types, not just objects. I defined it only for object types because we box only object types. Err, object types and lists. If we have a need to call it for arbitrary types, we can do that, we just need to pick names carefully, and write suitable contracts. >> >> QAPISchemaBuiltinType overrides: >> >> def c_type(self): >> return self._c_type_name >> >> def c_param_type(self): >> if self.name == 'str': >> return 'const ' + self._c_type_name >> return self._c_type_name > ... > >> >> Lots of trivial code, as so often with OO. > > But I'm liking it a bit better than the two flags. Your suggestion came > after my v11; at this point, if you want me to pursue the idea, I'm glad > to do it as a followup, and include it in my next series where I finish > the conversion of simple unions. I need to run an errand now. When I'm back, I'll review whether the series can go to qapi-next without a respin.