From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu7Di-0007Cs-JJ for qemu-devel@nongnu.org; Wed, 04 Nov 2015 18:11:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu7De-00044d-Hl for qemu-devel@nongnu.org; Wed, 04 Nov 2015 18:11:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu7De-00044V-Ac for qemu-devel@nongnu.org; Wed, 04 Nov 2015 18:11:54 -0500 References: <1446618049-13596-1-git-send-email-eblake@redhat.com> <1446618049-13596-20-git-send-email-eblake@redhat.com> <87a8qtd1wk.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <563A90B8.8040407@redhat.com> Date: Wed, 4 Nov 2015 16:11:52 -0700 MIME-Version: 1.0 In-Reply-To: <87a8qtd1wk.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xwbhf2hIQng9b1f0H4EUxLOxNCEmJ7lIf" Subject: Re: [Qemu-devel] [PATCH v9 19/27] qapi: Check for qapi collisions of flat union branches 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) --xwbhf2hIQng9b1f0H4EUxLOxNCEmJ7lIf Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/04/2015 12:01 PM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Right now, our ad hoc parser ensures that we cannot have a >> flat union that introduces any qapi member names that would >> conflict with the non-variant qapi members already present >> from the union's base type (see flat-union-clash-member.json). >> We want QAPISchema*.check() to make the same check, so we can >> later reduce some of the ad hoc checks. >> >> @@ -1068,6 +1069,14 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObj= ectTypeMember): >> def check(self, schema, tag_type, seen): >> QAPISchemaObjectTypeMember.check(self, schema) >> assert self.name in tag_type.values >> + if seen: >> + # This variant is used within a union; ensure each qapi m= ember >> + # field does not collide with the union's non-variant mem= bers. >> + assert isinstance(self.type, QAPISchemaObjectType) >> + assert not self.type.variants # not implemented >> + self.type.check(schema) >> + for m in self.type.members: >> + m.check_clash(seen) >> >> # This function exists to support ugly simple union special cases= >> # TODO get rid of them, and drop the function >=20 > Two call chains: >=20 > * QAPISchemaObjectType.check() via QAPISchemaObjectTypeVariants.check()= >=20 > In this case, the new conditional executes. >=20 > * QAPISchemaAlternateType.check() via same >=20 > In this case, it doesn't. >=20 > Why can't we simply add the new code to QAPISchemaObjectType.check()? We could, but we'd need a nested for-loop: for v in variants.variants: v.type.check(schema) assert not v.type.variants vseen =3D dict(seen) for m in v.type.members: m.check_clash(seen) > The rest of the clash checking is already there... You do have a point there. I guess it wouldn't be the end of the world to have the loop nesting be explicit rather than indirect through the intermediate Variants.check(). I'll play with it; and depending on what I do, that may mean I don't have to munge your other patches quite so heavily. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xwbhf2hIQng9b1f0H4EUxLOxNCEmJ7lIf 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/ iQEcBAEBCAAGBQJWOpC4AAoJEKeha0olJ0Nq6fQH/2wFlsaT1Rmpphc9nAA97SOx wAgaevTsAjP8ElMww/uMGmJJf582YLM5lxHJ/+qbZmiQsUBqxFmWfFDqee96O9Ew 7DYFTlUpJdezcc5V8ERQ4GA79l0vzT3mrra4hOt5QxsQUfmYh68UMF1txRfQHFb6 OpqFRMlJ6w4j6opVLbsGJdhRoMmHv9VhHnTGzDesrIxvLPud7NzrKV0jd2BNRKQ7 WEfjbi4ruL6ZhdKThAd89OQnh4FIB55GZAuuJqNrK9vPi5ApqXl9dzkkas9FOwzh fE1Ks4nf+lSdd1kI1xyd9KeQ50n68XqunSMjx5qIxPFVjPXyCiYQYOhtOgsrPO4= =pClt -----END PGP SIGNATURE----- --xwbhf2hIQng9b1f0H4EUxLOxNCEmJ7lIf--