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.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index 8a04a0680e..3d82848a6e 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -181,10 +181,8 @@ void V8TemplateMapTraits::Dispose(v8::Isolate* isolate,
CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(isolate, id);
if (!pObjDef)
return;
- if (pObjDef->m_pDestructor) {
- pObjDef->m_pDestructor(
- CFXJS_Engine::EngineFromIsolateCurrentContext(isolate), obj);
- }
+ if (pObjDef->m_pDestructor)
+ pObjDef->m_pDestructor(obj);
CFXJS_Engine::FreeObjectPrivate(obj);
}
@@ -271,16 +269,12 @@ CFXJS_Engine* CFXJS_Engine::EngineFromIsolateCurrentContext(
return EngineFromContext(pIsolate->GetCurrentContext());
}
+// static
CFXJS_Engine* CFXJS_Engine::EngineFromContext(v8::Local<v8::Context> pContext) {
return static_cast<CFXJS_Engine*>(
pContext->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
}
-void CFXJS_Engine::SetEngineInContext(CFXJS_Engine* pEngine,
- v8::Local<v8::Context> pContext) {
- pContext->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pEngine);
-}
-
// static
int CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
@@ -288,6 +282,16 @@ int CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) {
}
// static
+void CFXJS_Engine::SetObjectPrivate(v8::Local<v8::Object> pObj,
+ std::unique_ptr<CJS_Object> p) {
+ CFXJS_PerObjectData* pPerObjectData =
+ CFXJS_PerObjectData::GetFromObject(pObj);
+ if (!pPerObjectData)
+ return;
+ pPerObjectData->m_pPrivate = std::move(p);
+}
+
+// static
void CFXJS_Engine::FreeObjectPrivate(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
pObj->SetAlignedPointerInInternalField(0, nullptr);
@@ -295,6 +299,10 @@ void CFXJS_Engine::FreeObjectPrivate(v8::Local<v8::Object> pObj) {
delete pData;
}
+void CFXJS_Engine::SetIntoContext(v8::Local<v8::Context> pContext) {
+ pContext->SetAlignedPointerInEmbedderData(kPerContextDataIndex, this);
+}
+
int CFXJS_Engine::DefineObj(const char* sObjName,
FXJSOBJTYPE eObjType,
CFXJS_Engine::Constructor pConstructor,
@@ -394,7 +402,7 @@ void CFXJS_Engine::InitializeEngine() {
v8::Local<v8::Context> v8Context = v8::Context::New(
GetIsolate(), nullptr, GetGlobalObjectTemplate(GetIsolate()));
v8::Context::Scope context_scope(v8Context);
- SetEngineInContext(this, v8Context);
+ SetIntoContext(v8Context);
int maxID = CFXJS_ObjDefinition::MaxID(GetIsolate());
m_StaticObjects.resize(maxID + 1);
@@ -449,7 +457,7 @@ void CFXJS_Engine::ReleaseEngine() {
if (!pObj.IsEmpty()) {
if (pObjDef->m_pDestructor)
- pObjDef->m_pDestructor(this, pObj);
+ pObjDef->m_pDestructor(pObj);
FreeObjectPrivate(pObj);
}
}
@@ -527,15 +535,6 @@ void CFXJS_Engine::Error(const WideString& message) {
GetIsolate()->ThrowException(NewString(message.AsStringView()));
}
-void CFXJS_Engine::SetObjectPrivate(v8::Local<v8::Object> pObj,
- std::unique_ptr<CJS_Object> p) {
- CFXJS_PerObjectData* pPerObjectData =
- CFXJS_PerObjectData::GetFromObject(pObj);
- if (!pPerObjectData)
- return;
- pPerObjectData->m_pPrivate = std::move(p);
-}
-
CJS_Object* CFXJS_Engine::GetObjectPrivate(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
if (!pData && !pObj.IsEmpty()) {