qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-6.2 08/10] docs: qom: Show actual typecast functions in e


From: Peter Maydell
Subject: Re: [PATCH for-6.2 08/10] docs: qom: Show actual typecast functions in examples
Date: Mon, 2 Aug 2021 13:25:43 +0100

On Thu, 29 Jul 2021 at 19:03, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> 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 <ehabkost@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);
> +   }

...aha, you can ignore my remark on the previous patch :-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]