From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCp3B-0008U1-3s for qemu-devel@nongnu.org; Tue, 14 Jun 2016 10:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCp36-0006qg-Q1 for qemu-devel@nongnu.org; Tue, 14 Jun 2016 10:10:40 -0400 Date: Tue, 14 Jun 2016 15:10:26 +0100 From: "Daniel P. Berrange" Message-ID: <20160614141026.GT4310@redhat.com> Reply-To: "Daniel P. Berrange" References: <1464885987-4039-1-git-send-email-berrange@redhat.com> <1464885987-4039-3-git-send-email-berrange@redhat.com> <5fec2dd2-b4e4-5e6c-a2cc-9aba498976da@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5fec2dd2-b4e4-5e6c-a2cc-9aba498976da@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 02/11] qapi: allow QmpInputVisitor to auto-cast types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Eric Blake , Max Reitz , Markus Armbruster , Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-block@nongnu.org On Wed, Jun 08, 2016 at 02:01:23PM +0200, Paolo Bonzini wrote: > > > On 02/06/2016 18:46, Daniel P. Berrange wrote: > > Currently the QmpInputVisitor assumes that all scalar > > values are directly represented as their final types. > > ie it assumes an 'int' is using QInt, and a 'bool' is > > using QBool. > > > > This extends it so that QString is optionally permitted > > for any of the non-string scalar types. This behaviour > > is turned on by requesting the 'autocast' flag in the > > constructor. > > > > This makes it possible to use QmpInputVisitor with a > > QDict produced from QemuOpts, where everything is in > > string format. > > Perhaps this should instead be a separate QmpStringInputVisitor visitor > that _only_ accepts strings? You can reuse most of the QmpInputVisitor > by putting it in the same file, because the struct and list visitors are > compatible. Yes, that actually works out quite nicely indeed, and in fact showed up a bug in my unit tests too :-) Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|