mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-07-07 19:40:36 +00:00
qlit: add QLIT_QNULL and QLIT_BOOL
As they are going to be used in the following patches. Backports commit 6c6084c1b0802f5265d5c7dc27f7125d9fd1cceb from qemu
This commit is contained in:
parent
2833ad4f4c
commit
bc2ffe2a71
|
@ -23,6 +23,7 @@ typedef struct QLitObject QLitObject;
|
||||||
struct QLitObject {
|
struct QLitObject {
|
||||||
int type;
|
int type;
|
||||||
union {
|
union {
|
||||||
|
bool qbool;
|
||||||
int64_t qnum;
|
int64_t qnum;
|
||||||
const char *qstr;
|
const char *qstr;
|
||||||
QLitDictEntry *qdict;
|
QLitDictEntry *qdict;
|
||||||
|
@ -35,6 +36,10 @@ struct QLitDictEntry {
|
||||||
QLitObject value;
|
QLitObject value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define QLIT_QNULL \
|
||||||
|
{ .type = QTYPE_QNULL }
|
||||||
|
#define QLIT_QBOOL(val) \
|
||||||
|
{ .type = QTYPE_QBOOL, .value.qbool = (val) }
|
||||||
#define QLIT_QNUM(val) \
|
#define QLIT_QNUM(val) \
|
||||||
{ .type = QTYPE_QNUM, .value.qnum = (val) }
|
{ .type = QTYPE_QNUM, .value.qnum = (val) }
|
||||||
#define QLIT_QSTR(val) \
|
#define QLIT_QSTR(val) \
|
||||||
|
|
|
@ -54,6 +54,8 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lhs->type) {
|
switch (lhs->type) {
|
||||||
|
case QTYPE_QBOOL:
|
||||||
|
return lhs->value.qbool == qbool_get_bool(qobject_to_qbool(rhs));
|
||||||
case QTYPE_QNUM:
|
case QTYPE_QNUM:
|
||||||
g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val));
|
g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val));
|
||||||
return lhs->value.qnum == val;
|
return lhs->value.qnum == val;
|
||||||
|
@ -85,6 +87,8 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs)
|
||||||
|
|
||||||
return helper.result;
|
return helper.result;
|
||||||
}
|
}
|
||||||
|
case QTYPE_QNULL:
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue