summaryrefslogtreecommitdiff
path: root/fxjs/fxjs_v8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/fxjs_v8.cpp')
-rw-r--r--fxjs/fxjs_v8.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index 50345cfcd1..e73ab0a8f0 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -177,8 +177,8 @@ void V8TemplateMapTraits::Dispose(v8::Isolate* isolate,
if (!pObjDef)
return;
if (pObjDef->m_pDestructor) {
- pObjDef->m_pDestructor(CFXJS_Engine::CurrentEngineFromIsolate(isolate),
- obj);
+ pObjDef->m_pDestructor(
+ CFXJS_Engine::EngineFromIsolateCurrentContext(isolate), obj);
}
CFXJS_Engine::FreeObjectPrivate(obj);
}
@@ -261,10 +261,19 @@ CFXJS_Engine::CFXJS_Engine(v8::Isolate* pIsolate) : CJS_V8(pIsolate) {}
CFXJS_Engine::~CFXJS_Engine() = default;
// static
-CFXJS_Engine* CFXJS_Engine::CurrentEngineFromIsolate(v8::Isolate* pIsolate) {
+CFXJS_Engine* CFXJS_Engine::EngineFromIsolateCurrentContext(
+ v8::Isolate* pIsolate) {
+ return EngineFromContext(pIsolate->GetCurrentContext());
+}
+
+CFXJS_Engine* CFXJS_Engine::EngineFromContext(v8::Local<v8::Context> pContext) {
return static_cast<CFXJS_Engine*>(
- pIsolate->GetCurrentContext()->GetAlignedPointerFromEmbedderData(
- kPerContextDataIndex));
+ pContext->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
+}
+
+void CFXJS_Engine::SetEngineInContext(CFXJS_Engine* pEngine,
+ v8::Local<v8::Context> pContext) {
+ pContext->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pEngine);
}
// static
@@ -385,8 +394,7 @@ void CFXJS_Engine::InitializeEngine() {
v8::Local<v8::Context> v8Context = v8::Context::New(
GetIsolate(), nullptr, GetGlobalObjectTemplate(GetIsolate()));
v8::Context::Scope context_scope(v8Context);
-
- v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, this);
+ SetEngineInContext(this, v8Context);
int maxID = CFXJS_ObjDefinition::MaxID(GetIsolate());
m_StaticObjects.resize(maxID + 1);