[email protected] writes:
>> Add element_info and element_size fields to PropertyInfo.
>>
>> Add typed array PropertyInfo definitions. Each one knows its element
>> type at compile time through the new element_info and element_size
>> fields of PropertyInfo.
>>
>> Update DEFINE_PROP_ARRAY() to use them instead of the generic
>> qdev_prop_array.
>>
>> Use PropertyInfo fields element_info and element_size instead of
>> Property fields arrayinfo and arrayfieldsize. Remove arrayinfo and
>> arrayfieldsize.
>>
>> Infrastructure changes:
>> - Make get_prop_array, set_prop_array, release_prop_array, and
>> default_prop_array non-static so they can be used by
>> DEFINE_PROP_ARRAY_INFO in other translation units
>> - Add DEFINE_PROP_ARRAY_INFO macro in qdev-prop-internal.h
>>
>> Signed-off-by: Marc-André Lureau <[email protected]>
>> Signed-off-by: Markus Armbruster <[email protected]>
>> Message-ID: <[email protected]>
[...]
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index e2ea8945956c..7a7d4f9d7910 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
[...]
>> @@ -854,18 +860,24 @@ out_obj:
>> }
>> }
>>
>> -static void default_prop_array(ObjectProperty *op, const Property *prop)
>> +void default_prop_array(ObjectProperty *op, const Property *prop)
>> {
>> object_property_set_default_list(op);
>> }
>>
>> -const PropertyInfo qdev_prop_array = {
>> - .type = "list",
>> - .get = get_prop_array,
>> - .set = set_prop_array,
>> - .release = release_prop_array,
>> - .set_default_value = default_prop_array,
>> -};
>> +const PropertyInfo qdev_prop_uint8_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint8, uint8_t, &uint8List_type_info);
>> +const PropertyInfo qdev_prop_uint16_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint16, uint16_t,
>> &uint16List_type_info);
>> +const PropertyInfo qdev_prop_uint32_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint32, uint32_t,
>> &uint32List_type_info);
>> +const PropertyInfo qdev_prop_uint64_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint64, uint64_t,
>> &uint64List_type_info);
>> +const PropertyInfo qdev_prop_string_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_string, char *, &strList_type_info);
>> +
>> +const PropertyInfo qdev_prop_link_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_link, void *, NULL);
>
> It could use &strList_type_info, since qdev_prop_link uses
> &str_type_info and serialize as object-path strings.
Point.
>> /* --- public helpers --- */
>>
>> diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h
>> index 3197bd853dab..652f158223c0 100644
>> --- a/hw/display/apple-gfx.h
>> +++ b/hw/display/apple-gfx.h
>> @@ -69,6 +69,7 @@ void *apple_gfx_host_ptr_for_gpa_range(uint64_t
>> guest_physical,
>> MemoryRegion **mapping_in_region);
>>
>> extern const PropertyInfo qdev_prop_apple_gfx_display_mode;
>> +extern const PropertyInfo qdev_prop_apple_gfx_display_mode_array;
>>
>> #endif
>>
>> diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
>> index 4db80f0b107e..f800f84aa2b5 100644
>> --- a/hw/display/apple-gfx.m
>> +++ b/hw/display/apple-gfx.m
>> @@ -16,6 +16,7 @@
>> #include "qemu/cutils.h"
>> #include "qemu/log.h"
>> #include "qapi/qapi-builtin-type-infos.h"
>> +#include "hw/core/qdev-prop-internal.h"
>> #include "qapi/visitor.h"
>> #include "qapi/error.h"
>> #include "qemu/aio-wait.h"
>> @@ -880,3 +881,8 @@ static void apple_gfx_set_display_mode(Object *obj,
>> Visitor *v,
>> .get = apple_gfx_get_display_mode,
>> .set = apple_gfx_set_display_mode,
>> };
>> +
>> +const PropertyInfo qdev_prop_apple_gfx_display_mode_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_apple_gfx_display_mode,
>> + AppleGFXDisplayMode,
>> + &strList_type_info);
>
> indented with tabs
Oops.
Thank you!