From c12701da10e9e5dbdc82c7d8f33892d3ebdcce86 Mon Sep 17 00:00:00 2001 From: halx99 Date: Wed, 18 Nov 2020 12:16:36 +0800 Subject: [PATCH] Merge: 53122216ee a708c2f904 Merge branch 'master' of https://github.com/c4games/engine-x --- .gitmodules | 9 --------- extensions/GUI/CCControlExtension/CCControl.cpp | 4 +++- extensions/scripting/lua-bindings/CMakeLists.txt | 4 ---- .../scripting/lua-bindings/manual/CCLuaStack.cpp | 13 +++++++++---- 4 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b3bdfed93f..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "tools/cocos2d-console"] - path = tools/cocos2d-console - url = git://github.com/cocos2d/cocos2d-console.git -[submodule "tools/bindings-generator"] - path = tools/bindings-generator - url = git://github.com/cocos2d/bindings-generator.git -[submodule "tests/cpp-tests/Resources/ccs-res"] - path = tests/cpp-tests/Resources/ccs-res - url = git://github.com/dumganhar/ccs-res.git diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 82cb7bd587..a3edfab5de 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -121,7 +121,9 @@ void Control::sendActionsForControlEvents(EventType controlEvents) #if CC_ENABLE_SCRIPT_BINDING cocos2d::BasicScriptData data(this,(void*)&controlEvents); cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(event); + auto scriptEngine = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine(); + if(scriptEngine) + scriptEngine->sendEvent(event); #endif } } diff --git a/extensions/scripting/lua-bindings/CMakeLists.txt b/extensions/scripting/lua-bindings/CMakeLists.txt index c766bf493e..5becef74e5 100644 --- a/extensions/scripting/lua-bindings/CMakeLists.txt +++ b/extensions/scripting/lua-bindings/CMakeLists.txt @@ -185,10 +185,6 @@ if(WINDOWS) target_compile_definitions(${ENGINEX_LUA_LIB} PUBLIC _USRLUASTATIC) endif() -target_compile_definitions(${ENGINEX_LUA_LIB} - PUBLIC LUA_COMPAT_MODULE -) - set_target_properties(${ENGINEX_LUA_LIB} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" diff --git a/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp b/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp index d8ffc0299d..2e97cf769f 100644 --- a/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -69,8 +69,7 @@ namespace { size_t sz; s = lua_tolstring(L, -1, &sz); /* get result */ if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("print")); + return luaL_error(L, "'tostring' must return a string to 'print'"); if (i>1) out->append("\t"); out->append(s, sz); lua_pop(L, 1); /* pop result */ @@ -188,11 +187,17 @@ void LuaStack::addSearchPath(const char* path) void LuaStack::addLuaLoader(lua_CFunction func) { if (!func) return; + +#if LUA_VERSION_NUM >= 504 || (LUA_VERSION_NUM >= 502 && !defined(LUA_COMPAT_LOADERS)) + const char* realname = "searchers"; +#else + const char* realname = "loaders"; +#endif // stack content after the invoking of the function // get loader table lua_getglobal(_state, "package"); /* L: package */ - lua_getfield(_state, -1, "loaders"); /* L: package, loaders */ + lua_getfield(_state, -1, realname); /* L: package, loaders */ // insert loader into index 2 lua_pushcfunction(_state, func); /* L: package, loaders, func */ @@ -205,7 +210,7 @@ void LuaStack::addLuaLoader(lua_CFunction func) lua_rawseti(_state, -2, 2); /* L: package, loaders */ // set loaders into package - lua_setfield(_state, -2, "loaders"); /* L: package */ + lua_setfield(_state, -2, realname); /* L: package */ lua_pop(_state, 1); }