Re: [PATCH v3 07/15] qom/object.c: add object_class_property_add_uint32_ptr()

[email protected]
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <178716196330.2018258.6471457150873358597.b4-review@b4>
> This adds a class property that references a uint32_t within the object instance
> and is intended to be a replacement for object_property_add_uint32_ptr().
> 
> Signed-off-by: Mark Cave-Ayland <[email protected]>
> Message-ID: <[email protected]>
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index eba675d218eb..e0c88453b1e0 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -2129,6 +2129,24 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
>                                      const uint32_t *v,
>                                      ObjectPropertyFlags flags);
>  
> +/**
> + * object_class_property_add_uint32_ptr:
> + * @klass: the object class to add a property to
> + * @name: the name of the property
> + * @offset: the offset from the object instance where the uint8 value is
> + *   stored

Should be "uint32 value", not "uint8 value".

> + * @flags: bitwise-or'd ObjectPropertyFlags
> + *
> + * Add an integer property in memory.  This function will add a
> + * property of type 'uint16'.

Should be "property of type 'uint32'", not 'uint16'.

> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
> +                                    const char *name,
> +                                    ptrdiff_t offset,
> +                                    ObjectPropertyFlags flags);
> +
>  /**
>   * object_class_static_property_add_uint32_ptr:
>   * @klass: the object class to add a static property to
> diff --git a/qom/object.c b/qom/object.c
> index a480fdd40089..fe032c96190c 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
>      OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
>  
>  DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
> +DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
>  
>  #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
>  #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
> @@ -2870,6 +2871,26 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
>                                 getter, setter, NULL, (void *)v);
>  }
>  
> +ObjectProperty *
> +object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
> +                                     ptrdiff_t offset,
> +                                     ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_class_get_uint32_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_class_set_uint32_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "uint32",
> +                                     getter, setter, NULL, (void *)offset);
> +}
> +
>  ObjectProperty *
>  object_class_static_property_add_uint32_ptr(ObjectClass *klass,
>                                              const char *name,

Reviewed-by: Marc-André Lureau <[email protected]>

-- 
Marc-André Lureau <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.