From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJXFL-0007iw-Q8 for qemu-devel@nongnu.org; Sat, 02 Jul 2016 22:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJXFH-0006Ml-Jz for qemu-devel@nongnu.org; Sat, 02 Jul 2016 22:34:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJXFH-0006Lg-Br for qemu-devel@nongnu.org; Sat, 02 Jul 2016 22:34:55 -0400 References: <1463784024-17242-1-git-send-email-eblake@redhat.com> <1463784024-17242-4-git-send-email-eblake@redhat.com> <87porjdht3.fsf@dusky.pond.sub.org> <57600A99.7030209@redhat.com> From: Eric Blake Message-ID: <577879CC.2010700@redhat.com> Date: Sat, 2 Jul 2016 20:34:52 -0600 MIME-Version: 1.0 In-Reply-To: <57600A99.7030209@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1GWmnXhciSerA0gVXHPULq7DdtBM90egX" Subject: Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1GWmnXhciSerA0gVXHPULq7DdtBM90egX From: Eric Blake To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth Message-ID: <577879CC.2010700@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered References: <1463784024-17242-1-git-send-email-eblake@redhat.com> <1463784024-17242-4-git-send-email-eblake@redhat.com> <87porjdht3.fsf@dusky.pond.sub.org> <57600A99.7030209@redhat.com> In-Reply-To: <57600A99.7030209@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/14/2016 07:46 AM, Eric Blake wrote: >> I'd let the cases not mentioned default to the empty type (ample >> precedence in other languages), but I can live with making the user as= k >> for the empty type explicitly. But we should then make that less >> cumbersome than now: you have to define an empty struct type, and use >> that. Examples of such hoop-jumping: CpuInfoOther, Abort, >> NetdevNoneOptions. >=20 > Later in the series, I do just that, so that we can write 'other':{} > instead of 'other':'CpuInfoOther'. >=20 > What I did not do (but maybe should) is make that short syntax possible= > on simple unions (so that we could do 'abort':{} rather than > 'abort':'Abort') - and merely distinguish that simple unions cannot > stick anything within the {}, thus leaving non-empty anonymous branches= > only for discriminated unions. Can do that as a followup or if this > series needs a respin. In fact, it turns out that allowing 'abort':{} for 'TransactionAction' is harder than I thought - we still have to create a wrapper type, and the wrapper type must still be used to parse: 'action': { 'type':'abort', 'data': {} } and qapi-types.h would look roughly like: +struct q_obj_q_empty_wrapper { + q_empty *data; +}; =2E.. struct TransactionAction { TransactionActionKind type; union { /* union tag is @type */ q_obj_BlockdevSnapshot_wrapper blockdev_snapshot; q_obj_BlockdevSnapshotSync_wrapper blockdev_snapshot_sync; q_obj_DriveBackup_wrapper drive_backup; q_obj_BlockdevBackup_wrapper blockdev_backup; - q_obj_Abort_wrapper abort; + q_obj_q_empty_wrapper abort; but as I said elsewhere in this thread, we then have to figure out how to emit 'q_empty' and 'visit_type_q_empty_members()' without running into duplicate definitions. For that matter, it might be nice if the parser would allow: 'action': { 'type':'abort' } that is, treat 'data' as optional if the only thing data would contain is an empty dictionary - but that would be even trickier to code. So for v8, I'm not getting rid of any empty types for simple unions. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1GWmnXhciSerA0gVXHPULq7DdtBM90egX 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/ iQEcBAEBCAAGBQJXeHnMAAoJEKeha0olJ0NquZYH/1cOHSkjdsDteuSkPlK/Ub2/ ku6smFAqrolLSRNn6gp3uRdMq1NOCvvCd7cbejpHPB1aXl0crhtJcrOtAyHY1WwS ynYapiXr2dBJWD69b/pgDl0pa43Q+JLhfEo9oqU/kd3BSs3TG9NJWrxD4dIDe7/e PzOTPM3mLTsCakOH38VsN2zGqP57vgfnbL6wwJu2SuW4KfN5BRMQOr3tyt3gQKWD HcuEWG8BvpgEbNjmMJtstvdOSBMXV2B1NpqvL9Q1GqXR/vyvIbuNFsQ33+YVelMU upJ8eR0c2DuGM+4sCiNE2NQHUFBwbvC5LJjMEZQvELKEQycc3TsZ5DHMG7ECQxY= =K37B -----END PGP SIGNATURE----- --1GWmnXhciSerA0gVXHPULq7DdtBM90egX--