diff --git a/native/cocos/bindings/jswrapper/v8/Class.cpp b/native/cocos/bindings/jswrapper/v8/Class.cpp index 821a0b79bd2..6c3536273e7 100644 --- a/native/cocos/bindings/jswrapper/v8/Class.cpp +++ b/native/cocos/bindings/jswrapper/v8/Class.cpp @@ -206,6 +206,7 @@ bool Class::defineFunction(const char *name, v8::FunctionCallback func, void *da if (jsName.IsEmpty()) { return false; } + _constructorTemplate.Get(__isolate)->PrototypeTemplate()->Set(jsName.ToLocalChecked(), v8::FunctionTemplate::New(__isolate, func, createExternal(__isolate, data))); return true; } @@ -218,7 +219,18 @@ bool Class::defineProperty(const char *name, v8::FunctionCallback getter, v8::Fu auto prototypeTemplate = _constructorTemplate.Get(__isolate)->PrototypeTemplate(); auto externalData = createExternal(__isolate, data); - prototypeTemplate->SetAccessorProperty(jsName.ToLocalChecked(), v8::FunctionTemplate::New(__isolate, getter, externalData), v8::FunctionTemplate::New(__isolate, setter, externalData)); + + v8::Local getterTemplate = v8::Local(); + v8::Local setterTemplate = v8::Local(); + + if (getter != nullptr) { + getterTemplate = v8::FunctionTemplate::New(__isolate, getter, externalData); + } + + if (setter != nullptr) { + setterTemplate = v8::FunctionTemplate::New(__isolate, setter, externalData); + } + prototypeTemplate->SetAccessorProperty(jsName.ToLocalChecked(), getterTemplate, setterTemplate); return true; } @@ -246,7 +258,18 @@ bool Class::defineStaticProperty(const char *name, v8::FunctionCallback getter, } auto externalData = createExternal(__isolate, data); - _constructorTemplate.Get(__isolate)->SetAccessorProperty(jsName.ToLocalChecked(), v8::FunctionTemplate::New(__isolate, getter, externalData), v8::FunctionTemplate::New(__isolate, setter, externalData)); + v8::Local getterTemplate = v8::Local(); + v8::Local setterTemplate = v8::Local(); + + if (getter != nullptr) { + getterTemplate = v8::FunctionTemplate::New(__isolate, getter, externalData); + } + + if (setter != nullptr) { + setterTemplate = v8::FunctionTemplate::New(__isolate, setter, externalData); + } + + _constructorTemplate.Get(__isolate)->SetAccessorProperty(jsName.ToLocalChecked(), getterTemplate, setterTemplate); return true; } diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp index 67f08968d7f..bf308fb44b6 100644 --- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp +++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp @@ -246,7 +246,11 @@ class ScriptEngineV8Context { ~ScriptEngineV8Context() { v8::V8::Dispose(); +#if V8_MAJOR_VERSION > 9 || ( V8_MAJOR_VERSION == 9 && V8_MINOR_VERSION > 7) + v8::V8::DisposePlatform(); +#else v8::V8::ShutdownPlatform(); +#endif delete platform; } v8::Platform *platform = nullptr; @@ -279,12 +283,22 @@ void ScriptEngine::onFatalErrorCallback(const char *location, const char *messag getInstance()->callExceptionCallback(location, message, "(no stack information)"); } -void ScriptEngine::onOOMErrorCallback(const char *location, bool isHeapOom) { +void ScriptEngine::onOOMErrorCallback(const char *location, +#if V8_MAJOR_VERSION > 10 || (V8_MAJOR_VERSION == 10 && V8_MINOR_VERSION > 4) + const v8::OOMDetails& details +#else + bool isHeapOom +#endif + ) { ccstd::string errorStr = "[OOM ERROR] location: "; errorStr += location; ccstd::string message; message = "is heap out of memory: "; +#if V8_MAJOR_VERSION > 10 || (V8_MAJOR_VERSION == 10 && V8_MINOR_VERSION > 4) + if (details.is_heap_oom) { +#else if (isHeapOom) { +#endif message += "true"; } else { message += "false"; @@ -899,6 +913,7 @@ bool ScriptEngine::evalString(const char *script, uint32_t length /* = 0 */, Val if (!success) { SE_LOGE("ScriptEngine::evalString script %s, failed!\n", fileName); } + return success; } diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.h b/native/cocos/bindings/jswrapper/v8/ScriptEngine.h index 59940b65226..c1ada9b3777 100644 --- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.h +++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.h @@ -361,7 +361,14 @@ class ScriptEngine final { private: static void privateDataFinalize(PrivateObjectBase *privateObj); static void onFatalErrorCallback(const char *location, const char *message); - static void onOOMErrorCallback(const char *location, bool isHeapOom); + + static void onOOMErrorCallback(const char *location, +#if V8_MAJOR_VERSION > 10 || (V8_MAJOR_VERSION == 10 && V8_MINOR_VERSION > 4) + const v8::OOMDetails& details +#else + bool isHeapOom +#endif + ); static void onMessageCallback(v8::Local message, v8::Local data); static void onPromiseRejectCallback(v8::PromiseRejectMessage msg); diff --git a/native/cocos/bindings/jswrapper/v8/debugger/inspector_agent.cpp b/native/cocos/bindings/jswrapper/v8/debugger/inspector_agent.cpp index 942b212f9db..6f06a12853d 100644 --- a/native/cocos/bindings/jswrapper/v8/debugger/inspector_agent.cpp +++ b/native/cocos/bindings/jswrapper/v8/debugger/inspector_agent.cpp @@ -391,7 +391,11 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel { explicit ChannelImpl(V8Inspector *inspector, InspectorSessionDelegate *delegate) : delegate_(delegate) { +#if V8_MAJOR_VERSION > 10 || (V8_MAJOR_VERSION == 10 && V8_MINOR_VERSION > 3) + session_ = inspector->connect(1, this, StringView(), v8_inspector::V8Inspector::ClientTrustLevel::kFullyTrusted); +#else session_ = inspector->connect(1, this, StringView()); +#endif } virtual ~ChannelImpl() {} diff --git a/native/cocos/platform/android/libcocos2dx/build.gradle b/native/cocos/platform/android/libcocos2dx/build.gradle index 6309734c1b2..5c47318e45b 100644 --- a/native/cocos/platform/android/libcocos2dx/build.gradle +++ b/native/cocos/platform/android/libcocos2dx/build.gradle @@ -1,9 +1,7 @@ apply plugin: 'com.android.library' android { - ndkPath PROP_NDK_PATH compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() - ndkPath PROP_NDK_PATH namespace 'com.cocos.lib' defaultConfig { minSdkVersion PROP_MIN_SDK_VERSION diff --git a/native/external-config.json b/native/external-config.json index 88416cdce72..432a1a05969 100644 --- a/native/external-config.json +++ b/native/external-config.json @@ -3,6 +3,6 @@ "type": "github", "owner": "cocos-creator", "name": "engine-native-external", - "checkout": "v3.8.2-9" + "checkout": "v3.8.2-11" } } \ No newline at end of file