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
This commit is contained in:
iamyhw@gmail.com 2012-07-09 02:53:40 +00:00
parent 7729b4a1e4
commit 961a6a51c9
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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