qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/7] qom: add description field in ObjectProperty st


From: arei.gonglei
Subject: [Qemu-devel] [PATCH 4/7] qom: add description field in ObjectProperty struct
Date: Tue, 23 Sep 2014 21:08:34 +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         | 12 ++++++++++++
 2 files changed, 27 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 81542fb..b889db3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1676,6 +1676,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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]