qemu/include/qapi/qmp
Max Reitz 1a56b1e2ab qapi: Add qobject_to()
This is a dynamic casting macro that, given a QObject type, returns an
object as that type or NULL if the object is of a different type (or
NULL itself).

The macro uses lower-case letters because:
1. There does not seem to be a hard rule on whether qemu macros have to
   be upper-cased,
2. The current situation in qapi/qmp is inconsistent (compare e.g.
   QINCREF() vs. qdict_put()),
3. qobject_to() will evaluate its @obj parameter only once, thus it is
   generally not important to the caller whether it is a macro or not,
4. I prefer it aesthetically.

The macro parameter order is chosen with typename first for
consistency with other QAPI macros like QAPI_CLONE(), as well as
for legibility (read it as "qobject to" type "applied to" obj).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20180224154033.29559-3-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
[eblake: swap parameter order to list type first, avoid clang ubsan
warning on QOBJECT(NULL) and container_of(NULL,type,base)]
Signed-off-by: Eric Blake <eblake@redhat.com>
2018-03-19 14:49:04 -05:00
..
dispatch.h Include qapi/qmp/qdict.h exactly where needed 2018-02-09 13:52:15 +01:00
json-lexer.h include: Clean up includes 2016-02-23 12:43:05 +00:00
json-parser.h Include qapi/qmp/qlist.h exactly where needed 2018-02-09 13:52:15 +01:00
json-streamer.h include: Clean up includes 2016-02-23 12:43:05 +00:00
qbool.h Typedef the subtypes of QObject in qemu/typedefs.h, too 2018-02-09 13:52:15 +01:00
qdict.h qdict: Introduce qdict_rename_keys() 2018-03-09 15:17:47 +01:00
qerror.h qmp: Eliminate silly QERR_QMP_* macros 2017-03-05 09:14:19 +01:00
qjson.h Include qapi/qmp/qstring.h exactly where needed 2018-02-09 13:52:15 +01:00
qlist.h qdict qlist: Make most helper macros functions 2018-02-09 13:52:15 +01:00
qlit.h qlit: add qobject_from_qlit() 2018-03-19 10:00:14 -05:00
qnull.h qapi: Add qobject_is_equal() 2017-11-17 18:21:30 +01:00
qnum.h Typedef the subtypes of QObject in qemu/typedefs.h, too 2018-02-09 13:52:15 +01:00
qobject.h qapi: Add qobject_to() 2018-03-19 14:49:04 -05:00
qstring.h Typedef the subtypes of QObject in qemu/typedefs.h, too 2018-02-09 13:52:15 +01:00