From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEyH-0006Qr-0N for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:10:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeEy3-0004wb-KC for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:52 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49378 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEy3-0004w8-8b for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:39 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 15 Oct 2014 05:09:18 +0200 Message-Id: <1413342561-4754-45-git-send-email-afaerber@suse.de> In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de> References: <1413342561-4754-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 44/47] qom: Add description field in ObjectProperty struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei , Markus Armbruster , Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Gonglei The descriptions can serve as documentation in the code, and they can be used to provide better help. Copy property descriptions when copying alias properties. Cc: Markus Armbruster Signed-off-by: Gonglei Reviewed-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Andreas F=C3=A4rber --- include/qom/object.h | 14 ++++++++++++++ qom/object.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 8a05a81..89c3092 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; @@ -1275,6 +1276,19 @@ void object_property_add_alias(Object *obj, const = char *name, Error **errp); =20 /** + * object_property_set_description: + * @obj: the object owning the property + * @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 **er= rp); + +/** * object_child_foreach: * @obj: the object whose children will be navigated * @fn: the iterator function to be called diff --git a/qom/object.c b/qom/object.c index 575291f..a751367 100644 --- a/qom/object.c +++ b/qom/object.c @@ -369,6 +369,7 @@ static void object_property_del_all(Object *obj) =20 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 *nam= e, Error **errp) =20 g_free(prop->name); g_free(prop->type); + g_free(prop->description); g_free(prop); } =20 @@ -1672,10 +1674,28 @@ void object_property_add_alias(Object *obj, const= char *name, } op->resolve =3D property_resolve_alias; =20 + object_property_set_description(obj, name, + target_prop->description, + &error_abort); + out: g_free(prop_type); } =20 +void object_property_set_description(Object *obj, const char *name, + const char *description, Error **er= rp) +{ + ObjectProperty *op; + + op =3D object_property_find(obj, name, errp); + if (!op) { + return; + } + + g_free(op->description); + op->description =3D g_strdup(description); +} + static void object_instance_init(Object *obj) { object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); --=20 1.8.4.5