[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 4/7] qom: add description field in ObjectProperty
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v3 4/7] qom: add description field in ObjectProperty struct |
Date: |
Sat, 27 Sep 2014 13:13:58 +0800 |
From: Gonglei <address@hidden>
The descriptions can serve as documentation in the code,
and they can be used to provide better help.
Cc: Paolo Bonzini <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Cc: Markus Armbruster <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
include/qom/object.h | 15 +++++++++++++++
qom/object.c | 14 ++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 8a05a81..ddc600d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -338,6 +338,7 @@ typedef struct ObjectProperty
{
gchar *name;
gchar *type;
+ gchar *description;
ObjectPropertyAccessor *get;
ObjectPropertyAccessor *set;
ObjectPropertyResolve *resolve;
@@ -1274,6 +1275,20 @@ void object_property_add_alias(Object *obj, const char
*name,
Object *target_obj, const char *target_name,
Error **errp);
+
+/**
+ * object_property_set_description:
+ * @obj: the object to set a property's description to
+ * @name: the name of the property
+ * @description: the description of the property on the object
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Set an object property's description.
+ *
+ */
+void object_property_set_description(Object *obj, const char *name,
+ const char *description, Error **errp);
+
/**
* object_child_foreach:
* @obj: the object whose children will be navigated
diff --git a/qom/object.c b/qom/object.c
index 575291f..c9b67cf 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -369,6 +369,7 @@ static void object_property_del_all(Object *obj)
g_free(prop->name);
g_free(prop->type);
+ g_free(prop->description);
g_free(prop);
}
}
@@ -803,6 +804,7 @@ void object_property_del(Object *obj, const char *name,
Error **errp)
g_free(prop->name);
g_free(prop->type);
+ g_free(prop->description);
g_free(prop);
}
@@ -1676,6 +1678,18 @@ out:
g_free(prop_type);
}
+void object_property_set_description(Object *obj, const char *name,
+ const char *description, Error **errp)
+{
+ ObjectProperty *op;
+
+ op = object_property_find(obj, name, errp);
+ if (!op) {
+ return;
+ }
+ op->description = description ? g_strdup(description) : NULL;
+}
+
static void object_instance_init(Object *obj)
{
object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
--
1.7.12.4
- [Qemu-devel] [PATCH v3 0/7] add description field in ObjectProperty and PropertyInfo struct, arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 6/7] qmp: print descriptions of object properties, arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 2/7] qom: add error handler for object alias property, arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 7/7] qdev: drop legacy_name from qdev properties, arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 5/7] qdev: set the object property's description to the qdev property's., arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 4/7] qom: add description field in ObjectProperty struct,
arei.gonglei <=
- [Qemu-devel] [PATCH v3 3/7] qdev: add description field in PropertyInfo struct, arei.gonglei, 2014/09/27
- [Qemu-devel] [PATCH v3 1/7] qom: add error handler for object_property_print(), arei.gonglei, 2014/09/27
- Re: [Qemu-devel] [PATCH v3 0/7] add description field in ObjectProperty and PropertyInfo struct, Andreas Färber, 2014/09/29