All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>
Subject: [RFC PATCH-for-5.2 2/5] qom: Split ObjectPropertyAccessor as ObjectProperty[Get/Set]
Date: Wed, 15 Jul 2020 19:58:32 +0200	[thread overview]
Message-ID: <20200715175835.27744-3-philmd@redhat.com> (raw)
In-Reply-To: <20200715175835.27744-1-philmd@redhat.com>

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 --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;
-- 
2.21.3



  parent reply	other threads:[~2020-07-15 18:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 17:58 [RFC PATCH-for-5.2 0/5] qom: Let ObjectPropertyGet functions return a boolean value Philippe Mathieu-Daudé
2020-07-15 17:58 ` [PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region() Philippe Mathieu-Daudé
2020-07-16  8:29   ` Markus Armbruster
2020-07-16  8:38     ` Philippe Mathieu-Daudé
2020-07-16  9:36       ` Markus Armbruster
2020-07-15 17:58 ` Philippe Mathieu-Daudé [this message]
2020-07-15 17:58 ` [PATCH-for-5.2 3/5] qom: Use g_autofree in ObjectPropertyGet functions Philippe Mathieu-Daudé
2020-07-15 17:58 ` [RFC PATCH-for-5.2 4/5] qom: Let ObjectPropertyGet functions return a boolean value Philippe Mathieu-Daudé
2020-07-16  9:07   ` Markus Armbruster
2020-09-07 14:26     ` Markus Armbruster
2020-09-07 14:36       ` Peter Maydell
2020-09-07 14:36       ` Philippe Mathieu-Daudé
2020-07-15 17:58 ` [RFC PATCH-for-5.2 5/5] hw/virtio: Simplify virtio_mem_set_requested_size() Philippe Mathieu-Daudé
2020-07-16  9:14   ` Markus Armbruster
2020-07-16  8:25 ` [RFC PATCH-for-5.2 0/5] qom: Let ObjectPropertyGet functions return a boolean value Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200715175835.27744-3-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.