15 #ifndef SHAKA_EMBEDDED_MAPPING_JS_ENGINE_H_ 16 #define SHAKA_EMBEDDED_MAPPING_JS_ENGINE_H_ 18 #include <glog/logging.h> 23 #include <unordered_map> 47 void OnPromiseReject(v8::PromiseRejectMessage
message);
48 void AddDestructor(
void*
object, std::function<
void(
void*)> destruct);
49 v8::Isolate* isolate()
const {
52 DCHECK(v8::Locker::IsLocked(isolate_));
55 #elif defined(USING_JSC) 56 JSContextRef context()
const;
66 v8::HandleScope handles;
67 v8::Isolate::Scope isolate_scope;
68 v8::Context::Scope context_scope;
74 class ArrayBufferAllocator :
public v8::ArrayBuffer::Allocator {
76 void* Allocate(
size_t length)
override;
77 void* AllocateUninitialized(
size_t length)
override;
78 void Free(
void* data,
size_t)
override;
81 v8::Isolate* CreateIsolate();
82 v8::Global<v8::Context> CreateContext();
84 ArrayBufferAllocator allocator_;
85 std::unordered_map<void*, std::function<void(void*)>> destructors_;
86 v8::Isolate* isolate_;
87 v8::Global<v8::Context> context_;
88 #elif defined(USING_JSC) 89 JSGlobalContextRef context_;
90 std::thread::id thread_id_;
98 #endif // SHAKA_EMBEDDED_MAPPING_JS_ENGINE_H_
Handle< JsObject > global_handle()
ReturnVal< JsValue > global_value()