aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-09-30 15:45:27 +0100
committerMarkus Armbruster <armbru@redhat.com>2016-10-25 16:25:54 +0200
commit09e68369a88d7de0f988972bf28eec1b80cc47f9 (patch)
tree0d6f22681baf45b13f1eaf4cbb50ab7a2ce185c8
parentb3db211f3c80bb996a704d665fe275619f728bd4 (diff)
qapi: rename QmpInputVisitor to QObjectInputVisitor
The QmpInputVisitor has no direct dependency on QMP. It is valid to use it anywhere that one has a QObject. Rename it to better reflect its functionality as a generic QObject to QAPI converter. The previous commit renamed the files, this one renames C identifiers. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1475246744-29302-5-git-send-email-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Straightforwardly rebased, split into file and identifier rename] Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--docs/qapi-code-gen.txt2
-rw-r--r--include/qapi/qobject-input-visitor.h4
-rw-r--r--qapi/qobject-input-visitor.c168
-rw-r--r--qmp.c2
-rw-r--r--qom/qom-qobject.c2
-rw-r--r--scripts/qapi-commands.py2
-rw-r--r--target-s390x/cpu_models.c2
-rw-r--r--tests/check-qnull.c2
-rw-r--r--tests/test-qmp-commands.c2
-rw-r--r--tests/test-qobject-input-strict.c2
-rw-r--r--tests/test-qobject-input-visitor.c2
-rw-r--r--tests/test-visitor-serialization.c2
12 files changed, 97 insertions, 95 deletions
diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt
index 5d4c2cdd7e..d2604b6a4b 100644
--- a/docs/qapi-code-gen.txt
+++ b/docs/qapi-code-gen.txt
@@ -1024,7 +1024,7 @@ Example:
Visitor *v;
UserDefOneList *arg1 = NULL;
- v = qmp_input_visitor_new(QOBJECT(args), true);
+ v = qobject_input_visitor_new(QOBJECT(args), true);
visit_start_struct(v, NULL, NULL, 0, &err);
if (err) {
goto out;
diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h
index cd7414c4c0..cde328da9f 100644
--- a/include/qapi/qobject-input-visitor.h
+++ b/include/qapi/qobject-input-visitor.h
@@ -17,7 +17,7 @@
#include "qapi/visitor.h"
#include "qapi/qmp/qobject.h"
-typedef struct QmpInputVisitor QmpInputVisitor;
+typedef struct QObjectInputVisitor QObjectInputVisitor;
/*
* Return a new input visitor that converts a QObject to a QAPI object.
@@ -25,6 +25,6 @@ typedef struct QmpInputVisitor QmpInputVisitor;
* Set @strict to reject a parse that doesn't consume all keys of a
* dictionary; otherwise excess input is ignored.
*/
-Visitor *qmp_input_visitor_new(QObject *obj, bool strict);
+Visitor *qobject_input_visitor_new(QObject *obj, bool strict);
#endif
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 81da76cc36..0063327b3b 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -34,7 +34,7 @@ typedef struct StackObject
QSLIST_ENTRY(StackObject) node;
} StackObject;
-struct QmpInputVisitor
+struct QObjectInputVisitor
{
Visitor visitor;
@@ -49,14 +49,14 @@ struct QmpInputVisitor
bool strict;
};
-static QmpInputVisitor *to_qiv(Visitor *v)
+static QObjectInputVisitor *to_qiv(Visitor *v)
{
- return container_of(v, QmpInputVisitor, visitor);
+ return container_of(v, QObjectInputVisitor, visitor);
}
-static QObject *qmp_input_get_object(QmpInputVisitor *qiv,
- const char *name,
- bool consume, Error **errp)
+static QObject *qobject_input_get_object(QObjectInputVisitor *qiv,
+ const char *name,
+ bool consume, Error **errp)
{
StackObject *tos;
QObject *qobj;
@@ -102,8 +102,9 @@ static void qdict_add_key(const char *key, QObject *obj, void *opaque)
g_hash_table_insert(h, (gpointer) key, NULL);
}
-static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj,
- void *qapi, Error **errp)
+static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,
+ QObject *obj, void *qapi,
+ Error **errp)
{
GHashTable *h;
StackObject *tos = g_new0(StackObject, 1);
@@ -125,9 +126,9 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj,
}
-static void qmp_input_check_struct(Visitor *v, Error **errp)
+static void qobject_input_check_struct(Visitor *v, Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
+ QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && !tos->entry);
@@ -145,7 +146,7 @@ static void qmp_input_check_struct(Visitor *v, Error **errp)
}
}
-static void qmp_input_stack_object_free(StackObject *tos)
+static void qobject_input_stack_object_free(StackObject *tos)
{
if (tos->h) {
g_hash_table_unref(tos->h);
@@ -154,21 +155,21 @@ static void qmp_input_stack_object_free(StackObject *tos)
g_free(tos);
}
-static void qmp_input_pop(Visitor *v, void **obj)
+static void qobject_input_pop(Visitor *v, void **obj)
{
- QmpInputVisitor *qiv = to_qiv(v);
+ QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && tos->qapi == obj);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
- qmp_input_stack_object_free(tos);
+ qobject_input_stack_object_free(tos);
}
-static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
- size_t size, Error **errp)
+static void qobject_input_start_struct(Visitor *v, const char *name, void **obj,
+ size_t size, Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
Error *err = NULL;
if (obj) {
@@ -183,7 +184,7 @@ static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
return;
}
- qmp_input_push(qiv, qobj, obj, &err);
+ qobject_input_push(qiv, qobj, obj, &err);
if (err) {
error_propagate(errp, err);
return;
@@ -195,11 +196,12 @@ static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
}
-static void qmp_input_start_list(Visitor *v, const char *name,
- GenericList **list, size_t size, Error **errp)
+static void qobject_input_start_list(Visitor *v, const char *name,
+ GenericList **list, size_t size,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
const QListEntry *entry;
if (!qobj) {
@@ -214,7 +216,7 @@ static void qmp_input_start_list(Visitor *v, const char *name,
return;
}
- entry = qmp_input_push(qiv, qobj, list, errp);
+ entry = qobject_input_push(qiv, qobj, list, errp);
if (list) {
if (entry) {
*list = g_malloc0(size);
@@ -224,10 +226,10 @@ static void qmp_input_start_list(Visitor *v, const char *name,
}
}
-static GenericList *qmp_input_next_list(Visitor *v, GenericList *tail,
- size_t size)
+static GenericList *qobject_input_next_list(Visitor *v, GenericList *tail,
+ size_t size)
{
- QmpInputVisitor *qiv = to_qiv(v);
+ QObjectInputVisitor *qiv = to_qiv(v);
StackObject *so = QSLIST_FIRST(&qiv->stack);
if (!so->entry) {
@@ -238,12 +240,12 @@ static GenericList *qmp_input_next_list(Visitor *v, GenericList *tail,
}
-static void qmp_input_start_alternate(Visitor *v, const char *name,
- GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp)
+static void qobject_input_start_alternate(Visitor *v, const char *name,
+ GenericAlternate **obj, size_t size,
+ bool promote_int, Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, false, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, false, errp);
if (!qobj) {
*obj = NULL;
@@ -256,11 +258,11 @@ static void qmp_input_start_alternate(Visitor *v, const char *name,
}
}
-static void qmp_input_type_int64(Visitor *v, const char *name, int64_t *obj,
- Error **errp)
+static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
@@ -276,12 +278,12 @@ static void qmp_input_type_int64(Visitor *v, const char *name, int64_t *obj,
*obj = qint_get_int(qint);
}
-static void qmp_input_type_uint64(Visitor *v, const char *name, uint64_t *obj,
- Error **errp)
+static void qobject_input_type_uint64(Visitor *v, const char *name,
+ uint64_t *obj, Error **errp)
{
/* FIXME: qobject_to_qint mishandles values over INT64_MAX */
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
@@ -297,11 +299,11 @@ static void qmp_input_type_uint64(Visitor *v, const char *name, uint64_t *obj,
*obj = qint_get_int(qint);
}
-static void qmp_input_type_bool(Visitor *v, const char *name, bool *obj,
- Error **errp)
+static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QBool *qbool;
if (!qobj) {
@@ -317,11 +319,11 @@ static void qmp_input_type_bool(Visitor *v, const char *name, bool *obj,
*obj = qbool_get_bool(qbool);
}
-static void qmp_input_type_str(Visitor *v, const char *name, char **obj,
- Error **errp)
+static void qobject_input_type_str(Visitor *v, const char *name, char **obj,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QString *qstr;
*obj = NULL;
@@ -338,11 +340,11 @@ static void qmp_input_type_str(Visitor *v, const char *name, char **obj,
*obj = g_strdup(qstring_get_str(qstr));
}
-static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
- Error **errp)
+static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
QFloat *qfloat;
@@ -365,11 +367,11 @@ static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
"number");
}
-static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj,
- Error **errp)
+static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
+ Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
*obj = NULL;
if (!qobj) {
@@ -380,10 +382,10 @@ static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj,
*obj = qobj;
}
-static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
+static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, true, errp);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
if (!qobj) {
return;
@@ -395,10 +397,10 @@ static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
}
}
-static void qmp_input_optional(Visitor *v, const char *name, bool *present)
+static void qobject_input_optional(Visitor *v, const char *name, bool *present)
{
- QmpInputVisitor *qiv = to_qiv(v);
- QObject *qobj = qmp_input_get_object(qiv, name, false, NULL);
+ QObjectInputVisitor *qiv = to_qiv(v);
+ QObject *qobj = qobject_input_get_object(qiv, name, false, NULL);
if (!qobj) {
*present = false;
@@ -408,44 +410,44 @@ static void qmp_input_optional(Visitor *v, const char *name, bool *present)
*present = true;
}
-static void qmp_input_free(Visitor *v)
+static void qobject_input_free(Visitor *v)
{
- QmpInputVisitor *qiv = to_qiv(v);
+ QObjectInputVisitor *qiv = to_qiv(v);
while (!QSLIST_EMPTY(&qiv->stack)) {
StackObject *tos = QSLIST_FIRST(&qiv->stack);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
- qmp_input_stack_object_free(tos);
+ qobject_input_stack_object_free(tos);
}
qobject_decref(qiv->root);
g_free(qiv);
}
-Visitor *qmp_input_visitor_new(QObject *obj, bool strict)
+Visitor *qobject_input_visitor_new(QObject *obj, bool strict)
{
- QmpInputVisitor *v;
+ QObjectInputVisitor *v;
assert(obj);
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
- v->visitor.start_struct = qmp_input_start_struct;
- v->visitor.check_struct = qmp_input_check_struct;
- v->visitor.end_struct = qmp_input_pop;
- v->visitor.start_list = qmp_input_start_list;
- v->visitor.next_list = qmp_input_next_list;
- v->visitor.end_list = qmp_input_pop;
- v->visitor.start_alternate = qmp_input_start_alternate;
- v->visitor.type_int64 = qmp_input_type_int64;
- v->visitor.type_uint64 = qmp_input_type_uint64;
- v->visitor.type_bool = qmp_input_type_bool;
- v->visitor.type_str = qmp_input_type_str;
- v->visitor.type_number = qmp_input_type_number;
- v->visitor.type_any = qmp_input_type_any;
- v->visitor.type_null = qmp_input_type_null;
- v->visitor.optional = qmp_input_optional;
- v->visitor.free = qmp_input_free;
+ 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.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;
+ v->visitor.type_str = qobject_input_type_str;
+ 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->strict = strict;
v->root = obj;
diff --git a/qmp.c b/qmp.c
index 564bee0b35..a06cb7ba62 100644
--- a/qmp.c
+++ b/qmp.c
@@ -675,7 +675,7 @@ void qmp_object_add(const char *type, const char *id,
pdict = qdict_new();
}
- v = qmp_input_visitor_new(QOBJECT(pdict), true);
+ v = qobject_input_visitor_new(QOBJECT(pdict), true);
obj = user_creatable_add_type(type, id, pdict, v, errp);
visit_free(v);
if (obj) {
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index 92e6b269b2..f2b1d58494 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -23,7 +23,7 @@ void object_property_set_qobject(Object *obj, QObject *value,
{
Visitor *v;
/* TODO: Should we reject, rather than ignore, excess input? */
- v = qmp_input_visitor_new(value, false);
+ v = qobject_input_visitor_new(value, false);
object_property_set(obj, v, name, errp);
visit_free(v);
}
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index e61ad646aa..ee2a751a17 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -130,7 +130,7 @@ def gen_marshal(name, arg_type, boxed, ret_type):
push_indent()
ret += mcgen('''
- v = qmp_input_visitor_new(QOBJECT(args), true);
+ v = qobject_input_visitor_new(QOBJECT(args), true);
visit_start_struct(v, NULL, NULL, 0, &err);
if (err) {
goto out;
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index 18293802b6..c1e729df5e 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -345,7 +345,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
}
if (qdict) {
- visitor = qmp_input_visitor_new(info->props, true);
+ visitor = qobject_input_visitor_new(info->props, true);
visit_start_struct(visitor, NULL, NULL, 0, errp);
if (*errp) {
object_unref(obj);
diff --git a/tests/check-qnull.c b/tests/check-qnull.c
index 7a1cd94526..550c1e6807 100644
--- a/tests/check-qnull.c
+++ b/tests/check-qnull.c
@@ -47,7 +47,7 @@ static void qnull_visit_test(void)
g_assert(qnull_.refcnt == 1);
obj = qnull();
- v = qmp_input_visitor_new(obj, true);
+ v = qobject_input_visitor_new(obj, true);
qobject_decref(obj);
visit_type_null(v, NULL, &error_abort);
visit_free(v);
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index e582758509..ff944811e8 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -244,7 +244,7 @@ static void test_dealloc_partial(void)
ud2_dict = qdict_new();
qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));
- v = qmp_input_visitor_new(QOBJECT(ud2_dict), true);
+ v = qobject_input_visitor_new(QOBJECT(ud2_dict), true);
visit_type_UserDefTwo(v, NULL, &ud2, &err);
visit_free(v);
QDECREF(ud2_dict);
diff --git a/tests/test-qobject-input-strict.c b/tests/test-qobject-input-strict.c
index c6aac20dee..4087ea3dd3 100644
--- a/tests/test-qobject-input-strict.c
+++ b/tests/test-qobject-input-strict.c
@@ -53,7 +53,7 @@ static Visitor *validate_test_init_internal(TestInputVisitorData *data,
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
- data->qiv = qmp_input_visitor_new(data->obj, true);
+ data->qiv = qobject_input_visitor_new(data->obj, true);
g_assert(data->qiv);
return data->qiv;
}
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index ced457f36e..0e65e63c5e 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -49,7 +49,7 @@ static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data,
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
- data->qiv = qmp_input_visitor_new(data->obj, false);
+ data->qiv = qobject_input_visitor_new(data->obj, false);
g_assert(data->qiv);
return data->qiv;
}
diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c
index 7e5805ff53..de03c4c122 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -1040,7 +1040,7 @@ static void qmp_deserialize(void **native_out, void *datap,
obj = qobject_from_json(qstring_get_str(output_json));
QDECREF(output_json);
- d->qiv = qmp_input_visitor_new(obj, true);
+ d->qiv = qobject_input_visitor_new(obj, true);
qobject_decref(obj_orig);
qobject_decref(obj);
visit(d->qiv, native_out, errp);