summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_class.cpp40
-rw-r--r--fxjs/cfxjse_class.h12
-rw-r--r--fxjs/cfxjse_engine.cpp4
-rw-r--r--fxjs/cfxjse_value.cpp15
-rw-r--r--fxjs/cfxjse_value.h8
5 files changed, 40 insertions, 39 deletions
diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp
index 0d68147326..8e49ebe373 100644
--- a/fxjs/cfxjse_class.cpp
+++ b/fxjs/cfxjse_class.cpp
@@ -142,7 +142,9 @@ void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
v8::ObjectTemplate::New(pIsolate);
hCallBackInfoTemplate->SetInternalFieldCount(2);
v8::Local<v8::Object> hCallBackInfo =
- hCallBackInfoTemplate->NewInstance();
+ hCallBackInfoTemplate
+ ->NewInstance(pValue->GetIsolate()->GetCurrentContext())
+ .ToLocalChecked();
hCallBackInfo->SetAlignedPointerInInternalField(
0, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClass));
hCallBackInfo->SetInternalField(
@@ -251,6 +253,21 @@ void NamedPropertyEnumeratorCallback(
info.GetReturnValue().Set(v8::Array::New(info.GetIsolate()));
}
+void SetUpNamedPropHandler(v8::Isolate* pIsolate,
+ v8::Local<v8::ObjectTemplate>* pObjectTemplate,
+ const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition) {
+ v8::NamedPropertyHandlerConfiguration configuration(
+ lpClassDefinition->dynPropGetter ? NamedPropertyGetterCallback : nullptr,
+ lpClassDefinition->dynPropSetter ? NamedPropertySetterCallback : nullptr,
+ lpClassDefinition->dynPropTypeGetter ? NamedPropertyQueryCallback
+ : nullptr,
+ nullptr, NamedPropertyEnumeratorCallback,
+ v8::External::New(pIsolate,
+ const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)),
+ v8::PropertyHandlerFlags::kNonMasking);
+ (*pObjectTemplate)->SetHandler(configuration);
+}
+
} // namespace
// static
@@ -280,7 +297,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(2);
v8::Local<v8::ObjectTemplate> hObjectTemplate =
hFunctionTemplate->InstanceTemplate();
- SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition);
+ SetUpNamedPropHandler(pIsolate, &hObjectTemplate, lpClassDefinition);
if (lpClassDefinition->methNum) {
for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
@@ -310,23 +327,6 @@ CFXJSE_Class* CFXJSE_Class::Create(
return pResult;
}
-// static
-void CFXJSE_Class::SetUpNamedPropHandler(
- v8::Isolate* pIsolate,
- v8::Local<v8::ObjectTemplate>& hObjectTemplate,
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition) {
- v8::NamedPropertyHandlerConfiguration configuration(
- lpClassDefinition->dynPropGetter ? NamedPropertyGetterCallback : 0,
- lpClassDefinition->dynPropSetter ? NamedPropertySetterCallback : 0,
- lpClassDefinition->dynPropTypeGetter ? NamedPropertyQueryCallback : 0, 0,
- NamedPropertyEnumeratorCallback,
- v8::External::New(pIsolate,
- const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)),
- v8::PropertyHandlerFlags::kNonMasking);
- hObjectTemplate->SetHandler(configuration);
-}
-
-CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext)
- : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
+CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext) : m_pContext(lpContext) {}
CFXJSE_Class::~CFXJSE_Class() {}
diff --git a/fxjs/cfxjse_class.h b/fxjs/cfxjse_class.h
index 056525f30b..fd9786ea3b 100644
--- a/fxjs/cfxjse_class.h
+++ b/fxjs/cfxjse_class.h
@@ -20,11 +20,6 @@ class CFXJSE_Class {
const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion,
bool bIsJSGlobal);
- static void SetUpNamedPropHandler(
- v8::Isolate* pIsolate,
- v8::Local<v8::ObjectTemplate>& hObjectTemplate,
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition);
-
explicit CFXJSE_Class(CFXJSE_Context* lpContext);
~CFXJSE_Class();
@@ -32,12 +27,13 @@ class CFXJSE_Class {
v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
protected:
+ friend class CFXJSE_Context;
+ friend class CFXJSE_Value;
+
ByteString m_szClassName;
UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_lpClassDefinition;
- UnownedPtr<CFXJSE_Context> m_pContext;
+ UnownedPtr<CFXJSE_Context> const m_pContext;
v8::Global<v8::FunctionTemplate> m_hTemplate;
- friend class CFXJSE_Context;
- friend class CFXJSE_Value;
};
#endif // FXJS_CFXJSE_CLASS_H_
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index a4fc0a2bdb..1812d02e50 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -805,7 +805,9 @@ v8::Local<v8::Value> CFXJSE_Engine::NewXFAObject(
v8::EscapableHandleScope scope(GetIsolate());
v8::Local<v8::FunctionTemplate> klass =
v8::Local<v8::FunctionTemplate>::New(GetIsolate(), tmpl);
- v8::Local<v8::Object> object = klass->InstanceTemplate()->NewInstance();
+ v8::Local<v8::Object> object = klass->InstanceTemplate()
+ ->NewInstance(m_JsContext->GetContext())
+ .ToLocalChecked();
FXJSE_UpdateObjectBinding(object, obj);
return scope.Escape(object);
}
diff --git a/fxjs/cfxjse_value.cpp b/fxjs/cfxjse_value.cpp
index 6afba97c2d..6d0f6f7fdf 100644
--- a/fxjs/cfxjse_value.cpp
+++ b/fxjs/cfxjse_value.cpp
@@ -84,7 +84,10 @@ void CFXJSE_Value::SetObject(CFXJSE_HostObject* lpObject,
CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate());
v8::Local<v8::FunctionTemplate> hClass =
v8::Local<v8::FunctionTemplate>::New(GetIsolate(), pClass->m_hTemplate);
- v8::Local<v8::Object> hObject = hClass->InstanceTemplate()->NewInstance();
+ v8::Local<v8::Object> hObject =
+ hClass->InstanceTemplate()
+ ->NewInstance(GetIsolate()->GetCurrentContext())
+ .ToLocalChecked();
FXJSE_UpdateObjectBinding(hObject, lpObject);
m_hValue.Reset(GetIsolate(), hObject);
}
@@ -125,11 +128,11 @@ bool CFXJSE_Value::SetObjectProperty(const ByteStringView& szPropName,
v8::Local<v8::Value> hPropValue =
v8::Local<v8::Value>::New(GetIsolate(), lpPropValue->DirectGetValue());
- return (bool)hObject.As<v8::Object>()->Set(
+ return static_cast<bool>(hObject.As<v8::Object>()->Set(
v8::String::NewFromUtf8(GetIsolate(), szPropName.unterminated_c_str(),
v8::String::kNormalString,
szPropName.GetLength()),
- hPropValue);
+ hPropValue));
}
bool CFXJSE_Value::GetObjectProperty(const ByteStringView& szPropName,
@@ -159,7 +162,7 @@ bool CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx,
v8::Local<v8::Value> hPropValue =
v8::Local<v8::Value>::New(GetIsolate(), lpPropValue->DirectGetValue());
- return (bool)hObject.As<v8::Object>()->Set(uPropIdx, hPropValue);
+ return static_cast<bool>(hObject.As<v8::Object>()->Set(uPropIdx, hPropValue));
}
bool CFXJSE_Value::GetObjectPropertyByIdx(uint32_t uPropIdx,
@@ -219,7 +222,7 @@ bool CFXJSE_Value::SetObjectOwnProperty(const ByteStringView& szPropName,
v8::Local<v8::Value>::New(GetIsolate(), lpPropValue->m_hValue);
return hObject.As<v8::Object>()
->DefineOwnProperty(
- m_pIsolate->GetCurrentContext(),
+ GetIsolate()->GetCurrentContext(),
v8::String::NewFromUtf8(GetIsolate(), szPropName.unterminated_c_str(),
v8::String::kNormalString,
szPropName.GetLength()),
@@ -249,7 +252,7 @@ bool CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction,
v8::String::NewFromUtf8(GetIsolate(),
"(function (oldfunction, newthis) { return "
"oldfunction.bind(newthis); })");
- v8::Local<v8::Context> hContext = m_pIsolate->GetCurrentContext();
+ v8::Local<v8::Context> hContext = GetIsolate()->GetCurrentContext();
v8::Local<v8::Function> hBinderFunc =
v8::Script::Compile(hContext, hBinderFuncSource)
.ToLocalChecked()
diff --git a/fxjs/cfxjse_value.h b/fxjs/cfxjse_value.h
index dd01843990..f83ddc31c7 100644
--- a/fxjs/cfxjse_value.h
+++ b/fxjs/cfxjse_value.h
@@ -88,11 +88,11 @@ class CFXJSE_Value {
friend class CFXJSE_Class;
friend class CFXJSE_Context;
- CFXJSE_Value();
- CFXJSE_Value(const CFXJSE_Value&);
- CFXJSE_Value& operator=(const CFXJSE_Value&);
+ CFXJSE_Value() = delete;
+ CFXJSE_Value(const CFXJSE_Value&) = delete;
+ CFXJSE_Value& operator=(const CFXJSE_Value&) = delete;
- UnownedPtr<v8::Isolate> m_pIsolate;
+ UnownedPtr<v8::Isolate> const m_pIsolate;
v8::Global<v8::Value> m_hValue;
};