mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-05-07 20:12:34 +00: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. Backports commit 481b002cc81ed7fc7b06e32e9d4d495d81739d14 from qemu
This commit is contained in:
parent
0ae71ac202
commit
105a6be9b0
|
@ -211,6 +211,7 @@ copy $(SolutionDir)..\include\unicorn\*.h $(SolutionDir)distro\include\unicorn\
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qfloat.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qfloat.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qint.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qint.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qlist.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qlist.c" />
|
||||||
|
<ClCompile Include="..\..\..\qemu\qobject\qnull.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qstring.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qstring.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qom\container.c" />
|
<ClCompile Include="..\..\..\qemu\qom\container.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qom\cpu.c" />
|
<ClCompile Include="..\..\..\qemu\qom\cpu.c" />
|
||||||
|
|
|
@ -98,6 +98,9 @@
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qlist.c">
|
<ClCompile Include="..\..\..\qemu\qobject\qlist.c">
|
||||||
<Filter>qemu\qobject</Filter>
|
<Filter>qemu\qobject</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\qemu\qobject\qnull.c">
|
||||||
|
<Filter>qemu\qobject</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qstring.c">
|
<ClCompile Include="..\..\..\qemu\qobject\qstring.c">
|
||||||
<Filter>qemu\qobject</Filter>
|
<Filter>qemu\qobject</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qfloat.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qfloat.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qint.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qint.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qlist.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qlist.c" />
|
||||||
|
<ClCompile Include="..\..\..\qemu\qobject\qnull.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qstring.c" />
|
<ClCompile Include="..\..\..\qemu\qobject\qstring.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qom\container.c" />
|
<ClCompile Include="..\..\..\qemu\qom\container.c" />
|
||||||
<ClCompile Include="..\..\..\qemu\qom\cpu.c" />
|
<ClCompile Include="..\..\..\qemu\qom\cpu.c" />
|
||||||
|
|
|
@ -132,6 +132,9 @@
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qlist.c">
|
<ClCompile Include="..\..\..\qemu\qobject\qlist.c">
|
||||||
<Filter>qemu\qobject</Filter>
|
<Filter>qemu\qobject</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\qemu\qobject\qnull.c">
|
||||||
|
<Filter>qemu\qobject</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\qemu\qobject\qstring.c">
|
<ClCompile Include="..\..\..\qemu\qobject\qstring.c">
|
||||||
<Filter>qemu\qobject</Filter>
|
<Filter>qemu\qobject</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Based on ideas by Avi Kivity <avi@redhat.com>
|
* Based on ideas by Avi Kivity <avi@redhat.com>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Red Hat Inc.
|
* Copyright (C) 2009, 2015 Red Hat Inc.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Luiz Capitulino <lcapitulino@redhat.com>
|
* Luiz Capitulino <lcapitulino@redhat.com>
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
QTYPE_NONE,
|
QTYPE_NONE,
|
||||||
|
QTYPE_QNULL,
|
||||||
QTYPE_QINT,
|
QTYPE_QINT,
|
||||||
QTYPE_QSTRING,
|
QTYPE_QSTRING,
|
||||||
QTYPE_QDICT,
|
QTYPE_QDICT,
|
||||||
|
@ -111,4 +112,12 @@ static inline qtype_code qobject_type(const QObject *obj)
|
||||||
return obj->type->code;
|
return obj->type->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern QObject qnull_;
|
||||||
|
|
||||||
|
static inline QObject *qnull(void)
|
||||||
|
{
|
||||||
|
qobject_incref(&qnull_);
|
||||||
|
return &qnull_;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* QOBJECT_H */
|
#endif /* QOBJECT_H */
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
util-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
|
util-obj-y = qint.o qnull.o qstring.o qdict.o qlist.o qfloat.o qbool.o
|
||||||
|
|
29
qemu/qobject/qnull.c
Normal file
29
qemu/qobject/qnull.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* QNull
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Markus Armbruster <armbru@redhat.com>
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU LGPL, version 2.1
|
||||||
|
* or later. See the COPYING.LIB file in the top-level directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu-common.h"
|
||||||
|
#include "qapi/qmp/qobject.h"
|
||||||
|
|
||||||
|
static void qnull_destroy_obj(QObject *obj)
|
||||||
|
{
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const QType qnull_type = {
|
||||||
|
QTYPE_QNULL,
|
||||||
|
qnull_destroy_obj,
|
||||||
|
};
|
||||||
|
|
||||||
|
QObject qnull_ = {
|
||||||
|
&qnull_type,
|
||||||
|
1,
|
||||||
|
};
|
Loading…
Reference in a new issue