提交 961a6a51 编写于 作者: I iamyhw@gmail.com

Display the function name and the line Numbers, when detect widget type.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2210 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 7729b4a1
...@@ -155,13 +155,13 @@ void rtgui_object_destroy(rtgui_object_t *object) ...@@ -155,13 +155,13 @@ void rtgui_object_destroy(rtgui_object_t *object)
* @return Returns the object * @return Returns the object
* @note You usually do not need to call this function, use specific macros instead (ETK_IS_WIDGET() for example) * @note You usually do not need to call this function, use specific macros instead (ETK_IS_WIDGET() for example)
*/ */
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_type) rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_type, const char* func, int line)
{ {
if (!obj) return RT_NULL; if (!obj) return RT_NULL;
if (!rtgui_type_inherits_from(obj->type, obj_type)) if (!rtgui_type_inherits_from(obj->type, obj_type))
{ {
rt_kprintf("Invalid cast from \"%s\" to \"%s\"\n", rtgui_type_name_get(obj->type), rtgui_type_name_get(obj_type)); rt_kprintf("%s[%d]: Invalid cast from \"%s\" to \"%s\"\n", func, line, rtgui_type_name_get(obj->type), rtgui_type_name_get(obj_type));
} }
return obj; return obj;
......
...@@ -74,7 +74,7 @@ const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object); ...@@ -74,7 +74,7 @@ const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object);
#ifdef RTGUI_USING_CAST_CHECK #ifdef RTGUI_USING_CAST_CHECK
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \ #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type))) ((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type), __FUNCTION__, __LINE__))
#else #else
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj)) #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj))
#endif #endif
...@@ -128,7 +128,7 @@ rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_e ...@@ -128,7 +128,7 @@ rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_e
void rtgui_object_name_set(rtgui_object_t *object, const char *name); void rtgui_object_name_set(rtgui_object_t *object, const char *name);
const char *rtgui_object_name_get(rtgui_object_t *object); const char *rtgui_object_name_get(rtgui_object_t *object);
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type); rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type, const char* func, int line);
rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object); rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object);
#ifdef __cplusplus #ifdef __cplusplus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册