From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoVyS-0002CT-Av for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:39:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoVyQ-0001y6-KE for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:39:11 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:50636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoVyQ-0001xw-An for qemu-devel@nongnu.org; Tue, 10 Jul 2012 04:39:10 -0400 Received: by pbbro12 with SMTP id ro12so22241816pbb.4 for ; Tue, 10 Jul 2012 01:39:08 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FFBEA25.6060705@redhat.com> Date: Tue, 10 Jul 2012 10:39:01 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1341900967-4344-1-git-send-email-qemulist@gmail.com> <1341900967-4344-3-git-send-email-qemulist@gmail.com> In-Reply-To: <1341900967-4344-3-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/5] qom: introduce object_is_type_str(), so we can judge its type. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Blue Swirl , Jan Kiszka , qemu-devel@nongnu.org, Anthony Liguori , =?ISO-8859-15?Q?Andreas_F=E4rber?= Il 10/07/2012 08:16, Liu Ping Fan ha scritto: > Signed-off-by: Liu Ping Fan > --- > include/qemu/object.h | 2 ++ > qom/object.c | 6 ++++++ > 2 files changed, 8 insertions(+), 0 deletions(-) > > diff --git a/include/qemu/object.h b/include/qemu/object.h > index 8b17776..a66e996 100644 > --- a/include/qemu/object.h > +++ b/include/qemu/object.h > @@ -479,6 +479,8 @@ void object_initialize(void *obj, const char *typename); > */ > void object_finalize(void *obj); > > +bool object_is_type_str(Object *obj, const char *typename); Please call this object_is_instance_of, and just call object_dynamic_cast internally so that interfaces are handled properly. Paolo > + > /** > * object_dynamic_cast: > * @obj: The object to cast. > diff --git a/qom/object.c b/qom/object.c > index 00bb3b0..6c27d90 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -425,6 +425,12 @@ static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type) > return false; > } > > +bool object_is_type_str(Object *obj, const char *typename) > +{ > + TypeImpl *target_type = type_get_by_name(typename); > + return !target_type || type_is_ancestor(obj->class->type, target_type); > +} > + > static bool object_is_type(Object *obj, TypeImpl *target_type) > { > return !target_type || type_is_ancestor(obj->class->type, target_type); >