From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
eric.auger@linaro.org, qemu-devel@nongnu.org,
sean.stalley@intel.com, pbonzini@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [PATCH v2 3/9] qom: Expose property helpers for get/set of integers
Date: Wed, 2 Jul 2014 20:01:27 +0200 [thread overview]
Message-ID: <1404324093-19225-4-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1404324093-19225-1-git-send-email-agraf@suse.de>
We have helper functions to easily expose integers as QOM object properties.
However, these are read only.
This patch makes the getter function world accessible and adds a generic
setter for integer properties.
We can use these later with the generic object_property_add to not dupliate
simple logic all over the place.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
include/qom/property.h | 128 +++++++++++++++++++++++++++++++++++++++++++++++++
qom/property.c | 14 +++++-
2 files changed, 140 insertions(+), 2 deletions(-)
diff --git a/include/qom/property.h b/include/qom/property.h
index bb09523..470c722 100644
--- a/include/qom/property.h
+++ b/include/qom/property.h
@@ -63,6 +63,38 @@ void object_property_add_uint8_ptr(Object *obj, const char *name,
const uint8_t *v, Error **errp);
/**
+ * object_property_get_uint8_ptr:
+ * @obj: the object to get the property from
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value we write the result to
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to read an integer value of type 'uint8' into the visitor.
+ * Use this as the 'get' argument in object_property_add if your field is a
+ * uint8_t value.
+ */
+void object_property_get_uint8_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
+ * object_property_set_uint8_ptr:
+ * @obj: the object to set the property in
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to set an integer value of type 'uint8' to a given value.
+ * Use this as the 'set' argument in object_property_add if your field is a
+ * uint8_t value.
+ */
+void object_property_set_uint8_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
* object_property_add_uint16_ptr:
* @obj: the object to add a property to
* @name: the name of the property
@@ -76,6 +108,38 @@ void object_property_add_uint16_ptr(Object *obj, const char *name,
const uint16_t *v, Error **errp);
/**
+ * object_property_get_uint16_ptr:
+ * @obj: the object to get the property from
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value we write the result to
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to read an integer value of type 'uint16' into the visitor.
+ * Use this as the 'get' argument in object_property_add if your field is a
+ * uint16_t value.
+ */
+void object_property_get_uint16_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
+ * object_property_set_uint16_ptr:
+ * @obj: the object to set the property in
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to set an integer value of type 'uint16' to a given value.
+ * Use this as the 'set' argument in object_property_add if your field is a
+ * uint16_t value.
+ */
+void object_property_set_uint16_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
* object_property_add_uint32_ptr:
* @obj: the object to add a property to
* @name: the name of the property
@@ -89,6 +153,38 @@ void object_property_add_uint32_ptr(Object *obj, const char *name,
const uint32_t *v, Error **errp);
/**
+ * object_property_get_uint32_ptr:
+ * @obj: the object to get the property from
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value we write the result to
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to read an integer value of type 'uint32' into the visitor.
+ * Use this as the 'get' argument in object_property_add if your field is a
+ * uint32_t value.
+ */
+void object_property_get_uint32_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
+ * object_property_set_uint32_ptr:
+ * @obj: the object to set the property in
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to set an integer value of type 'uint32' to a given value.
+ * Use this as the 'set' argument in object_property_add if your field is a
+ * uint32_t value.
+ */
+void object_property_set_uint32_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
* object_property_add_uint64_ptr:
* @obj: the object to add a property to
* @name: the name of the property
@@ -101,4 +197,36 @@ void object_property_add_uint32_ptr(Object *obj, const char *name,
void object_property_add_uint64_ptr(Object *obj, const char *name,
const uint64_t *v, Error **Errp);
+/**
+ * object_property_get_uint64_ptr:
+ * @obj: the object to get the property from
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value we write the result to
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to read an integer value of type 'uint64' into the visitor.
+ * Use this as the 'get' argument in object_property_add if your field is a
+ * uint64_t value.
+ */
+void object_property_get_uint64_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
+/**
+ * object_property_set_uint64_ptr:
+ * @obj: the object to set the property in
+ * @v: visitor to the property
+ * @opaque: pointer to the integer value
+ * @name: name of the property
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Visitor function to set an integer value of type 'uint64' to a given value.
+ * Use this as the 'set' argument in object_property_add if your field is a
+ * uint64_t value.
+ */
+void object_property_set_uint64_ptr(Object *obj, struct Visitor *v,
+ void *opaque, const char *name,
+ Error **errp);
+
#endif /* !QEMU_PROPERTY_H */
diff --git a/qom/property.c b/qom/property.c
index 944daff..b4f27e9 100644
--- a/qom/property.c
+++ b/qom/property.c
@@ -153,7 +153,7 @@ void object_property_add_bool(Object *obj, const char *name,
#define DECLARE_PROP_SET_GET(name, valtype) \
\
-static void glue(glue(property_get_,name),_ptr)(Object *obj, Visitor *v, \
+void glue(glue(object_property_get_,name),_ptr)(Object *obj, Visitor *v, \
void *opaque, \
const char *name, \
Error **errp) \
@@ -162,11 +162,21 @@ static void glue(glue(property_get_,name),_ptr)(Object *obj, Visitor *v, \
glue(visit_type_,name)(v, &value, name, errp); \
} \
\
+void glue(glue(object_property_set_,name),_ptr)(Object *obj, Visitor *v, \
+ void *opaque, \
+ const char *name, \
+ Error **errp) \
+{ \
+ valtype value; \
+ glue(visit_type_,name)(v, &value, name, errp); \
+ *(valtype *)opaque = value; \
+} \
+ \
void glue(glue(object_property_add_,name),_ptr)(Object *obj, const char *name, \
const valtype *v, \
Error **errp) \
{ \
- ObjectPropertyAccessor *get = glue(glue(property_get_,name),_ptr); \
+ ObjectPropertyAccessor *get = glue(glue(object_property_get_,name),_ptr); \
object_property_add(obj, name, stringify(name), get, NULL, NULL, (void *)v,\
errp); \
} \
--
1.8.1.4
next prev parent reply other threads:[~2014-07-02 18:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 18:01 [Qemu-devel] [PATCH v2 0/9] Dynamic sysbus device allocation support Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 1/9] qom: Move property helpers to own file Alexander Graf
2014-07-31 13:46 ` Peter Crosthwaite
2014-07-31 14:12 ` Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 2/9] qom: macroify integer property helpers Alexander Graf
2014-07-31 13:44 ` Peter Crosthwaite
2014-07-02 18:01 ` Alexander Graf [this message]
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 4/9] qom: Add generic object property g_free helper Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 5/9] sysbus: Add user map hints Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 6/9] sysbus: Make devices spawnable via -device Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 7/9] PPC: e500: Support dynamically spawned sysbus devices Alexander Graf
2014-07-30 14:55 ` Peter Maydell
2014-07-31 4:07 ` Peter Crosthwaite
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 8/9] e500: Add support for eTSEC in device tree Alexander Graf
2014-07-02 18:01 ` [Qemu-devel] [PATCH v2 9/9] PPC: Fix default config ordering and add eTSEC for ppc64 Alexander Graf
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=1404324093-19225-4-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=afaerber@suse.de \
--cc=eric.auger@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sean.stalley@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).