unicorn/qemu/include/qapi
Max Reitz dbdba16732
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).

Backports commit 1a56b1e2ab5e9d6d89386ca953b4afb419e15abe from qemu
2018-03-20 10:45:59 -04:00
..
qmp qapi: Add qobject_to() 2018-03-20 10:45:59 -04:00
clone-visitor.h qapi: New QAPI_CLONE_MEMBERS() 2018-03-03 17:36:02 -05:00
dealloc-visitor.h qapi: Add new visit_free() function 2018-02-25 01:05:41 -05:00
error.h qapi: Move qapi-schema.json to qapi/, rename generated files 2018-03-09 11:35:11 -05:00
qobject-input-visitor.h qapi: merge QInt and QFloat in QNum 2018-03-03 18:16:28 -05:00
qobject-output-visitor.h qapi: merge QInt and QFloat in QNum 2018-03-03 18:16:28 -05:00
string-input-visitor.h string-input-visitor: Favor new visit_free() function 2018-02-25 01:08:04 -05:00
visitor-impl.h qapi: Use QNull for a more regular visit_type_null() 2018-03-07 16:50:16 -05:00
visitor.h qapi: Move qapi-schema.json to qapi/, rename generated files 2018-03-09 11:35:11 -05:00