From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGVWE-0002JF-Ht for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:26:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGVW9-0001sp-MB for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:26:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGVW9-0001sg-ER for qemu-devel@nongnu.org; Thu, 20 Feb 2014 10:26:29 -0500 Message-ID: <53061EA1.1010508@redhat.com> Date: Thu, 20 Feb 2014 08:26:25 -0700 From: Eric Blake MIME-Version: 1.0 References: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1392875695-15627-5-git-send-email-xiawenc@linux.vnet.ibm.com> <87a9dlzvxq.fsf@blackfin.pond.sub.org> In-Reply-To: <87a9dlzvxq.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Okq4L35c0hctsRhGmjAbjohtesEOWTNxJ" Subject: Re: [Qemu-devel] [PATCH V7 04/11] qapi script: check correctness of discriminator values in union List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Wenchao Xia Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Okq4L35c0hctsRhGmjAbjohtesEOWTNxJ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/20/2014 07:43 AM, Markus Armbruster wrote: > Wenchao Xia writes: >=20 >> It will check whether base is set, whether discriminator is found >> in base, whether the values specified are written correctly, and >> whether all enum values are covered, when discriminator is a >=20 > And every member of the discriminator enum type must also occur as key > of the union's member 'data'. Why? >=20 > Consider: >=20 > { 'enum': 'FooEnum', 'data': [ 'plain', 'bells', 'whistles' ] } >=20 > { 'type': 'CommonFooOptions', > 'data': { 'type: 'FooType', 'readonly': 'bool' } } > { 'union': 'FooOptions', > 'base': 'CommonFooOptions', > 'discriminator': 'type', > 'data': { 'bells': 'BellsOptions', > 'whistles': 'WhistlesOptions' } } >=20 > Type 'plain' doesn't have options beyond CommonFooOptions. I'd still rather make it explicit that we KNOW that this branch of the union has no additional options: { 'union': 'FooOptions', 'base': 'CommonFooOptions', 'discriminator': 'type', 'data': { 'plain': {}, 'bells': 'BellsOptions', 'whistles': 'WhistlesOptions' } } to show that we explicitly thought about all the cases. We don't currently have any such unions with an empty branch, but it would be worth documenting in the qapi text and explicitly testing that it works if we intend to support this. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Okq4L35c0hctsRhGmjAbjohtesEOWTNxJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTBh6hAAoJEKeha0olJ0Nqd0gIAIr8OprZ5W6GyV0IDBysVKNC f17FA1Sz9iD+fKHoKjE+T/x0z0Mw4ma3n7AZU1G8vlClwBIIPjjb0OlJoSlbDOWf 2IWVcORXqaEtjb9n3QsO6GoZ+nkhihczhwBNa0ZWfU1kdcr5Cy5EPowY27sY8Itr hHm7eq1MfaNgAl9ZLoTVnx5x6euVRWaB3NpLWPD+N6nnVY9rX7fASS76K12CO0S4 9LnaRKSBrk9C/4hmaMAHUT3qc5/Q0fWwOEs34BfPjw6+bpi4aijCUPwZS2RMBnUZ CYF1lbpEhjtflJ+IXsRHINzXvVVTqD6ei3WE4+8uaID3hM6L5PVUGx2ANBhB+EA= =UKFW -----END PGP SIGNATURE----- --Okq4L35c0hctsRhGmjAbjohtesEOWTNxJ--