summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-03 11:48:11 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-02-07 10:20:12 +0100
commit1ed5b918ceda9a92dd00a2d432aa431bea2da66a (patch)
tree4f92ed4750d942cf33d8105f176f65e11b3e603e /include
parentc9344f2220ec9878493af5a39b7f0f337e58123a (diff)
downloadqemu-1ed5b918ceda9a92dd00a2d432aa431bea2da66a.tar.gz
qemu-1ed5b918ceda9a92dd00a2d432aa431bea2da66a.tar.bz2
qemu-1ed5b918ceda9a92dd00a2d432aa431bea2da66a.zip
qom: clean up cast macros
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/object.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/include/qemu/object.h b/include/qemu/object.h
index 9d0251d56a..ab1c48ca3c 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -259,6 +259,16 @@ struct TypeInfo
((Object *)(obj))
/**
+ * OBJECT_CLASS:
+ * @class: A derivative of #ObjectClas.
+ *
+ * Converts a class to an #ObjectClass. Since all objects are #Objects,
+ * this function will always succeed.
+ */
+#define OBJECT_CLASS(class) \
+ ((ObjectClass *)(class))
+
+/**
* OBJECT_CHECK:
* @type: The C type to use for the return value.
* @obj: A derivative of @type to cast.
@@ -272,7 +282,7 @@ struct TypeInfo
* generated.
*/
#define OBJECT_CHECK(type, obj, name) \
- ((type *)object_dynamic_cast_assert((Object *)(obj), (name)))
+ ((type *)object_dynamic_cast_assert(OBJECT(obj), (name)))
/**
* OBJECT_CLASS_CHECK:
@@ -280,11 +290,12 @@ struct TypeInfo
* @obj: A derivative of @type to cast.
* @name: the QOM typename of @class.
*
- * A type safe version of @object_check_class. This macro is typically wrapped
- * by each type to perform type safe casts of a class to a specific class type.
+ * A type safe version of @object_class_dynamic_cast_assert. This macro is
+ * typically wrapped by each type to perform type safe casts of a class to a
+ * specific class type.
*/
#define OBJECT_CLASS_CHECK(class, obj, name) \
- ((class *)object_class_dynamic_cast_assert((ObjectClass *)(obj), (name)))
+ ((class *)object_class_dynamic_cast_assert(OBJECT_CLASS(obj), (name)))
/**
* OBJECT_GET_CLASS:
@@ -299,9 +310,6 @@ struct TypeInfo
#define OBJECT_GET_CLASS(class, obj, name) \
OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name)
-#define OBJECT_CLASS(class) \
- ((ObjectClass *)(class))
-
/**
* InterfaceClass:
* @parent_class: the base class