@@ -535,6 +535,14 @@ Type type_register_static(const TypeInfo *info);
Type type_register(const TypeInfo *info);
/**
+ * type_get_by_name:
+ * @name: The name of the type
+ *
+ * Returns: The #Type with that name if it exists, else NULL.
+ */
+Type type_get_by_name(const char *name);
+
+/**
* object_class_dynamic_cast_assert:
* @klass: The #ObjectClass to attempt to cast.
* @typename: The QOM typename of the class to cast to.
@@ -140,7 +140,7 @@ TypeImpl *type_register_static(const TypeInfo *info)
return type_register(info);
}
-static TypeImpl *type_get_by_name(const char *name)
+TypeImpl *type_get_by_name(const char *name)
{
if (name == NULL) {
return NULL;
Following the type_register() precedence, the definition returns "TypeImpl *", while the declaration returns "Type". Fine, because the latter is actually a typedef for the former. For the record, I don't think this typedef'ing away the "*" is a good idea. It only complicates matters. When I see TypeImpl *type_get_by_name(const char *name) it's immediately obvious that the value has pointer semantics, and a null pointer must be the error value. Moreover, it's unusual in QEMU code. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- include/qemu/object.h | 8 ++++++++ qom/object.c | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-)