mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-29 18:36:59 +00:00
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. Backports commit 15280c360e54a65e2c7be1a47bfbe41dce1ef986 from qemu
This commit is contained in:
parent
5a66d7f326
commit
f89de73110
|
@ -2749,7 +2749,11 @@ symbols = (
|
|||
'qdict_new',
|
||||
'qdict_next',
|
||||
'qdict_next_entry',
|
||||
'qdict_put_bool',
|
||||
'qdict_put_int',
|
||||
'qdict_put_null',
|
||||
'qdict_put_obj',
|
||||
'qdict_put_str',
|
||||
'qdict_size',
|
||||
'qdict_type',
|
||||
'qemu_clock_get_us',
|
||||
|
@ -2803,7 +2807,11 @@ symbols = (
|
|||
'qint_from_int',
|
||||
'qint_get_int',
|
||||
'qint_type',
|
||||
'qlist_append_bool',
|
||||
'qlist_append_int',
|
||||
'qlist_append_null',
|
||||
'qlist_append_obj',
|
||||
'qlist_append_str',
|
||||
'qlist_copy',
|
||||
'qlist_copy_elem',
|
||||
'qlist_destroy_obj',
|
||||
|
|
|
@ -54,15 +54,10 @@ 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);
|
||||
|
|
|
@ -30,13 +30,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))
|
||||
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); \
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/dealloc-visitor.h"
|
||||
#include "qapi/qmp/qnull.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "qemu-common.h"
|
||||
#include "qapi/visitor-impl.h"
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qapi/qmp/qnull.h"
|
||||
#include "qapi/qmp/qnum.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
|
||||
typedef struct StackObject {
|
||||
|
|
|
@ -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/qdict.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
|
|
|
@ -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'
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#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/qlist.h"
|
||||
#include "qapi/qmp/qstring.h"
|
||||
|
|
Loading…
Reference in a new issue