qapi: Factor out common part of qobject input visitor creation

Backports commit abe81bc21a6996c62e66ed2d051373c0df24f870 from qemu
This commit is contained in:
Markus Armbruster 2018-03-03 17:26:13 -05:00 committed by Lioncash
parent c4e0911f95
commit 247a511c4a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -482,12 +482,11 @@ static void qobject_input_free(Visitor *v)
g_free(qiv); g_free(qiv);
} }
Visitor *qobject_input_visitor_new(QObject *obj) static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj)
{ {
QObjectInputVisitor *v; QObjectInputVisitor *v = g_malloc0(sizeof(*v));
assert(obj); assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT; v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qobject_input_start_struct; v->visitor.start_struct = qobject_input_start_struct;
@ -498,6 +497,19 @@ Visitor *qobject_input_visitor_new(QObject *obj)
v->visitor.next_list = qobject_input_next_list; v->visitor.next_list = qobject_input_next_list;
v->visitor.check_list = qobject_input_check_list; v->visitor.check_list = qobject_input_check_list;
v->visitor.end_list = qobject_input_pop; v->visitor.end_list = qobject_input_pop;
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 = qobject_input_visitor_base_new(obj);
v->visitor.type_int64 = qobject_input_type_int64; v->visitor.type_int64 = qobject_input_type_int64;
v->visitor.type_uint64 = qobject_input_type_uint64; v->visitor.type_uint64 = qobject_input_type_uint64;
v->visitor.type_bool = qobject_input_type_bool; v->visitor.type_bool = qobject_input_type_bool;
@ -505,11 +517,6 @@ Visitor *qobject_input_visitor_new(QObject *obj)
v->visitor.type_number = qobject_input_type_number; v->visitor.type_number = qobject_input_type_number;
v->visitor.type_any = qobject_input_type_any; v->visitor.type_any = qobject_input_type_any;
v->visitor.type_null = qobject_input_type_null; 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; return &v->visitor;
} }