diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-04-19 17:01:42 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-05-04 08:27:53 +0200 |
commit | 3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (patch) | |
tree | e0f8f345f94f9de6b203da0e4a8ff06b23e4c5ae /include/qapi/qmp/qdict.h | |
parent | 7ee9edfdb117da47c86c9764d90f0be11a648666 (diff) |
qobject: use a QObjectBase_ struct
By moving the base fields to a QObjectBase_, QObject can be a type
which also has a 'base' field. This allows writing a generic QOBJECT()
macro that will work with any QObject type, including QObject
itself. The container_of() macro ensures that the object to cast has a
QObjectBase_ base field, giving some type safety guarantees. QObject
must have no members but QObjectBase_ base, or else QOBJECT() breaks.
QObjectBase_ is not a typedef and uses a trailing underscore to make
it obvious it is not for normal use and to avoid potential abuse.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180419150145.24795-3-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi/qmp/qdict.h')
-rw-r--r-- | include/qapi/qmp/qdict.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 2cc3e906f7..921a28d2d3 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -25,7 +25,7 @@ typedef struct QDictEntry { } QDictEntry; struct QDict { - QObject base; + struct QObjectBase_ base; size_t size; QLIST_HEAD(,QDictEntry) table[QDICT_BUCKET_MAX]; }; |