فهرست منبع

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
iamyhw@gmail.com 13 سال پیش
والد
کامیت
961a6a51c9
2فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 2 2
      components/rtgui/common/rtgui_object.c
  2. 2 2
      components/rtgui/include/rtgui/rtgui_object.h

+ 2 - 2
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;

+ 2 - 2
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