-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathAppRuntime_iOS.mm
More file actions
41 lines (32 loc) · 1006 Bytes
/
AppRuntime_iOS.mm
File metadata and controls
41 lines (32 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "AppRuntime.h"
#import <Foundation/NSObjCRuntime.h>
namespace Babylon
{
void AppRuntime::DefaultUnhandledExceptionHandler(const Napi::Error& error)
{
NSLog(@"[Uncaught Error] %s", Napi::GetErrorString(error).data());
}
void AppRuntime::RunPlatformTier()
{
RunEnvironmentTier();
}
void AppRuntime::RunEnvironmentTier(const char*)
{
auto globalContext = JSGlobalContextCreateInGroup(nullptr, nullptr);
if (@available(iOS 16.4, *)) {
JSGlobalContextSetInspectable(globalContext, m_options.EnableDebugger);
}
Napi::Env env = Napi::Attach(globalContext);
Run(env);
JSGlobalContextRelease(globalContext);
// Detach must come after JSGlobalContextRelease since it triggers finalizers which require env.
Napi::Detach(env);
}
void AppRuntime::Execute(Dispatchable<void()> callback)
{
@autoreleasepool
{
callback();
}
}
}