From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zer8W-0002Fx-KI for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:59:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zer8T-00039o-Ef for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:59:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zer8T-00039P-5D for qemu-devel@nongnu.org; Wed, 23 Sep 2015 16:59:29 -0400 References: <1442872682-6523-1-git-send-email-eblake@redhat.com> <1442872682-6523-47-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <560312AE.1080502@redhat.com> Date: Wed, 23 Sep 2015 14:59:26 -0600 MIME-Version: 1.0 In-Reply-To: <1442872682-6523-47-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MI7kRFmtlRdqtdVJFwxkrbmKCkLNqbbpg" Subject: Re: [Qemu-devel] [PATCH v5 46/46] qapi: Allow anonymous base for flat union 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) --MI7kRFmtlRdqtdVJFwxkrbmKCkLNqbbpg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2015 03:58 PM, Eric Blake wrote: > Rather than requiring all flat unions to explicitly create > a separate base struct, we want to allow the qapi schema > to specify the common fields via an inline dictionary. This > is similar to how commands can specify inline types for the > arguments. >=20 > Now that the feature is legal, we can drop the former > flat-union-bad-base negative test, and instead change the > positive tests in qapi-schema-test to use it. >=20 > Signed-off-by: Eric Blake > --- > +++ b/scripts/qapi-visit.py > @@ -272,10 +272,17 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s= **obj, const char *name, Error >=20 > tag_key =3D variants.tag_member.name > if base: > - ret +=3D mcgen(''' > + if not base.is_implicit(): > + ret +=3D mcgen(''' > visit_type_%(c_name)s_fields(v, (%(c_name)s **)obj, &err); > ''', > - c_name=3Dc_name(base.name)) > + c_name=3Dc_name(base.name)) > + else: > + push_indent() > + ret +=3D gen_visit_fields(base.members, '(*obj)->', False,= > + 'err', 'out_obj') > + pop_indent() > + tag_key =3D variants.tag_member.name > else: > ret +=3D mcgen(''' > visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); > ''', > 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; > } Whoops - this results in two back-to-back 'if (err)' clauses in the generated output when an implicit base is used (harmless, other than wasted effort). I'll avoid the duplication in v6. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --MI7kRFmtlRdqtdVJFwxkrbmKCkLNqbbpg 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/ iQEcBAEBCAAGBQJWAxKuAAoJEKeha0olJ0NqGaAH/10UyN5wtj3ROD6BCGywTsmu JArXkVAB8QOsL0J/fCTBtizlS5W99ejc+lAGp+N1QYcomS/YP3cVKC4wEStGJ/cH MTCWo3fNloZbZXdX3DWRlQ3EVQ3sF/uc75tSd0HCq0VC5kd29fl4qYk66FsgRHlT BcwuHP3n6lKkT0KaeB7EAaUzzi6cA3pyE8O99ycdyKA0lJo6p+kM+jIkJIQXWDnf 3CVbgRuVBcQu6b/FEBkVX3w9neiEhA7iESKbNX/TNLohwBoG6S3a/nTI5y38vh2M Q/a3Ug86EirgCWZK8O5WxJYbq+c+7tbXlt+wefW+pXmhsv5nMec60r2BAYgB0qA= =OPUV -----END PGP SIGNATURE----- --MI7kRFmtlRdqtdVJFwxkrbmKCkLNqbbpg--