@samitouri / QOSamiQemu / commits / 0a38021b85

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

This macro will be used to generate the boilerplate property_class_set_type_ptr() QOM set function for the specified scalar type. 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-3-mark.caveayland@nutanix.com>

Mark Cave-Ayland committed Aug 25, 2026 at 14:41 UTC 0a38021b85044666079a995900d37f6d766cedd5
1 file changed +17
qom/object.c
+17
@@ -2722,7 +2722,24 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2722 visit_type_##type(v, name, &value, errp); \
2723 }
2724
2725 +#define OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) \
2726 + static void property_class_set_##type##_ptr(Object *obj, Visitor *v, \
2727 + const char *name, \
2728 + void *opaque, Error **errp) \
2729 + { \
2730 + type##_t *field = (type##_t *)object_class_prop_ptr(obj, \
2731 + (ptrdiff_t)opaque); \
2732 + type##_t value; \
2733 + \
2734 + if (!visit_type_##type(v, name, &value, errp)) { \
2735 + return; \
2736 + } \
2737 + \
2738 + *field = value; \
2739 + }
2740 +
2741 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
2742 +#undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
2743
2744
2745 ObjectProperty *