From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zer4z-0000Er-KL for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zer4w-0001SJ-CN for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:55:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zer4w-0001Rl-50 for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:55:50 -0400 References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-36-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <560311CF.4010005@redhat.com> Date: Wed, 23 Sep 2015 14:55:43 -0600 MIME-Version: 1.0 In-Reply-To: <1442872682-6523-36-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="08Tp10aFmWimuU4nkvUatoSNGLt8FS11x" Subject: Re: [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, ehabkost@redhat.com, Michael Roth , armbru@redhat.com, DirtY.iCE.hu@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --08Tp10aFmWimuU4nkvUatoSNGLt8FS11x Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2015 03:57 PM, Eric Blake wrote: > The code for visiting the base class of a child struct created > visit_type_Base_fields(); the code for visiting the base class > of a flat union created visit_type_Union_fields(). If the same > type is shared between a struct and a union, the two functions > differed only by whether they visited the discriminator used by > the union. But if the base class always visits all its fields, > then we don't need to revisit the discriminator specially for > a union. By consistently visiting the base class fields under > the name of the base class, we can eliminate some redundant > code. >=20 > Now that gen_visit_struct_fields() can potentially collect more > than one function into 'ret', a regular expression searching for > whether a label was used may hit a false positive within the > body of the first function. But using a regex was overkill, > since we can easily determine when we jumped to a label. >=20 > visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); > - if (err) { > - goto out_obj; > - } > - switch ((*obj)->%(c_name)s) { > ''', > - c_type=3Dvariants.tag_member.type.c_name(), > - c_name=3Dc_name(tag_key), name=3Dtag_key) > + c_type=3Dvariants.tag_member.type.c_name(), > + c_name=3Dc_name(tag_key), name=3Dtag_key) > + ret +=3D mcgen(''' > + if (err) { > + goto out_obj; > + } > + switch ((*obj)->%(c_name)s) { Rebase snafu - I botched the generated indentation within this mcgen() by 4 spaces. Shouldn't affect a technical review, and I will fix it up for v6. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --08Tp10aFmWimuU4nkvUatoSNGLt8FS11x 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/ iQEcBAEBCAAGBQJWAxHPAAoJEKeha0olJ0NqKHAIAJ9rgEGT0hXtDmsZDqq4phw5 kgUvLNhUhSm13bTv1E1VVuD3Lf6GhnHao3KgFAJ95YQct+YLytm3JTmaJ2mx8HGX xU6RNr8sqHCcGsGqRh761guTZBK1hT5Lmh9habNBjhWSk4QjL5LBCzhTCn0V/ReZ R3f/nrWIhNsYek2qcJp45MGRKkvc/12Ryw5O7ix19ulOGHmZLp6/nCPKpgGwxz5m ITT98aFgXbW1QqSpGF5lapc8YbYSI+DZeWYCBoNRdRH+Hdz2aUe6cGnhMrnd+gJ4 +QSvD3UsWfN6jP59qfNrGMjVKIECdmRsrAyqVWeSFhm9+JMzeDMXNP//9BP6V0g= =eJm/ -----END PGP SIGNATURE----- --08Tp10aFmWimuU4nkvUatoSNGLt8FS11x--