From 222f2cbd51774b95129051da9d85710a58dd1269 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 26 Nov 2014 21:54:18 +0800 Subject: [PATCH 1/4] Decrease the package size of lua_empty_test --- cocos/scripting/lua-bindings/CMakeLists.txt | 1 + .../lua-bindings/manual/cocos2d/LuaOpengl.cpp | 3 - .../manual/cocos2d/LuaScriptHandlerMgr.cpp | 2 - .../cocos2d/lua_cocos2dx_deprecated.cpp | 2 - .../manual/cocos2d/lua_cocos2dx_manual.cpp | 226 ----------------- .../lua_cocos2dx_coco_studio_manual.cpp | 4 + .../lua_cocos2dx_csloader_manual.cpp | 78 ++++++ .../lua_cocos2dx_csloader_manual.hpp | 40 +++ .../manual/ui/lua_cocos2dx_ui_manual.cpp | 231 ++++++++++++++++-- .../lua-bindings/proj.android/Android.mk | 1 + .../project.pbxproj | 24 ++ .../proj.win32/libluacocos2d.vcxproj | 2 + .../proj.win32/libluacocos2d.vcxproj.filters | 6 + .../project/Classes/lua_module_register.h | 2 - tools/tolua/cocos2dx.ini | 7 +- tools/tolua/genbindings.py | 1 + 16 files changed, 364 insertions(+), 266 deletions(-) create mode 100644 cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.cpp create mode 100644 cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.hpp diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index a447fa3e9d..e34ac04e6a 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -93,6 +93,7 @@ set(lua_bindings_manual_files manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp manual/cocostudio/CustomGUIReader.cpp manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp + manual/cocostudio/lua_cocos2dx_csloader_manual.cpp manual/controller/lua_cocos2dx_controller_manual.cpp manual/extension/lua_cocos2dx_extension_manual.cpp manual/network/lua_extensions.c diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/LuaOpengl.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/LuaOpengl.cpp index 21bae98b01..b73fb5c1be 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/LuaOpengl.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/LuaOpengl.cpp @@ -26,7 +26,6 @@ #include #include "tolua_fix.h" #include "cocos2d.h" -#include "extensions/cocos-ext.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" @@ -34,8 +33,6 @@ #include "LuaBasicConversions.h" using namespace cocos2d; -using namespace cocos2d::extension; - void GLNode::draw(Renderer *renderer, const cocos2d::Mat4& transform, uint32_t flags) diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.cpp index c9b8fbc342..9e92ea3db8 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.cpp @@ -26,14 +26,12 @@ #include #include "tolua_fix.h" #include "cocos2d.h" -#include "extensions/cocos-ext.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #include "LuaOpengl.h" using namespace cocos2d; -using namespace cocos2d::extension; NS_CC_BEGIN 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 eb64b99bb1..afb42f3999 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp @@ -27,10 +27,8 @@ #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" -#include "cocos-ext.h" USING_NS_CC; -USING_NS_CC_EXT; #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 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 92ac42a610..ad1187407a 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -31,9 +31,6 @@ #else #include #endif -#include "ui/UIWidget.h" -#include "ActionTimeline/CCActionTimeline.h" -#include "ActionTimeline/CSLoader.h" static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) { @@ -6643,182 +6640,6 @@ static void extendTMXLayer(lua_State* tolua_S) lua_pop(tolua_S, 1); } -static int tolua_cocos2dx_EventListenerFocus_create(lua_State* tolua_S) -{ - if (nullptr == tolua_S) - return 0; - - int argc = 0; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create(); - if(nullptr == tolua_ret) - return 0; - - int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; - int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus"); - - return 1; - } - - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:create", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_create'.",&tolua_err); - return 0; -#endif -} - -static void cloneFocusHandler(const EventListenerFocus* src,EventListenerFocus* dst ) -{ - if (nullptr == src || nullptr == dst) - return; - - LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); - if (0 != handler) - { - int newscriptHandler = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); - dst->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){ - lua_State* tolua_S = LuaEngine::getInstance()->getLuaStack()->getLuaState(); - int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1; - int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetLostFocus,"ccui.Widget"); - id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1; - luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetGetFocus,"ccui.Widget"); - LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); - }; - } -} - -static int tolua_cocos2dx_EventListenerFocus_clone(lua_State* tolua_S) -{ - if (nullptr == tolua_S) - return 0; - - int argc = 0; - EventListenerFocus* self = nullptr; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_clone'\n", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create(); - if(nullptr == tolua_ret) - return 0; - - cloneFocusHandler(self, tolua_ret); - - int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; - int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus"); - - return 1; - } - - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:clone", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_clone'.",&tolua_err); - return 0; -#endif -} - - -static int tolua_cocos2dx_EventListenerFocus_registerScriptHandler(lua_State* tolua_S) -{ - if (nullptr == tolua_S) - return 0; - - int argc = 0; - EventListenerFocus* self = nullptr; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'\n", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); - - self->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){ - int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1; - int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetLostFocus,"ccui.Widget"); - id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1; - luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr; - toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetGetFocus,"ccui.Widget"); - LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); - }; - return 0; - } - - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:registerScriptHandler", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'.",&tolua_err); - return 0; -#endif -} - -static void extendEventListenerFocus(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "cc.EventListenerFocus"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - tolua_function(tolua_S, "create", tolua_cocos2dx_EventListenerFocus_create); - tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerFocus_registerScriptHandler); - tolua_function(tolua_S, "clone", tolua_cocos2dx_EventListenerFocus_clone); - } - lua_pop(tolua_S, 1); -} - int lua_cocos2dx_Application_isIOS64bit(lua_State* tolua_S) { @@ -7088,51 +6909,6 @@ static void extendCamera(lua_State* tolua_S) lua_pop(tolua_S, 1); } -int lua_cocos2dx_CSLoader_createTimeline(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.CSLoader",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.CSLoader:createTimeline"); - if(!ok) - return 0; - cocostudio::timeline::ActionTimeline* ret = cocos2d::CSLoader::createTimeline(arg0); - object_to_luaval(tolua_S, "ccs.ActionTimeline",(cocostudio::timeline::ActionTimeline*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CSLoader:createTimeline",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CSLoader_createTimeline'.",&tolua_err); -#endif - return 0; -} - -static void extendCSLoader(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "cc.CSLoader"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - tolua_function(tolua_S, "createTimeline", lua_cocos2dx_CSLoader_createTimeline); - } - lua_pop(tolua_S, 1); -} - int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) @@ -7184,12 +6960,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendGLProgramState(tolua_S); extendOrbitCamera(tolua_S); extendTMXLayer(tolua_S); - extendEventListenerFocus(tolua_S); extendApplication(tolua_S); extendTextureCache(tolua_S); extendGLView(tolua_S); extendCamera(tolua_S); - extendCSLoader(tolua_S); return 0; } diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp index 0243049d2a..16deb0d062 100644 --- a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp @@ -23,6 +23,8 @@ ****************************************************************************/ #include "lua_cocos2dx_coco_studio_manual.hpp" #include "lua_cocos2dx_studio_auto.hpp" +#include "lua_cocos2dx_csloader_auto.hpp" +#include "lua_cocos2dx_csloader_manual.hpp" #include "cocos2d.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" @@ -599,7 +601,9 @@ int register_cocostudio_module(lua_State* L) if (lua_istable(L,-1))//stack:...,_G, { register_all_cocos2dx_studio(L); + register_all_cocos2dx_csloader(L); register_all_cocos2dx_coco_studio_manual(L); + register_all_cocos2dx_csloader_manual(L); lua_register_cocos2dx_coco_studio_CustomGUIReader(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.cpp new file mode 100644 index 0000000000..9cd71589b2 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "lua_cocos2dx_csloader_manual.hpp" +#include "tolua_fix.h" +#include "LuaBasicConversions.h" +#include "CCLuaValue.h" +#include "CCLuaEngine.h" +#include "ActionTimeline/CCActionTimeline.h" +#include "ActionTimeline/CSLoader.h" + +int lua_cocos2dx_csloader_CSLoader_createTimeline(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CSLoader",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.CSLoader:createTimeline"); + if(!ok) + return 0; + cocostudio::timeline::ActionTimeline* ret = cocos2d::CSLoader::createTimeline(arg0); + object_to_luaval(tolua_S, "ccs.ActionTimeline",(cocostudio::timeline::ActionTimeline*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CSLoader:createTimeline",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CSLoader_createTimeline'.",&tolua_err); +#endif + return 0; +} + +int register_all_cocos2dx_csloader_manual(lua_State* L) +{ + lua_pushstring(L, "cc.CSLoader"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "createTimeline", lua_cocos2dx_csloader_CSLoader_createTimeline); + } + lua_pop(L, 1); + + return 0; +} + diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.hpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.hpp new file mode 100644 index 0000000000..85b2acd95d --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.hpp @@ -0,0 +1,40 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_COCOSTUDIO_LUA_COCOS2DX_CSLOADER_MANUAL_H +#define COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_COCOSTUDIO_LUA_COCOS2DX_CSLOADER_MANUAL_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +#include "base/CCRef.h" +#include + +TOLUA_API int register_all_cocos2dx_csloader_manual(lua_State* L); + +#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H 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 c971314eab..8699b02a36 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 @@ -680,9 +680,9 @@ static void extendLayoutParameter(lua_State* L) } -static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S) +static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* L) { - if (NULL == tolua_S) + if (NULL == L) return 0; int argc = 0; @@ -690,29 +690,29 @@ static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(tolua_S,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); + tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); return 0; } #endif - argc = lua_gettop(tolua_S) - 1; + argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif - LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); self->registerScriptEditBoxHandler(handler); return 0; } @@ -722,16 +722,16 @@ static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'.",&tolua_err); + tolua_error(L,"#ferror in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'.",&tolua_err); return 0; #endif } -static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua_S) +static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* L) { - if (NULL == tolua_S) + if (NULL == L) return 0; int argc = 0; @@ -739,19 +739,19 @@ static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; #endif - self = static_cast(tolua_tousertype(tolua_S,1,0)); + self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); + tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); return 0; } #endif - argc = lua_gettop(tolua_S) - 1; + argc = lua_gettop(L) - 1; if (0 == argc) { @@ -764,25 +764,25 @@ static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'.",&tolua_err); + tolua_error(L,"#ferror in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'.",&tolua_err); return 0; #endif } -static void extendEditBox(lua_State* tolua_S) +static void extendEditBox(lua_State* L) { - lua_pushstring(tolua_S, "ccui.EditBox"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) + lua_pushstring(L, "ccui.EditBox"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) { - lua_pushstring(tolua_S,"registerScriptEditBoxHandler"); - lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_registerScriptEditBoxHandler ); - lua_rawset(tolua_S,-3); - lua_pushstring(tolua_S,"unregisterScriptEditBoxHandler"); - lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler ); - lua_rawset(tolua_S,-3); + lua_pushstring(L,"registerScriptEditBoxHandler"); + lua_pushcfunction(L,tolua_cocos2d_EditBox_registerScriptEditBoxHandler ); + lua_rawset(L,-3); + lua_pushstring(L,"unregisterScriptEditBoxHandler"); + lua_pushcfunction(L,tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler ); + lua_rawset(L,-3); } - lua_pop(tolua_S, 1); + lua_pop(L, 1); } int register_all_cocos2dx_ui_manual(lua_State* L) @@ -802,6 +802,182 @@ int register_all_cocos2dx_ui_manual(lua_State* L) return 0; } +static int tolua_cocos2dx_EventListenerFocus_create(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(L, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(L) - 1; + + if (argc == 0) + { + cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create(); + if(nullptr == tolua_ret) + return 0; + + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus"); + + return 1; + } + + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:create", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_create'.",&tolua_err); + return 0; +#endif +} + +static void cloneFocusHandler(const EventListenerFocus* src,EventListenerFocus* dst ) +{ + if (nullptr == src || nullptr == dst) + return; + + LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); + if (0 != handler) + { + int newscriptHandler = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); + dst->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){ + lua_State* L = LuaEngine::getInstance()->getLuaStack()->getLuaState(); + int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1; + int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr; + toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetLostFocus,"ccui.Widget"); + id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1; + luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr; + toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetGetFocus,"ccui.Widget"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); + }; + } +} + +static int tolua_cocos2dx_EventListenerFocus_clone(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + EventListenerFocus* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_clone'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (argc == 0) + { + cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create(); + if(nullptr == tolua_ret) + return 0; + + cloneFocusHandler(self, tolua_ret); + + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus"); + + return 1; + } + + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:clone", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_clone'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2dx_EventListenerFocus_registerScriptHandler(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + EventListenerFocus* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'\n", nullptr); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (argc == 1) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = toluafix_ref_function(L,2,0); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS); + + self->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){ + int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1; + int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr; + toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetLostFocus,"ccui.Widget"); + id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1; + luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr; + toluafix_pushusertype_ccobject(L, id, luaID, (void*)widgetGetFocus,"ccui.Widget"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); + }; + return 0; + } + + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n", "cc.EventListenerFocus:registerScriptHandler", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendEventListenerFocusEvent(lua_State* L) +{ + lua_pushstring(L, "cc.EventListenerFocus"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "create", tolua_cocos2dx_EventListenerFocus_create); + tolua_function(L, "registerScriptHandler", tolua_cocos2dx_EventListenerFocus_registerScriptHandler); + tolua_function(L, "clone", tolua_cocos2dx_EventListenerFocus_clone); + } + lua_pop(L, 1); +} + int register_ui_moudle(lua_State* L) { lua_getglobal(L, "_G"); @@ -813,6 +989,7 @@ int register_ui_moudle(lua_State* L) register_all_cocos2dx_experimental_video(L); register_all_cocos2dx_experimental_video_manual(L); #endif + extendEventListenerFocusEvent(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index 0c6f4bfb58..dd0d0471a9 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -95,6 +95,7 @@ LOCAL_SRC_FILES += ../manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp \ #cocostudio LOCAL_SRC_FILES += ../manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp \ ../manual/cocostudio/CustomGUIReader.cpp \ + ../manual/cocostudio/lua_cocos2dx_csloader_manual.cpp \ ../auto/lua_cocos2dx_studio_auto.cpp #spine diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 08fe13ec79..7faa13a769 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -143,6 +143,14 @@ 155C7E2719A71CDE00F08B25 /* lua_cocos2dx_ui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15C1BD1A1986526C00A46ACC /* lua_cocos2dx_ui_manual.cpp */; }; 155C7E2819A71CE600F08B25 /* lua_cocos2dx_ui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15C1BD1B1986526C00A46ACC /* lua_cocos2dx_ui_manual.hpp */; }; 155C7E2919A71CE800F08B25 /* lua_cocos2dx_ui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15C1BD1B1986526C00A46ACC /* lua_cocos2dx_ui_manual.hpp */; }; + 1595523A1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */; }; + 1595523B1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */; }; + 1595523C1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */; }; + 1595523D1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */; }; + 159552401A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */; }; + 159552411A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */; }; + 159552421A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */; }; + 159552431A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */; }; 15AC69D519876E9300D17520 /* lua_cocos2dx_physics_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AACE75218BC45C200215002 /* lua_cocos2dx_physics_auto.cpp */; }; 15AC69D619876EA200D17520 /* lua_cocos2dx_physics_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE75318BC45C200215002 /* lua_cocos2dx_physics_auto.hpp */; }; 15AC69D91987710400D17520 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = 1ABCA1F918CD8F6E0087CE3A /* tolua_event.c */; }; @@ -317,6 +325,10 @@ 156EADF21977A2BA00F53709 /* lua_cocos2dx_experimental_video_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_experimental_video_auto.hpp; sourceTree = ""; }; 158C128519A0FA1300781A76 /* lua_cocos2dx_3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_3d_manual.cpp; sourceTree = ""; }; 158C128619A0FA1300781A76 /* lua_cocos2dx_3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_cocos2dx_3d_manual.h; sourceTree = ""; }; + 159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_csloader_auto.cpp; sourceTree = ""; }; + 159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_csloader_auto.hpp; sourceTree = ""; }; + 1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_csloader_manual.cpp; sourceTree = ""; }; + 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_csloader_manual.hpp; sourceTree = ""; }; 15C1BCC019864D8700A46ACC /* lua_cocos2dx_cocosbuilder_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_cocosbuilder_auto.cpp; sourceTree = ""; }; 15C1BCC119864D8700A46ACC /* lua_cocos2dx_cocosbuilder_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_cocosbuilder_auto.hpp; sourceTree = ""; }; 15C1BCC219864D8700A46ACC /* lua_cocos2dx_cocosdenshion_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_cocosdenshion_auto.cpp; sourceTree = ""; }; @@ -561,6 +573,8 @@ 15EFA400198B2AB2000C57D3 /* cocostudio */ = { isa = PBXGroup; children = ( + 1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */, + 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */, 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */, 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */, 15EFA401198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.cpp */, @@ -572,6 +586,8 @@ 1AACE74818BC45C200215002 /* auto */ = { isa = PBXGroup; children = ( + 159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */, + 159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */, 3E2BDB0319C5E5FE0055CDCD /* lua_cocos2dx_audioengine_auto.cpp */, 3E2BDB0419C5E5FE0055CDCD /* lua_cocos2dx_audioengine_auto.hpp */, 1516227F19A0F3E3006099B8 /* lua_cocos2dx_3d_auto.cpp */, @@ -801,6 +817,7 @@ 15415ADB19A71A53004F1E71 /* unix.h in Headers */, 155C7DF419A71C3700F08B25 /* lua_cocos2dx_3d_manual.h in Headers */, 15415ABB19A71A53004F1E71 /* luasocket.h in Headers */, + 159552421A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */, 155C7E2419A71CD800F08B25 /* lua_cocos2dx_experimental_video_manual.hpp in Headers */, 15415ACF19A71A53004F1E71 /* tcp.h in Headers */, 15415AAB19A71A53004F1E71 /* buffer.h in Headers */, @@ -828,6 +845,7 @@ 15C1C2ED19874CBE00A46ACC /* CCLuaObjcBridge.h in Headers */, 15C1C2EE19874CBE00A46ACC /* tolua_fix.h in Headers */, 155C7E2019A71CCC00F08B25 /* LuaSkeletonAnimation.h in Headers */, + 1595523C1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp in Headers */, 15415AB719A71A53004F1E71 /* io.h in Headers */, 566F016119B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15C1C2DC19874B4400A46ACC /* xxtea.h in Headers */, @@ -870,6 +888,7 @@ 15415ADC19A71A53004F1E71 /* unix.h in Headers */, 155C7DF519A71C3900F08B25 /* lua_cocos2dx_3d_manual.h in Headers */, 15415ABC19A71A53004F1E71 /* luasocket.h in Headers */, + 159552431A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */, 155C7E2519A71CDA00F08B25 /* lua_cocos2dx_experimental_video_manual.hpp in Headers */, 15415AD019A71A53004F1E71 /* tcp.h in Headers */, 15415AAC19A71A53004F1E71 /* buffer.h in Headers */, @@ -897,6 +916,7 @@ 15EFA641198B32BB000C57D3 /* CCLuaObjcBridge.h in Headers */, 15EFA642198B32BB000C57D3 /* tolua_fix.h in Headers */, 155C7E2119A71CCE00F08B25 /* LuaSkeletonAnimation.h in Headers */, + 1595523D1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp in Headers */, 15415AB819A71A53004F1E71 /* io.h in Headers */, 566F016219B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15EFA62B198B3220000C57D3 /* LuaOpengl.h in Headers */, @@ -1019,6 +1039,7 @@ F4FE0D5719ECD00100B8B12B /* luasocket_scripts.c in Sources */, 15415AC519A71A53004F1E71 /* select.c in Sources */, 155C7DFE19A71C5A00F08B25 /* CCBProxy.cpp in Sources */, + 1595523A1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */, 15415AD919A71A53004F1E71 /* unix.c in Sources */, 155C7E0619A71C7600F08B25 /* lua_cocos2dx_extension_manual.cpp in Sources */, 15C1C2DD19874B8800A46ACC /* CCLuaBridge.cpp in Sources */, @@ -1062,6 +1083,7 @@ 15415AA919A71A53004F1E71 /* buffer.c in Sources */, 15C1C2CD1987495500A46ACC /* lua_cocos2dx_auto.cpp in Sources */, 15415AB919A71A53004F1E71 /* luasocket.c in Sources */, + 159552401A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp in Sources */, 155C7E1219A71CA200F08B25 /* Lua_web_socket.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1095,6 +1117,7 @@ F4FE0D5819ECD00100B8B12B /* luasocket_scripts.c in Sources */, 15EFA639198B328B000C57D3 /* tolua_fix.cpp in Sources */, 155C7DFF19A71C5C00F08B25 /* CCBProxy.cpp in Sources */, + 1595523B1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */, 155C7DF019A71C1E00F08B25 /* lua_cocos2dx_spine_auto.cpp in Sources */, 155C7E0719A71C7800F08B25 /* lua_cocos2dx_extension_manual.cpp in Sources */, 15EFA625198B31FB000C57D3 /* LuaOpengl.cpp in Sources */, @@ -1138,6 +1161,7 @@ 15EFA618198B2E2B000C57D3 /* lua_cocos2dx_auto.cpp in Sources */, 15EFA619198B2E2B000C57D3 /* lua_cocos2dx_physics_auto.cpp in Sources */, 15415AB219A71A53004F1E71 /* inet.c in Sources */, + 159552411A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp in Sources */, 155C7E1319A71CA400F08B25 /* Lua_web_socket.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index ae56cff4bc..8f863b3178 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -41,6 +41,7 @@ + @@ -111,6 +112,7 @@ + diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index 0dd25138b7..c518226ad8 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -276,6 +276,9 @@ manual\audioengine + + auto + @@ -482,6 +485,9 @@ manual\audioengine + + auto + diff --git a/tests/lua-empty-test/project/Classes/lua_module_register.h b/tests/lua-empty-test/project/Classes/lua_module_register.h index 04b44661af..a337e44af0 100644 --- a/tests/lua-empty-test/project/Classes/lua_module_register.h +++ b/tests/lua-empty-test/project/Classes/lua_module_register.h @@ -1,13 +1,11 @@ #ifndef __TEST_LUA_TESTS_PROJECT_CLASSES_LUA_MODULE_REGISTER_H__ #define __TEST_LUA_TESTS_PROJECT_CLASSES_LUA_MODULE_REGISTER_H__ -#include "network/lua_cocos2dx_network_manual.h" #include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h" int lua_module_register(lua_State* L) { - register_network_module(L); register_cocosdenshion_module(L); return 1; } diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 55af15b345..a612f8cc65 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -22,11 +22,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device CSLoader ClippingRectangleNode .*Light$ +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -144,8 +144,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS DirectionLight3D::[*], PointLight3D::[*], SpotLight3D::[*], - AmbientLight3D::[*], - CSLoader::[nodeFromXML nodeFromProtocolBuffers createTimeline nodeWithFlatBuffers] + AmbientLight3D::[*] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], diff --git a/tools/tolua/genbindings.py b/tools/tolua/genbindings.py index 08b298c8d7..89901ab552 100755 --- a/tools/tolua/genbindings.py +++ b/tools/tolua/genbindings.py @@ -139,6 +139,7 @@ def main(): 'cocos2dx_cocosdenshion.ini': ('cocos2dx_cocosdenshion', 'lua_cocos2dx_cocosdenshion_auto'), \ 'cocos2dx_3d.ini': ('cocos2dx_3d', 'lua_cocos2dx_3d_auto'), \ 'cocos2dx_audioengine.ini': ('cocos2dx_audioengine', 'lua_cocos2dx_audioengine_auto'), \ + 'cocos2dx_csloader.ini' : ('cocos2dx_csloader', 'lua_cocos2dx_csloader_auto'), \ } target = 'lua' generator_py = '%s/generator.py' % cxx_generator_root From 6cf092b855cdfdf03e2f10aa8e4e106a86e8e89f Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 27 Nov 2014 10:22:39 +0800 Subject: [PATCH 2/4] Add cocos2dx_csloader.ini to generate the related lua bindings --- tools/tolua/cocos2dx_csloader.ini | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tools/tolua/cocos2dx_csloader.ini diff --git a/tools/tolua/cocos2dx_csloader.ini b/tools/tolua/cocos2dx_csloader.ini new file mode 100644 index 0000000000..ef7116c724 --- /dev/null +++ b/tools/tolua/cocos2dx_csloader.ini @@ -0,0 +1,60 @@ +[cocos2dx_csloader] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_csloader + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu*$". +classes = CSLoader + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = CSLoader::[nodeFromXML nodeFromProtocolBuffers createTimeline nodeWithFlatBuffers] + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = no + From 6398f99ed2612af8962fed2b51e9faddcd38bdd3 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 27 Nov 2014 11:17:48 +0800 Subject: [PATCH 3/4] Update the CMakeLists.txt for lua-tests --- tests/lua-tests/project/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index 404e5d2ea9..c7b617335c 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -54,7 +54,7 @@ else() pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}${RES_PREFIX}/res - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/Resources/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/src COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}/Resources/src/cocos COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/cpp-tests/Resources ${APP_BIN_DIR}${RES_PREFIX}/res ) From ed573149dd360f3cdf1c57a0bb98bcbd29a21858 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 27 Nov 2014 19:42:32 +0800 Subject: [PATCH 4/4] Resolve the project setting error on the platforms --- cocos/scripting/lua-bindings/CMakeLists.txt | 1 + cocos/scripting/lua-bindings/proj.android/Android.mk | 1 + .../scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj | 2 ++ .../lua-bindings/proj.win32/libluacocos2d.vcxproj.filters | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index e34ac04e6a..d7d0d49167 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -120,6 +120,7 @@ set(lua_bindings_auto_files auto/lua_cocos2dx_physics_auto.cpp auto/lua_cocos2dx_spine_auto.cpp auto/lua_cocos2dx_studio_auto.cpp + auto/lua_cocos2dx_csloader_auto.cpp auto/lua_cocos2dx_ui_auto.cpp auto/lua_cocos2dx_audioengine_auto.cpp ) diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index dd0d0471a9..f0d253bd0c 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -96,6 +96,7 @@ LOCAL_SRC_FILES += ../manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp \ LOCAL_SRC_FILES += ../manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp \ ../manual/cocostudio/CustomGUIReader.cpp \ ../manual/cocostudio/lua_cocos2dx_csloader_manual.cpp \ + ../auto/lua_cocos2dx_csloader_auto.cpp \ ../auto/lua_cocos2dx_studio_auto.cpp #spine diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index 8f863b3178..316f62829c 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -67,6 +67,7 @@ + @@ -138,6 +139,7 @@ + diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index c518226ad8..4b48815b83 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -279,6 +279,9 @@ auto + + manual\cocostudio + @@ -488,6 +491,9 @@ auto + + manual\cocostudio +