qom/object.c: add object_class_property_add_uint16_ptr()
This adds a class property that references a uint16_t within the object instance and is intended to be a replacement for object_property_add_uint16_ptr(). 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-13-mark.caveayland@nutanix.com>
Mark Cave-Ayland committed
Aug 25, 2026 at 14:41 UTC
5182d78050ec3b2ab28b0f121bfba25014dbbff7
2 files changed
+39
include/qom/object.h
+18
@@ -2108,6 +2108,24 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
2108
const uint16_t *v,
2109
ObjectPropertyFlags flags);
2110
2111
+/**
2112
+ * object_class_property_add_uint16_ptr:
2113
+ * @klass: the object class to add a property to
2114
+ * @name: the name of the property
2115
+ * @offset: the offset from the object instance where the uint16 value is
2116
+ * stored
2117
+ * @flags: bitwise-or'd ObjectPropertyFlags
2118
+ *
2119
+ * Add an integer property in memory. This function will add a
2120
+ * property of type 'uint16'.
2121
+ *
2122
+ * Returns: The newly added property on success, or %NULL on failure.
2123
+ */
2124
+ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
2125
+ const char *name,
2126
+ ptrdiff_t offset,
2127
+ ObjectPropertyFlags flags);
2128
+
2129
/**
2130
* object_class_static_property_add_uint16_ptr:
2131
* @klass: the object class to add a static property to
qom/object.c
+21
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2742
OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
2743
2744
DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
2745
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint16)
2746
DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
2747
DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
2748
@@ -2874,6 +2875,26 @@ object_property_add_uint16_ptr(Object *obj, const char *name,
2875
getter, setter, NULL, (void *)v);
2876
}
2877
2878
+ObjectProperty *
2879
+object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
2880
+ ptrdiff_t offset,
2881
+ ObjectPropertyFlags flags)
2882
+{
2883
+ ObjectPropertyAccessor *getter = NULL;
2884
+ ObjectPropertyAccessor *setter = NULL;
2885
+
2886
+ if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
2887
+ getter = property_class_get_uint16_ptr;
2888
+ }
2889
+
2890
+ if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
2891
+ setter = property_class_set_uint16_ptr;
2892
+ }
2893
+
2894
+ return object_class_property_add(klass, name, "uint16",
2895
+ getter, setter, NULL, (void *)offset);
2896
+}
2897
+
2898
ObjectProperty *
2899
object_class_static_property_add_uint16_ptr(ObjectClass *klass,
2900
const char *name,