From c026aa82f97e3bb2c9da19d151f280dd0cc36808 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 14 Jan 2015 15:09:37 +0800 Subject: [PATCH] Add CC_DEPRECATED_ATTRIBUTE flag --- .../manual/3d/lua_cocos2dx_3d_manual.cpp | 2 +- .../manual/cocos2d/lua_cocos2dx_manual.cpp | 16 ++--- .../spine/lua_cocos2dx_spine_manual.cpp | 2 +- .../project/Classes/lua_test_bindings.cpp | 60 ++++++++++++++----- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index 5fa5c75f92..c948c249f4 100644 --- a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -28,7 +28,7 @@ extern int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* L); -int lua_cocos2dx_3d_Sprite3D_setBlendFunc01(lua_State* L) +CC_DEPRECATED_ATTRIBUTE int lua_cocos2dx_3d_Sprite3D_setBlendFunc01(lua_State* L) { int argc = 0; cocos2d::Sprite3D* cobj = nullptr; 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 9c4dda0158..ff636d65da 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -3413,7 +3413,7 @@ tolua_lerror: } extern int lua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_Sprite_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_Sprite_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3426,7 +3426,7 @@ static int tolua_cocos2dx_Sprite_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_SpriteBatchNode_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_SpriteBatchNode_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_SpriteBatchNode_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3439,7 +3439,7 @@ static int tolua_cocos2dx_SpriteBatchNode_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_MotionStreak_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_MotionStreak_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_MotionStreak_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3452,7 +3452,7 @@ static int tolua_cocos2dx_MotionStreak_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_AtlasNode_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_AtlasNode_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_AtlasNode_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3465,7 +3465,7 @@ static int tolua_cocos2dx_AtlasNode_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_ParticleBatchNode_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_ParticleBatchNode_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_ParticleBatchNode_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3478,7 +3478,7 @@ static int tolua_cocos2dx_ParticleBatchNode_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_LayerColor_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_LayerColor_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3491,7 +3491,7 @@ static int tolua_cocos2dx_LayerColor_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_ParticleSystem_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_ParticleSystem_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) @@ -3504,7 +3504,7 @@ static int tolua_cocos2dx_ParticleSystem_setBlendFunc01(lua_State* tolua_S) extern int lua_cocos2dx_DrawNode_setBlendFunc(lua_State* tolua_S); -static int tolua_cocos2dx_DrawNode_setBlendFunc01(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_cocos2dx_DrawNode_setBlendFunc01(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) diff --git a/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp b/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp index 4ac90289a6..16ab65b7cd 100644 --- a/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp @@ -322,7 +322,7 @@ tolua_lerror: extern int lua_cocos2dx_spine_SkeletonRenderer_setBlendFunc(lua_State* tolua_S); -static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S) +CC_DEPRECATED_ATTRIBUTE static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S) { int argc = lua_gettop(tolua_S) - 1; if (argc == 2) diff --git a/tests/lua-tests/project/Classes/lua_test_bindings.cpp b/tests/lua-tests/project/Classes/lua_test_bindings.cpp index 90bc5a2f25..2a014fb2da 100644 --- a/tests/lua-tests/project/Classes/lua_test_bindings.cpp +++ b/tests/lua-tests/project/Classes/lua_test_bindings.cpp @@ -417,20 +417,6 @@ int lua_cocos2dx_DrawNode3D_setBlendFunc(lua_State* L) cobj->setBlendFunc(arg0); return 0; } - else if (argc == 2) - { - CCLOG("setBlendFunc of cc.DrawNode3D will deprecate two int parameter form,please pass a table like {src = xx, dst = xx} as a parameter"); - GLenum src, dst; - if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.DrawNode3D:setBlendFunc")) - return 0; - - if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.DrawNode3D:setBlendFunc")) - return 0; - - BlendFunc blendFunc = {src, dst}; - cobj->setBlendFunc(blendFunc); - return 0; - } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:setBlendFunc",argc, 1); return 0; @@ -443,6 +429,50 @@ tolua_lerror: return 0; } +CC_DEPRECATED_ATTRIBUTE int lua_cocos2dx_DrawNode3D_setBlendFunc01(lua_State* L) +{ + int argc = 0; + cocos2d::DrawNode3D* cobj = nullptr; + tolua_Error tolua_err; + + if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror; + + cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_setBlendFunc'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc != 2) + { + goto tolua_lerror; + } + else + { + CCLOG("setBlendFunc of cc.DrawNode3D will deprecate two int parameter form,please pass a table like {src = xx, dst = xx} as a parameter"); + + GLenum src, dst; + if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.DrawNode3D:setBlendFunc")) + return 0; + + if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.DrawNode3D:setBlendFunc")) + return 0; + + BlendFunc blendFunc = {src, dst}; + cobj->setBlendFunc(blendFunc); + lua_settop(L, 1); + return 1; + } + +tolua_lerror: + return lua_cocos2dx_DrawNode3D_setBlendFunc(L); +} + int lua_cocos2dx_DrawNode3D_drawLine(lua_State* L) { int argc = 0; @@ -657,7 +687,7 @@ int lua_register_cocos2dx_DrawNode3D(lua_State* L) tolua_beginmodule(L,"DrawNode3D"); tolua_function(L,"getBlendFunc",lua_cocos2dx_DrawNode3D_getBlendFunc); - tolua_function(L,"setBlendFunc",lua_cocos2dx_DrawNode3D_setBlendFunc); + tolua_function(L,"setBlendFunc",lua_cocos2dx_DrawNode3D_setBlendFunc01); tolua_function(L,"drawLine",lua_cocos2dx_DrawNode3D_drawLine); tolua_function(L,"clear",lua_cocos2dx_DrawNode3D_clear); tolua_function(L,"drawCube",lua_cocos2dx_DrawNode3D_drawCube);