diff --git a/cocos/scripting/lua-bindings/manual/CCLuaBridge.cpp b/cocos/scripting/lua-bindings/manual/CCLuaBridge.cpp index feca8244e9..a6889bd7b2 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaBridge.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaBridge.cpp @@ -51,7 +51,7 @@ int LuaBridge::pushLuaFunctionById(int functionId) lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { - int value = lua_tonumber(L, -1); + int value = lua_tointeger(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { @@ -85,7 +85,7 @@ int LuaBridge::retainLuaFunctionById(int functionId) } // increase counter - int retainCount = lua_tonumber(L, -1); + int retainCount = lua_tointeger(L, -1); retainCount++; lua_pop(L, 1); /* L: id_r */ lua_pushinteger(L, functionId); /* L: id_r id */ @@ -130,7 +130,7 @@ int LuaBridge::releaseLuaFunctionById(int functionId) return 0; } - int retainCount = lua_tonumber(L, -1); + int retainCount = lua_tointeger(L, -1); retainCount--; if (retainCount > 0) @@ -155,7 +155,7 @@ int LuaBridge::releaseLuaFunctionById(int functionId) lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { - int value = lua_tonumber(L, -1); + int value = lua_tointeger(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { @@ -214,7 +214,7 @@ int LuaBridge::retainLuaFunction(lua_State *L, int functionIndex, int *retainCou } else { - functionId = lua_tonumber(L, -1); + functionId = lua_tointeger(L, -1); } // get function retain @@ -230,7 +230,7 @@ int LuaBridge::retainLuaFunction(lua_State *L, int functionIndex, int *retainCou else { // add retain count - retainCount = lua_tonumber(L, -1); + retainCount = lua_tointeger(L, -1); retainCount++; lua_pop(L, 1); lua_pushinteger(L, retainCount); diff --git a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp index 62c9ec8502..8637fa8d8b 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp @@ -420,10 +420,10 @@ int LuaEngine::handleAccelerometerEvent(void* data) return 0; Acceleration* accelerationValue = static_cast(basicScriptData->value); - _stack->pushFloat(accelerationValue->x); - _stack->pushFloat(accelerationValue->y); - _stack->pushFloat(accelerationValue->z); - _stack->pushFloat(accelerationValue->timestamp); + _stack->pushFloat(float(accelerationValue->x)); + _stack->pushFloat(float(accelerationValue->y)); + _stack->pushFloat(float(accelerationValue->z)); + _stack->pushFloat(float(accelerationValue->timestamp)); int ret = _stack->executeFunctionByHandler(handler, 4); _stack->clean(); return ret; diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index 8ebfee94b1..bec3d21fba 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -340,12 +340,12 @@ bool luaval_to_vec2(lua_State* L,int lo,cocos2d::Vec2* outValue, const char* fun { lua_pushstring(L, "x"); lua_gettable(L, lo); - outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->x = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "y"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->y = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -372,17 +372,17 @@ bool luaval_to_vec3(lua_State* L,int lo,cocos2d::Vec3* outValue, const char* fun { lua_pushstring(L, "x"); lua_gettable(L, lo); - outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->x = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "y"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->y = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "z"); lua_gettable(L, lo); - outValue->z = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->z = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -409,22 +409,22 @@ bool luaval_to_vec4(lua_State* L,int lo,cocos2d::Vec4* outValue, const char* fun { lua_pushstring(L, "x"); lua_gettable(L, lo); - outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->x = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "y"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->y = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "z"); lua_gettable(L, lo); - outValue->z = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->z = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "w"); lua_gettable(L, lo); - outValue->w = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->w = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -490,17 +490,17 @@ bool luaval_to_physics_material(lua_State* L,int lo,PhysicsMaterial* outValue, c { lua_pushstring(L, "density"); lua_gettable(L, lo); - outValue->density = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->density = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "restitution"); lua_gettable(L, lo); - outValue->restitution = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->restitution = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "friction"); lua_gettable(L, lo); - outValue->friction = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->friction = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -580,12 +580,12 @@ bool luaval_to_size(lua_State* L,int lo,Size* outValue, const char* funcName) { lua_pushstring(L, "width"); /* L: paramStack key */ lua_gettable(L,lo);/* L: paramStack paramStack[lo][key] */ - outValue->width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->width = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1);/* L: paramStack*/ lua_pushstring(L, "height"); lua_gettable(L,lo); - outValue->height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->height = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); } @@ -612,22 +612,22 @@ bool luaval_to_rect(lua_State* L,int lo,Rect* outValue, const char* funcName) { lua_pushstring(L, "x"); lua_gettable(L,lo); - outValue->origin.x = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->origin.x = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "y"); lua_gettable(L,lo); - outValue->origin.y = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->origin.y = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "width"); lua_gettable(L,lo); - outValue->size.width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->size.width = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "height"); lua_gettable(L,lo); - outValue->size.height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->size.height = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); } @@ -654,22 +654,22 @@ bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue, const char* funcNa { lua_pushstring(L, "r"); lua_gettable(L,lo); - outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->r = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); - outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->g = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); - outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->b = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); lua_pushstring(L, "a"); lua_gettable(L,lo); - outValue->a = lua_isnil(L,-1) ? 255 : lua_tonumber(L,-1); + outValue->a = lua_isnil(L,-1) ? 255 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); } @@ -696,22 +696,22 @@ bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue, const char* funcNa { lua_pushstring(L, "r"); lua_gettable(L,lo); - outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->r = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); - outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->g = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); - outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->b = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "a"); lua_gettable(L,lo); - outValue->a = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->a = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); } @@ -738,17 +738,17 @@ bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue, const char* funcNa { lua_pushstring(L, "r"); lua_gettable(L,lo); - outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->r = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); - outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->g = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); - outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + outValue->b = lua_isnil(L,-1) ? 0 : static_cast(lua_tonumber(L,-1)); lua_pop(L,1); } @@ -945,7 +945,7 @@ bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue , c lua_gettable(L,lo); if (!lua_isnil(L,-1)) { - outValue->_shadow._shadowOpacity = lua_tonumber(L,-1); + outValue->_shadow._shadowOpacity = (float)lua_tonumber(L,-1); } lua_pop(L,1); } @@ -1011,7 +1011,7 @@ bool luaval_to_ttfconfig(lua_State* L,int lo, cocos2d::TTFConfig* outValue, cons lua_pushstring(L, "fontSize"); lua_gettable(L,lo); - outValue->fontSize = lua_isnumber(L, -1)?(int)lua_tointeger(L, -1) : 0; + outValue->fontSize = lua_isnumber(L, -1)?(float)lua_tointeger(L, -1) : 0.0f; lua_pop(L,1); lua_pushstring(L, "glyphs"); @@ -1071,7 +1071,7 @@ bool luaval_to_mat4(lua_State* L, int lo, cocos2d::Mat4* outValue , const char* lua_gettable(L,lo); if (tolua_isnumber(L, -1, 0, &tolua_err)) { - outValue->m[i] = tolua_tonumber(L, -1, 0); + outValue->m[i] = (float)tolua_tonumber(L, -1, 0); } else { @@ -1976,22 +1976,22 @@ bool luaval_to_quaternion(lua_State* L,int lo,cocos2d::Quaternion* outValue, con { lua_pushstring(L, "x"); lua_gettable(L, lo); - outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->x = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "y"); lua_gettable(L, lo); - outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->y = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "z"); lua_gettable(L, lo); - outValue->z = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->z = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "w"); lua_gettable(L, lo); - outValue->w = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->w = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; @@ -2017,22 +2017,22 @@ bool luaval_to_texparams(lua_State* L,int lo,cocos2d::Texture2D::TexParams* outV { lua_pushstring(L, "minFilter"); lua_gettable(L, lo); - outValue->minFilter = utils::toBackendSamplerFilter(lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1)); + outValue->minFilter = utils::toBackendSamplerFilter(lua_isnil(L, -1) ? 0 : lua_tointeger(L, -1)); lua_pop(L, 1); lua_pushstring(L, "magFilter"); lua_gettable(L, lo); - outValue->magFilter = utils::toBackendSamplerFilter(lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1)); + outValue->magFilter = utils::toBackendSamplerFilter(lua_isnil(L, -1) ? 0 : lua_tointeger(L, -1)); lua_pop(L, 1); lua_pushstring(L, "wrapS"); lua_gettable(L, lo); - outValue->sAddressMode = utils::toBackendAddressMode(lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1)); + outValue->sAddressMode = utils::toBackendAddressMode(lua_isnil(L, -1) ? 0 : lua_tointeger(L, -1)); lua_pop(L, 1); lua_pushstring(L, "wrapT"); lua_gettable(L, lo); - outValue->tAddressMode = utils::toBackendAddressMode(lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1)); + outValue->tAddressMode = utils::toBackendAddressMode(lua_isnil(L, -1) ? 0 : lua_tointeger(L, -1)); lua_pop(L, 1); } return ok; @@ -2054,21 +2054,19 @@ bool luaval_to_tex2f(lua_State* L, int lo, cocos2d::Tex2F* outValue, const char* ok = false; } - if (ok) { lua_pushstring(L, "u"); lua_gettable(L, lo); - outValue->u = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->u = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "v"); lua_gettable(L, lo); - outValue->v = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->v = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); } return ok; - } diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp index 730802404b..83756745d4 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp @@ -1541,7 +1541,7 @@ static int tolua_cocos2d_kmGLLoadMatrix00(lua_State* tolua_S) else #endif { - mat4.m[i] = tolua_tonumber(tolua_S, -1, 0); + mat4.m[i] = (float)tolua_tonumber(tolua_S, -1, 0); lua_pop(tolua_S, 1); } } diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 8fb16a7388..ef46db0c5e 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -448,7 +448,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) if (argc > 0 ) { Vector items; - uint32_t i = 1; + int i = 1; while (i <= argc) { #if COCOS2D_DEBUG >= 1 @@ -598,7 +598,7 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) return 0; } - for (uint32_t i = 0; i < argc; ++i) + for (auto i = 0; i < argc; ++i) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, i + 2,"cc.MenuItem",0,&tolua_err) ) @@ -1414,7 +1414,7 @@ static int lua_cocos2dx_Layer_setAccelerometerInterval(lua_State* L) if (!tolua_isnumber(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif - double interval = tolua_tonumber(L, 2, 0); + float interval = (float)tolua_tonumber(L, 2, 0); Device::setAccelerometerInterval(interval); return 0; } @@ -1997,7 +1997,7 @@ int tolua_cocos2d_Sequence_create(lua_State* tolua_S) } else { - uint32_t i = 1; + int i = 1; while (i <= argc) { #if COCOS2D_DEBUG >= 1 @@ -7830,10 +7830,10 @@ static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S) if (!ok) return 0; - x = tolua_tonumber(tolua_S, 2, 0); - y = tolua_tonumber(tolua_S, 3, 0); - z = tolua_tonumber(tolua_S, 4, 0); - w = tolua_tonumber(tolua_S, 5, 0); + x = (float)tolua_tonumber(tolua_S, 2, 0); + y = (float)tolua_tonumber(tolua_S, 3, 0); + z = (float)tolua_tonumber(tolua_S, 4, 0); + w = (float)tolua_tonumber(tolua_S, 5, 0); mat.transformVector(x,y,z,w, &dst); vec3_to_luaval(tolua_S, dst); @@ -8832,7 +8832,7 @@ static int tolua_cocos2d_bytearray_floatv(lua_State *L) } lua_pop(L, 1); lua_newtable(L); - for (auto idx = 0; idx < arg.size(); idx++) + for (size_t idx = 0; idx < arg.size(); idx++) { lua_pushnumber(L, arg[idx]); lua_rawseti(L, 1, idx + 1); diff --git a/cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.cpp b/cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.cpp index 69a0d1133d..bde0eb0c54 100644 --- a/cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.cpp +++ b/cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_conversions.cpp @@ -54,38 +54,38 @@ bool luaval_to_navmeshagentparam(lua_State* L, int lo, cocos2d::NavMeshAgentPara { lua_pushstring(L, "radius"); lua_gettable(L,lo); - outValue->radius = lua_isnumber(L, -1)? (float)lua_tonumber(L, -1) : 0.6; + outValue->radius = lua_isnumber(L, -1)? (float)lua_tonumber(L, -1) : 0.6f; lua_pop(L,1); lua_pushstring(L, "height"); lua_gettable(L,lo); - outValue->height = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 2.0; + outValue->height = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 2.0f; lua_pop(L,1); lua_pushstring(L, "maxAcceleration"); lua_gettable(L, lo); - outValue->maxAcceleration = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 8.0; + outValue->maxAcceleration = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 8.0f; lua_pop(L, 1); lua_pushstring(L, "maxSpeed"); lua_gettable(L, lo); - outValue->maxSpeed = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 3.5; + outValue->maxSpeed = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 3.5f; lua_pop(L, 1); lua_pushstring(L, "collisionQueryRange"); lua_gettable(L, lo); - outValue->collisionQueryRange = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : outValue->radius * 12.0; + outValue->collisionQueryRange = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : outValue->radius * 12.0f; lua_pop(L, 1); lua_pushstring(L, "pathOptimizationRange"); lua_gettable(L, lo); - outValue->pathOptimizationRange = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : outValue->radius * 30.0; + outValue->pathOptimizationRange = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : outValue->radius * 30.0f; lua_pop(L, 1); lua_pushstring(L, "separationWeight"); lua_gettable(L, lo); - outValue->separationWeight = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 2.0; + outValue->separationWeight = lua_isnumber(L, -1)?(float)lua_tonumber(L, -1) : 2.0f; lua_pop(L, 1); lua_pushstring(L, "updateFlags"); diff --git a/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp b/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp index 457ec3b1df..83af83dc17 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp @@ -382,6 +382,9 @@ static int lua_cocos2dx_XMLHttpRequest_constructor(lua_State* L) if (argc == 0) { self = new (std::nothrow) LuaMinXmlHttpRequest(); +#if COCOS2D_DEBUG >= 1 + if (self == nullptr) goto tolua_lerror; +#endif tolua_pushusertype(L, (void*)self, "cc.XMLHttpRequest"); tolua_register_gc(L, lua_gettop(L)); return 1; @@ -772,7 +775,7 @@ static int lua_get_XMLHttpRequest_response(lua_State* L) self->getByteData(tmpData); - for (int i = 0 ; i < self->getDataSize(); i++) + for (size_t i = 0 ; i < self->getDataSize(); i++) { LuaValue value = LuaValue::intValue(tmpData[i]); array.push_back(value); diff --git a/cocos/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp b/cocos/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp index 147edefd0d..f4bc2e8654 100644 --- a/cocos/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp @@ -52,7 +52,7 @@ bool luaval_to_Physics3DRigidBodyDes(lua_State* L,int lo,cocos2d::Physics3DRigid { lua_pushstring(L, "mass"); lua_gettable(L, lo); - outValue->mass = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + outValue->mass = lua_isnil(L, -1) ? 0.0f : (float)lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "localInertia"); @@ -553,7 +553,7 @@ int lua_cocos2dx_physics3d_Physics3DShape_createHeightfield(lua_State* L) tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DShape_createHeightfield'", nullptr); return 0; } - cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7); + cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], (float)arg3, (float)arg4, (float)arg5, arg6, arg7); object_to_luaval(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret); return 1; } @@ -582,7 +582,7 @@ int lua_cocos2dx_physics3d_Physics3DShape_createHeightfield(lua_State* L) tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DShape_createHeightfield'", nullptr); return 0; } - cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7, arg8); + cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], (float)arg3, (float)arg4, (float)arg5, arg6, arg7, arg8); object_to_luaval(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret); return 1; } diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp index 642fd44642..ed30f98f4e 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp @@ -770,22 +770,22 @@ static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) Margin margin; lua_pushstring(L, "left"); lua_gettable(L,2); - margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + margin.left = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "top"); lua_gettable(L,2); - margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + margin.top = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "right"); lua_gettable(L,2); - margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + margin.right = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "bottom"); lua_gettable(L,2); - margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + margin.bottom = lua_isnil(L,-1) ? 0.0f : (float)lua_tonumber(L,-1); lua_pop(L,1); self->setMargin(margin);