From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abqhS-0000mT-U1 for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:27:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abqhN-0008H6-VM for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:27:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abqhN-0008Gn-Nl for qemu-devel@nongnu.org; Fri, 04 Mar 2016 09:27:21 -0500 References: <1456443528-13901-1-git-send-email-eblake@redhat.com> <1456443528-13901-16-git-send-email-eblake@redhat.com> <8737s76ah2.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56D99B48.2060900@redhat.com> Date: Fri, 4 Mar 2016 07:27:20 -0700 MIME-Version: 1.0 In-Reply-To: <8737s76ah2.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="D6oMrSBqVJ4IS1a2kTs0wE7j1sBVAsgxo" Subject: Re: [Qemu-devel] [PATCH v2 15/19] qapi-visit: Move error check into gen_visit_members_call() 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) --D6oMrSBqVJ4IS1a2kTs0wE7j1sBVAsgxo Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/03/2016 04:56 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> When first introduced, neither branch of gen_visit_members_call() >> would output a goto. But now that the implicit struct visit >> always ends with a goto, we should do the same for regular >> struct visits, so that callers don't have to worry about whether >> they are creating two identical goto's in a row. >> >> Generated code gets slightly larger; if desired, we could patch >> qapi.py:gen_visit_members() to have a mode where it skips the >> final goto and leave it up to the callers when to use that mode, >> but that adds more maintenance burden when the compiler should >> be smart enough to not bloat the .o file just because the .c >> file got larger. >> >> Signed-off-by: Eric Blake >> >> +++ b/scripts/qapi-visit.py >> @@ -48,6 +48,7 @@ def gen_visit_members_call(typ, direct_name, implici= t_name=3DNone): > assert isinstance(typ, QAPISchemaObjectType) > if typ.is_empty(): > pass > elif typ.is_implicit(): > assert implicit_name > assert not typ.variants > ret +=3D gen_visit_members(typ.members, prefix=3Dimplicit_na= me) >=20 > This is the goto-generating part mentioned in the commit message. >=20 >> @@ -95,9 +95,9 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_n= ame)s *obj, Error **errp) >> } >> ''') >> >> - # 'goto out' produced for base, by gen_visit_members() for each m= ember, >> - # and if variants were present >> - if base or members or variants: >> + # 'goto out' produced for non-empty base, by gen_visit_members() = for >> + # each member, and if variants were present >> + if (base and not base.is_empty()) or members or variants: >> ret +=3D mcgen(''' >> >> out: >=20 > Uh, sure this hunk belongs to this patch? Unfortunately, yeah - because the empty base case doesn't generate a goto. I'm leaning more and more towards not bothering to special case empty types on the next round. I've already started playing with making type.c_name() work on implicit types - it generates names like '_obj_Foo_wrapper', which won't collide (because we reserved leading underscore for our own use), but also doesn't quite match conventional naming conventions - but as long as it is used only in generated code, it isn't that bad. And with an implicit type directly laid out, I can then just blindly call visit_type_FOO_members(), even for implicit base or variant. The v4 spin of the second half of this series is looking promising... --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --D6oMrSBqVJ4IS1a2kTs0wE7j1sBVAsgxo 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/ iQEcBAEBCAAGBQJW2ZtIAAoJEKeha0olJ0NqVrcH/i+NAxV/FSg4+i1ilK7hW6ND 2FEvayb5tB6t4ZAZsXMzpguMbsawSL5DGy/rFkD9G4cI4UFW0xVQZpapFXOF9i7p VWEUsRQ9OAJvj/+elCgI3XWJnnQ31XtkJwi27uL7VRXjWGqMnso2UiuSEPPue7YZ 060oHRsNO6fcRJJiWcNHjzY0D6G3L3SHkLoaY3w9krztvzu9rLK5o/dskJVezDAF Dr/+1g2x1yE0fn+s2idWejex+hkvt6K+Bb8Yzl9dJlvp6hzTxEqBuQylGIxIHjZr Aopk4MUXB7jeJza7y8cOOsPa/YL6QjASqofvaj6vp2qUSbKwjZIHJUaJ0p2SrNQ= =uuIV -----END PGP SIGNATURE----- --D6oMrSBqVJ4IS1a2kTs0wE7j1sBVAsgxo--