@@ -475,8 +475,11 @@ struct TypeInfo
* If an invalid object is passed to this function, a run time assert will be
* generated.
*/
+#define TYPE_GET_BY_NAME(name) \
+ ({ static Type _type; \
+ if (!__builtin_constant_p(name)) { \
+ extern void do_not_use_TYPE_GET_BY_NAME(void); \
+ do_not_use_TYPE_GET_B_NAME(); \
+ } \
+ _type ?: (_type = type_get_by_name(name)); })
+
#define OBJECT_CHECK(type, obj, name) \
- ((type *)object_dynamic_cast_assert(OBJECT(obj), (name)))
+ ((type *)object_dynamic_cast_with_type_assert(OBJECT(obj), \
+ __builtin_constant_p((name)) ? TYPE_GET_BY_NAME(name) \
+ : type_get_by_name(name)))
/**
* OBJECT_CLASS_CHECK: