| 61 | v8::Local<v8::Context> context() { return m_context.Get(m_isolate); } |
| 62 | |
| 63 | void initV8() { |
| 64 | static std::unique_ptr<v8::Platform> m_platform; |
| 65 | if (!m_platform) { |
| 66 | app::ResourceFinder rf; |
| 67 | rf.includeBinDir("snapshot_blob.bin"); |
| 68 | if (rf.findFirst()) { |
| 69 | v8::V8::InitializeExternalStartupData(rf.filename().c_str()); |
| 70 | } else { |
| 71 | v8::V8::InitializeICU(); |
| 72 | } |
| 73 | |
| 74 | m_platform = v8::platform::NewDefaultPlatform(); |
| 75 | v8::V8::InitializePlatform(m_platform.get()); |
| 76 | v8::V8::Initialize(); |
| 77 | } |
| 78 | |
| 79 | v8::Isolate::CreateParams params; |
| 80 | params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); |
| 81 | m_isolate = v8::Isolate::New(params); |
| 82 | |
| 83 | v8::Isolate::Scope isolatescope(m_isolate); |
| 84 | v8::HandleScope handle_scope(m_isolate); |
| 85 | m_context = v8::Global<v8::Context>(m_isolate, v8::Context::New(m_isolate)); |
| 86 | } |
| 87 | |
| 88 | bool raiseEvent(const std::vector<script::Value>& event) override { |
| 89 | // return eval("if (typeof onEvent === \"function\") onEvent(\"" + event + "\");"); |
nothing calls this directly
no test coverage detected