Browse Source

Modify tolua_isnumber and tolua_isstring function to fixed issue #182.

aster2013 12 years ago
parent
commit
b7990b94da

+ 0 - 67
Source/Engine/LuaScript/pkgs/UI/UIElement.pkg

@@ -345,73 +345,6 @@ static int tolua_UILuaAPI_UIElement_CreateChild00(lua_State* tolua_S)
 #endif
 }
 
-#define TOLUA_DISABLE_tolua_UILuaAPI_UIElement_GetChild00
-static int tolua_UILuaAPI_UIElement_GetChild00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"const UIElement",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
-  const UIElement* self = (const UIElement*)  tolua_tousertype(tolua_S,1,0);
-  unsigned index = ((unsigned)  tolua_tonumber(tolua_S,2,0));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetChild'", NULL);
-#endif
- {
-  UIElement* tolua_ret = (UIElement*)  self->GetChild(index);
-  if (tolua_ret)
-    tolua_pushusertype(tolua_S,(void*)tolua_ret,tolua_ret->GetTypeName().CString());
-  else
-    lua_pushnil(tolua_S);
- }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetChild'.",&tolua_err);
- return 0;
-#endif
-}
-
-#define TOLUA_DISABLE_tolua_UILuaAPI_UIElement_GetChild01
-static int tolua_UILuaAPI_UIElement_GetChild01(lua_State* tolua_S)
-{
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"const UIElement",0,&tolua_err) ||
- !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
- !tolua_isboolean(tolua_S,3,1,&tolua_err) ||
- !tolua_isnoobj(tolua_S,4,&tolua_err)
- )
- goto tolua_lerror;
- else
- {
-  const UIElement* self = (const UIElement*)  tolua_tousertype(tolua_S,1,0);
-  const String name = ((const String)  tolua_tourho3dstring(tolua_S,2,0));
-  bool recursive = ((bool)  tolua_toboolean(tolua_S,3,false));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetChild'", NULL);
-#endif
- {
-  UIElement* tolua_ret = (UIElement*)  self->GetChild(name,recursive);
-  if (tolua_ret)
-    tolua_pushusertype(tolua_S,(void*)tolua_ret,tolua_ret->GetTypeName().CString());
-  else
-    lua_pushnil(tolua_S);
- }
- }
- return 1;
-tolua_lerror:
- return tolua_UILuaAPI_UIElement_GetChild00(tolua_S);
-}
-
 #define GetStyle GetAppliedStyle
 #define SetColorAttr SetColor
 $}

+ 13 - 9
Source/ThirdParty/toluapp/src/lib/tolua_is.c

@@ -229,7 +229,9 @@ TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
 {
 	if (def && lua_gettop(L)<abs(lo))
 		return 1;
-	if (lua_isnumber(L,lo))
+    // Modifyed by Aster Jian for Urho3D.
+    // if (lua_isnumber(L,lo))
+    if (lua_type(L, lo) == LUA_TNUMBER)
 		return 1;
 	err->index = lo;
 	err->array = 0;
@@ -239,14 +241,16 @@ TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
 
 TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err)
 {
-	if (def && lua_gettop(L)<abs(lo))
-		return 1;
- if (lua_isnil(L,lo) || lua_isstring(L,lo))
-		return 1;
-	err->index = lo;
-	err->array = 0;
-	err->type = "string";
-	return 0;
+    if (def && lua_gettop(L)<abs(lo))
+        return 1;
+    // Modifyed by Aster Jian for Urho3D.
+    // if (lua_isnil(L,lo) || lua_isstring(L,lo))
+    if (lua_isnil(L,lo) || lua_type(L,lo) == LUA_TSTRING)
+        return 1;
+    err->index = lo;
+    err->array = 0;
+    err->type = "string";
+    return 0;
 }
 
 TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err)