From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOXwy-0006df-4L for qemu-devel@nongnu.org; Wed, 27 Jan 2016 16:48:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOXwx-0007HG-1p for qemu-devel@nongnu.org; Wed, 27 Jan 2016 16:48:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOXww-0007Gz-Qk for qemu-devel@nongnu.org; Wed, 27 Jan 2016 16:48:26 -0500 References: <1453219845-30939-27-git-send-email-eblake@redhat.com> <1453902888-20457-1-git-send-email-armbru@redhat.com> <1453902888-20457-2-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <56A93B28.2010804@redhat.com> Date: Wed, 27 Jan 2016 14:48:24 -0700 MIME-Version: 1.0 In-Reply-To: <1453902888-20457-2-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r7uIids6W6VJ9tX4Q3BB1fbh9pmqVXKfk" Subject: Re: [Qemu-devel] [PATCH 1/3] qapi-visit: Simplify how we visit common union members List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r7uIids6W6VJ9tX4Q3BB1fbh9pmqVXKfk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/27/2016 06:54 AM, Markus Armbruster wrote: > For a simple union SU, gen_visit_union() generates a visit of its > single tag member, like this: >=20 > visit_type_SUKind(v, "type", &(*obj)->type, &err); >=20 > For a flat union FU with base B, it generates a visit of its base > fields: >=20 > visit_type_B_fields(v, (B **)obj, &err); >=20 > Instead, we can simply visit the common members using the same fields > visit function we use for structs, generated with > gen_visit_struct_fields(). This function visits the base if any, then > the local members. I like how you've split up my gen_struct/gen_union merge into a few more steps. I'll be incorporating your patch into my v10 spin. >=20 > For a simple union SU, visit_type_SU_fields() contains exactly the old > tag member visit, because there is no base, and the tag member is the > only member. For instance, the code generated for > qapi-schema-test.json's UserDefNativeListUnion changes like this: >=20 > @@ -740,6 +766,19 @@ out: > error_propagate(errp, err); > } >=20 > +static void visit_type_UserDefNativeListUnion_fields(Visitor *v, U= serDefNativeListUnion **obj, Error **errp) I may try to rewrite the commit to pick a shorter example, though :) >=20 > As you see, the generated code grows a bit, but in practice, it's lost > in the noise: qapi-schema.json's qapi-visit.c gains roughly 1%. >=20 > This simplification became possible with commit 441cbac "qapi-visit: > Convert to QAPISchemaVisitor, fixing bugs". It's a step towards > unifying gen_struct() and gen_union(). >=20 > Signed-off-by: Markus Armbruster > --- > scripts/qapi-visit.py | 27 ++++----------------------- > 1 file changed, 4 insertions(+), 23 deletions(-) >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --r7uIids6W6VJ9tX4Q3BB1fbh9pmqVXKfk 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/ iQEcBAEBCAAGBQJWqTsoAAoJEKeha0olJ0NqHb4H/3EOA9c80VL6jv2mKqv5EvP8 b1AZgs4i9HNu9mIOVcxTAFin17Yy5dhbtMBMwpwbecmvr7GyFDbbSpYwhLUmvoM/ 8/fp0qQaDrQ6UQKb2+yd3vD5tuOkZLBz6ZeLay4L3wjyN5qLB4oDzlD8cL4ayROT +3O5C965OUgUyisj1EDqVyz4s4cc4CzSbIBDpSeGLBQ1UJm/mqlOJiv0BDHYwl8J yu5+acf0gcIQS4nkW492dBJan3ilekMHQcsc5yV1GlBPErLXdkmAZEcmO2Z7DHWE a+iGOJYKA3ezBiD6vs8nMt5dGsvdKbF9XDEMUuEvzSH8D5c4Jt25EDTy/iaCFPg= =CRZZ -----END PGP SIGNATURE----- --r7uIids6W6VJ9tX4Q3BB1fbh9pmqVXKfk--