[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH target-arm v4 02/12] qom: Add object_property_add_bo
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH target-arm v4 02/12] qom: Add object_property_add_bool_ptr() |
Date: |
Tue, 10 Dec 2013 18:54:07 -0800 |
Integers have an API to add a property via a pointer to storage -
object_property_add_uintXX_ptr(). This is convenient for defining
dynamic properties without having to define local setters and getters.
This patch does the same for the boolean type - object can now easily
define boolean properties with the trivial setters and getters.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
include/qom/object.h | 13 +++++++++++++
qom/object.c | 24 ++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index a275db2..c68aba3 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1113,6 +1113,19 @@ void object_property_add_bool(Object *obj, const char
*name,
Error **errp);
/**
+ * object_property_add_bool_ptr:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @v: pointer to value
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add a bool property in memory. This function will add a
+ * property of type 'bool'.
+ */
+void object_property_add_bool_ptr(Object *obj, const char *name,
+ const bool *v, Error **errp);
+
+/**
* object_property_add_uint8_ptr:
* @obj: the object to add a property to
* @name: the name of the property
diff --git a/qom/object.c b/qom/object.c
index 07b454b..6c9cef9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1345,6 +1345,23 @@ static char *qdev_get_type(Object *obj, Error **errp)
return g_strdup(object_get_typename(obj));
}
+static void property_get_bool_ptr(Object *obj, Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
+{
+ bool value = *(bool *)opaque;
+ visit_type_bool(v, &value, name, errp);
+}
+
+static void property_set_bool_ptr(Object *obj, Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
+{
+ bool value;
+ visit_type_bool(v, &value, name, errp);
+ *(bool *)opaque = value;
+}
+
static void property_get_uint8_ptr(Object *obj, Visitor *v,
void *opaque, const char *name,
Error **errp)
@@ -1413,6 +1430,13 @@ static void property_set_uint64_ptr(Object *obj, Visitor
*v,
*(uint64_t *)opaque = value;
}
+void object_property_add_bool_ptr(Object *obj, const char *name,
+ const bool *v, Error **errp)
+{
+ object_property_add(obj, name, "bool", property_get_bool_ptr,
+ property_set_bool_ptr, NULL, (void *)v, errp);
+}
+
void object_property_add_uint8_ptr(Object *obj, const char *name,
const uint8_t *v, Error **errp)
{
--
1.8.5.1
- [Qemu-devel] [PATCH target-arm v4 00/12] Fix Support for ARM CBAR and reset-hivecs, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 01/12] qom: Make uintXX added properties writable, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 02/12] qom: Add object_property_add_bool_ptr(),
Peter Crosthwaite <=
- [Qemu-devel] [PATCH target-arm v4 03/12] target-arm/helper.c: Allow cp15.c15 dummy override, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 04/12] target-arm: Define and use ARM_FEATURE_CBAR, Peter Crosthwaite, 2013/12/10
- Re: [Qemu-devel] [PATCH target-arm v4 00/12] Fix Support for ARM CBAR and reset-hivecs, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 05/12] target-arm/cpu: Convert reset CBAR to a property, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 06/12] arm/highbank: Use object_new() rather than cpu_arm_init(), Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 07/12] arm/highbank: Fix CBAR initialisation, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 08/12] arm/xilinx_zynq: Use object_new() rather than cpu_arm_init(), Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 09/12] arm/xilinx_zynq: Implement CBAR initialisation, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 10/12] arm/highbank.c: Fix MPCore periphbase name, Peter Crosthwaite, 2013/12/10
- [Qemu-devel] [PATCH target-arm v4 11/12] ARM: cpu: add "reset_hivecs" property, Peter Crosthwaite, 2013/12/10