qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 26/26] qapi: Improve qobject visitor documentation
Date: Sun, 26 Feb 2017 22:43:44 +0100	[thread overview]
Message-ID: <1488145424-14974-27-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1488145424-14974-1-git-send-email-armbru@redhat.com>

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qapi/qobject-input-visitor.h  | 37 ++++++++++++++++++++++++++++++++++-
 include/qapi/qobject-output-visitor.h | 35 +++++++++++++++++++++++++++++----
 2 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h
index 21db9c4..0b7633a 100644
--- a/include/qapi/qobject-input-visitor.h
+++ b/include/qapi/qobject-input-visitor.h
@@ -1,6 +1,7 @@
 /*
  * Input Visitor
  *
+ * Copyright (C) 2017 Red Hat, Inc.
  * Copyright IBM, Corp. 2011
  *
  * Authors:
@@ -20,7 +21,41 @@
 typedef struct QObjectInputVisitor QObjectInputVisitor;
 
 /*
- * Return a new input visitor that converts a QObject to a QAPI object.
+ * Create a QObject input visitor for @obj
+ *
+ * A QObject input visitor visit builds a QAPI object from a QObject.
+ * This simultaneously walks the QAPI object being built and the
+ * QObject.  The latter walk starts at @obj.
+ *
+ * visit_type_FOO() creates an instance of QAPI type FOO.  The visited
+ * QObject must match FOO.  QDict matches struct/union types, QList
+ * matches list types, QString matches type 'str' and enumeration
+ * types, QInt matches integer types, QFloat matches type 'number',
+ * QBool matches type 'bool'.  Type 'any' is matched by QObject.  A
+ * QAPI alternate type is matched when one of its member types is.
+ *
+ * visit_start_struct() ... visit_end_struct() visits a QDict and
+ * creates a QAPI struct/union.  Visits in between visit the
+ * dictionary members.  visit_optional() is true when the QDict has
+ * this member.  visit_check_struct() fails if unvisited members
+ * remain.
+ *
+ * visit_start_list() ... visit_end_list() visits a QList and creates
+ * a QAPI list.  Visits in between visit list members, one after the
+ * other.  visit_next_list() returns NULL when all QList members have
+ * been visited.  visit_check_list() fails if unvisited members
+ * remain.
+ *
+ * visit_start_alternate() ... visit_end_alternate() visits a QObject
+ * and creates a QAPI alternate.  The visit in between visits the same
+ * QObject and initializes the alternate member that is in use.
+ *
+ * Error messages refer to parts of @obj in JavaScript/Python syntax.
+ * For example, 'a.b[2]' refers to the second member of the QList
+ * member 'b' of the QDict member 'a' of QDict @obj.
+ *
+ * The caller is responsible for freeing the visitor with
+ * visit_free().
  */
 Visitor *qobject_input_visitor_new(QObject *obj);
 
diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-output-visitor.h
index 8241877..9b990c3 100644
--- a/include/qapi/qobject-output-visitor.h
+++ b/include/qapi/qobject-output-visitor.h
@@ -19,11 +19,38 @@
 
 typedef struct QObjectOutputVisitor QObjectOutputVisitor;
 
-/*
- * Create a new QObject output visitor.
+/**
+ * Create a QObject output visitor for @obj
  *
- * If everything else succeeds, pass @result to visit_complete() to
- * collect the result of the visit.
+ * A QObject output visitor visit builds a QObject from QAPI Object.
+ * This simultaneously walks the QAPI object and the QObject being
+ * built.  The latter walk starts at @obj.
+ *
+ * visit_type_FOO() creates a QObject for QAPI type FOO.  It creates a
+ * QDict for struct/union types, a QList for list types, QString for
+ * type 'str' and enumeration types, QInt for integer types, QFloat
+ * for type 'number', QBool for type 'bool'.  For type 'any', it
+ * increments the QObject's reference count.  For QAPI alternate
+ * types, it creates the QObject for the member that is in use.
+ *
+ * visit_start_struct() ... visit_end_struct() visits a QAPI
+ * struct/union and creates a QDict.  Visits in between visit the
+ * members.  visit_optional() is true when the struct/union has this
+ * member.  visit_check_struct() does nothing.
+ *
+ * visit_start_list() ... visit_end_list() visits a QAPI list and
+ * creates a QList.  Visits in between visit list members, one after
+ * the other.  visit_next_list() returns NULL when all QAPI list
+ * members have been visited.  visit_check_list() does nothing.
+ *
+ * visit_start_alternate() ... visit_end_alternate() visits a QAPI
+ * alternate.  The visit in between creates the QObject for the
+ * alternate member that is in use.
+ *
+ * Errors are not expected to happen.
+ *
+ * The caller is responsible for freeing the visitor with
+ * visit_free().
  */
 Visitor *qobject_output_visitor_new(QObject **result);
 
-- 
2.7.4

  parent reply	other threads:[~2017-02-26 21:43 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26 21:43 [Qemu-devel] [PATCH v2 00/26] qapi: QMP dispatch and input visitor work Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 01/26] qga: Fix crash on non-dictionary QMP argument Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 02/26] libqtest: Work around a "QMP wants a newline" bug Markus Armbruster
2017-02-27 16:36   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 03/26] qmp-test: New, covering basic QMP protocol Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 04/26] qmp: Dumb down how we run QMP command registration Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 05/26] qmp: Clean up how we enforce capability negotiation Markus Armbruster
2017-02-27 16:39   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 06/26] qmp: Drop duplicated QMP command object checks Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 07/26] qmp: Eliminate silly QERR_QMP_* macros Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 08/26] qmp: Improve QMP dispatch error messages Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 09/26] qapi: Improve a QObject input visitor error message Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 10/26] qapi: Clean up after commit 3d344c2 Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 11/26] qapi: Make QObject input visitor set *list reliably Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 12/26] qapi: Improve qobject input visitor error reporting Markus Armbruster
2017-02-27 16:45   ` Eric Blake
2017-02-28  8:42     ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 13/26] qapi: Drop string input visitor method optional() Markus Armbruster
2017-02-27 16:46   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 14/26] qapi: Make string input and opts visitor require non-null input Markus Armbruster
2017-02-27 16:58   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 15/26] qom: Make object_property_set_qobject()'s input visitor strict Markus Armbruster
2017-02-27 19:25   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 16/26] test-qobject-input-visitor: Use strict visitor Markus Armbruster
2017-02-27 22:49   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 17/26] qapi: Drop unused non-strict qobject input visitor Markus Armbruster
2017-02-28 14:56   ` Eric Blake
2017-02-28 17:29     ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 18/26] tests-qobject-input-strict: Merge into test-qobject-input-visitor Markus Armbruster
2017-02-28 15:39   ` Eric Blake
2017-02-28 16:57     ` Markus Armbruster
2017-02-28 17:10       ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 19/26] test-string-input-visitor: Tear down existing test automatically Markus Armbruster
2017-02-28 15:44   ` Eric Blake
2017-02-28 16:08     ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 20/26] test-string-input-visitor: Improve list coverage Markus Armbruster
2017-02-28 15:47   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 21/26] tests: Cover partial input visit of list Markus Armbruster
2017-02-28 15:55   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 22/26] test-qobject-input-visitor: Cover missing nested struct member Markus Armbruster
2017-02-28 16:00   ` Eric Blake
2017-02-28 16:52     ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 23/26] qapi: Make input visitors detect unvisited list tails Markus Armbruster
2017-02-28 16:09   ` Eric Blake
2017-02-28 16:55     ` Markus Armbruster
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 24/26] tests: Cover input visit beyond end of list Markus Armbruster
2017-02-28 16:19   ` Eric Blake
2017-02-26 21:43 ` [Qemu-devel] [PATCH v2 25/26] qapi: Fix object " Markus Armbruster
2017-02-28 16:20   ` Eric Blake
2017-02-26 21:43 ` Markus Armbruster [this message]
2017-02-28 16:22   ` [Qemu-devel] [PATCH v2 26/26] qapi: Improve qobject visitor documentation Eric Blake
2017-02-26 22:23 ` [Qemu-devel] [PATCH v2 00/26] qapi: QMP dispatch and input visitor work no-reply

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=1488145424-14974-27-git-send-email-armbru@redhat.com \
    --to=armbru@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).