qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
This more accurately reflects that these properties are held within the class and not the object. Update the documentation to describe the few cases where static properties should be used. Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20260717135254.508701-7-mark.caveayland@nutanix.com>
Mark Cave-Ayland committed
Jul 17, 2026 at 14:51 UTC
6b97f3d4d6a5c3017f6f7655019097c777f5eb86
3 files changed
+59
-30
hw/riscv/spike.c
+3
-2
@@ -278,8 +278,9 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data)
278
object_class_property_add_str(oc, "signature", NULL, spike_set_signature);
279
object_class_property_set_description(oc, "signature",
280
"File to write ACT test signature");
281
- object_class_property_add_uint8_ptr(oc, "signature-granularity",
282
- &line_size, OBJ_PROP_FLAG_WRITE);
281
+ object_class_static_property_add_uint8_ptr(oc, "signature-granularity",
282
+ &line_size,
283
+ OBJ_PROP_FLAG_WRITE);
284
object_class_property_set_description(oc, "signature-granularity",
285
"Size of each line in ACT signature "
286
"file");
include/qom/object.h
+40
-16
@@ -2034,18 +2034,24 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
2034
ObjectPropertyFlags flags);
2035
2036
/**
2037
- * object_class_property_add_uint8_ptr:
2038
- * @klass: the object class to add a property to
2037
+ * object_class_static_property_add_uint8_ptr:
2038
+ * @klass: the object class to add a static property to
2039
* @name: the name of the property
2040
* @v: pointer to value
2041
* @flags: bitwise-or'd ObjectPropertyFlags
2042
*
2043
- * Add an integer property in memory. This function will add a
2043
+ * Add a static integer property in memory. This function will add a
2044
* property of type 'uint8'.
2045
*
2046
+ * A static property is one which is stored outside of the object instance,
2047
+ * typically in global variables. It is only appropriate to use static
2048
+ * properties when the class is designed as a singleton. If there is a
2049
+ * possibility of multiple instances, then properties must be stored
2050
+ * per-instance.
2051
+ *
2052
* Returns: The newly added property on success, or %NULL on failure.
2053
*/
2048
-ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
2054
+ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
2055
const char *name,
2056
const uint8_t *v,
2057
ObjectPropertyFlags flags);
@@ -2067,18 +2073,24 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
2073
ObjectPropertyFlags flags);
2074
2075
/**
2070
- * object_class_property_add_uint16_ptr:
2071
- * @klass: the object class to add a property to
2076
+ * object_class_static_property_add_uint16_ptr:
2077
+ * @klass: the object class to add a static property to
2078
* @name: the name of the property
2079
* @v: pointer to value
2080
* @flags: bitwise-or'd ObjectPropertyFlags
2081
*
2076
- * Add an integer property in memory. This function will add a
2082
+ * Add a static integer property in memory. This function will add a
2083
* property of type 'uint16'.
2084
*
2085
+ * A static property is one which is stored outside of the object instance,
2086
+ * typically in global variables. It is only appropriate to use static
2087
+ * properties when the class is designed as a singleton. If there is a
2088
+ * possibility of multiple instances, then properties must be stored
2089
+ * per-instance.
2090
+ *
2091
* Returns: The newly added property on success, or %NULL on failure.
2092
*/
2081
-ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
2093
+ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
2094
const char *name,
2095
const uint16_t *v,
2096
ObjectPropertyFlags flags);
@@ -2100,18 +2112,24 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
2112
ObjectPropertyFlags flags);
2113
2114
/**
2103
- * object_class_property_add_uint32_ptr:
2104
- * @klass: the object class to add a property to
2115
+ * object_class_static_property_add_uint32_ptr:
2116
+ * @klass: the object class to add a static property to
2117
* @name: the name of the property
2118
* @v: pointer to value
2119
* @flags: bitwise-or'd ObjectPropertyFlags
2120
*
2109
- * Add an integer property in memory. This function will add a
2121
+ * Add a static integer property in memory. This function will add a
2122
* property of type 'uint32'.
2123
*
2124
+ * A static property is one which is stored outside of the object instance,
2125
+ * typically in global variables. It is only appropriate to use static
2126
+ * properties when the class is designed as a singleton. If there is a
2127
+ * possibility of multiple instances, then properties must be stored
2128
+ * per-instance.
2129
+ *
2130
* Returns: The newly added property on success, or %NULL on failure.
2131
*/
2114
-ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
2132
+ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
2133
const char *name,
2134
const uint32_t *v,
2135
ObjectPropertyFlags flags);
@@ -2133,18 +2151,24 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
2151
ObjectPropertyFlags flags);
2152
2153
/**
2136
- * object_class_property_add_uint64_ptr:
2137
- * @klass: the object class to add a property to
2154
+ * object_class_static_property_add_uint64_ptr:
2155
+ * @klass: the object class to add a static property to
2156
* @name: the name of the property
2157
* @v: pointer to value
2158
* @flags: bitwise-or'd ObjectPropertyFlags
2159
*
2142
- * Add an integer property in memory. This function will add a
2160
+ * Add a static integer property in memory. This function will add a
2161
* property of type 'uint64'.
2162
*
2163
+ * A static property is one which is stored outside of the object instance,
2164
+ * typically in global variables. It is only appropriate to use static
2165
+ * properties when the class is designed as a singleton. If there is a
2166
+ * possibility of multiple instances, then properties must be stored
2167
+ * per-instance.
2168
+ *
2169
* Returns: The newly added property on success, or %NULL on failure.
2170
*/
2147
-ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
2171
+ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
2172
const char *name,
2173
const uint64_t *v,
2174
ObjectPropertyFlags flags);
qom/object.c
+16
-12
@@ -2724,9 +2724,10 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
2724
}
2725
2726
ObjectProperty *
2727
-object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
2728
- const uint8_t *v,
2729
- ObjectPropertyFlags flags)
2727
+object_class_static_property_add_uint8_ptr(ObjectClass *klass,
2728
+ const char *name,
2729
+ const uint8_t *v,
2730
+ ObjectPropertyFlags flags)
2731
{
2732
ObjectPropertyAccessor *getter = NULL;
2733
ObjectPropertyAccessor *setter = NULL;
@@ -2764,9 +2765,10 @@ object_property_add_uint16_ptr(Object *obj, const char *name,
2765
}
2766
2767
ObjectProperty *
2767
-object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
2768
- const uint16_t *v,
2769
- ObjectPropertyFlags flags)
2768
+object_class_static_property_add_uint16_ptr(ObjectClass *klass,
2769
+ const char *name,
2770
+ const uint16_t *v,
2771
+ ObjectPropertyFlags flags)
2772
{
2773
ObjectPropertyAccessor *getter = NULL;
2774
ObjectPropertyAccessor *setter = NULL;
@@ -2804,9 +2806,10 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
2806
}
2807
2808
ObjectProperty *
2807
-object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
2808
- const uint32_t *v,
2809
- ObjectPropertyFlags flags)
2809
+object_class_static_property_add_uint32_ptr(ObjectClass *klass,
2810
+ const char *name,
2811
+ const uint32_t *v,
2812
+ ObjectPropertyFlags flags)
2813
{
2814
ObjectPropertyAccessor *getter = NULL;
2815
ObjectPropertyAccessor *setter = NULL;
@@ -2844,9 +2847,10 @@ object_property_add_uint64_ptr(Object *obj, const char *name,
2847
}
2848
2849
ObjectProperty *
2847
-object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
2848
- const uint64_t *v,
2849
- ObjectPropertyFlags flags)
2850
+object_class_static_property_add_uint64_ptr(ObjectClass *klass,
2851
+ const char *name,
2852
+ const uint64_t *v,
2853
+ ObjectPropertyFlags flags)
2854
{
2855
ObjectPropertyAccessor *getter = NULL;
2856
ObjectPropertyAccessor *setter = NULL;