From 975ef6c8997114c14d840ec9e67cdfc01be29da9 Mon Sep 17 00:00:00 2001 From: johnche Date: Mon, 8 Apr 2024 20:55:20 +0800 Subject: [PATCH] =?UTF-8?q?[unity]=E5=9B=9E=E9=80=80ExecuteModule=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/native_src/Inc/BackendEnv.h | 2 -- unity/native_src/Src/BackendEnv.cpp | 2 -- unity/native_src/Src/JSEngine.cpp | 14 ++++---------- unity/native_src_il2cpp/Src/Puerts.cpp | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/unity/native_src/Inc/BackendEnv.h b/unity/native_src/Inc/BackendEnv.h index 4aa57a028f..45b7a577f8 100644 --- a/unity/native_src/Inc/BackendEnv.h +++ b/unity/native_src/Inc/BackendEnv.h @@ -25,8 +25,6 @@ #endif -#define EXECUTEMODULEGLOBANAME "__puertsExecuteModule" - namespace PUERTS_NAMESPACE { class BackendEnv diff --git a/unity/native_src/Src/BackendEnv.cpp b/unity/native_src/Src/BackendEnv.cpp index ff53796e23..f7dad824b7 100644 --- a/unity/native_src/Src/BackendEnv.cpp +++ b/unity/native_src/Src/BackendEnv.cpp @@ -312,8 +312,6 @@ void BackendEnv::Initialize(void* external_quickjs_runtime, void* external_quick Global->Set(Context, v8::String::NewFromUtf8(Isolate, "__tgjsSetPromiseRejectCallback").ToLocalChecked(), v8::FunctionTemplate::New(Isolate, &SetPromiseRejectCallback)->GetFunction(Context).ToLocalChecked()).Check(); } - - Global->Set(Context, v8::String::NewFromUtf8(Isolate, EXECUTEMODULEGLOBANAME).ToLocalChecked(), v8::FunctionTemplate::New(Isolate, esmodule::ExecuteModule)->GetFunction(Context).ToLocalChecked()).Check(); } void BackendEnv::UnInitialize() diff --git a/unity/native_src/Src/JSEngine.cpp b/unity/native_src/Src/JSEngine.cpp index ad5bd6a771..3d5a5fa23f 100644 --- a/unity/native_src/Src/JSEngine.cpp +++ b/unity/native_src/Src/JSEngine.cpp @@ -234,16 +234,10 @@ namespace PUERTS_NAMESPACE v8::HandleScope HandleScope(MainIsolate); v8::Local Context = ResultInfo.Context.Get(MainIsolate); v8::Context::Scope ContextScope(Context); - v8::Local Global = Context->Global(); - auto Ret = Global->Get(Context, v8::String::NewFromUtf8(MainIsolate, EXECUTEMODULEGLOBANAME).ToLocalChecked()); - v8::Local Func; - if (Ret.ToLocal(&Func) && Func->IsFunction()) - { - ModuleExecutor = CreateJSFunction( - MainIsolate, Context, - Func.As() - ); - } + ModuleExecutor = CreateJSFunction( + MainIsolate, Context, + v8::FunctionTemplate::New(MainIsolate, esmodule::ExecuteModule)->GetFunction(Context).ToLocalChecked() + ); } return ModuleExecutor; } diff --git a/unity/native_src_il2cpp/Src/Puerts.cpp b/unity/native_src_il2cpp/Src/Puerts.cpp index 2cb3c4684d..4c1c6f2ea2 100644 --- a/unity/native_src_il2cpp/Src/Puerts.cpp +++ b/unity/native_src_il2cpp/Src/Puerts.cpp @@ -291,7 +291,7 @@ static v8::Value* GetModuleExecutor(v8::Context* env) auto Isolate = Context->GetIsolate(); - return *v8::FunctionTemplate::New(Isolate, puerts::esmodule::ExecuteModule)->GetFunction(Context).ToLocalChecked();; + return *v8::FunctionTemplate::New(Isolate, puerts::esmodule::ExecuteModule)->GetFunction(Context).ToLocalChecked(); } static void* GetJSObjectValue(const PersistentObjectInfo* objectInfo, const char* key, const void* Typeid)