Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Tencent/puerts
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieyang committed Dec 31, 2021
2 parents 881e8fc + 3c1242f commit 7a64616
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion unity/Assets/Puerts/Src/JsEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public JsEnv(ILoader loader, IntPtr externalRuntime, IntPtr externalContext)

public JsEnv(ILoader loader, int debugPort, IntPtr externalRuntime, IntPtr externalContext)
{
const int libVersionExpect = 14;
const int libVersionExpect = 15;
int libVersion = PuertsDLL.GetLibVersion();
if (libVersion != libVersionExpect)
{
Expand Down
2 changes: 1 addition & 1 deletion unity/native_src/Src/Puerts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cstring>
#include "V8Utils.h"

#define LIB_VERSION 14
#define LIB_VERSION 15

using puerts::JSEngine;
using puerts::FValue;
Expand Down
14 changes: 8 additions & 6 deletions unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ void FJsEnvImpl::UvRunOnce()
if (TryCatch.HasCaught())
{
Logger->Error(FString::Printf(TEXT("uv_run throw: %s"), *FV8Utils::TryCatchToString(Isolate, &TryCatch)));
return;
}

LastJob = nullptr;
Expand All @@ -180,11 +179,12 @@ void FJsEnvImpl::UvRunOnce()
void FJsEnvImpl::PollEvents()
{
#if PLATFORM_WINDOWS
DWORD bytes, timeout;
DWORD bytes;
DWORD timeout = uv_backend_timeout(&NodeUVLoop);
ULONG_PTR key;
OVERLAPPED* overlapped;

timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;

GetQueuedCompletionStatus(NodeUVLoop.iocp, &bytes, &key, &overlapped, timeout);

Expand All @@ -193,6 +193,7 @@ void FJsEnvImpl::PollEvents()
PostQueuedCompletionStatus(NodeUVLoop.iocp, bytes, key, overlapped);
#elif PLATFORM_LINUX
int timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;

// Wait for new libuv events.
int r;
Expand All @@ -203,6 +204,7 @@ void FJsEnvImpl::PollEvents()
#elif PLATFORM_MAC
struct timeval tv;
int timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;
if (timeout != -1) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
Expand Down Expand Up @@ -367,9 +369,7 @@ FJsEnvImpl::FJsEnvImpl(std::shared_ptr<IJSModuleLoader> InModuleLoader, std::sha
NodeEnv,
"const publicRequire ="
" require('module').createRequire(process.cwd() + '/');"
"globalThis.require = publicRequire;"
"globalThis.embedVars = { nön_ascıı: '🏳️‍🌈' };"
"require('vm').runInThisContext(process.argv[1]);");
"globalThis.require = publicRequire;");

if (LoadenvRet.IsEmpty()) // There has been a JS exception.
{
Expand Down Expand Up @@ -477,6 +477,7 @@ FJsEnvImpl::FJsEnvImpl(std::shared_ptr<IJSModuleLoader> InModuleLoader, std::sha
Isolate->SetPromiseRejectCallback(&PromiseRejectCallback<FJsEnvImpl>);
Global->Set(Context, FV8Utils::ToV8String(Isolate, "__tgjsSetPromiseRejectCallback"), v8::FunctionTemplate::New(Isolate, &SetPromiseRejectCallback<FJsEnvImpl>)->GetFunction(Context).ToLocalChecked()).Check();

//#if !defined(WITH_NODEJS)
Global->Set(Context, FV8Utils::ToV8String(Isolate, "setTimeout"), v8::FunctionTemplate::New(Isolate, [](const v8::FunctionCallbackInfo<v8::Value>& Info)
{
auto Self = static_cast<FJsEnvImpl*>((v8::Local<v8::External>::Cast(Info.Data()))->Value());
Expand All @@ -500,6 +501,7 @@ FJsEnvImpl::FJsEnvImpl(std::shared_ptr<IJSModuleLoader> InModuleLoader, std::sha
auto Self = static_cast<FJsEnvImpl*>((v8::Local<v8::External>::Cast(Info.Data()))->Value());
Self->ClearInterval(Info);
}, This)->GetFunction(Context).ToLocalChecked()).Check();
//#endif

Global->Set(Context, FV8Utils::ToV8String(Isolate, "dumpStatisticsLog"), v8::FunctionTemplate::New(Isolate, [](const v8::FunctionCallbackInfo<v8::Value>& Info)
{
Expand Down

0 comments on commit 7a64616

Please sign in to comment.