From 006ca09f3027d86346fce707e9295975c6558f42 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 Jun 2017 13:52:24 +0200 Subject: qapi: Separate type QNull from QObject Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Daniel P. Berrange --- include/qapi/qmp/qobject.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index b8ddbca405..3543b552f4 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -93,11 +93,15 @@ static inline QType qobject_type(const QObject *obj) return obj->type; } -extern QObject qnull_; +typedef struct QNull { + QObject base; +} QNull; -static inline QObject *qnull(void) +extern QNull qnull_; + +static inline QNull *qnull(void) { - qobject_incref(&qnull_); + QINCREF(&qnull_); return &qnull_; } -- cgit v1.2.3 From d2f95f4d482374485234790a6fc3cca29ebb7355 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 Jun 2017 18:22:59 +0200 Subject: qapi: Use QNull for a more regular visit_type_null() Make visit_type_null() take an @obj argument like its buddies. This helps keep the next commit simple. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Daniel P. Berrange --- include/qapi/visitor-impl.h | 3 ++- include/qapi/visitor.h | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index dcd656ab76..8ccb3b6c20 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -103,7 +103,8 @@ struct Visitor Error **errp); /* Must be set to visit explicit null values. */ - void (*type_null)(Visitor *v, const char *name, Error **errp); + void (*type_null)(Visitor *v, const char *name, QNull **obj, + Error **errp); /* Must be set for input visitors to visit structs, optional otherwise. The core takes care of the return type in the public interface. */ diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 74768aabda..fe9faf469f 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -618,10 +618,10 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp); * @name expresses the relationship of the null value to its parent * container; see the general description of @name above. * - * Unlike all other visit_type_* functions, no obj parameter is - * needed; rather, this is a witness that an explicit null value is - * expected rather than any other type. + * @obj must be non-NULL. Input visitors set *@obj to the value; + * other visitors ignore *@obj. */ -void visit_type_null(Visitor *v, const char *name, Error **errp); +void visit_type_null(Visitor *v, const char *name, QNull **obj, + Error **errp); #endif -- cgit v1.2.3 From 4d2d5c41a9e8ee201cda8be8701f7f9fc92e71aa Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 Jun 2017 19:25:14 +0200 Subject: qapi: Introduce a first class 'null' type I expect the 'null' type to be useful mostly for members of alternate types. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrange Reviewed-by: Eric Blake Signed-off-by: Markus Armbruster --- include/qapi/qmp/qobject.h | 4 ++-- include/qemu/typedefs.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index 3543b552f4..eab29edd12 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -93,9 +93,9 @@ static inline QType qobject_type(const QObject *obj) return obj->type; } -typedef struct QNull { +struct QNull { QObject base; -} QNull; +}; extern QNull qnull_; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 7b0d4e7e05..39bc8351a3 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -89,6 +89,7 @@ typedef struct QEMUSGList QEMUSGList; typedef struct QEMUTimer QEMUTimer; typedef struct QEMUTimerListGroup QEMUTimerListGroup; typedef struct QObject QObject; +typedef struct QNull QNull; typedef struct RAMBlock RAMBlock; typedef struct Range Range; typedef struct SerialState SerialState; -- cgit v1.2.3