From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHKLo-0003yX-8O for qemu-devel@nongnu.org; Mon, 20 Jul 2015 19:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHKLj-0006QY-Fs for qemu-devel@nongnu.org; Mon, 20 Jul 2015 19:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHKLj-0006QS-8S for qemu-devel@nongnu.org; Mon, 20 Jul 2015 19:19:55 -0400 References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-9-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <55AD8213.80702@redhat.com> Date: Mon, 20 Jul 2015 17:19:47 -0600 MIME-Version: 1.0 In-Reply-To: <1435782155-31412-9-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8iORl1CTaeNqGeRoT5VdEncqSOdjnWhm4" Subject: Re: [Qemu-devel] [PATCH RFC v2 08/47] qapi-visit: Fix generated code when schema has forward refs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8iORl1CTaeNqGeRoT5VdEncqSOdjnWhm4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/01/2015 02:21 PM, Markus Armbruster wrote: > The visit_type_implicit_FOO() are generated on demand, right before > their first use. Used by visit_type_STRUCT_fields() when STRUCT has > base FOO, and by visit_type_UNION() when flat UNION has member a FOO. >=20 > If the schema defines FOO after its first use as struct base or flat > union member, visit_type_implicit_FOO() calls > visit_type_implicit_FOO() before its definition, which doesn't > compile. None of our public qapi .json files currently do this, so no difference to the generated code used in qemu proper. >=20 > Rearrange qapi-schema-test.json to demonstrate the bug. Indeed, without testsuite exposure, nothing was relying on this fix. >=20 > Fix by generating the necessary forward declaration. >=20 > Signed-off-by: Markus Armbruster > --- > scripts/qapi-visit.py | 15 ++++++++++++++- > tests/qapi-schema/qapi-schema-test.json | 30 +++++++++++++++++--------= ----- > tests/qapi-schema/qapi-schema-test.out | 10 +++++----- > 3 files changed, 36 insertions(+), 19 deletions(-) >=20 > +++ b/scripts/qapi-visit.py > @@ -17,13 +17,23 @@ from qapi import * > import re > =20 > implicit_structs =3D [] > +struct_fields_seen =3D set() > =20 > def generate_visit_implicit_struct(type): > global implicit_structs > if type in implicit_structs: > return '' > implicit_structs.append(type) > - return mcgen(''' =2E.. > + ret +=3D mcgen(''' Oddly enough, the ''' is at the same indentation,... > =20 > static void visit_type_implicit_%(c_type)s(Visitor *m, %(c_type)s **ob= j, Error **errp) > { > @@ -38,8 +48,11 @@ static void visit_type_implicit_%(c_type)s(Visitor *= m, %(c_type)s **obj, Error * > } > ''', > c_type=3Dtype_name(type)) > + return ret so nothing needed to be reindented here :) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8iORl1CTaeNqGeRoT5VdEncqSOdjnWhm4 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/ iQEcBAEBCAAGBQJVrYITAAoJEKeha0olJ0NqGXsH/27x3IbnYIrnU85yIulyx0+M c4Vjy4svuVj8jhPXgp/i4P08FPpwKym68w6m3or9vX/oPC9ajhRAwRZwzqPTF1UB u9GALPci6xQe5RBPrftLr2vYVBltFgEBCsorLjOR2ta3HBkPN60VqhkRvLo8xa5w 2JNd6ruKgoNEvbS6PgdyBXR3f3ToPsZ+W4meFJIJnTiqGjakj+zcsGFI3+Rg9B2D ZiUuRqCcBXM7z3TfmSsTJeYV6z3TU33HAsggagtK88tDrsh5X1TR6GsuhoA8nlXl rHKRUZxgIizlMyYqbU1K1qZ+ARbljmUT6CnZNTh/COP+gB2r4yiIdDL+Gt8TjII= =Zfv1 -----END PGP SIGNATURE----- --8iORl1CTaeNqGeRoT5VdEncqSOdjnWhm4--