[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/26] object: add object_property_get_defaut()
From: |
Marc-André Lureau |
Subject: |
[PATCH 07/26] object: add object_property_get_defaut() |
Date: |
Sun, 1 Dec 2019 15:15:12 +0400 |
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>
---
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 e15ebd486b..8d442cf633 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -361,6 +361,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;
@@ -371,6 +378,7 @@ struct ObjectProperty
ObjectPropertyResolve *resolve;
ObjectPropertyRelease *release;
ObjectPropertyInit *init;
+ ObjectPropertyGetDefault *get_default;
void *opaque;
};
@@ -1214,6 +1222,15 @@ bool object_property_get_bool(Object *obj, const char
*name,
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
diff --git a/qom/object.c b/qom/object.c
index 4b9f8d8668..844a2d66bf 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1405,6 +1405,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)
{
--
2.24.0
- [PATCH 01/26] object: add extra sanity checks, (continued)
- [PATCH 01/26] object: add extra sanity checks, Marc-André Lureau, 2019/12/01
- [PATCH 02/26] qdev: remove duplicated qdev_property_add_static() doc, Marc-André Lureau, 2019/12/01
- [PATCH 03/26] qdev: remove extraneous error, Marc-André Lureau, 2019/12/01
- [PATCH 04/26] qdev: move helper function to monitor/misc, Marc-André Lureau, 2019/12/01
- [PATCH 05/26] object: avoid extra class property key duplication, Marc-André Lureau, 2019/12/01
- [PATCH 06/26] object: add class property initializer, Marc-André Lureau, 2019/12/01
- [PATCH 07/26] object: add object_property_get_defaut(),
Marc-André Lureau <=
- [PATCH 08/26] object: make object_class_property_add* return property, Marc-André Lureau, 2019/12/01
- [PATCH 09/26] qstring: add qstring_free(), Marc-André Lureau, 2019/12/01
- [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}(), Marc-André Lureau, 2019/12/01
- [PATCH 11/26] object: do not free class properties, Marc-André Lureau, 2019/12/01
- [PATCH 12/26] object: check strong flag with &, Marc-André Lureau, 2019/12/01
- [PATCH 13/26] object: rename link "child" to "target", Marc-André Lureau, 2019/12/01
- [PATCH 14/26] object: add direct link flag, Marc-André Lureau, 2019/12/01
- [PATCH 15/26] object: express const link with link property, Marc-André Lureau, 2019/12/01
- [PATCH 16/26] object: add object_class_property_add_link(), Marc-André Lureau, 2019/12/01
- [PATCH 17/26] object: release all props, Marc-André Lureau, 2019/12/01