From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adJtW-0005Zr-0c for qemu-devel@nongnu.org; Tue, 08 Mar 2016 10:50:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adJtS-0004cK-KQ for qemu-devel@nongnu.org; Tue, 08 Mar 2016 10:49:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adJtS-0004cC-CQ for qemu-devel@nongnu.org; Tue, 08 Mar 2016 10:49:54 -0500 References: <1457194595-16189-1-git-send-email-eblake@redhat.com> <1457194595-16189-2-git-send-email-eblake@redhat.com> <87ziu9b7ns.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56DEF4A0.8030707@redhat.com> Date: Tue, 8 Mar 2016 08:49:52 -0700 MIME-Version: 1.0 In-Reply-To: <87ziu9b7ns.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hI84iq7Kup2r79C2Sai9kvSdPcmgkDJCl" Subject: Re: [Qemu-devel] [PATCH v4 01/10] qapi: Assert in places where variants are not handled 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) --hI84iq7Kup2r79C2Sai9kvSdPcmgkDJCl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/08/2016 03:12 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> We are getting closer to the point where we could use one union >> as the base or variant type within another union type (as long >> as there are no collisions between any possible combination of >> member names allowed across all discriminator choices). But >> until we get to that point, it is worth asserting that variants >> are not present in places where we are not prepared to handle >> them: base types must still be plain structs, and anywhere we >> explode a struct into a parameter list (events and command >> marshalling), we don't support variants in that explosion. >> >> Signed-off-by: Eric Blake >> >> +++ b/scripts/qapi.py >> @@ -960,6 +960,7 @@ class QAPISchemaObjectType(QAPISchemaType): >> assert isinstance(self.base, QAPISchemaObjectType) >> self.base.check(schema) >> self.base.check_clash(schema, self.info, seen) >> + assert not self.base.variants >=20 > I'd move this two lines up, so it's next to the isinstance. >=20 > Assertions in .check() are place-holders for semantic checks that > haven't been moved from the old semantic analysis to the classes. > Whenever we add one, we should double-check the old semantic analysis > catches whatever we assert. For object types, that's check_struct() an= d > check_union(). Both check_type() the base with allow_metas=3D['struct'= ]), > so we're good. >=20 > Inconsistency: you add the check for base, but not for variants. >=20 > On closer look, adding it for either is actually redundant, because > se.f.base.check_clash() already asserts it, with a nice "not > implemented" comment. >=20 > If we think asserting twice is useful for base, then it's useful for > variants, too. But I think asserting once suffices. So basically, we can drop this hunk, right? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --hI84iq7Kup2r79C2Sai9kvSdPcmgkDJCl 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/ iQEcBAEBCAAGBQJW3vSgAAoJEKeha0olJ0Nqz9UH/3qCdUWCtp6WekF0wJVdo6Mq FgJosjJpN5MLMZPHxILtS+YVP0PVbgmAGKnzG/jZKLrU6+y+IymfvVPkZVBAOPh/ A8VARg22VDdxG13X8u2GeYw3lWyknCMnbobRi6/mqz1rS8GbH05w0gQgXn1YNdQR m9uKUQbvQwFlzM85t3AKxbvmzPSnmsYgwnARuy85vWZXvi/WbB/xplUs5wEddozr q2+eLfZpZ/+32q9RR2xfuLgDOi0wTHKQjr8o2hVL6V0ogbYn1mII/E+aTdDZvO61 3BhQqujz/xlbA9uLS9bsHwENd3eeRQokh08u3b/M3DPBS7LJSFK+PzKENdMh66U= =UxI+ -----END PGP SIGNATURE----- --hI84iq7Kup2r79C2Sai9kvSdPcmgkDJCl--