From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxGGt-0000W4-Su for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:46:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxGGs-0006tp-8i for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:46:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxGGs-0006tf-1C for qemu-devel@nongnu.org; Thu, 11 Jul 2013 08:46:54 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6BCkrJV021650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Jul 2013 08:46:53 -0400 Message-ID: <51DEA93C.90500@redhat.com> Date: Thu, 11 Jul 2013 06:46:52 -0600 From: Eric Blake MIME-Version: 1.0 References: <1373363617-4723-1-git-send-email-kwolf@redhat.com> <1373363617-4723-3-git-send-email-kwolf@redhat.com> <51DE9DB1.90801@redhat.com> In-Reply-To: <51DE9DB1.90801@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2QGXDAWWHROOGKJMBDVEK" Subject: Re: [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2QGXDAWWHROOGKJMBDVEK Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/11/2013 05:57 AM, Eric Blake wrote: > On 07/09/2013 03:53 AM, Kevin Wolf wrote: >> The new 'base' key in a union definition refers to a struct type, whic= h >> is inlined into the union definition and can represent fields common t= o >> all kinds. >=20 > Is it worth listing an example of intended use in the commit message? > If I understand correctly, then this qapi-schema.json file: >=20 > { 'type': 'Base', > 'data': { 'main': 'str' } } > { 'type': 'Extra1', > 'data': { 'foo': 'str' } } > { 'type': 'Extra2', > 'data': { 'bar': 'str' } } > { 'union': 'Type', > 'base': 'BaseType', > 'data': { 'variant1': 'Extra1', > 'variant2': 'Extra2' } } > { 'command': 'test', > 'data': { 'arg': 'Type' } } >=20 > would then be used over the wire as: >=20 > { "execute": "test", > "arguments": { "arg": { "type": "variant1", > "data": { "main": "hello", "foo": "world" } } } } > { "execute": "test", > "arguments": { "arg": { "type": "variant2", > "data": { "main": "hi", "bar": "there" } } } } I just read patch 6/11, and it looks like I'm a bit off; it looks like the usage syntax with a base type is actually: { "execute": "test", "arguments": { "arg": { "type": "variant1", "main": "hello", "data": { "foo": "world" } } } } { "execute": "test", "arguments": { "arg": { "type": "variant2", "main": "hi", "data": { "bar": "there" } } } } That is, a union type is automatically granted two top-level keys "type" and "data", and a base type grants it additional top-level keys; nested keys under "data" are still tied to just the type listed in the union. See why a commit message can make a difference in understanding? :) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2QGXDAWWHROOGKJMBDVEK 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.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR3qk8AAoJEKeha0olJ0NqTm4H/3OTu/icHp/k12D2624jMJW3 CdUHXJIKCxZhgIitVZC+qglb+Qo1JUfr5+xReMuElcS4xo0yrMWcGYPnELHBE3BJ zWEA/oUnXpcRjq73TWY5Z8vHSf+Hrv+6SoSqBg+ZA3qIi6Vd0q5jdbBkgA3hpFkU UphiU7uz00hAJSqr8ku/r3C5WwsDGYGsA92o+d6y7gBhXehqZ0LQoKmgfxk1PuP4 eiVXVzDwoMySuz+fF31AchjMIHRHoSY+AKvgqELSXkkT/WYL7IxW0uM7pdNvubQz 73/EyVjqs75KyvRUfQxHmiFUGgA/JYwRGuwPZVnDAKrbd1dELP0rvHcOojxwEfg= =J+iR -----END PGP SIGNATURE----- ------enig2QGXDAWWHROOGKJMBDVEK--