提交 15280c36 编写于 作者: M Markus Armbruster

qdict qlist: Make most helper macros functions

The macro expansions of qdict_put_TYPE() and qlist_append_TYPE() need
qbool.h, qnull.h, qnum.h and qstring.h to compile.  We include qnull.h
and qnum.h in the headers, but not qbool.h and qstring.h.  Works,
because we include those wherever the macros get used.

Open-coding these helpers is of dubious value.  Turn them into
functions and drop the includes from the headers.

This cleanup makes the number of objects depending on qapi/qmp/qnum.h
from 4551 (out of 4743) to 46 in my "build everything" tree.  For
qapi/qmp/qnull.h, the number drops from 4552 to 21.
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <20180201111846.21846-10-armbru@redhat.com>
上级 6b673957
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qobject-output-visitor.h" #include "qapi/qobject-output-visitor.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/option.h" #include "qemu/option.h"
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi-visit.h" #include "qapi-visit.h"
#include "qapi/error.h" #include "qapi/error.h"
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qnum.h"
#include "acpi-build.h" #include "acpi-build.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/bitmap.h" #include "qemu/bitmap.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qnull.h"
#include "cpu.h" #include "cpu.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "hw/ppc/spapr_drc.h" #include "hw/ppc/spapr_drc.h"
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlist.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#define QDICT_BUCKET_MAX 512 #define QDICT_BUCKET_MAX 512
...@@ -55,17 +53,11 @@ void qdict_destroy_obj(QObject *obj); ...@@ -55,17 +53,11 @@ void qdict_destroy_obj(QObject *obj);
#define qdict_put(qdict, key, obj) \ #define qdict_put(qdict, key, obj) \
qdict_put_obj(qdict, key, QOBJECT(obj)) qdict_put_obj(qdict, key, QOBJECT(obj))
/* Helpers for int, bool, null, and string */ void qdict_put_bool(QDict *qdict, const char *key, bool value);
#define qdict_put_int(qdict, key, value) \ void qdict_put_int(QDict *qdict, const char *key, int64_t value);
qdict_put(qdict, key, qnum_from_int(value)) void qdict_put_null(QDict *qdict, const char *key);
#define qdict_put_bool(qdict, key, value) \ void qdict_put_str(QDict *qdict, const char *key, const char *value);
qdict_put(qdict, key, qbool_from_bool(value))
#define qdict_put_str(qdict, key, value) \
qdict_put(qdict, key, qstring_from_str(value))
#define qdict_put_null(qdict, key) \
qdict_put(qdict, key, qnull())
/* High level helpers */
double qdict_get_double(const QDict *qdict, const char *key); double qdict_get_double(const QDict *qdict, const char *key);
int64_t qdict_get_int(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key);
bool qdict_get_bool(const QDict *qdict, const char *key); bool qdict_get_bool(const QDict *qdict, const char *key);
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#define QLIST_H #define QLIST_H
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qnull.h"
#include "qemu/queue.h" #include "qemu/queue.h"
typedef struct QListEntry { typedef struct QListEntry {
...@@ -31,15 +29,10 @@ struct QList { ...@@ -31,15 +29,10 @@ struct QList {
#define qlist_append(qlist, obj) \ #define qlist_append(qlist, obj) \
qlist_append_obj(qlist, QOBJECT(obj)) qlist_append_obj(qlist, QOBJECT(obj))
/* Helpers for int, bool, and string */ void qlist_append_bool(QList *qlist, bool value);
#define qlist_append_int(qlist, value) \ void qlist_append_int(QList *qlist, int64_t value);
qlist_append(qlist, qnum_from_int(value)) void qlist_append_null(QList *qlist);
#define qlist_append_bool(qlist, value) \ void qlist_append_str(QList *qlist, const char *value);
qlist_append(qlist, qbool_from_bool(value))
#define qlist_append_str(qlist, value) \
qlist_append(qlist, qstring_from_str(value))
#define qlist_append_null(qlist) \
qlist_append(qlist, qnull())
#define QLIST_FOREACH_ENTRY(qlist, var) \ #define QLIST_FOREACH_ENTRY(qlist, var) \
for ((var) = ((qlist)->head.tqh_first); \ for ((var) = ((qlist)->head.tqh_first); \
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "block/block.h" #include "block/block.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/qmp/qnull.h"
#include "qemu/rcu.h" #include "qemu/rcu.h"
#include "block.h" #include "block.h"
#include "postcopy-ram.h" #include "postcopy-ram.h"
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "sysemu/tpm.h" #include "sysemu/tpm.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-parser.h"
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/dealloc-visitor.h" #include "qapi/dealloc-visitor.h"
#include "qapi/qmp/qnull.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/visitor-impl.h" #include "qapi/visitor-impl.h"
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "qemu/option.h" #include "qemu/option.h"
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "qemu/queue.h" #include "qemu/queue.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
typedef struct QStackEntry { typedef struct QStackEntry {
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "qapi/error.h" #include "qapi/error.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-parser.h"
#include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-lexer.h"
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "qapi/qmp/qnum.h" #include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/error.h" #include "qapi/error.h"
...@@ -143,6 +144,26 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) ...@@ -143,6 +144,26 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
} }
} }
void qdict_put_int(QDict *qdict, const char *key, int64_t value)
{
qdict_put(qdict, key, qnum_from_int(value));
}
void qdict_put_bool(QDict *qdict, const char *key, bool value)
{
qdict_put(qdict, key, qbool_from_bool(value));
}
void qdict_put_str(QDict *qdict, const char *key, const char *value)
{
qdict_put(qdict, key, qstring_from_str(value));
}
void qdict_put_null(QDict *qdict, const char *key)
{
qdict_put(qdict, key, qnull());
}
/** /**
* qdict_get(): Lookup for a given 'key' * qdict_get(): Lookup for a given 'key'
* *
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qemu/unicode.h" #include "qemu/unicode.h"
typedef struct JSONParsingState typedef struct JSONParsingState
......
...@@ -11,8 +11,12 @@ ...@@ -11,8 +11,12 @@
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlist.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/qmp/qstring.h"
#include "qemu/queue.h" #include "qemu/queue.h"
#include "qemu-common.h" #include "qemu-common.h"
...@@ -64,6 +68,26 @@ void qlist_append_obj(QList *qlist, QObject *value) ...@@ -64,6 +68,26 @@ void qlist_append_obj(QList *qlist, QObject *value)
QTAILQ_INSERT_TAIL(&qlist->head, entry, next); QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
} }
void qlist_append_int(QList *qlist, int64_t value)
{
qlist_append(qlist, qnum_from_int(value));
}
void qlist_append_bool(QList *qlist, bool value)
{
qlist_append(qlist, qbool_from_bool(value));
}
void qlist_append_str(QList *qlist, const char *value)
{
qlist_append(qlist, qstring_from_str(value));
}
void qlist_append_null(QList *qlist)
{
qlist_append(qlist, qnull());
}
/** /**
* qlist_iter(): Iterate over all the list's stored values. * qlist_iter(): Iterate over all the list's stored values.
* *
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "qapi/qmp/qlit.h" #include "qapi/qmp/qlit.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "qom/qom-qobject.h" #include "qom/qom-qobject.h"
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#define MAX_INTERFACES 32 #define MAX_INTERFACES 32
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "disas/disas.h" #include "disas/disas.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "tcg-op.h" #include "tcg-op.h"
#include "qapi/qmp/qnull.h"
#include "qemu/host-utils.h" #include "qemu/host-utils.h"
#include "exec/cpu_ldst.h" #include "exec/cpu_ldst.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qemu-common.h" #include "qemu-common.h"
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlit.h" #include "qapi/qmp/qlit.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu-common.h" #include "qemu-common.h"
static void escaped_string(void) static void escaped_string(void)
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qemu-common.h" #include "qemu-common.h"
......
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "test-qmp-commands.h" #include "test-qmp-commands.h"
#include "qapi/error.h" #include "qapi/error.h"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "test-qapi-event.h" #include "test-qapi-event.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi/qmp-event.h" #include "qapi/qmp-event.h"
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "qapi/qobject-input-visitor.h" #include "qapi/qobject-input-visitor.h"
#include "test-qapi-visit.h" #include "test-qapi-visit.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "test-qmp-introspect.h" #include "test-qmp-introspect.h"
#include "qmp-introspect.h" #include "qmp-introspect.h"
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "qapi/qobject-output-visitor.h" #include "qapi/qobject-output-visitor.h"
#include "test-qapi-visit.h" #include "test-qapi-visit.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
typedef struct TestOutputVisitorData { typedef struct TestOutputVisitorData {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qapi/qmp/qbool.h" #include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qapi/qmp/qerror.h" #include "qapi/qmp/qerror.h"
#include "qemu/option_int.h" #include "qemu/option_int.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册