Patchwork [09/20] qapi: QmpOutputVisitor, implement array handling

login
register
mail settings
Submitter Michael Roth
Date Aug. 14, 2012, 4:27 p.m.
Message ID <1344961646-21194-10-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/177389/
State New
Headers show

Comments

Michael Roth - Aug. 14, 2012, 4:27 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qapi/qmp-output-visitor.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch

diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index 2bce9d5..ea08795 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -181,6 +181,23 @@  static void qmp_output_type_number(Visitor *v, double *obj, const char *name,
     qmp_output_add(qov, name, qfloat_from_double(*obj));
 }
 
+static void qmp_output_start_carray(Visitor *v, void **obj, const char *name,
+                                    size_t elem_count, size_t elem_size,
+                                    Error **errp)
+{
+    qmp_output_start_list(v, name, errp);
+}
+
+static void qmp_output_next_carray(Visitor *v, Error **errp)
+{
+}
+
+static void qmp_output_end_carray(Visitor *v, Error **errp)
+{
+    QmpOutputVisitor *qov = to_qov(v);
+    qmp_output_pop(qov);
+}
+
 QObject *qmp_output_get_qobject(QmpOutputVisitor *qov)
 {
     QObject *obj = qmp_output_first(qov);
@@ -228,6 +245,9 @@  QmpOutputVisitor *qmp_output_visitor_new(void)
     v->visitor.type_bool = qmp_output_type_bool;
     v->visitor.type_str = qmp_output_type_str;
     v->visitor.type_number = qmp_output_type_number;
+    v->visitor.start_carray = qmp_output_start_carray;
+    v->visitor.next_carray = qmp_output_next_carray;
+    v->visitor.end_carray = qmp_output_end_carray;
 
     QTAILQ_INIT(&v->stack);