From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6B7k-0002fT-VZ for qemu-devel@nongnu.org; Fri, 09 Mar 2012 20:29:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6B7i-0000gE-P3 for qemu-devel@nongnu.org; Fri, 09 Mar 2012 20:29:32 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38663 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6B7i-0000g5-Et for qemu-devel@nongnu.org; Fri, 09 Mar 2012 20:29:30 -0500 Message-ID: <4F5AAE77.4040706@suse.de> Date: Sat, 10 Mar 2012 02:29:27 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1330207654-25841-1-git-send-email-afaerber@suse.de> <4F57369F.5020808@suse.de> In-Reply-To: <4F57369F.5020808@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] qom: Introduce object_class_get_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paolo Bonzini , Jan Kiszka , qemu-devel@nongnu.org Am 07.03.2012 11:21, schrieb Andreas F=C3=A4rber: > Am 25.02.2012 23:07, schrieb Andreas F=C3=A4rber: >> This function allows to obtain a singly-linked list of classes, which >> can be sorted by the caller. >> >> Signed-off-by: Andreas F=C3=A4rber >> Cc: Anthony Liguori >=20 > Ping? You requested me to do it via GSList instead of GTree, and the > qom-cpu branch has been successfully rebased onto it. Ping^2! Anthony, is this in your queue or do you want a PULL? Andreas >> --- >> v1 -> v2: >> * Instead of [object_class_foreach_ordered()] using a GCompareFunc wi= th a GTree internally, >> return a GSList so that the caller can sort herself (suggested by A= nthony). >> * Add documentation. >> >> include/qemu/object.h | 11 +++++++++++ >> qom/object.c | 17 +++++++++++++++++ >> 2 files changed, 28 insertions(+), 0 deletions(-) >> >> diff --git a/include/qemu/object.h b/include/qemu/object.h >> index 69e4b7b..ddc3b81 100644 >> --- a/include/qemu/object.h >> +++ b/include/qemu/object.h >> @@ -560,6 +560,17 @@ ObjectClass *object_class_by_name(const char *typ= ename); >> void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque= ), >> const char *implements_type, bool include_a= bstract, >> void *opaque); >> + >> +/** >> + * object_class_get_list: >> + * @implements_type: The type to filter for, including its derivative= s. >> + * @include_abstract: Whether to include abstract classes. >> + * >> + * Returns: A singly-linked list of the classes in reverse hashtable = order. >> + */ >> +GSList *object_class_get_list(const char *implements_type, >> + bool include_abstract); >> + >> /** >> * object_ref: >> * @obj: the object >> diff --git a/qom/object.c b/qom/object.c >> index aa037d2..eef0b22 100644 >> --- a/qom/object.c >> +++ b/qom/object.c >> @@ -572,6 +572,23 @@ void object_class_foreach(void (*fn)(ObjectClass = *klass, void *opaque), >> g_hash_table_foreach(type_table_get(), object_class_foreach_tramp= , &data); >> } >> =20 >> +static void object_class_get_list_tramp(ObjectClass *klass, void *opa= que) >> +{ >> + GSList **list =3D opaque; >> + >> + *list =3D g_slist_prepend(*list, klass); >> +} >> + >> +GSList *object_class_get_list(const char *implements_type, >> + bool include_abstract) >> +{ >> + GSList *list =3D NULL; >> + >> + object_class_foreach(object_class_get_list_tramp, >> + implements_type, include_abstract, &list); >> + return list; >> +} >> + >> void object_ref(Object *obj) >> { >> obj->ref++; >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg