mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-30 14:07:00 +00:00
qobject: Use 'bool' for qbool
We require a C99 compiler, so let's use 'bool' instead of 'int' when dealing with boolean values. There are few enough clients to fix them all in one pass. Backports commit fc48ffc39ed1060856475e4320d5896f26c945e8 from qemu
This commit is contained in:
parent
1f6f6b2863
commit
d544d83348
|
@ -19,11 +19,11 @@
|
|||
|
||||
typedef struct QBool {
|
||||
QObject_HEAD;
|
||||
int value;
|
||||
bool value;
|
||||
} QBool;
|
||||
|
||||
QBool *qbool_from_int(int value);
|
||||
int qbool_get_int(const QBool *qb);
|
||||
QBool *qbool_from_bool(bool value);
|
||||
bool qbool_get_bool(const QBool *qb);
|
||||
QBool *qobject_to_qbool(const QObject *obj);
|
||||
|
||||
#endif /* QBOOL_H */
|
||||
|
|
|
@ -248,7 +248,7 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
|
|||
return;
|
||||
}
|
||||
|
||||
*obj = qbool_get_int(qobject_to_qbool(qobj));
|
||||
*obj = qbool_get_bool(qobject_to_qbool(qobj));
|
||||
}
|
||||
|
||||
static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
|
||||
|
|
|
@ -166,7 +166,7 @@ static void qmp_output_type_bool(Visitor *v, bool *obj, const char *name,
|
|||
Error **errp)
|
||||
{
|
||||
QmpOutputVisitor *qov = to_qov(v);
|
||||
qmp_output_add(qov, name, qbool_from_int(*obj));
|
||||
qmp_output_add(qov, name, qbool_from_bool(*obj));
|
||||
}
|
||||
|
||||
static void qmp_output_type_str(Visitor *v, char **obj, const char *name,
|
||||
|
|
|
@ -23,11 +23,11 @@ static const QType qbool_type = {
|
|||
};
|
||||
|
||||
/**
|
||||
* qbool_from_int(): Create a new QBool from an int
|
||||
* qbool_from_bool(): Create a new QBool from a bool
|
||||
*
|
||||
* Return strong reference.
|
||||
*/
|
||||
QBool *qbool_from_int(int value)
|
||||
QBool *qbool_from_bool(bool value)
|
||||
{
|
||||
QBool *qb;
|
||||
|
||||
|
@ -39,9 +39,9 @@ QBool *qbool_from_int(int value)
|
|||
}
|
||||
|
||||
/**
|
||||
* qbool_get_int(): Get the stored int
|
||||
* qbool_get_bool(): Get the stored bool
|
||||
*/
|
||||
int qbool_get_int(const QBool *qb)
|
||||
bool qbool_get_bool(const QBool *qb)
|
||||
{
|
||||
return qb->value;
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
|
|||
int qdict_get_bool(const QDict *qdict, const char *key)
|
||||
{
|
||||
QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
|
||||
return qbool_get_int(qobject_to_qbool(obj));
|
||||
return qbool_get_bool(qobject_to_qbool(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -322,7 +322,7 @@ int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value)
|
|||
if (!obj || qobject_type(obj) != QTYPE_QBOOL)
|
||||
return def_value;
|
||||
|
||||
return qbool_get_int(qobject_to_qbool(obj));
|
||||
return qbool_get_bool(qobject_to_qbool(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -893,7 +893,7 @@ Object *object_property_get_link(struct uc_struct *uc, Object *obj, const char *
|
|||
void object_property_set_bool(struct uc_struct *uc, Object *obj, bool value,
|
||||
const char *name, Error **errp)
|
||||
{
|
||||
QBool *qbool = qbool_from_int(value);
|
||||
QBool *qbool = qbool_from_bool(value);
|
||||
object_property_set_qobject(uc, obj, QOBJECT(qbool), name, errp);
|
||||
|
||||
QDECREF(qbool);
|
||||
|
@ -914,7 +914,7 @@ bool object_property_get_bool(struct uc_struct *uc, Object *obj, const char *nam
|
|||
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
|
||||
retval = false;
|
||||
} else {
|
||||
retval = qbool_get_int(qbool);
|
||||
retval = qbool_get_bool(qbool);
|
||||
}
|
||||
|
||||
QDECREF(qbool);
|
||||
|
|
Loading…
Reference in a new issue