[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 37/59] object: add object_property_get_defaut()
From: |
Paolo Bonzini |
Subject: |
[PULL 37/59] object: add object_property_get_defaut() |
Date: |
Thu, 23 Jan 2020 14:48:40 +0100 |
From: Marc-André Lureau <address@hidden>
The new callback will be used in following "object: add
object_property_set_defaut_{bool,str,int,uint}()" and "vl: print
default value in object help" patches.
Signed-off-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qom/object.h | 17 +++++++++++++++++
qom/object.c | 9 +++++++++
2 files changed, 26 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 29f47d3..ca47308 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -367,6 +367,13 @@ typedef void (ObjectPropertyRelease)(Object *obj,
*/
typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop);
+/**
+ * ObjectPropertyGetDefault:
+ *
+ * Get an allocated string representation of the default value.
+ */
+typedef char *(ObjectPropertyGetDefault)(ObjectProperty *prop);
+
struct ObjectProperty
{
gchar *name;
@@ -377,6 +384,7 @@ struct ObjectProperty
ObjectPropertyResolve *resolve;
ObjectPropertyRelease *release;
ObjectPropertyInit *init;
+ ObjectPropertyGetDefault *get_default;
void *opaque;
};
@@ -1234,6 +1242,15 @@ void object_property_set_int(Object *obj, int64_t value,
const char *name, Error **errp);
/**
+ * object_property_get_defaut:
+ * @prop: the property to get default value
+ *
+ * Return an allocated string that represents the default property
+ * value or NULL.
+ */
+char *object_property_get_default(ObjectProperty *prop);
+
+/**
* object_property_get_int:
* @obj: the object
* @name: the name of the property
diff --git a/qom/object.c b/qom/object.c
index cd7ce81..49c2429 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1438,6 +1438,15 @@ int64_t object_property_get_int(Object *obj, const char
*name,
return retval;
}
+char *object_property_get_default(ObjectProperty *prop)
+{
+ if (!prop->get_default) {
+ return NULL;
+ }
+
+ return prop->get_default(prop);
+}
+
void object_property_set_uint(Object *obj, uint64_t value,
const char *name, Error **errp)
{
--
1.8.3.1
- [PULL 27/59] qom/object: Display more helpful message when a parent is missing, (continued)
- [PULL 27/59] qom/object: Display more helpful message when a parent is missing, Paolo Bonzini, 2020/01/23
- [PULL 28/59] accel: Introduce the current_accel() wrapper, Paolo Bonzini, 2020/01/23
- [PULL 30/59] accel/tcg: Sanitize include path, Paolo Bonzini, 2020/01/23
- [PULL 29/59] accel: Replace current_machine->accelerator by current_accel() wrapper, Paolo Bonzini, 2020/01/23
- [PULL 31/59] object: add extra sanity checks, Paolo Bonzini, 2020/01/23
- [PULL 32/59] qdev: remove duplicated qdev_property_add_static() doc, Paolo Bonzini, 2020/01/23
- [PULL 33/59] qdev: remove extraneous error, Paolo Bonzini, 2020/01/23
- [PULL 34/59] qdev: move helper function to monitor/misc, Paolo Bonzini, 2020/01/23
- [PULL 35/59] object: avoid extra class property key duplication, Paolo Bonzini, 2020/01/23
- [PULL 36/59] object: add class property initializer, Paolo Bonzini, 2020/01/23
- [PULL 37/59] object: add object_property_get_defaut(),
Paolo Bonzini <=
- [PULL 38/59] object: make object_class_property_add* return property, Paolo Bonzini, 2020/01/23
- [PULL 39/59] qstring: add qstring_free(), Paolo Bonzini, 2020/01/23
- [PULL 40/59] object: add object_property_set_defaut_{bool, str, int, uint}(), Paolo Bonzini, 2020/01/23
- [PULL 41/59] object: do not free class properties, Paolo Bonzini, 2020/01/23
- [PULL 42/59] object: check strong flag with &, Paolo Bonzini, 2020/01/23
- [PULL 43/59] object: rename link "child" to "target", Paolo Bonzini, 2020/01/23
- [PULL 47/59] object: release all props, Paolo Bonzini, 2020/01/23
- [PULL 44/59] object: add direct link flag, Paolo Bonzini, 2020/01/23
- [PULL 45/59] object: express const link with link property, Paolo Bonzini, 2020/01/23
- [PULL 48/59] object: return self in object_ref(), Paolo Bonzini, 2020/01/23