From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpe4u-0003iW-3g for qemu-devel@nongnu.org; Fri, 23 Oct 2015 11:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zpe4l-0003WL-M7 for qemu-devel@nongnu.org; Fri, 23 Oct 2015 11:16:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpe4l-0003WF-Dr for qemu-devel@nongnu.org; Fri, 23 Oct 2015 11:16:15 -0400 References: <1445576998-2921-1-git-send-email-eblake@redhat.com> <1445576998-2921-9-git-send-email-eblake@redhat.com> <87vb9xbp4c.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <562A4F3A.5060805@redhat.com> Date: Fri, 23 Oct 2015 09:16:10 -0600 MIME-Version: 1.0 In-Reply-To: <87vb9xbp4c.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VsMQHrm6NGfKs4PKhNGE15GpQWMOjujud" Subject: Re: [Qemu-devel] [PATCH v10 08/25] qapi-types: Refactor base fields output List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VsMQHrm6NGfKs4PKhNGE15GpQWMOjujud Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/23/2015 09:06 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Move code from gen_union() into gen_struct_fields() in order for >> a later patch to share code when enumerating inherited fields >> for struct types. >> >> No change to generated code. >> >> Signed-off-by: Eric Blake >> >> --- >> if base: >> - ret +=3D mcgen(''' >> - /* Members inherited from %(c_name)s: */ >> -''', >> - c_name=3Dc_name(base.name)) >> - ret +=3D gen_struct_fields(base.members) >> - ret +=3D mcgen(''' >> - /* Own members: */ >> -''') >> + ret +=3D gen_struct_fields([], base) >> else: >> ret +=3D mcgen(''' >> %(c_type)s kind; >=20 > One baby step towards >=20 > gen_struct_fields(members, base); >=20 > which is where we want both gen_struct() and gen_union() to go. Yep, it's almost like you're peering ahead to my unpublished patch queue = :) >=20 > Slightly confusing: members are *local* members, while base.members are= > *all* members. But the same exists elsewhere already, so let's not > worry about it. I am seriously debating about renaming things to gen_visit_struct(...local_members), just to make it obvious that we have only local members in that variable. Separate patch, I can add it in v11 if we need a respin, otherwise a later subset would be fine. >=20 > I kind of dislike gen_struct_fields() taking two parameters and calling= > itself for one, but I guess we can reconsider after gen_struct() and > gen_union() are unified. gen_struct_fields() might have just one calle= r > then. Yes, after my patch that unifies gen_struct/union into a single gen_object(), there is just a single caller, so I could inline it at that point. I also debated whether to open-code the for loop over members, instead of using a 1-deep recursive call with base=3DNone, just so things are a bit less magic. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VsMQHrm6NGfKs4PKhNGE15GpQWMOjujud Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWKk86AAoJEKeha0olJ0NqC78H/ROMLggBIW6oKh6GgQtA5/CB ZvEUAi82YzVDnc+lDk83Yayj26+st/hWoXllVJk+yRX8m8rzYkNtXNSdwAq9C/wX LXfs4rvtev8SgHTX0z0UQYyPKe0nh0A6nh3yjNzd8KXqFOJL0NAThFoVSjMWem60 6iNtynNbtHCOPn+KV3xFIDnoGdOx3L0Fe27kXJeaag7zL4XsaChiAF+8E/rQ9zpP +z2ekfJvt/J6m/szUsR+YK3Kpta0++F9K3zoUZoeIefdF4BJxeQw3RKp+CmljjX2 jrkB3z34eQSLxw0idZIdys9uJDzJdDl9OeM1kOVCZ5Mbl1dJlR/sAwPOTsWpcNQ= =4QL6 -----END PGP SIGNATURE----- --VsMQHrm6NGfKs4PKhNGE15GpQWMOjujud--