mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 09:02:00 -06:00
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 <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> [AF: Document possible NULL return value] Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
eb2aeacf98
commit
e7cce67f27
2 changed files with 21 additions and 0 deletions
|
@ -547,6 +547,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *klass,
|
||||||
ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
|
ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
|
||||||
const char *typename);
|
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:
|
* object_class_get_name:
|
||||||
* @klass: The class to obtain the QOM typename for.
|
* @klass: The class to obtain the QOM typename for.
|
||||||
|
|
13
qom/object.c
13
qom/object.c
|
@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename)
|
||||||
return type->class;
|
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
|
typedef struct OCFData
|
||||||
{
|
{
|
||||||
void (*fn)(ObjectClass *klass, void *opaque);
|
void (*fn)(ObjectClass *klass, void *opaque);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue