mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qobject: Add a special null QObject
I'm going to fix the JSON parser to recognize null. The obvious representation of JSON null as (QObject *)NULL doesn't work, because the parser already uses it as an error value. Perhaps we should change it to free NULL for null, but that's more than I can do right now. Create a special null QObject instead. The existing QDict, QList, and QString all represent something that is a pointer in C and could therefore be associated with NULL. But right now, all three of these sub-types are always non-null once created, so the new null sentinel object is intentionally unrelated to them. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
a7c3181628
commit
481b002cc8
4 changed files with 43 additions and 2 deletions
|
@ -127,6 +127,9 @@ static void to_json_list_iter(QObject *obj, void *opaque)
|
|||
static void to_json(const QObject *obj, QString *str, int pretty, int indent)
|
||||
{
|
||||
switch (qobject_type(obj)) {
|
||||
case QTYPE_QNULL:
|
||||
qstring_append(str, "null");
|
||||
break;
|
||||
case QTYPE_QINT: {
|
||||
QInt *val = qobject_to_qint(obj);
|
||||
char buffer[1024];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue