@samitouri / QOSamiQemu / commits / 70d3ce61f4

qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro

This macro will be used to generate the boilerplate property_class_get_type_ptr() QOM get function for the specified scalar type. Note that since the macro is currently unused, the object_class_prop_ptr() helper function is temporarily marked as __attribute__((unused)) to allow compilation to succeed. Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20260825134320.1039012-2-mark.caveayland@nutanix.com>

Mark Cave-Ayland committed Aug 25, 2026 at 14:41 UTC 70d3ce61f41ad6964386ef17861466e46fede518
1 file changed +22
qom/object.c
+22
@@ -2703,6 +2703,28 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
2703 #undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
2704
2705
2706 +__attribute__((unused))
2707 +static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2708 +{
2709 + void *ptr = obj;
2710 + ptr += offset;
2711 +
2712 + return ptr;
2713 +}
2714 +
2715 +#define OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
2716 + static void property_class_get_##type##_ptr(Object *obj, Visitor *v, \
2717 + const char *name, \
2718 + void *opaque, Error **errp) \
2719 + { \
2720 + type##_t value = *(type##_t *)object_class_prop_ptr(obj, \
2721 + (ptrdiff_t)opaque); \
2722 + visit_type_##type(v, name, &value, errp); \
2723 + }
2724 +
2725 +#undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
2726 +
2727 +
2728 ObjectProperty *
2729 object_property_add_uint8_ptr(Object *obj, const char *name,
2730 const uint8_t *v,