From 961a6a51c99924ecc3cf59d40aad4dc1c048a9f5 Mon Sep 17 00:00:00 2001 From: "iamyhw@gmail.com" Date: Mon, 9 Jul 2012 02:53:40 +0000 Subject: [PATCH] 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 --- components/rtgui/common/rtgui_object.c | 4 ++-- components/rtgui/include/rtgui/rtgui_object.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/rtgui/common/rtgui_object.c b/components/rtgui/common/rtgui_object.c index 1ee7c1cb10..95a7c4e17e 100644 --- a/components/rtgui/common/rtgui_object.c +++ b/components/rtgui/common/rtgui_object.c @@ -155,13 +155,13 @@ void rtgui_object_destroy(rtgui_object_t *object) * @return Returns the object * @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 (!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; diff --git a/components/rtgui/include/rtgui/rtgui_object.h b/components/rtgui/include/rtgui/rtgui_object.h index 84d163192e..eb9c005c30 100644 --- a/components/rtgui/include/rtgui/rtgui_object.h +++ b/components/rtgui/include/rtgui/rtgui_object.h @@ -74,7 +74,7 @@ const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object); #ifdef RTGUI_USING_CAST_CHECK #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 #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj)) #endif @@ -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); 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); #ifdef __cplusplus