For clarity and to avoid encouraging people to copy the examples, show the actual typecast functions being defined by OBJECT_DECLARE* macros in the examples.
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- docs/devel/qom.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst index aa1f672efbe..3ae6f75a1a2 100644 --- a/docs/devel/qom.rst +++ b/docs/devel/qom.rst @@ -303,8 +303,10 @@ This is equivalent to the following: typedef struct MyDevice MyDevice; G_DEFINE_AUTOPTR_CLEANUP_FUNC(MyDevice, object_unref) - #define MY_DEVICE(void *obj) - OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE) + static inline MyDevice *MY_DEVICE(void *obj) + { + return OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE); + } The 'struct MyDevice' needs to be declared separately. @@ -327,12 +329,18 @@ This is equivalent to the following: G_DEFINE_AUTOPTR_CLEANUP_FUNC(MyDevice, object_unref) - #define MY_DEVICE_GET_CLASS(void *obj) \ - OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE) - #define MY_DEVICE_CLASS(void *klass) \ - OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE) - #define MY_DEVICE(void *obj) - OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE) + static inline MyDeviceClass *MY_DEVICE_GET_CLASS(void *obj) + { + return OBJECT_GET_CLASS(MyDeviceClass, obj, TYPE_MY_DEVICE); + } + static inline MyDeviceClass *MY_DEVICE_CLASS(void *klass) + { + return OBJECT_CLASS_CHECK(MyDeviceClass, klass, TYPE_MY_DEVICE); + } + static inline MyDevice *MY_DEVICE(void *obj) + { + return OBJECT_CHECK(MyDevice, obj, TYPE_MY_DEVICE); + } Type definition macros ---------------------- -- 2.31.1