mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2024-10-13 23:23:57 +03:00
qapi: Replace qobject_to_X(o) by qobject_to(X, o)
This patch was generated using the following Coccinelle script: @@ expression Obj; @@ ( - qobject_to_qnum(Obj) + qobject_to(QNum, Obj) | - qobject_to_qstring(Obj) + qobject_to(QString, Obj) | - qobject_to_qdict(Obj) + qobject_to(QDict, Obj) | - qobject_to_qlist(Obj) + qobject_to(QList, Obj) | - qobject_to_qbool(Obj) + qobject_to(QBool, Obj) ) and a bit of manual fix-up for overly long lines and three places in tests/check-qjson.c that Coccinelle did not find. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-Id: <20180224154033.29559-4-mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [eblake: swap order from qobject_to(o, X), rebase to master, also a fix to latent false-positive compiler complaint about hw/i386/acpi-build.c] Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
1a56b1e2ab
commit
7dc847ebba
4
block.c
4
block.c
@ -1457,7 +1457,7 @@ static QDict *parse_json_filename(const char *filename, Error **errp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
options = qobject_to_qdict(options_obj);
|
||||
options = qobject_to(QDict, options_obj);
|
||||
if (!options) {
|
||||
qobject_decref(options_obj);
|
||||
error_setg(errp, "Invalid JSON object given");
|
||||
@ -2433,7 +2433,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp)
|
||||
}
|
||||
visit_complete(v, &obj);
|
||||
|
||||
qdict = qobject_to_qdict(obj);
|
||||
qdict = qobject_to(QDict, obj);
|
||||
qdict_flatten(qdict);
|
||||
|
||||
/* bdrv_open_inherit() defaults to the values in bdrv_flags (for
|
||||
|
@ -647,7 +647,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
|
||||
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
|
12
block/qapi.c
12
block/qapi.c
@ -647,29 +647,29 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
|
||||
{
|
||||
switch (qobject_type(obj)) {
|
||||
case QTYPE_QNUM: {
|
||||
QNum *value = qobject_to_qnum(obj);
|
||||
QNum *value = qobject_to(QNum, obj);
|
||||
char *tmp = qnum_to_string(value);
|
||||
func_fprintf(f, "%s", tmp);
|
||||
g_free(tmp);
|
||||
break;
|
||||
}
|
||||
case QTYPE_QSTRING: {
|
||||
QString *value = qobject_to_qstring(obj);
|
||||
QString *value = qobject_to(QString, obj);
|
||||
func_fprintf(f, "%s", qstring_get_str(value));
|
||||
break;
|
||||
}
|
||||
case QTYPE_QDICT: {
|
||||
QDict *value = qobject_to_qdict(obj);
|
||||
QDict *value = qobject_to(QDict, obj);
|
||||
dump_qdict(func_fprintf, f, comp_indent, value);
|
||||
break;
|
||||
}
|
||||
case QTYPE_QLIST: {
|
||||
QList *value = qobject_to_qlist(obj);
|
||||
QList *value = qobject_to(QList, obj);
|
||||
dump_qlist(func_fprintf, f, comp_indent, value);
|
||||
break;
|
||||
}
|
||||
case QTYPE_QBOOL: {
|
||||
QBool *value = qobject_to_qbool(obj);
|
||||
QBool *value = qobject_to(QBool, obj);
|
||||
func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
|
||||
break;
|
||||
}
|
||||
@ -730,7 +730,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
|
||||
|
||||
visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
|
||||
visit_complete(v, &obj);
|
||||
data = qdict_get(qobject_to_qdict(obj), "data");
|
||||
data = qdict_get(qobject_to(QDict, obj), "data");
|
||||
dump_qobject(func_fprintf, f, 1, data);
|
||||
qobject_decref(obj);
|
||||
visit_free(v);
|
||||
|
@ -996,7 +996,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
|
||||
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
@ -3125,7 +3125,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
|
||||
/* Now get the QAPI type BlockdevCreateOptions */
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto finish;
|
||||
|
@ -764,7 +764,7 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
|
||||
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
@ -263,14 +263,14 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,
|
||||
if (!keypairs_json) {
|
||||
return ret;
|
||||
}
|
||||
keypairs = qobject_to_qlist(qobject_from_json(keypairs_json,
|
||||
&error_abort));
|
||||
keypairs = qobject_to(QList,
|
||||
qobject_from_json(keypairs_json, &error_abort));
|
||||
remaining = qlist_size(keypairs) / 2;
|
||||
assert(remaining);
|
||||
|
||||
while (remaining--) {
|
||||
name = qobject_to_qstring(qlist_pop(keypairs));
|
||||
value = qobject_to_qstring(qlist_pop(keypairs));
|
||||
name = qobject_to(QString, qlist_pop(keypairs));
|
||||
value = qobject_to(QString, qlist_pop(keypairs));
|
||||
assert(name && value);
|
||||
key = qstring_get_str(name);
|
||||
|
||||
|
@ -1887,7 +1887,7 @@ static int sd_create_prealloc(BlockdevOptionsSheepdog *location, int64_t size,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
qdict = qobject_to_qdict(obj);
|
||||
qdict = qobject_to(QDict, obj);
|
||||
qdict_flatten(qdict);
|
||||
|
||||
qdict_put_str(qdict, "driver", "sheepdog");
|
||||
|
@ -1997,7 +1997,7 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
|
||||
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
@ -1120,7 +1120,7 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
|
||||
|
||||
qobj = qdict_crumple(qdict, errp);
|
||||
QDECREF(qdict);
|
||||
qdict = qobject_to_qdict(qobj);
|
||||
qdict = qobject_to(QDict, qobj);
|
||||
if (qdict == NULL) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
@ -334,7 +334,8 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,
|
||||
|
||||
case QTYPE_QSTRING: {
|
||||
unsigned long long length;
|
||||
const char *str = qstring_get_str(qobject_to_qstring(entry->value));
|
||||
const char *str = qstring_get_str(qobject_to(QString,
|
||||
entry->value));
|
||||
if (parse_uint_full(str, &length, 10) == 0 &&
|
||||
length > 0 && length <= UINT_MAX) {
|
||||
block_acct_add_interval(stats, (unsigned) length);
|
||||
@ -346,7 +347,7 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,
|
||||
}
|
||||
|
||||
case QTYPE_QNUM: {
|
||||
int64_t length = qnum_get_int(qobject_to_qnum(entry->value));
|
||||
int64_t length = qnum_get_int(qobject_to(QNum, entry->value));
|
||||
|
||||
if (length > 0 && length <= UINT_MAX) {
|
||||
block_acct_add_interval(stats, (unsigned) length);
|
||||
@ -4054,7 +4055,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
||||
}
|
||||
|
||||
visit_complete(v, &obj);
|
||||
qdict = qobject_to_qdict(obj);
|
||||
qdict = qobject_to(QDict, obj);
|
||||
|
||||
qdict_flatten(qdict);
|
||||
|
||||
|
@ -154,21 +154,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
|
||||
/* Fill in optional s3/s4 related properties */
|
||||
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
|
||||
if (o) {
|
||||
pm->s3_disabled = qnum_get_uint(qobject_to_qnum(o));
|
||||
pm->s3_disabled = qnum_get_uint(qobject_to(QNum, o));
|
||||
} else {
|
||||
pm->s3_disabled = false;
|
||||
}
|
||||
qobject_decref(o);
|
||||
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
|
||||
if (o) {
|
||||
pm->s4_disabled = qnum_get_uint(qobject_to_qnum(o));
|
||||
pm->s4_disabled = qnum_get_uint(qobject_to(QNum, o));
|
||||
} else {
|
||||
pm->s4_disabled = false;
|
||||
}
|
||||
qobject_decref(o);
|
||||
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
|
||||
if (o) {
|
||||
pm->s4_val = qnum_get_uint(qobject_to_qnum(o));
|
||||
pm->s4_val = qnum_get_uint(qobject_to(QNum, o));
|
||||
} else {
|
||||
pm->s4_val = false;
|
||||
}
|
||||
@ -507,14 +507,14 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
|
||||
static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
|
||||
bool pcihp_bridge_en)
|
||||
{
|
||||
Aml *dev, *notify_method, *method;
|
||||
Aml *dev, *notify_method = NULL, *method;
|
||||
QObject *bsel;
|
||||
PCIBus *sec;
|
||||
int i;
|
||||
|
||||
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
|
||||
if (bsel) {
|
||||
uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel));
|
||||
uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
|
||||
|
||||
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
|
||||
notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
|
||||
@ -624,7 +624,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
|
||||
|
||||
/* If bus supports hotplug select it and notify about local events */
|
||||
if (bsel) {
|
||||
uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel));
|
||||
uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
|
||||
|
||||
aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
|
||||
aml_append(method,
|
||||
@ -2638,12 +2638,12 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
|
||||
if (!o) {
|
||||
return false;
|
||||
}
|
||||
mcfg->mcfg_base = qnum_get_uint(qobject_to_qnum(o));
|
||||
mcfg->mcfg_base = qnum_get_uint(qobject_to(QNum, o));
|
||||
qobject_decref(o);
|
||||
|
||||
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
|
||||
assert(o);
|
||||
mcfg->mcfg_size = qnum_get_uint(qobject_to_qnum(o));
|
||||
mcfg->mcfg_size = qnum_get_uint(qobject_to(QNum, o));
|
||||
qobject_decref(o);
|
||||
return true;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
|
||||
/* Unthrottled event */
|
||||
monitor_qapi_event_emit(event, qdict);
|
||||
} else {
|
||||
QDict *data = qobject_to_qdict(qdict_get(qdict, "data"));
|
||||
QDict *data = qobject_to(QDict, qdict_get(qdict, "data"));
|
||||
MonitorQAPIEventState key = { .event = event, .data = data };
|
||||
|
||||
evstate = g_hash_table_lookup(monitor_qapi_event_state, &key);
|
||||
@ -3777,7 +3777,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
qdict = qobject_to_qdict(req);
|
||||
qdict = qobject_to(QDict, req);
|
||||
if (qdict) {
|
||||
id = qdict_get(qdict, "id");
|
||||
qobject_incref(id);
|
||||
@ -3793,7 +3793,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
|
||||
rsp = qmp_dispatch(cur_mon->qmp.commands, req);
|
||||
|
||||
if (mon->qmp.commands == &qmp_cap_negotiation_commands) {
|
||||
qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error");
|
||||
qdict = qdict_get_qdict(qobject_to(QDict, rsp), "error");
|
||||
if (qdict
|
||||
&& !g_strcmp0(qdict_get_try_str(qdict, "class"),
|
||||
QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) {
|
||||
@ -3814,7 +3814,7 @@ err_out:
|
||||
|
||||
if (rsp) {
|
||||
if (id) {
|
||||
qdict_put_obj(qobject_to_qdict(rsp), "id", id);
|
||||
qdict_put_obj(qobject_to(QDict, rsp), "id", id);
|
||||
id = NULL;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
|
||||
bool has_exec_key = false;
|
||||
QDict *dict = NULL;
|
||||
|
||||
dict = qobject_to_qdict(request);
|
||||
dict = qobject_to(QDict, request);
|
||||
if (!dict) {
|
||||
error_setg(errp, "QMP input must be a JSON object");
|
||||
return NULL;
|
||||
|
@ -137,7 +137,7 @@ static QObject *qobject_input_try_get_object(QObjectInputVisitor *qiv,
|
||||
|
||||
if (qobject_type(qobj) == QTYPE_QDICT) {
|
||||
assert(name);
|
||||
ret = qdict_get(qobject_to_qdict(qobj), name);
|
||||
ret = qdict_get(qobject_to(QDict, qobj), name);
|
||||
if (tos->h && consume && ret) {
|
||||
bool removed = g_hash_table_remove(tos->h, name);
|
||||
assert(removed);
|
||||
@ -185,7 +185,7 @@ static const char *qobject_input_get_keyval(QObjectInputVisitor *qiv,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qstr = qobject_to_qstring(qobj);
|
||||
qstr = qobject_to(QString, qobj);
|
||||
if (!qstr) {
|
||||
switch (qobject_type(qobj)) {
|
||||
case QTYPE_QDICT:
|
||||
@ -224,11 +224,11 @@ static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,
|
||||
|
||||
if (qobject_type(obj) == QTYPE_QDICT) {
|
||||
h = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
qdict_iter(qobject_to_qdict(obj), qdict_add_key, h);
|
||||
qdict_iter(qobject_to(QDict, obj), qdict_add_key, h);
|
||||
tos->h = h;
|
||||
} else {
|
||||
assert(qobject_type(obj) == QTYPE_QLIST);
|
||||
tos->entry = qlist_first(qobject_to_qlist(obj));
|
||||
tos->entry = qlist_first(qobject_to(QList, obj));
|
||||
tos->index = -1;
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
qnum = qobject_to_qnum(qobj);
|
||||
qnum = qobject_to(QNum, qobj);
|
||||
if (!qnum || !qnum_get_try_int(qnum, obj)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||
full_name(qiv, name), "integer");
|
||||
@ -430,7 +430,7 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
qnum = qobject_to_qnum(qobj);
|
||||
qnum = qobject_to(QNum, qobj);
|
||||
if (!qnum) {
|
||||
goto err;
|
||||
}
|
||||
@ -477,7 +477,7 @@ static void qobject_input_type_bool(Visitor *v, const char *name, bool *obj,
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
qbool = qobject_to_qbool(qobj);
|
||||
qbool = qobject_to(QBool, qobj);
|
||||
if (!qbool) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||
full_name(qiv, name), "boolean");
|
||||
@ -518,7 +518,7 @@ static void qobject_input_type_str(Visitor *v, const char *name, char **obj,
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
qstr = qobject_to_qstring(qobj);
|
||||
qstr = qobject_to(QString, qobj);
|
||||
if (!qstr) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||
full_name(qiv, name), "string");
|
||||
@ -547,7 +547,7 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
qnum = qobject_to_qnum(qobj);
|
||||
qnum = qobject_to(QNum, qobj);
|
||||
if (!qnum) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||
full_name(qiv, name), "number");
|
||||
@ -734,7 +734,7 @@ Visitor *qobject_input_visitor_new_str(const char *str,
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
args = qobject_to_qdict(obj);
|
||||
args = qobject_to(QDict, obj);
|
||||
assert(args);
|
||||
v = qobject_input_visitor_new(QOBJECT(args));
|
||||
} else {
|
||||
|
@ -92,11 +92,11 @@ static void qobject_output_add_obj(QObjectOutputVisitor *qov, const char *name,
|
||||
switch (qobject_type(cur)) {
|
||||
case QTYPE_QDICT:
|
||||
assert(name);
|
||||
qdict_put_obj(qobject_to_qdict(cur), name, value);
|
||||
qdict_put_obj(qobject_to(QDict, cur), name, value);
|
||||
break;
|
||||
case QTYPE_QLIST:
|
||||
assert(!name);
|
||||
qlist_append_obj(qobject_to_qlist(cur), value);
|
||||
qlist_append_obj(qobject_to(QList, cur), value);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
|
@ -607,7 +607,7 @@ static void process_event(JSONMessageParser *parser, GQueue *tokens)
|
||||
g_assert(s && parser);
|
||||
|
||||
g_debug("process_event: called");
|
||||
qdict = qobject_to_qdict(json_parser_parse_err(tokens, NULL, &err));
|
||||
qdict = qobject_to(QDict, json_parser_parse_err(tokens, NULL, &err));
|
||||
if (err || !qdict) {
|
||||
QDECREF(qdict);
|
||||
qdict = qdict_new();
|
||||
|
2
qmp.c
2
qmp.c
@ -705,7 +705,7 @@ void qmp_object_add(const char *type, const char *id,
|
||||
Object *obj;
|
||||
|
||||
if (props) {
|
||||
pdict = qobject_to_qdict(props);
|
||||
pdict = qobject_to(QDict, props);
|
||||
if (!pdict) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
|
||||
return;
|
||||
|
@ -308,7 +308,7 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict, va_list *ap)
|
||||
goto out;
|
||||
}
|
||||
|
||||
qdict_put_obj(dict, qstring_get_str(qobject_to_qstring(key)), value);
|
||||
qdict_put_obj(dict, qstring_get_str(qobject_to(QString, key)), value);
|
||||
|
||||
qobject_decref(key);
|
||||
|
||||
|
@ -55,7 +55,7 @@ QBool *qobject_to_qbool(const QObject *obj)
|
||||
*/
|
||||
bool qbool_is_equal(const QObject *x, const QObject *y)
|
||||
{
|
||||
return qobject_to_qbool(x)->value == qobject_to_qbool(y)->value;
|
||||
return qobject_to(QBool, x)->value == qobject_to(QBool, y)->value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,5 +65,5 @@ bool qbool_is_equal(const QObject *x, const QObject *y)
|
||||
void qbool_destroy_obj(QObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
g_free(qobject_to_qbool(obj));
|
||||
g_free(qobject_to(QBool, obj));
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ size_t qdict_size(const QDict *qdict)
|
||||
*/
|
||||
double qdict_get_double(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qnum_get_double(qobject_to_qnum(qdict_get(qdict, key)));
|
||||
return qnum_get_double(qobject_to(QNum, qdict_get(qdict, key)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ double qdict_get_double(const QDict *qdict, const char *key)
|
||||
*/
|
||||
int64_t qdict_get_int(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qnum_get_int(qobject_to_qnum(qdict_get(qdict, key)));
|
||||
return qnum_get_int(qobject_to(QNum, qdict_get(qdict, key)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,7 +232,7 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
|
||||
*/
|
||||
bool qdict_get_bool(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qbool_get_bool(qobject_to_qbool(qdict_get(qdict, key)));
|
||||
return qbool_get_bool(qobject_to(QBool, qdict_get(qdict, key)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,7 +240,7 @@ bool qdict_get_bool(const QDict *qdict, const char *key)
|
||||
*/
|
||||
QList *qdict_get_qlist(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qobject_to_qlist(qdict_get(qdict, key));
|
||||
return qobject_to(QList, qdict_get(qdict, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,7 +248,7 @@ QList *qdict_get_qlist(const QDict *qdict, const char *key)
|
||||
*/
|
||||
QDict *qdict_get_qdict(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qobject_to_qdict(qdict_get(qdict, key));
|
||||
return qobject_to(QDict, qdict_get(qdict, key));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,7 +262,7 @@ QDict *qdict_get_qdict(const QDict *qdict, const char *key)
|
||||
*/
|
||||
const char *qdict_get_str(const QDict *qdict, const char *key)
|
||||
{
|
||||
return qstring_get_str(qobject_to_qstring(qdict_get(qdict, key)));
|
||||
return qstring_get_str(qobject_to(QString, qdict_get(qdict, key)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,7 +275,7 @@ const char *qdict_get_str(const QDict *qdict, const char *key)
|
||||
int64_t qdict_get_try_int(const QDict *qdict, const char *key,
|
||||
int64_t def_value)
|
||||
{
|
||||
QNum *qnum = qobject_to_qnum(qdict_get(qdict, key));
|
||||
QNum *qnum = qobject_to(QNum, qdict_get(qdict, key));
|
||||
int64_t val;
|
||||
|
||||
if (!qnum || !qnum_get_try_int(qnum, &val)) {
|
||||
@ -294,7 +294,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,
|
||||
*/
|
||||
bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value)
|
||||
{
|
||||
QBool *qbool = qobject_to_qbool(qdict_get(qdict, key));
|
||||
QBool *qbool = qobject_to(QBool, qdict_get(qdict, key));
|
||||
|
||||
return qbool ? qbool_get_bool(qbool) : def_value;
|
||||
}
|
||||
@ -309,7 +309,7 @@ bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value)
|
||||
*/
|
||||
const char *qdict_get_try_str(const QDict *qdict, const char *key)
|
||||
{
|
||||
QString *qstr = qobject_to_qstring(qdict_get(qdict, key));
|
||||
QString *qstr = qobject_to(QString, qdict_get(qdict, key));
|
||||
|
||||
return qstr ? qstring_get_str(qstr) : NULL;
|
||||
}
|
||||
@ -432,8 +432,8 @@ void qdict_del(QDict *qdict, const char *key)
|
||||
*/
|
||||
bool qdict_is_equal(const QObject *x, const QObject *y)
|
||||
{
|
||||
const QDict *dict_x = qobject_to_qdict(x);
|
||||
const QDict *dict_y = qobject_to_qdict(y);
|
||||
const QDict *dict_x = qobject_to(QDict, x);
|
||||
const QDict *dict_y = qobject_to(QDict, y);
|
||||
const QDictEntry *e;
|
||||
|
||||
if (qdict_size(dict_x) != qdict_size(dict_y)) {
|
||||
@ -461,7 +461,7 @@ void qdict_destroy_obj(QObject *obj)
|
||||
QDict *qdict;
|
||||
|
||||
assert(obj != NULL);
|
||||
qdict = qobject_to_qdict(obj);
|
||||
qdict = qobject_to(QDict, obj);
|
||||
|
||||
for (i = 0; i < QDICT_BUCKET_MAX; i++) {
|
||||
QDictEntry *entry = QLIST_FIRST(&qdict->table[i]);
|
||||
@ -532,9 +532,9 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix)
|
||||
new_key = g_strdup_printf("%s.%i", prefix, i);
|
||||
|
||||
if (qobject_type(value) == QTYPE_QDICT) {
|
||||
qdict_flatten_qdict(qobject_to_qdict(value), target, new_key);
|
||||
qdict_flatten_qdict(qobject_to(QDict, value), target, new_key);
|
||||
} else if (qobject_type(value) == QTYPE_QLIST) {
|
||||
qdict_flatten_qlist(qobject_to_qlist(value), target, new_key);
|
||||
qdict_flatten_qlist(qobject_to(QList, value), target, new_key);
|
||||
} else {
|
||||
/* All other types are moved to the target unchanged. */
|
||||
qobject_incref(value);
|
||||
@ -568,11 +568,11 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
|
||||
if (qobject_type(value) == QTYPE_QDICT) {
|
||||
/* Entries of QDicts are processed recursively, the QDict object
|
||||
* itself disappears. */
|
||||
qdict_flatten_qdict(qobject_to_qdict(value), target,
|
||||
qdict_flatten_qdict(qobject_to(QDict, value), target,
|
||||
new_key ? new_key : entry->key);
|
||||
delete = true;
|
||||
} else if (qobject_type(value) == QTYPE_QLIST) {
|
||||
qdict_flatten_qlist(qobject_to_qlist(value), target,
|
||||
qdict_flatten_qlist(qobject_to(QList, value), target,
|
||||
new_key ? new_key : entry->key);
|
||||
delete = true;
|
||||
} else if (prefix) {
|
||||
@ -904,7 +904,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp)
|
||||
qdict_put_obj(two_level, prefix, child);
|
||||
}
|
||||
qobject_incref(ent->value);
|
||||
qdict_put_obj(qobject_to_qdict(child), suffix, ent->value);
|
||||
qdict_put_obj(qobject_to(QDict, child), suffix, ent->value);
|
||||
} else {
|
||||
if (child) {
|
||||
error_setg(errp, "Key %s prefix is already set as a dict",
|
||||
@ -926,7 +926,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp)
|
||||
ent = qdict_next(two_level, ent)) {
|
||||
|
||||
if (qobject_type(ent->value) == QTYPE_QDICT) {
|
||||
child = qdict_crumple(qobject_to_qdict(ent->value), errp);
|
||||
child = qdict_crumple(qobject_to(QDict, ent->value), errp);
|
||||
if (!child) {
|
||||
goto error;
|
||||
}
|
||||
@ -961,7 +961,7 @@ QObject *qdict_crumple(const QDict *src, Error **errp)
|
||||
}
|
||||
|
||||
qobject_incref(child);
|
||||
qlist_append_obj(qobject_to_qlist(dst), child);
|
||||
qlist_append_obj(qobject_to(QList, dst), child);
|
||||
}
|
||||
QDECREF(multi_level);
|
||||
multi_level = NULL;
|
||||
|
@ -137,14 +137,14 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
|
||||
qstring_append(str, "null");
|
||||
break;
|
||||
case QTYPE_QNUM: {
|
||||
QNum *val = qobject_to_qnum(obj);
|
||||
QNum *val = qobject_to(QNum, obj);
|
||||
char *buffer = qnum_to_string(val);
|
||||
qstring_append(str, buffer);
|
||||
g_free(buffer);
|
||||
break;
|
||||
}
|
||||
case QTYPE_QSTRING: {
|
||||
QString *val = qobject_to_qstring(obj);
|
||||
QString *val = qobject_to(QString, obj);
|
||||
const char *ptr;
|
||||
int cp;
|
||||
char buf[16];
|
||||
@ -201,7 +201,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
|
||||
}
|
||||
case QTYPE_QDICT: {
|
||||
ToJsonIterState s;
|
||||
QDict *val = qobject_to_qdict(obj);
|
||||
QDict *val = qobject_to(QDict, obj);
|
||||
|
||||
s.count = 0;
|
||||
s.str = str;
|
||||
@ -220,7 +220,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
|
||||
}
|
||||
case QTYPE_QLIST: {
|
||||
ToJsonIterState s;
|
||||
QList *val = qobject_to_qlist(obj);
|
||||
QList *val = qobject_to(QList, obj);
|
||||
|
||||
s.count = 0;
|
||||
s.str = str;
|
||||
@ -238,7 +238,7 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
|
||||
break;
|
||||
}
|
||||
case QTYPE_QBOOL: {
|
||||
QBool *val = qobject_to_qbool(obj);
|
||||
QBool *val = qobject_to(QBool, obj);
|
||||
|
||||
if (qbool_get_bool(val)) {
|
||||
qstring_append(str, "true");
|
||||
|
@ -173,8 +173,8 @@ QList *qobject_to_qlist(const QObject *obj)
|
||||
*/
|
||||
bool qlist_is_equal(const QObject *x, const QObject *y)
|
||||
{
|
||||
const QList *list_x = qobject_to_qlist(x);
|
||||
const QList *list_y = qobject_to_qlist(y);
|
||||
const QList *list_x = qobject_to(QList, x);
|
||||
const QList *list_y = qobject_to(QList, y);
|
||||
const QListEntry *entry_x, *entry_y;
|
||||
|
||||
entry_x = qlist_first(list_x);
|
||||
@ -203,7 +203,7 @@ void qlist_destroy_obj(QObject *obj)
|
||||
QListEntry *entry, *next_entry;
|
||||
|
||||
assert(obj != NULL);
|
||||
qlist = qobject_to_qlist(obj);
|
||||
qlist = qobject_to(QList, obj);
|
||||
|
||||
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
|
||||
QTAILQ_REMOVE(&qlist->head, entry, next);
|
||||
|
@ -69,16 +69,16 @@ bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs)
|
||||
|
||||
switch (lhs->type) {
|
||||
case QTYPE_QBOOL:
|
||||
return lhs->value.qbool == qbool_get_bool(qobject_to_qbool(rhs));
|
||||
return lhs->value.qbool == qbool_get_bool(qobject_to(QBool, rhs));
|
||||
case QTYPE_QNUM:
|
||||
return lhs->value.qnum == qnum_get_int(qobject_to_qnum(rhs));
|
||||
return lhs->value.qnum == qnum_get_int(qobject_to(QNum, rhs));
|
||||
case QTYPE_QSTRING:
|
||||
return (strcmp(lhs->value.qstr,
|
||||
qstring_get_str(qobject_to_qstring(rhs))) == 0);
|
||||
qstring_get_str(qobject_to(QString, rhs))) == 0);
|
||||
case QTYPE_QDICT:
|
||||
return qlit_equal_qdict(lhs, qobject_to_qdict(rhs));
|
||||
return qlit_equal_qdict(lhs, qobject_to(QDict, rhs));
|
||||
case QTYPE_QLIST:
|
||||
return qlit_equal_qlist(lhs, qobject_to_qlist(rhs));
|
||||
return qlit_equal_qlist(lhs, qobject_to(QList, rhs));
|
||||
case QTYPE_QNULL:
|
||||
return true;
|
||||
default:
|
||||
|
@ -221,8 +221,8 @@ QNum *qobject_to_qnum(const QObject *obj)
|
||||
*/
|
||||
bool qnum_is_equal(const QObject *x, const QObject *y)
|
||||
{
|
||||
QNum *num_x = qobject_to_qnum(x);
|
||||
QNum *num_y = qobject_to_qnum(y);
|
||||
QNum *num_x = qobject_to(QNum, x);
|
||||
QNum *num_y = qobject_to(QNum, y);
|
||||
|
||||
switch (num_x->kind) {
|
||||
case QNUM_I64:
|
||||
@ -271,5 +271,5 @@ bool qnum_is_equal(const QObject *x, const QObject *y)
|
||||
void qnum_destroy_obj(QObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
g_free(qobject_to_qnum(obj));
|
||||
g_free(qobject_to(QNum, obj));
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ const char *qstring_get_str(const QString *qstring)
|
||||
*/
|
||||
bool qstring_is_equal(const QObject *x, const QObject *y)
|
||||
{
|
||||
return !strcmp(qobject_to_qstring(x)->string,
|
||||
qobject_to_qstring(y)->string);
|
||||
return !strcmp(qobject_to(QString, x)->string,
|
||||
qobject_to(QString, y)->string);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +145,7 @@ void qstring_destroy_obj(QObject *obj)
|
||||
QString *qs;
|
||||
|
||||
assert(obj != NULL);
|
||||
qs = qobject_to_qstring(obj);
|
||||
qs = qobject_to(QString, obj);
|
||||
g_free(qs->string);
|
||||
g_free(qs);
|
||||
}
|
||||
|
@ -1142,7 +1142,7 @@ char *object_property_get_str(Object *obj, const char *name,
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
qstring = qobject_to_qstring(ret);
|
||||
qstring = qobject_to(QString, ret);
|
||||
if (!qstring) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
|
||||
retval = NULL;
|
||||
@ -1203,7 +1203,7 @@ bool object_property_get_bool(Object *obj, const char *name,
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
qbool = qobject_to_qbool(ret);
|
||||
qbool = qobject_to(QBool, ret);
|
||||
if (!qbool) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
|
||||
retval = false;
|
||||
@ -1235,7 +1235,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
|
||||
return -1;
|
||||
}
|
||||
|
||||
qnum = qobject_to_qnum(ret);
|
||||
qnum = qobject_to(QNum, ret);
|
||||
if (!qnum || !qnum_get_try_int(qnum, &retval)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
|
||||
retval = -1;
|
||||
@ -1264,7 +1264,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name,
|
||||
if (!ret) {
|
||||
return 0;
|
||||
}
|
||||
qnum = qobject_to_qnum(ret);
|
||||
qnum = qobject_to(QNum, ret);
|
||||
if (!qnum || !qnum_get_try_uint(qnum, &retval)) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint");
|
||||
retval = 0;
|
||||
|
@ -3141,7 +3141,7 @@ arch_query_cpu_model_expansion(CpuModelExpansionType type,
|
||||
|
||||
xc = x86_cpu_from_model(model->name,
|
||||
model->has_props ?
|
||||
qobject_to_qdict(model->props) :
|
||||
qobject_to(QDict, model->props) :
|
||||
NULL, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
|
@ -453,7 +453,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
|
||||
Object *obj;
|
||||
|
||||
if (info->props) {
|
||||
qdict = qobject_to_qdict(info->props);
|
||||
qdict = qobject_to(QDict, info->props);
|
||||
if (!qdict) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
|
||||
return;
|
||||
|
@ -51,7 +51,7 @@ static void qdict_put_obj_test(void)
|
||||
|
||||
g_assert(qdict_size(qdict) == 1);
|
||||
ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]);
|
||||
qn = qobject_to_qnum(ent->value);
|
||||
qn = qobject_to(QNum, ent->value);
|
||||
g_assert_cmpint(qnum_get_int(qn), ==, num);
|
||||
|
||||
QDECREF(qdict);
|
||||
@ -81,7 +81,7 @@ static void qdict_get_test(void)
|
||||
obj = qdict_get(tests_dict, key);
|
||||
g_assert(obj != NULL);
|
||||
|
||||
qn = qobject_to_qnum(obj);
|
||||
qn = qobject_to(QNum, obj);
|
||||
g_assert_cmpint(qnum_get_int(qn), ==, value);
|
||||
|
||||
QDECREF(tests_dict);
|
||||
@ -216,7 +216,7 @@ static void qdict_del_test(void)
|
||||
static void qobject_to_qdict_test(void)
|
||||
{
|
||||
QDict *tests_dict = qdict_new();
|
||||
g_assert(qobject_to_qdict(QOBJECT(tests_dict)) == tests_dict);
|
||||
g_assert(qobject_to(QDict, QOBJECT(tests_dict)) == tests_dict);
|
||||
|
||||
QDECREF(tests_dict);
|
||||
}
|
||||
@ -381,9 +381,9 @@ static void qdict_array_split_test(void)
|
||||
|
||||
qdict_array_split(test_dict, &test_list);
|
||||
|
||||
dict1 = qobject_to_qdict(qlist_pop(test_list));
|
||||
dict2 = qobject_to_qdict(qlist_pop(test_list));
|
||||
int1 = qobject_to_qnum(qlist_pop(test_list));
|
||||
dict1 = qobject_to(QDict, qlist_pop(test_list));
|
||||
dict2 = qobject_to(QDict, qlist_pop(test_list));
|
||||
int1 = qobject_to(QNum, qlist_pop(test_list));
|
||||
|
||||
g_assert(dict1);
|
||||
g_assert(dict2);
|
||||
@ -450,7 +450,7 @@ static void qdict_array_split_test(void)
|
||||
|
||||
qdict_array_split(test_dict, &test_list);
|
||||
|
||||
int1 = qobject_to_qnum(qlist_pop(test_list));
|
||||
int1 = qobject_to(QNum, qlist_pop(test_list));
|
||||
|
||||
g_assert(int1);
|
||||
g_assert(qlist_empty(test_list));
|
||||
@ -607,7 +607,7 @@ static void qdict_crumple_test_recursive(void)
|
||||
qdict_put_str(src, "vnc.acl..name", "acl0");
|
||||
qdict_put_str(src, "vnc.acl.rule..name", "acl0");
|
||||
|
||||
dst = qobject_to_qdict(qdict_crumple(src, &error_abort));
|
||||
dst = qobject_to(QDict, qdict_crumple(src, &error_abort));
|
||||
g_assert(dst);
|
||||
g_assert_cmpint(qdict_size(dst), ==, 1);
|
||||
|
||||
@ -629,14 +629,14 @@ static void qdict_crumple_test_recursive(void)
|
||||
g_assert(rules);
|
||||
g_assert_cmpint(qlist_size(rules), ==, 2);
|
||||
|
||||
rule = qobject_to_qdict(qlist_pop(rules));
|
||||
rule = qobject_to(QDict, qlist_pop(rules));
|
||||
g_assert(rule);
|
||||
g_assert_cmpint(qdict_size(rule), ==, 2);
|
||||
g_assert_cmpstr("fred", ==, qdict_get_str(rule, "match"));
|
||||
g_assert_cmpstr("allow", ==, qdict_get_str(rule, "policy"));
|
||||
QDECREF(rule);
|
||||
|
||||
rule = qobject_to_qdict(qlist_pop(rules));
|
||||
rule = qobject_to(QDict, qlist_pop(rules));
|
||||
g_assert(rule);
|
||||
g_assert_cmpint(qdict_size(rule), ==, 2);
|
||||
g_assert_cmpstr("bob", ==, qdict_get_str(rule, "match"));
|
||||
|
@ -60,7 +60,7 @@ static void escaped_string(void)
|
||||
QString *str;
|
||||
|
||||
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
|
||||
str = qobject_to_qstring(obj);
|
||||
str = qobject_to(QString, obj);
|
||||
g_assert(str);
|
||||
g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded);
|
||||
|
||||
@ -92,7 +92,7 @@ static void simple_string(void)
|
||||
QString *str;
|
||||
|
||||
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
|
||||
str = qobject_to_qstring(obj);
|
||||
str = qobject_to(QString, obj);
|
||||
g_assert(str);
|
||||
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
|
||||
|
||||
@ -123,7 +123,7 @@ static void single_quote_string(void)
|
||||
QString *str;
|
||||
|
||||
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
|
||||
str = qobject_to_qstring(obj);
|
||||
str = qobject_to(QString, obj);
|
||||
g_assert(str);
|
||||
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
|
||||
|
||||
@ -817,7 +817,7 @@ static void utf8_string(void)
|
||||
|
||||
obj = qobject_from_json(json_in, utf8_out ? &error_abort : NULL);
|
||||
if (utf8_out) {
|
||||
str = qobject_to_qstring(obj);
|
||||
str = qobject_to(QString, obj);
|
||||
g_assert(str);
|
||||
g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);
|
||||
} else {
|
||||
@ -843,7 +843,7 @@ static void utf8_string(void)
|
||||
*/
|
||||
if (0 && json_out != json_in) {
|
||||
obj = qobject_from_json(json_out, &error_abort);
|
||||
str = qobject_to_qstring(obj);
|
||||
str = qobject_to(QString, obj);
|
||||
g_assert(str);
|
||||
g_assert_cmpstr(qstring_get_str(str), ==, utf8_out);
|
||||
}
|
||||
@ -864,8 +864,8 @@ static void vararg_string(void)
|
||||
for (i = 0; test_cases[i].decoded; i++) {
|
||||
QString *str;
|
||||
|
||||
str = qobject_to_qstring(qobject_from_jsonf("%s",
|
||||
test_cases[i].decoded));
|
||||
str = qobject_to(QString,
|
||||
qobject_from_jsonf("%s", test_cases[i].decoded));
|
||||
g_assert(str);
|
||||
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
|
||||
|
||||
@ -893,8 +893,9 @@ static void simple_number(void)
|
||||
QNum *qnum;
|
||||
int64_t val;
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_json(test_cases[i].encoded,
|
||||
&error_abort));
|
||||
qnum = qobject_to(QNum,
|
||||
qobject_from_json(test_cases[i].encoded,
|
||||
&error_abort));
|
||||
g_assert(qnum);
|
||||
g_assert(qnum_get_try_int(qnum, &val));
|
||||
g_assert_cmpint(val, ==, test_cases[i].decoded);
|
||||
@ -920,7 +921,7 @@ static void large_number(void)
|
||||
uint64_t val;
|
||||
int64_t ival;
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_json(maxu64, &error_abort));
|
||||
qnum = qobject_to(QNum, qobject_from_json(maxu64, &error_abort));
|
||||
g_assert(qnum);
|
||||
g_assert_cmpuint(qnum_get_uint(qnum), ==, 18446744073709551615U);
|
||||
g_assert(!qnum_get_try_int(qnum, &ival));
|
||||
@ -930,7 +931,7 @@ static void large_number(void)
|
||||
QDECREF(str);
|
||||
QDECREF(qnum);
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_json(gtu64, &error_abort));
|
||||
qnum = qobject_to(QNum, qobject_from_json(gtu64, &error_abort));
|
||||
g_assert(qnum);
|
||||
g_assert_cmpfloat(qnum_get_double(qnum), ==, 18446744073709552e3);
|
||||
g_assert(!qnum_get_try_uint(qnum, &val));
|
||||
@ -941,7 +942,7 @@ static void large_number(void)
|
||||
QDECREF(str);
|
||||
QDECREF(qnum);
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_json(lti64, &error_abort));
|
||||
qnum = qobject_to(QNum, qobject_from_json(lti64, &error_abort));
|
||||
g_assert(qnum);
|
||||
g_assert_cmpfloat(qnum_get_double(qnum), ==, -92233720368547758e2);
|
||||
g_assert(!qnum_get_try_uint(qnum, &val));
|
||||
@ -973,7 +974,7 @@ static void float_number(void)
|
||||
QNum *qnum;
|
||||
|
||||
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
|
||||
qnum = qobject_to_qnum(obj);
|
||||
qnum = qobject_to(QNum, obj);
|
||||
g_assert(qnum);
|
||||
g_assert(qnum_get_double(qnum) == test_cases[i].decoded);
|
||||
|
||||
@ -997,17 +998,17 @@ static void vararg_number(void)
|
||||
double valuef = 2.323423423;
|
||||
int64_t val;
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_jsonf("%d", value));
|
||||
qnum = qobject_to(QNum, qobject_from_jsonf("%d", value));
|
||||
g_assert(qnum_get_try_int(qnum, &val));
|
||||
g_assert_cmpint(val, ==, value);
|
||||
QDECREF(qnum);
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_jsonf("%lld", value_ll));
|
||||
qnum = qobject_to(QNum, qobject_from_jsonf("%lld", value_ll));
|
||||
g_assert(qnum_get_try_int(qnum, &val));
|
||||
g_assert_cmpint(val, ==, value_ll);
|
||||
QDECREF(qnum);
|
||||
|
||||
qnum = qobject_to_qnum(qobject_from_jsonf("%f", valuef));
|
||||
qnum = qobject_to(QNum, qobject_from_jsonf("%f", valuef));
|
||||
g_assert(qnum_get_double(qnum) == valuef);
|
||||
QDECREF(qnum);
|
||||
}
|
||||
@ -1020,7 +1021,7 @@ static void keyword_literal(void)
|
||||
QString *str;
|
||||
|
||||
obj = qobject_from_json("true", &error_abort);
|
||||
qbool = qobject_to_qbool(obj);
|
||||
qbool = qobject_to(QBool, obj);
|
||||
g_assert(qbool);
|
||||
g_assert(qbool_get_bool(qbool) == true);
|
||||
|
||||
@ -1031,7 +1032,7 @@ static void keyword_literal(void)
|
||||
QDECREF(qbool);
|
||||
|
||||
obj = qobject_from_json("false", &error_abort);
|
||||
qbool = qobject_to_qbool(obj);
|
||||
qbool = qobject_to(QBool, obj);
|
||||
g_assert(qbool);
|
||||
g_assert(qbool_get_bool(qbool) == false);
|
||||
|
||||
@ -1041,13 +1042,13 @@ static void keyword_literal(void)
|
||||
|
||||
QDECREF(qbool);
|
||||
|
||||
qbool = qobject_to_qbool(qobject_from_jsonf("%i", false));
|
||||
qbool = qobject_to(QBool, qobject_from_jsonf("%i", false));
|
||||
g_assert(qbool);
|
||||
g_assert(qbool_get_bool(qbool) == false);
|
||||
QDECREF(qbool);
|
||||
|
||||
/* Test that non-zero values other than 1 get collapsed to true */
|
||||
qbool = qobject_to_qbool(qobject_from_jsonf("%i", 2));
|
||||
qbool = qobject_to(QBool, qobject_from_jsonf("%i", 2));
|
||||
g_assert(qbool);
|
||||
g_assert(qbool_get_bool(qbool) == true);
|
||||
QDECREF(qbool);
|
||||
|
@ -56,7 +56,7 @@ static void qobject_to_qlist_test(void)
|
||||
|
||||
qlist = qlist_new();
|
||||
|
||||
g_assert(qobject_to_qlist(QOBJECT(qlist)) == qlist);
|
||||
g_assert(qobject_to(QList, QOBJECT(qlist)) == qlist);
|
||||
|
||||
QDECREF(qlist);
|
||||
}
|
||||
@ -71,7 +71,7 @@ static void iter_func(QObject *obj, void *opaque)
|
||||
|
||||
g_assert(opaque == NULL);
|
||||
|
||||
qi = qobject_to_qnum(obj);
|
||||
qi = qobject_to(QNum, obj);
|
||||
g_assert(qi != NULL);
|
||||
|
||||
g_assert(qnum_get_try_int(qi, &val));
|
||||
|
@ -59,7 +59,7 @@ static void qlit_equal_qobject_test(void)
|
||||
|
||||
g_assert(!qlit_equal_qobject(&qlit_foo, qobj));
|
||||
|
||||
qdict_put |