[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 06/24] qapi: Factor out common part of qobject in
From: |
Markus Armbruster |
Subject: |
[Qemu-block] [PATCH v2 06/24] qapi: Factor out common part of qobject input visitor creation |
Date: |
Tue, 28 Feb 2017 22:26:52 +0100 |
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
qapi/qobject-input-visitor.c | 61 +++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index e2e3e70..270033e 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -619,22 +619,34 @@ static void qobject_input_free(Visitor *v)
g_free(qiv);
}
+static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj)
+{
+ QObjectInputVisitor *v = g_malloc0(sizeof(*v));
+
+ assert(obj);
+
+ v->visitor.type = VISITOR_INPUT;
+ v->visitor.start_struct = qobject_input_start_struct;
+ v->visitor.check_struct = qobject_input_check_struct;
+ v->visitor.end_struct = qobject_input_pop;
+ v->visitor.start_list = qobject_input_start_list;
+ v->visitor.next_list = qobject_input_next_list;
+ v->visitor.check_list = qobject_input_check_list;
+ v->visitor.end_list = qobject_input_pop;
+ v->visitor.start_alternate = qobject_input_start_alternate;
+ v->visitor.optional = qobject_input_optional;
+ v->visitor.free = qobject_input_free;
+
+ v->root = obj;
+ qobject_incref(obj);
+
+ return v;
+}
+
Visitor *qobject_input_visitor_new(QObject *obj)
{
- QObjectInputVisitor *v;
+ QObjectInputVisitor *v = qobject_input_visitor_base_new(obj);
- assert(obj);
- v = g_malloc0(sizeof(*v));
-
- v->visitor.type = VISITOR_INPUT;
- v->visitor.start_struct = qobject_input_start_struct;
- v->visitor.check_struct = qobject_input_check_struct;
- v->visitor.end_struct = qobject_input_pop;
- v->visitor.start_list = qobject_input_start_list;
- v->visitor.next_list = qobject_input_next_list;
- v->visitor.check_list = qobject_input_check_list;
- v->visitor.end_list = qobject_input_pop;
- v->visitor.start_alternate = qobject_input_start_alternate;
v->visitor.type_int64 = qobject_input_type_int64;
v->visitor.type_uint64 = qobject_input_type_uint64;
v->visitor.type_bool = qobject_input_type_bool;
@@ -642,30 +654,14 @@ Visitor *qobject_input_visitor_new(QObject *obj)
v->visitor.type_number = qobject_input_type_number;
v->visitor.type_any = qobject_input_type_any;
v->visitor.type_null = qobject_input_type_null;
- v->visitor.optional = qobject_input_optional;
- v->visitor.free = qobject_input_free;
-
- v->root = obj;
- qobject_incref(obj);
return &v->visitor;
}
Visitor *qobject_input_visitor_new_keyval(QObject *obj)
{
- QObjectInputVisitor *v;
+ QObjectInputVisitor *v = qobject_input_visitor_base_new(obj);
- v = g_malloc0(sizeof(*v));
-
- v->visitor.type = VISITOR_INPUT;
- v->visitor.start_struct = qobject_input_start_struct;
- v->visitor.check_struct = qobject_input_check_struct;
- v->visitor.end_struct = qobject_input_pop;
- v->visitor.start_list = qobject_input_start_list;
- v->visitor.next_list = qobject_input_next_list;
- v->visitor.check_list = qobject_input_check_list;
- v->visitor.end_list = qobject_input_pop;
- v->visitor.start_alternate = qobject_input_start_alternate;
v->visitor.type_int64 = qobject_input_type_int64_keyval;
v->visitor.type_uint64 = qobject_input_type_uint64_keyval;
v->visitor.type_bool = qobject_input_type_bool_keyval;
@@ -674,11 +670,6 @@ Visitor *qobject_input_visitor_new_keyval(QObject *obj)
v->visitor.type_any = qobject_input_type_any;
v->visitor.type_null = qobject_input_type_null;
v->visitor.type_size = qobject_input_type_size_keyval;
- v->visitor.optional = qobject_input_optional;
- v->visitor.free = qobject_input_free;
-
- v->root = obj;
- qobject_incref(obj);
return &v->visitor;
}
--
2.7.4
- [Qemu-block] [PATCH v2 10/24] qjson: Abort earlier on qobject_from_jsonf() misuse, (continued)
- [Qemu-block] [PATCH v2 10/24] qjson: Abort earlier on qobject_from_jsonf() misuse, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 13/24] block: More detailed syntax error reporting for JSON filenames, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 11/24] test-qobject-input-visitor: Abort earlier on bad test input, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 03/24] keyval: New keyval_parse(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 04/24] qapi: qobject input visitor variant for use with keyval_parse(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 15/24] test-visitor-serialization: Pass &error_abort to qobject_from_json(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 23/24] docs/qapi-code-gen.txt: Clarify naming rules, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 06/24] qapi: Factor out common part of qobject input visitor creation,
Markus Armbruster <=
- [Qemu-block] [PATCH v2 07/24] qapi: Factor out common qobject_input_get_keyval(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 16/24] monitor: Assert qmp_schema_json[] is sane, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 20/24] qapi: New qobject_input_visitor_new_str() for convenience, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 19/24] keyval: Restrict key components to valid QAPI names, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 22/24] qapi: Improve how keyval input visitor reports unexpected dicts, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 05/24] test-keyval: Cover use with qobject input visitor, Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 14/24] check-qjson: Test errors from qobject_from_json(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 12/24] qobject: Propagate parse errors through qobject_from_json(), Markus Armbruster, 2017/02/28
- [Qemu-block] [PATCH v2 18/24] qapi: New parse_qapi_name(), Markus Armbruster, 2017/02/28