diff mbox series

[RFC,PATCH-for-5.2,2/5] qom: Split ObjectPropertyAccessor as ObjectProperty[Get/Set]

Message ID 20200715175835.27744-3-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series qom: Let ObjectPropertyGet functions return a boolean value | expand

Commit Message

Philippe Mathieu-Daudé July 15, 2020, 5:58 p.m. UTC
To make refactors easier, split the common ObjectPropertyAccessor
type definition into ObjectPropertyGet() and ObjectPropertySet().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/hw/qdev-core.h |  4 ++--
 include/qom/object.h   | 48 ++++++++++++++++++++++++++++--------------
 hw/ppc/spapr_caps.c    |  4 ++--
 qom/object.c           | 44 +++++++++++++++++++-------------------
 4 files changed, 58 insertions(+), 42 deletions(-)
diff mbox series

Patch

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index fe78073c70..e2930beab8 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -287,8 +287,8 @@  struct PropertyInfo {
     int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
     void (*set_default_value)(ObjectProperty *op, const Property *prop);
     void (*create)(ObjectClass *oc, Property *prop);
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
+    ObjectPropertyGet *get;
+    ObjectPropertySet *set;
     ObjectPropertyRelease *release;
 };
 
diff --git a/include/qom/object.h b/include/qom/object.h
index 79c8f838b6..e9496ba970 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -310,20 +310,36 @@  typedef struct InterfaceInfo InterfaceInfo;
 typedef struct ObjectProperty ObjectProperty;
 
 /**
- * ObjectPropertyAccessor:
+ * ObjectPropertySet:
  * @obj: the object that owns the property
  * @v: the visitor that contains the property data
  * @name: the name of the property
  * @opaque: the object property opaque
- * @errp: a pointer to an Error that is filled if getting/setting fails.
+ * @errp: a pointer to an Error that is filled if setting fails.
  *
- * Called when trying to get/set a property.
+ * Called when trying to set a property.
  */
-typedef void (ObjectPropertyAccessor)(Object *obj,
-                                      Visitor *v,
-                                      const char *name,
-                                      void *opaque,
-                                      Error **errp);
+typedef void (ObjectPropertySet)(Object *obj,
+                                 Visitor *v,
+                                 const char *name,
+                                 void *opaque,
+                                 Error **errp);
+
+/**
+ * ObjectPropertyGet:
+ * @obj: the object that owns the property
+ * @v: the visitor that contains the property data
+ * @name: the name of the property
+ * @opaque: the object property opaque
+ * @errp: a pointer to an Error that is filled if getting fails.
+ *
+ * Called when trying to get a property.
+ */
+typedef void (ObjectPropertyGet)(Object *obj,
+                                 Visitor *v,
+                                 const char *name,
+                                 void *opaque,
+                                 Error **errp);
 
 /**
  * ObjectPropertyResolve:
@@ -370,8 +386,8 @@  struct ObjectProperty
     char *name;
     char *type;
     char *description;
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
+    ObjectPropertyGet *get;
+    ObjectPropertySet *set;
     ObjectPropertyResolve *resolve;
     ObjectPropertyRelease *release;
     ObjectPropertyInit *init;
@@ -1071,8 +1087,8 @@  void object_unref(Object *obj);
  */
 ObjectProperty *object_property_try_add(Object *obj, const char *name,
                                         const char *type,
-                                        ObjectPropertyAccessor *get,
-                                        ObjectPropertyAccessor *set,
+                                        ObjectPropertyGet *get,
+                                        ObjectPropertySet *set,
                                         ObjectPropertyRelease *release,
                                         void *opaque, Error **errp);
 
@@ -1083,8 +1099,8 @@  ObjectProperty *object_property_try_add(Object *obj, const char *name,
  */
 ObjectProperty *object_property_add(Object *obj, const char *name,
                                     const char *type,
-                                    ObjectPropertyAccessor *get,
-                                    ObjectPropertyAccessor *set,
+                                    ObjectPropertyGet *get,
+                                    ObjectPropertySet *set,
                                     ObjectPropertyRelease *release,
                                     void *opaque);
 
@@ -1092,8 +1108,8 @@  void object_property_del(Object *obj, const char *name);
 
 ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,
                                           const char *type,
-                                          ObjectPropertyAccessor *get,
-                                          ObjectPropertyAccessor *set,
+                                          ObjectPropertyGet *get,
+                                          ObjectPropertySet *set,
                                           ObjectPropertyRelease *release,
                                           void *opaque);
 
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 3225fc5a2e..7558db0c8b 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -58,8 +58,8 @@  typedef struct SpaprCapabilityInfo {
     int index;
 
     /* Getter and Setter Function Pointers */
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
+    ObjectPropertyGet *get;
+    ObjectPropertySet *set;
     const char *type;
     /* Possible values if this is a custom string type */
     SpaprCapPossible *possible;
diff --git a/qom/object.c b/qom/object.c
index 76f5f75239..e5324f2af7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1148,8 +1148,8 @@  void object_unref(Object *obj)
 
 ObjectProperty *
 object_property_try_add(Object *obj, const char *name, const char *type,
-                        ObjectPropertyAccessor *get,
-                        ObjectPropertyAccessor *set,
+                        ObjectPropertyGet *get,
+                        ObjectPropertySet *set,
                         ObjectPropertyRelease *release,
                         void *opaque, Error **errp)
 {
@@ -1198,8 +1198,8 @@  object_property_try_add(Object *obj, const char *name, const char *type,
 
 ObjectProperty *
 object_property_add(Object *obj, const char *name, const char *type,
-                    ObjectPropertyAccessor *get,
-                    ObjectPropertyAccessor *set,
+                    ObjectPropertyGet *get,
+                    ObjectPropertySet *set,
                     ObjectPropertyRelease *release,
                     void *opaque)
 {
@@ -1211,8 +1211,8 @@  ObjectProperty *
 object_class_property_add(ObjectClass *klass,
                           const char *name,
                           const char *type,
-                          ObjectPropertyAccessor *get,
-                          ObjectPropertyAccessor *set,
+                          ObjectPropertyGet *get,
+                          ObjectPropertySet *set,
                           ObjectPropertyRelease *release,
                           void *opaque)
 {
@@ -2486,8 +2486,8 @@  object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
                               ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint8_ptr;
@@ -2506,8 +2506,8 @@  object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
                                     const uint8_t *v,
                                     ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint8_ptr;
@@ -2526,8 +2526,8 @@  object_property_add_uint16_ptr(Object *obj, const char *name,
                                const uint16_t *v,
                                ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint16_ptr;
@@ -2546,8 +2546,8 @@  object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
                                      const uint16_t *v,
                                      ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint16_ptr;
@@ -2566,8 +2566,8 @@  object_property_add_uint32_ptr(Object *obj, const char *name,
                                const uint32_t *v,
                                ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint32_ptr;
@@ -2586,8 +2586,8 @@  object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
                                      const uint32_t *v,
                                      ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint32_ptr;
@@ -2606,8 +2606,8 @@  object_property_add_uint64_ptr(Object *obj, const char *name,
                                const uint64_t *v,
                                ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint64_ptr;
@@ -2626,8 +2626,8 @@  object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
                                      const uint64_t *v,
                                      ObjectPropertyFlags flags)
 {
-    ObjectPropertyAccessor *getter = NULL;
-    ObjectPropertyAccessor *setter = NULL;
+    ObjectPropertyGet *getter = NULL;
+    ObjectPropertySet *setter = NULL;
 
     if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
         getter = property_get_uint64_ptr;