From: Paolo Bonzini Date: Wed, 2 May 2012 11:30:54 +0000 (+0200) Subject: qom: Add object_class_get_parent() X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~3991^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7cce67f27bce49d8b6d09f4e66059d1fd117ebb;p=sdk%2Femulator%2Fqemu.git qom: Add object_class_get_parent() This simple bit of functionality was missing and we'll need it soon, so add it. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori [AF: Document possible NULL return value] Signed-off-by: Andreas Färber --- diff --git a/include/qemu/object.h b/include/qemu/object.h index d93b772..487559c 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -548,6 +548,14 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, const char *typename); /** + * object_class_get_parent: + * @klass: The class to obtain the parent for. + * + * Returns: The parent for @klass or %NULL if none. + */ +ObjectClass *object_class_get_parent(ObjectClass *klass); + +/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * diff --git a/qom/object.c b/qom/object.c index 6f839ad..9582230 100644 --- a/qom/object.c +++ b/qom/object.c @@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename) return type->class; } +ObjectClass *object_class_get_parent(ObjectClass *class) +{ + TypeImpl *type = type_get_parent(class->type); + + if (!type) { + return NULL; + } + + type_initialize(type); + + return type->class; +} + typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque);