From 09e2615e51c580a2dbe4989af64ca47170eb03ef Mon Sep 17 00:00:00 2001 From: halx99 Date: Wed, 18 Nov 2020 12:15:02 +0800 Subject: [PATCH] Add missing param JNIEnv* for natvie interfaces [ci build] --- .gitmodules | 9 +++++++++ .../jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp | 12 +++++------- extensions/GUI/CCControlExtension/CCControl.cpp | 4 +--- extensions/scripting/lua-bindings/CMakeLists.txt | 4 ++++ .../scripting/lua-bindings/manual/CCLuaStack.cpp | 13 ++++--------- .../platform/android/jni/Cocos2dxLuaJavaBridge.cpp | 12 ++++-------- 6 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..b3bdfed93f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[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/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp index 72470e69c7..cb1a76f5d5 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -42,7 +42,7 @@ extern "C" { cocos2d::Director::getInstance()->mainLoop(); } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause(JNIEnv* env) { if (Director::getInstance()->getOpenGLView()) { Application::getInstance()->applicationDidEnterBackground(); cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); @@ -50,7 +50,7 @@ extern "C" { } } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume(JNIEnv* env) { static bool firstTime = true; if (Director::getInstance()->getOpenGLView()) { // don't invoke at first to keep the same logic as iOS @@ -75,11 +75,9 @@ extern "C" { cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } - JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() { - JNIEnv * env = 0; - - if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) { - return 0; + JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText(JNIEnv* env) { + if (! env) { + return nullptr; } std::string pszText = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText(); return cocos2d::StringUtils::newStringUTFJNI(env, pszText); diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index a3edfab5de..82cb7bd587 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -121,9 +121,7 @@ void Control::sendActionsForControlEvents(EventType controlEvents) #if CC_ENABLE_SCRIPT_BINDING cocos2d::BasicScriptData data(this,(void*)&controlEvents); cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data); - auto scriptEngine = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine(); - if(scriptEngine) - scriptEngine->sendEvent(event); + cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(event); #endif } } diff --git a/extensions/scripting/lua-bindings/CMakeLists.txt b/extensions/scripting/lua-bindings/CMakeLists.txt index 5becef74e5..c766bf493e 100644 --- a/extensions/scripting/lua-bindings/CMakeLists.txt +++ b/extensions/scripting/lua-bindings/CMakeLists.txt @@ -185,6 +185,10 @@ 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 2e97cf769f..d8ffc0299d 100644 --- a/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/extensions/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -69,7 +69,8 @@ namespace { size_t sz; s = lua_tolstring(L, -1, &sz); /* get result */ if (s == NULL) - return luaL_error(L, "'tostring' must return a string to 'print'"); + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); if (i>1) out->append("\t"); out->append(s, sz); lua_pop(L, 1); /* pop result */ @@ -187,17 +188,11 @@ 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, realname); /* L: package, loaders */ + lua_getfield(_state, -1, "loaders"); /* L: package, loaders */ // insert loader into index 2 lua_pushcfunction(_state, func); /* L: package, loaders, func */ @@ -210,7 +205,7 @@ void LuaStack::addLuaLoader(lua_CFunction func) lua_rawseti(_state, -2, 2); /* L: package, loaders */ // set loaders into package - lua_setfield(_state, -2, realname); /* L: package */ + lua_setfield(_state, -2, "loaders"); /* L: package */ lua_pop(_state, 1); } diff --git a/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp b/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp index dbd52eeaea..e617704187 100644 --- a/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp +++ b/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp @@ -37,16 +37,14 @@ extern "C" { -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString - (JNIEnv *env, jclass cls, jint functionId, jstring value) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString(JNIEnv *env, jclass cls, jint functionId, jstring value) { std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(env, value); int ret = LuaJavaBridge::callLuaFunctionById(functionId, strValue.c_str()); return ret; } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString - (JNIEnv *env, jclass cls, jstring luaFunctionName, jstring value) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString(JNIEnv *env, jclass cls, jstring luaFunctionName, jstring value) { std::string functionNameStr = cocos2d::StringUtils::getStringUTFCharsJNI(env, luaFunctionName); std::string valueStr = cocos2d::StringUtils::getStringUTFCharsJNI(env, value); @@ -55,14 +53,12 @@ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobal return ret; } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction - (JNIEnv *env, jclass cls, jint luaFunctionId) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction(JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::retainLuaFunctionById(luaFunctionId); } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction - (JNIEnv *env, jclass cls, jint luaFunctionId) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction(JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::releaseLuaFunctionById(luaFunctionId); }