From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJq2H-0001MC-0G for qemu-devel@nongnu.org; Mon, 27 Jul 2015 17:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJq2B-0004Ou-Rk for qemu-devel@nongnu.org; Mon, 27 Jul 2015 17:34:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJq2B-0004Oi-Ke for qemu-devel@nongnu.org; Mon, 27 Jul 2015 17:34:07 -0400 References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-8-git-send-email-armbru@redhat.com> <55AD7F18.1010205@redhat.com> <87380d4vds.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <55B6A3C8.4050006@redhat.com> Date: Mon, 27 Jul 2015 15:34:00 -0600 MIME-Version: 1.0 In-Reply-To: <87380d4vds.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sVubOw3vWfnU5xI3oc3MkgEn1PCuN7gHx" Subject: Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --sVubOw3vWfnU5xI3oc3MkgEn1PCuN7gHx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/24/2015 06:01 AM, Markus Armbruster wrote: >> It might be worth tweaking the generator to output a C comment either >> here (at the start of the larger struct)... >> >>> char *string; >>> EnumOne enum1; >> >> ...or here (at the end of the base struct) mentioning that >> UserDefFlatUnion can be cast into its base struct UserDefUnionBase, to= >> make it easier when reading the generated code to trace back to that >> "inheritance" relationship. Right now, there is nothing in the >> generated UserDefFlatUnion that points you back to the qapi relationsh= ip >> of a base class. But it's not a show-stopper if you don't like my >> suggestion. >=20 > I do like it. Perhaps something like >=20 > struct UserDefFlatUnion > { > /* Members inherited from UserDefUnionBase: */ > char *string; > EnumOne enum1; > /* Own members: */ > ... > }; What about nested types? Whatever we pick has to look good when indirect bases are involved. Suppose we have Base -> Mid -> Derived as a struct inheritance. If we generate a comment at both start and end of visiting a base class (and visit base classes recursively), we'd have something like: struct Derived { /* Members inherited from Mid */ /* Members inherited from Base */ int one; /* End members inherited from Base */ int two; /* End members inherited from Mid */ /* own members */ int three; ... }; Don't know if that helps you think about it more, but now I'm just painting a bikeshed that just adds the tail comment. Here's the resulting RFC: http://thread.gmane.org/gmane.comp.emulators.qemu/353204 and the resulting generated structs: struct BlockdevOptionsQcow2 { - BlockdevOptionsGenericCOWFormat *base; + BlockdevRef *file; + /* End fields inherited from BlockdevOptionsGenericFormat. */ + bool has_backing; + BlockdevRef *backing; + /* End fields inherited from BlockdevOptionsGenericCOWFormat. */ bool has_lazy_refcounts; bool lazy_refcounts; =2E.. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --sVubOw3vWfnU5xI3oc3MkgEn1PCuN7gHx 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/ iQEcBAEBCAAGBQJVtqPIAAoJEKeha0olJ0NqoVcH/jKaXf5hjKdcFmgxjfFC/dva AJ5V1lrA7jgS+19xtqXSC72ZmfkAWnV3siJJ6NAWXGkO9dkmbaR3XiaDq3ML73AH kPThg4b6+nOMsDY2QcOIyV9kBsSqAHwrprTUCLJ96qdIzZN8egz9fHU2Vpy66i7x nKwjnpFMMt+VXlo8gEOUTouwYSRQ90Qoc9Tvyj1HwNwozfYSkrmwUC8HJKTlAYmt Je85NXvc5dzhYrSLdwDq92Xu8+2CW/NsL/8CCvx5FZPoNzqANPVqASX045ZmIukT 7Sa9w3brk7e0UKetKbcLYpc2rm3E89N0XpjpIGSRRkjRiGl9qwYofcwbvZqmQTY= =5ShD -----END PGP SIGNATURE----- --sVubOw3vWfnU5xI3oc3MkgEn1PCuN7gHx--