Skip to content

Commit

Permalink
[unity]PuertsDLL.GetLibBackend增加实例参数,并升级api版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Mar 25, 2024
1 parent 2611136 commit f174001
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions unity/Assets/core/upm/Runtime/Src/Default/JsEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ namespace Puerts
public delegate void JSFunctionCallback(IntPtr isolate, IntPtr info, IntPtr self, int argumentsLen);
public delegate object JSConstructorCallback(IntPtr isolate, IntPtr info, int argumentsLen);

public enum BackendType: int
{
V8 = 0,
Node = 1,
QuickJS = 2
public enum BackendType: int
{
V8 = 0,
Node = 1,
QuickJS = 2
}

public class JsEnv : IDisposable
Expand Down Expand Up @@ -102,7 +102,7 @@ public JsEnv(ILoader loader, IntPtr externalRuntime, IntPtr externalContext)

public JsEnv(ILoader loader, int debugPort, BackendType backend, IntPtr externalRuntime, IntPtr externalContext)
{
const int libVersionExpect = 32;
const int libVersionExpect = 33;
int libVersion = PuertsDLL.GetApiLevel();
if (libVersion != libVersionExpect)
{
Expand Down Expand Up @@ -152,11 +152,11 @@ public JsEnv(ILoader loader, int debugPort, BackendType backend, IntPtr external
GeneralGetterManager = new GeneralGetterManager();
GeneralSetterManager = new GeneralSetterManager();

if (PuertsDLL.GetLibBackend() == 0)
if (PuertsDLL.GetLibBackend(isolate) == 0)
Backend = new BackendV8(this);
else if (PuertsDLL.GetLibBackend() == 1)
else if (PuertsDLL.GetLibBackend(isolate) == 1)
Backend = new BackendNodeJS(this);
else if (PuertsDLL.GetLibBackend() == 2)
else if (PuertsDLL.GetLibBackend(isolate) == 2)
Backend = new BackendQuickJS(this);

// 注册JS对象通用GC回调
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static int GetApiLevel() {
}

[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetLibBackend();
public static extern int GetLibBackend(IntPtr isolate);

[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CreateJSEngine(int backendType);
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 @@ -32,7 +32,7 @@ V8_EXPORT int GetApiLevel()
return API_LEVEL;
}

V8_EXPORT int GetLibBackend()
V8_EXPORT int GetLibBackend(v8::Isolate *Isolate)
{
#if WITH_NODEJS
return puerts::JSEngineBackend::Node;
Expand Down

0 comments on commit f174001

Please sign in to comment.