From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vdgsa-0000rM-6M for qemu-devel@nongnu.org; Tue, 05 Nov 2013 08:41:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdgsV-00035r-CR for qemu-devel@nongnu.org; Tue, 05 Nov 2013 08:41:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdgsV-00035j-4o for qemu-devel@nongnu.org; Tue, 05 Nov 2013 08:41:07 -0500 Message-ID: <5278F56E.70104@redhat.com> Date: Tue, 05 Nov 2013 06:41:02 -0700 From: Eric Blake MIME-Version: 1.0 References: <1383611860-9053-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1383611860-9053-8-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1383611860-9053-8-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VIJ8cc0wP59MpaMtccvf7IBNCNUvISPrD" Subject: Re: [Qemu-devel] [PATCH RFC 07/10] qapi script: support direct inheritance for struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VIJ8cc0wP59MpaMtccvf7IBNCNUvISPrD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/04/2013 05:37 PM, Wenchao Xia wrote: > Now it is possible to inherit another struct inside data directly, > which saves trouble to define trivial structure. >=20 > Signed-off-by: Wenchao Xia > --- > docs/qapi-code-gen.txt | 21 +++++++++++++++++++++ > scripts/qapi-visit.py | 14 ++++++++++---- > 2 files changed, 31 insertions(+), 4 deletions(-) >=20 > diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt > index 0728f36..3e42ff4 100644 > --- a/docs/qapi-code-gen.txt > +++ b/docs/qapi-code-gen.txt > @@ -70,6 +70,27 @@ both fields like this: > { "file": "/some/place/my-image", > "backing": "/some/place/my-backing-file" } > =20 > +It is possible to directly inherit other struct by keyword '_base': > + > + { 'type': 'NetworkConnectionInfo', 'data': { 'host': 'str', 'service'= : 'str' } } > + { 'type': 'VncConnectionInfo', > + 'data': { > + 'server': { > + '_base': 'NetworkConnectionInfo', Interesting idea for shorthand. However, I would suggest that you pick a different character than '_', since '_' is valid in names. That is, we already have special handling of leading '*' to mark a field as optional, so I suggest something like '^' to mark a base class. By using a non-name character, it becomes more obvious that the leading character has a special meaning to the qapi generator. I'm also not convinced yet that we want this shorthand; in particular, I'm worried whether it will make the introspection patches harder to writ= e. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VIJ8cc0wP59MpaMtccvf7IBNCNUvISPrD 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.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSePVvAAoJEKeha0olJ0NqvwEH/0GJzgir0fa3lxYoW3hqATH2 ZSF5APt0ZC0DOZMYa0yE3vdBdVi/f90xfJnD9UtNL+bhV6Sx307aRVI6n5k4Zzb0 Gq8lHTOxdRXZBskcxernOIFPmDRQ1YnESEM/iDjmunxszDZ7rapuBWhmlMDxn8uy x3gPkIcs83QUqmeJqBlXlC7UnTIaxcheZ334t/qeP6IfA7OdsIxbfrVys7/6FOuS oyD6gzX2slypAbjxob3BjY6aEJWa2vZ91apUAbvMwKaqXOxUtTbbsrXeDoJROJBD B99MnEkM7owWLIV8hMlT6SGUTdnbz5k6nxvjG0yUTL22KjEJ+WNi0jJQvji8ERI= =lp2L -----END PGP SIGNATURE----- --VIJ8cc0wP59MpaMtccvf7IBNCNUvISPrD--