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: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180201111846.21846-10-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2018-02-01 12:18:36 +01:00
parent 6b67395762
commit 15280c360e
27 changed files with 84 additions and 23 deletions

View File

@ -32,6 +32,7 @@
#include "qapi/error.h"
#include "qapi/qobject-output-visitor.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "sysemu/block-backend.h"
#include "qemu/cutils.h"

View File

@ -40,6 +40,7 @@
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qapi-visit.h"
#include "qapi/error.h"

View File

@ -22,6 +22,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qapi/qmp/qnum.h"
#include "acpi-build.h"
#include "qemu-common.h"
#include "qemu/bitmap.h"

View File

@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qapi/qmp/qnull.h"
#include "cpu.h"
#include "qemu/cutils.h"
#include "hw/ppc/spapr_drc.h"

View File

@ -15,8 +15,6 @@
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qlist.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu/queue.h"
#define QDICT_BUCKET_MAX 512
@ -55,17 +53,11 @@ void qdict_destroy_obj(QObject *obj);
#define qdict_put(qdict, key, obj) \
qdict_put_obj(qdict, key, QOBJECT(obj))
/* Helpers for int, bool, null, and string */
#define qdict_put_int(qdict, key, value) \
qdict_put(qdict, key, qnum_from_int(value))
#define qdict_put_bool(qdict, key, 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())
void qdict_put_bool(QDict *qdict, const char *key, bool value);
void qdict_put_int(QDict *qdict, const char *key, int64_t value);
void qdict_put_null(QDict *qdict, const char *key);
void qdict_put_str(QDict *qdict, const char *key, const char *value);
/* High level helpers */
double qdict_get_double(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);

View File

@ -14,8 +14,6 @@
#define QLIST_H
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qnull.h"
#include "qemu/queue.h"
typedef struct QListEntry {
@ -31,15 +29,10 @@ struct QList {
#define qlist_append(qlist, obj) \
qlist_append_obj(qlist, QOBJECT(obj))
/* Helpers for int, bool, and string */
#define qlist_append_int(qlist, value) \
qlist_append(qlist, qnum_from_int(value))
#define qlist_append_bool(qlist, 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())
void qlist_append_bool(QList *qlist, bool value);
void qlist_append_int(QList *qlist, int64_t value);
void qlist_append_null(QList *qlist);
void qlist_append_str(QList *qlist, const char *value);
#define QLIST_FOREACH_ENTRY(qlist, var) \
for ((var) = ((qlist)->head.tqh_first); \

View File

@ -32,6 +32,7 @@
#include "block/block.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qnull.h"
#include "qemu/rcu.h"
#include "block.h"
#include "postcopy-ram.h"

View File

@ -54,6 +54,7 @@
#include "sysemu/tpm.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h"

View File

@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qapi/dealloc-visitor.h"
#include "qapi/qmp/qnull.h"
#include "qemu/queue.h"
#include "qemu-common.h"
#include "qapi/visitor-impl.h"

View File

@ -22,6 +22,8 @@
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu/cutils.h"
#include "qemu/option.h"

View File

@ -18,6 +18,8 @@
#include "qemu/queue.h"
#include "qemu-common.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
typedef struct QStackEntry {

View File

@ -16,6 +16,8 @@
#include "qapi/error.h"
#include "qemu-common.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/json-parser.h"
#include "qapi/qmp/json-lexer.h"

View File

@ -14,6 +14,7 @@
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qobject.h"
#include "qapi/error.h"
@ -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'
*

View File

@ -18,6 +18,7 @@
#include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qemu/unicode.h"
typedef struct JSONParsingState

View File

@ -11,8 +11,12 @@
*/
#include "qemu/osdep.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qlist.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qstring.h"
#include "qemu/queue.h"
#include "qemu-common.h"
@ -64,6 +68,26 @@ void qlist_append_obj(QList *qlist, QObject *value)
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.
*

View File

@ -17,6 +17,7 @@
#include "qapi/qmp/qlit.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"

View File

@ -10,6 +10,8 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"

View File

@ -27,6 +27,7 @@
#include "qom/qom-qobject.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#define MAX_INTERFACES 32

View File

@ -24,6 +24,7 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg-op.h"
#include "qapi/qmp/qnull.h"
#include "qemu/host-utils.h"
#include "exec/cpu_ldst.h"

View File

@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qapi/error.h"
#include "qemu-common.h"

View File

@ -17,6 +17,8 @@
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlit.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qemu-common.h"
static void escaped_string(void)

View File

@ -9,6 +9,8 @@
#include "qemu/osdep.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qemu-common.h"

View File

@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "test-qmp-commands.h"
#include "qapi/error.h"

View File

@ -18,6 +18,7 @@
#include "test-qapi-event.h"
#include "qapi/error.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp-event.h"

View File

@ -18,6 +18,8 @@
#include "qapi/qobject-input-visitor.h"
#include "test-qapi-visit.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h"
#include "test-qmp-introspect.h"
#include "qmp-introspect.h"

View File

@ -17,6 +17,8 @@
#include "qapi/qobject-output-visitor.h"
#include "test-qapi-visit.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qnull.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qjson.h"
typedef struct TestOutputVisitorData {

View File

@ -30,6 +30,7 @@
#include "qemu/error-report.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qerror.h"
#include "qemu/option_int.h"