mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 15:15:38 +00:00
qapi: Introduce a first class 'null' type
I expect the 'null' type to be useful mostly for members of alternate types. Backports commit 4d2d5c41a9e8ee201cda8be8701f7f9fc92e71aa from qemu
This commit is contained in:
parent
4a7abec7c9
commit
615e361cf2
|
@ -99,9 +99,9 @@ static inline QType qobject_type(const QObject *obj)
|
|||
return obj->type;
|
||||
}
|
||||
|
||||
typedef struct QNull {
|
||||
struct QNull {
|
||||
QObject base;
|
||||
} QNull;
|
||||
};
|
||||
|
||||
extern QNull qnull_;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ typedef struct QBool QBool;
|
|||
typedef struct QDict QDict;
|
||||
typedef struct QList QList;
|
||||
typedef struct QNum QNum;
|
||||
typedef struct QNull QNull;
|
||||
typedef struct QObject QObject;
|
||||
typedef struct QString QString;
|
||||
typedef struct RAMBlock RAMBlock;
|
||||
|
|
|
@ -28,6 +28,7 @@ except ImportError:
|
|||
from io import StringIO
|
||||
|
||||
builtin_types = {
|
||||
'null': 'QTYPE_QNULL',
|
||||
'str': 'QTYPE_QSTRING',
|
||||
'int': 'QTYPE_QNUM',
|
||||
'number': 'QTYPE_QNUM',
|
||||
|
@ -1064,6 +1065,7 @@ class QAPISchemaType(QAPISchemaEntity):
|
|||
|
||||
def alternate_qtype(self):
|
||||
json2qtype = {
|
||||
'null': 'QTYPE_QNULL',
|
||||
'string': 'QTYPE_QSTRING',
|
||||
'number': 'QTYPE_QNUM',
|
||||
'int': 'QTYPE_QNUM',
|
||||
|
@ -1523,7 +1525,8 @@ class QAPISchema(object):
|
|||
('uint64', 'int', 'uint64_t'),
|
||||
('size', 'int', 'uint64_t'),
|
||||
('bool', 'boolean', 'bool'),
|
||||
('any', 'value', 'QObject' + pointer_suffix)]:
|
||||
('any', 'value', 'QObject' + pointer_suffix),
|
||||
('null', 'null', 'QNull' + pointer_suffix)]:
|
||||
self._def_builtin_type(*t)
|
||||
self.the_empty_object_type = QAPISchemaObjectType(
|
||||
'q_empty', None, None, None, [], None)
|
||||
|
|
Loading…
Reference in a new issue