Skip to content

Commit

Permalink
[unity]回退ExecuteModule的修改
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Apr 8, 2024
1 parent dfc703d commit 975ef6c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 0 additions & 2 deletions unity/native_src/Inc/BackendEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#endif

#define EXECUTEMODULEGLOBANAME "__puertsExecuteModule"

namespace PUERTS_NAMESPACE
{
class BackendEnv
Expand Down
2 changes: 0 additions & 2 deletions unity/native_src/Src/BackendEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BackendEnv>)->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()
Expand Down
14 changes: 4 additions & 10 deletions unity/native_src/Src/JSEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,10 @@ namespace PUERTS_NAMESPACE
v8::HandleScope HandleScope(MainIsolate);
v8::Local<v8::Context> Context = ResultInfo.Context.Get(MainIsolate);
v8::Context::Scope ContextScope(Context);
v8::Local<v8::Object> Global = Context->Global();
auto Ret = Global->Get(Context, v8::String::NewFromUtf8(MainIsolate, EXECUTEMODULEGLOBANAME).ToLocalChecked());
v8::Local<v8::Value> Func;
if (Ret.ToLocal(&Func) && Func->IsFunction())
{
ModuleExecutor = CreateJSFunction(
MainIsolate, Context,
Func.As<v8::Function>()
);
}
ModuleExecutor = CreateJSFunction(
MainIsolate, Context,
v8::FunctionTemplate::New(MainIsolate, esmodule::ExecuteModule)->GetFunction(Context).ToLocalChecked()
);
}
return ModuleExecutor;
}
Expand Down
2 changes: 1 addition & 1 deletion unity/native_src_il2cpp/Src/Puerts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 975ef6c

Please sign in to comment.