From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd0wY-000638-Hw for qemu-devel@nongnu.org; Tue, 31 Mar 2015 14:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yd0wV-0007S0-6g for qemu-devel@nongnu.org; Tue, 31 Mar 2015 14:31:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd0wU-0007Ru-V7 for qemu-devel@nongnu.org; Tue, 31 Mar 2015 14:31:15 -0400 Message-ID: <551AE7EF.40406@redhat.com> Date: Tue, 31 Mar 2015 12:31:11 -0600 From: Eric Blake MIME-Version: 1.0 References: <1427227433-5030-1-git-send-email-eblake@redhat.com> <1427227433-5030-7-git-send-email-eblake@redhat.com> <87h9t76gng.fsf@blackfin.pond.sub.org> <55142006.50606@redhat.com> <20150331171320.GD4748@noname.redhat.com> <551AE45F.70801@redhat.com> In-Reply-To: <551AE45F.70801@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NDRUMkTDK8RhhNdfXQ3p6IW7jXqKWrVFO" Subject: Re: [Qemu-devel] [PATCH v5 06/28] qapi: Add some union tests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, famz@redhat.com, Markus Armbruster , wenchaoqemu@gmail.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --NDRUMkTDK8RhhNdfXQ3p6IW7jXqKWrVFO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/31/2015 12:15 PM, Eric Blake wrote: >>> Cool. Or more concretely, >>> >>> { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } } >>> >>> is identical on the wire to: >>> >>> { 'enum': 'MyEnum', 'data': ['one', 'two'] } >>> { 'type': 'Base', 'data': { 'type': 'MyEnum' } } >>> { 'type': 'Branch1', 'data': { 'data': 'str' } } >>> { 'type': 'Branch2', 'data': { 'data': 'int' } } >>> { 'union': 'Flat', 'base': 'Base', 'discriminator': 'type', >>> 'data': { 'one': 'Branch1', 'two': 'Branch2' } } >> >> Perhaps we should expose all unions for schema introspection in a way >> similar to this (possibly not splitting out Branch1 and Branch2 as >> independent types, though). We would just have to give a name to >> implicitly generated enums and base types. >=20 > So maybe we update the schema to allow anonymous types. That is: >=20 > { 'union': 'Simple', > 'data': { 'one': { 'name': 'str', 'value': 'int' } } } >=20 > would be nicer than the current requirement of: >=20 > { 'type': 'Branch1', 'data': { 'name': 'str', 'value': 'int' } } > { 'union': 'Simple', > 'data': { 'one': 'Branch1' } } Hmm; maybe we could support a notion of a 'common' dictionary for simple unions, containing all non-discriminator fields present in all branches, where (using anonymous types for compactness), and assuming the enum definition: { 'union': 'Simple', 'common': { 'readonly': 'bool' }, 'data': { 'one': 'str', 'two': 'int' } } is shorthand for: { 'union': 'Flat', 'base': { 'readonly': 'bool', 'type': 'Enum' }, 'discriminator': 'type', 'data': { 'one': { 'data': 'str' }, 'two': { 'data': 'int' } } } that is, where 'base' for flat unions is the union of the 'common' type and 'discriminator':'discriminator-type' member of simple unions. At any rate, any changes along these lines will be a later series. Time for me to get back to work on publishing v6 :) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --NDRUMkTDK8RhhNdfXQ3p6IW7jXqKWrVFO 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/ iQEcBAEBCAAGBQJVGufvAAoJEKeha0olJ0NqY+MH/iu2QSjC4MJYqS2TMZKccHB6 3j9JFlkBouhnmrXk53AfDtNvGoN6ZtRfymDTqgM5ggZLF6UJysfUppmYFKAgmBn/ Rd55S2G+E3OXj7Q9OxF1NNeKx6Zu8sd3GQE3ThfRWORJOOCq9sZmp3vCWSH3LgGf MjIX2OEU0DLFnGRQrcYA3JsdxftUblnZFZgO7WTIZPPv+4TdrnpJyII/TfpJ6bb5 zvDBboo6u/YF5uROIZOpipr0HYfVC07Nq1P/lVwA+MjHJvsl87KA2ekzpAB6BUw/ pHFsch/vN4QNCnEfoUHTKti1ocH/MMneAuGCcQaQh0hTWgH4L+0z0SzITab8Xos= =rEtR -----END PGP SIGNATURE----- --NDRUMkTDK8RhhNdfXQ3p6IW7jXqKWrVFO--