All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion
Date: Tue, 13 Sep 2016 11:05:08 +0200	[thread overview]
Message-ID: <87mvjccgqj.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1473088600-17930-6-git-send-email-berrange@redhat.com> (Daniel P. Berrange's message of "Mon, 5 Sep 2016 16:16:39 +0100")

"Daniel P. Berrange" <berrange@redhat.com> writes:

> 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 adds an alternative constructor for QmpInputVisitor
> that will set it up such that it expects a QString for
> all scalar types instead.
>
> This makes it possible to use QmpInputVisitor with a
> QDict produced from QemuOpts, where everything is in
> string format.

Can you explain how this is related to the Options visitor?

> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  include/qapi/qobject-input-visitor.h |  41 +++++++++-
>  qapi/qobject-input-visitor.c         | 115 +++++++++++++++++++++++++-
>  tests/test-qobject-input-visitor.c   | 152 ++++++++++++++++++++++++++++++++++-
>  3 files changed, 298 insertions(+), 10 deletions(-)
>
> diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h
> index cde328d..aa911cb 100644
> --- a/include/qapi/qobject-input-visitor.h
> +++ b/include/qapi/qobject-input-visitor.h
> @@ -19,12 +19,45 @@
>  
>  typedef struct QObjectInputVisitor QObjectInputVisitor;
>  
> -/*
> - * Return a new input visitor that converts a QObject to a QAPI object.
> +/**
> + * qobject_input_visitor_new:
> + * @obj: the input object to visit
> + * @strict: whether to require that all input keys are consumed
> + *
> + * Create a new input visitor that converts a QObject to a QAPI object.
> + *
> + * Any scalar values in the @obj input data structure should be in the
> + * required type already. i.e. if visiting a bool, the value should
> + * already be a QBool instance.
>   *
> - * Set @strict to reject a parse that doesn't consume all keys of a
> - * dictionary; otherwise excess input is ignored.
> + * If @strict is set to true, then an error will be reported if any
> + * dict keys are not consumed during visitation.
> + *
> + * The returned input visitor should be released by calling
> + * visit_free() when no longer required.
> + *
> + * Returns: a new input visitor
>   */

GDK-Doc style is an egregious waste of screen space and reader
bandwidth.  Much of the text is spent on restating the obvious, drowning
out the parts that are actually interesting.

Compare:

   /*
  - * Return a new input visitor that converts a QObject to a QAPI object.
  + * Create an input visitor that converts @obj to a QAPI object.
    *
  - * Set @strict to reject a parse that doesn't consume all keys of a
  - * dictionary; otherwise excess input is ignored.
  + * 
  + * If @strict is true, the visit is expected to consume all of @obj's
  + * keys.  Else, excess keys are silently ignored.
  + *
  + * Return the input visitor.  It should be destroyed with visit_free().
  + */

Like your version, this is vague on what exactly happens when a strict
visit fails to consume all keys.  It's more explicitly vague, though :)

GDK-Doc is that way so that a fairly dumb tool can generate fairly
usable library reference documentation.  We're not using that tool.
This is not a library.  I loathe having my read bandwidth wasted.

>  Visitor *qobject_input_visitor_new(QObject *obj, bool strict);
>  
> +/**
> + * qobject_string_input_visitor_new:
> + * @obj: the input object to visit
> + *
> + * Create a new input visitor that converts a QObject to a QAPI object.
> + *
> + * Any scalar values in the @obj input data structure should always be
> + * represented as strings. i.e. if visiting a boolean, the value should
> + * be a QString whose contents represent a valid boolean.
> + *
> + * The visitor always operates in strict mode, requiring all dict keys
> + * to be consumed during visitation.
> + *
> + * The returned input visitor should be released by calling
> + * visit_free() when no longer required.
> + *
> + * Returns: a new input visitor
> + */
> +Visitor *qobject_string_input_visitor_new(QObject *obj);
> +
>  #endif
[...]

  parent reply	other threads:[~2016-09-13  9:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 15:16 [Qemu-devel] [PATCH v11 0/6] QAPI/QOM work for non-scalar object properties Daniel P. Berrange
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 1/6] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-09-14 14:18   ` Kevin Wolf
2016-09-15 11:30     ` Daniel P. Berrange
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 2/6] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-09-14 14:33   ` Kevin Wolf
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 3/6] qapi: rename QmpInputVisitor to QObjectInputVisitor Daniel P. Berrange
2016-09-12 16:19   ` Markus Armbruster
2016-09-13 10:25     ` Daniel P. Berrange
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 4/6] qapi: rename QmpOutputVisitor to QObjectOutputVisitor Daniel P. Berrange
2016-09-12 16:20   ` Markus Armbruster
2016-09-13 10:25     ` Daniel P. Berrange
2016-09-12 18:24   ` Eric Blake
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion Daniel P. Berrange
2016-09-12 16:21   ` Markus Armbruster
2016-09-12 16:23     ` Daniel P. Berrange
2016-09-12 16:30       ` Daniel P. Berrange
2016-09-12 18:39   ` Eric Blake
2016-09-13 10:22     ` Daniel P. Berrange
2016-09-13  9:05   ` Markus Armbruster [this message]
2016-09-13  9:33     ` Daniel P. Berrange
2016-09-13 13:32       ` Markus Armbruster
2016-09-13 13:47         ` Daniel P. Berrange
2016-09-14 14:59   ` Kevin Wolf
2016-09-15 11:33     ` Daniel P. Berrange
2016-09-05 15:16 ` [Qemu-devel] [PATCH v11 6/6] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-09-12 18:20   ` Eric Blake
2016-09-13 10:32     ` Daniel P. Berrange
2016-09-14 15:04 ` [Qemu-devel] [PATCH v11 0/6] QAPI/QOM work for non-scalar object properties Kevin Wolf
2016-09-15 11:34   ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvjccgqj.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.