On 05/11/2017 09:29 AM, Markus Armbruster wrote: > Marc-André Lureau <[email protected]> writes: > >> We would like to use a same QObject type to represent numbers, whether >> they are int, uint, or floats. getters will allow some compatibility > > Please start your sentence with a capital letter ... > >> between the various types if the number fits other representations > > ... and end them with a period. >
>> +++ b/block/qapi.c
>> @@ -595,9 +595,11 @@ static void dump_qobject(fprintf_function func_fprintf,
>> void *f,
>> int comp_indent, QObject *obj)
>> {
>> switch (qobject_type(obj)) {
>> - case QTYPE_QINT: {
>> - QInt *value = qobject_to_qint(obj);
>> - func_fprintf(f, "%" PRId64, qint_get_int(value));
>> + case QTYPE_QNUM: {
>> + QNum *value = qobject_to_qnum(obj);
>> + char *tmp = qnum_to_string(value);
>> + func_fprintf(f, "%s", tmp);
>> + g_free(tmp);
>> break;
>> }
>> case QTYPE_QSTRING: {
>
> Becomes a bit awkward due to the dynamically allocated buffer. Let's
> ignore that for now.
>
> Aside: I don't like that the block layer has its own dump_qobject().
I should really revive my patches for a QAPI JSON output visitor.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
