Parcourir la source

fix some compiling warning, errors in the new object system.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1425 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong il y a 14 ans
Parent
commit
a876302695

+ 20 - 14
components/rtgui/common/rtgui_object.c

@@ -34,7 +34,7 @@ DEFINE_CLASS_TYPE(type, "object",
 	_rtgui_object_destructor,
 	sizeof(struct rtgui_object));
 
-void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object)
+void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object)
 {
 	/* first call parent's type */
 	if (type->parent != RT_NULL)
@@ -43,32 +43,38 @@ void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object)
 	if (type->constructor) type->constructor(object);
 }
 
-void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object)
-{
-	while (type)
+void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object)
+{
+	const rtgui_type_t *t;
+	
+	t = type;
+	while (t)
 	{
-		if (type->destructor) type->destructor(object);
-		type = type->parent;
+		if (t->destructor) t->destructor(object);
+		t = t->parent;
 	}
 }
 
-rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent)
-{
-	while (type)
+rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent)
+{
+	const rtgui_type_t *t;
+	
+	t = type;
+	while (t)
 	{
-		if (type == parent) return RT_TRUE;
-		type = type->parent;
+		if (t == parent) return RT_TRUE;
+		t = t->parent;
 	}
 
 	return RT_FALSE;
 }
 
-rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type)
+const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type)
 {
 	return type->parent;
 }
 
-const char *rtgui_type_name_get(rtgui_type_t *type)
+const char *rtgui_type_name_get(const rtgui_type_t *type)
 {
 	if (!type) return RT_NULL;
 
@@ -165,7 +171,7 @@ rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_t
  * @param object an object
  * @return Returns the type of @a object (RT_NULL on failure)
  */
-rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object)
+const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object)
 {
 	if (!object) return RT_NULL;
 

+ 8 - 8
components/rtgui/include/rtgui/rtgui_object.h

@@ -60,16 +60,16 @@ typedef struct rtgui_type rtgui_type_t;
 	const struct rtgui_type _rtgui_##type = { \
 	name, \
 	parent, \
-	constructor, \
-	destructor, \
+	RTGUI_CONSTRUCTOR(constructor), \
+	RTGUI_DESTRUCTOR(destructor), \
 	size }
 
-void          rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object);
-void          rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object);
-rt_bool_t     rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent);
-rtgui_type_t  *rtgui_type_parent_type_get(rtgui_type_t *type);
-const char	  *rtgui_type_name_get(rtgui_type_t *type);
-rtgui_type_t  *rtgui_type_get_from_name(const char *name);
+void          rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object);
+void          rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object);
+rt_bool_t     rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent);
+const rtgui_type_t  *rtgui_type_parent_type_get(const rtgui_type_t *type);
+const char	  *rtgui_type_name_get(const rtgui_type_t *type);
+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) \

+ 0 - 2
components/rtgui/widgets/container.c

@@ -120,12 +120,10 @@ rt_bool_t rtgui_container_event_handler(rtgui_widget_t* widget, rtgui_event_t* e
 		/* handle in child widget */
 		return rtgui_container_dispatch_mouse_event(container,
 			(struct rtgui_event_mouse*)event);
-		break;
 
 	case RTGUI_EVENT_MOUSE_MOTION:
 		return rtgui_container_dispatch_mouse_event(container,
 			(struct rtgui_event_mouse*)event);
-		break;
 
 	default:
 		/* call parent widget event handler */

+ 0 - 4
components/rtgui/widgets/menu.c

@@ -137,10 +137,6 @@ static void _rtgui_menu_item_ondraw(struct rtgui_listctrl *list, struct rtgui_dc
 	}
 }
 
-static void _rtgui_menu_item_onmouse()
-{
-}
-
 DEFINE_CLASS_TYPE(menu, "menu", 
 	RTGUI_WIDGET_TYPE,
 	_rtgui_menu_constructor,

+ 1 - 1
components/rtgui/widgets/toplevel.c

@@ -13,6 +13,7 @@
  */
 #include <rtgui/rtgui_system.h>
 #include <rtgui/widgets/toplevel.h>
+extern void rtgui_topwin_do_clip(rtgui_widget_t* widget);
 
 static void _rtgui_toplevel_constructor(rtgui_toplevel_t *toplevel)
 {
@@ -100,7 +101,6 @@ rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* ev
 
 void rtgui_toplevel_update_clip(rtgui_toplevel_t* top)
 {
-	rt_uint32_t idx;
 	rtgui_container_t* container;
 	struct rtgui_list_node* node;
 	rtgui_rect_t screen_rect;

+ 1 - 2
components/rtgui/widgets/widget.c

@@ -17,6 +17,7 @@
 #include <rtgui/widgets/widget.h>
 #include <rtgui/widgets/window.h>
 #include <rtgui/widgets/view.h>
+extern void rtgui_topwin_do_clip(rtgui_widget_t* widget);
 
 static void _rtgui_widget_constructor(rtgui_widget_t *widget)
 {
@@ -494,8 +495,6 @@ void rtgui_widget_show(rtgui_widget_t* widget)
 
 void rtgui_widget_hide(rtgui_widget_t* widget)
 {
-	rtgui_rect_t rect;
-
 	/* hide this widget */
 	RTGUI_WIDGET_HIDE(widget);