summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-12 10:37:52 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-12 10:37:52 -0700
commit08fea801054f3afadb95d0a54efe7da6683c5c5d (patch)
treedc81937c50050c91e6f3ca483d2c0d9d1feceed0
parent5a6c1398d0e559fb6a048cb0dca46ba9f9309a77 (diff)
downloadpdfium-08fea801054f3afadb95d0a54efe7da6683c5c5d.tar.xz
Rename fxjse/ to fxjs/ update files to match class names.
This Cl moves the fxjse/ directory to fxjs/ in anticipation of merging in fpdfsdk/jsapi. In the process the filenames are updated to better match the class contents. Static methods are moved to anonymous namespaces as possible. Review-Url: https://codereview.chromium.org/2136213002
-rw-r--r--BUILD.gn25
-rw-r--r--fpdfsdk/javascript/DEPS2
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp2
-rw-r--r--fpdfsdk/javascript/ijs_runtime.h2
-rw-r--r--fxjs/DEPS (renamed from fxjse/DEPS)0
-rw-r--r--fxjs/cfxjse_arguments.cpp56
-rw-r--r--fxjs/cfxjse_class.cpp433
-rw-r--r--fxjs/cfxjse_context.cpp (renamed from fxjse/context.cpp)69
-rw-r--r--fxjs/cfxjse_isolatetracker.cpp35
-rw-r--r--fxjs/cfxjse_isolatetracker.h (renamed from fxjse/scope_inline.h)47
-rw-r--r--fxjs/cfxjse_runtimedata.cpp (renamed from fxjse/runtime.cpp)65
-rw-r--r--fxjs/cfxjse_runtimedata.h (renamed from fxjse/runtime.h)28
-rw-r--r--fxjs/cfxjse_value.cpp (renamed from fxjse/value.cpp)181
-rw-r--r--fxjs/include/cfxjse_arguments.h (renamed from fxjse/include/cfxjse_arguments.h)8
-rw-r--r--fxjs/include/cfxjse_class.h (renamed from fxjse/include/cfxjse_class.h)14
-rw-r--r--fxjs/include/cfxjse_context.h (renamed from fxjse/context.h)18
-rw-r--r--fxjs/include/cfxjse_value.h102
-rw-r--r--fxjs/include/fxjse.h (renamed from fxjse/include/fxjse.h)6
-rw-r--r--fxjse/class.cpp291
-rw-r--r--fxjse/dynprop.cpp225
-rw-r--r--fxjse/include/cfxjse_value.h238
-rw-r--r--xfa.gyp25
-rw-r--r--xfa/fxfa/DEPS2
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp2
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp2
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp6
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.h3
-rw-r--r--xfa/fxfa/include/fxfa_basic.h4
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.h2
-rw-r--r--xfa/fxfa/parser/xfa_object.h2
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_datawindow.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_datawindow.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_eventpseudomodel.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_hostpseudomodel.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_imp.cpp6
-rw-r--r--xfa/fxfa/parser/xfa_script_imp.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_layoutpseudomodel.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_logpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_logpseudomodel.h2
-rw-r--r--xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/xfa_script_signaturepseudomodel.h2
46 files changed, 977 insertions, 954 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 7e408590ab..277137735f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -889,18 +889,19 @@ if (pdf_enable_xfa) {
static_library("xfa") {
sources = [
- "fxjse/class.cpp",
- "fxjse/context.cpp",
- "fxjse/context.h",
- "fxjse/dynprop.cpp",
- "fxjse/include/cfxjse_arguments.h",
- "fxjse/include/cfxjse_class.h",
- "fxjse/include/cfxjse_value.h",
- "fxjse/include/fxjse.h",
- "fxjse/runtime.cpp",
- "fxjse/runtime.h",
- "fxjse/scope_inline.h",
- "fxjse/value.cpp",
+ "fxjs/cfxjse_arguments.cpp",
+ "fxjs/cfxjse_class.cpp",
+ "fxjs/cfxjse_context.cpp",
+ "fxjs/cfxjse_isolatetracker.cpp",
+ "fxjs/cfxjse_isolatetracker.h",
+ "fxjs/cfxjse_runtimedata.cpp",
+ "fxjs/cfxjse_runtimedata.h",
+ "fxjs/cfxjse_value.cpp",
+ "fxjs/include/cfxjse_arguments.h",
+ "fxjs/include/cfxjse_class.h",
+ "fxjs/include/cfxjse_context.h",
+ "fxjs/include/cfxjse_value.h",
+ "fxjs/include/fxjse.h",
"xfa/fde/cfde_path.cpp",
"xfa/fde/cfde_path.h",
"xfa/fde/cfde_txtedtbuf.cpp",
diff --git a/fpdfsdk/javascript/DEPS b/fpdfsdk/javascript/DEPS
index 3adc40c859..5fb57284d1 100644
--- a/fpdfsdk/javascript/DEPS
+++ b/fpdfsdk/javascript/DEPS
@@ -1,5 +1,5 @@
include_rules = [
'+core/fdrm/crypto/include',
'+core/fpdfapi/fpdf_font/include',
- '+fxjse/include'
+ '+fxjs/include'
]
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 88530f7332..7eaf1451ca 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -31,7 +31,7 @@
#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#endif // PDF_ENABLE_XFA
// static
diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h
index b24a2dd916..cae465a849 100644
--- a/fpdfsdk/javascript/ijs_runtime.h
+++ b/fpdfsdk/javascript/ijs_runtime.h
@@ -11,7 +11,7 @@
#include "core/fxcrt/include/fx_system.h"
#ifdef PDF_ENABLE_XFA
-#include "fxjse/include/fxjse.h"
+#include "fxjs/include/fxjse.h"
#endif // PDF_ENABLE_XFA
class CPDFDoc_Environment;
diff --git a/fxjse/DEPS b/fxjs/DEPS
index 18698e4ce4..18698e4ce4 100644
--- a/fxjse/DEPS
+++ b/fxjs/DEPS
diff --git a/fxjs/cfxjse_arguments.cpp b/fxjs/cfxjse_arguments.cpp
new file mode 100644
index 0000000000..1ff425d8b1
--- /dev/null
+++ b/fxjs/cfxjse_arguments.cpp
@@ -0,0 +1,56 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/include/cfxjse_arguments.h"
+
+#include "fxjs/include/cfxjse_context.h"
+#include "fxjs/include/cfxjse_value.h"
+
+v8::Isolate* CFXJSE_Arguments::GetRuntime() const {
+ return m_pRetValue->GetIsolate();
+}
+
+int32_t CFXJSE_Arguments::GetLength() const {
+ return m_pInfo->Length();
+}
+
+std::unique_ptr<CFXJSE_Value> CFXJSE_Arguments::GetValue(int32_t index) const {
+ std::unique_ptr<CFXJSE_Value> lpArgValue(
+ new CFXJSE_Value(v8::Isolate::GetCurrent()));
+ lpArgValue->ForceSetValue((*m_pInfo)[index]);
+ return lpArgValue;
+}
+
+FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const {
+ return (*m_pInfo)[index]->BooleanValue();
+}
+
+int32_t CFXJSE_Arguments::GetInt32(int32_t index) const {
+ return static_cast<int32_t>((*m_pInfo)[index]->NumberValue());
+}
+
+FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const {
+ return static_cast<FX_FLOAT>((*m_pInfo)[index]->NumberValue());
+}
+
+CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const {
+ v8::Local<v8::String> hString = (*m_pInfo)[index]->ToString();
+ v8::String::Utf8Value szStringVal(hString);
+ return CFX_ByteString(*szStringVal);
+}
+
+CFXJSE_HostObject* CFXJSE_Arguments::GetObject(int32_t index,
+ CFXJSE_Class* pClass) const {
+ v8::Local<v8::Value> hValue = (*m_pInfo)[index];
+ ASSERT(!hValue.IsEmpty());
+ if (!hValue->IsObject())
+ return nullptr;
+ return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
+}
+
+CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
+ return m_pRetValue;
+}
diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp
new file mode 100644
index 0000000000..de22af7681
--- /dev/null
+++ b/fxjs/cfxjse_class.cpp
@@ -0,0 +1,433 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/include/cfxjse_class.h"
+
+#include "fxjs/include/cfxjse_context.h"
+#include "fxjs/include/cfxjse_value.h"
+
+namespace {
+
+void V8FunctionCallback_Wrapper(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ const FXJSE_FUNCTION_DESCRIPTOR* lpFunctionInfo =
+ static_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpFunctionInfo)
+ return;
+
+ CFX_ByteStringC szFunctionName(lpFunctionInfo->name);
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName, impl);
+ if (!lpRetValue->DirectGetValue().IsEmpty())
+ info.GetReturnValue().Set(lpRetValue->DirectGetValue());
+}
+
+void V8ClassGlobalConstructorCallback_Wrapper(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
+ static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpClassDefinition)
+ return;
+
+ CFX_ByteStringC szFunctionName(lpClassDefinition->name);
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl);
+ if (!lpRetValue->DirectGetValue().IsEmpty())
+ info.GetReturnValue().Set(lpRetValue->DirectGetValue());
+}
+
+void V8GetterCallback_Wrapper(v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
+ static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpPropertyInfo)
+ return;
+
+ CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ std::unique_ptr<CFXJSE_Value> lpPropValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ lpPropertyInfo->getProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
+ info.GetReturnValue().Set(lpPropValue->DirectGetValue());
+}
+
+void V8SetterCallback_Wrapper(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<void>& info) {
+ const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
+ static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpPropertyInfo)
+ return;
+
+ CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ std::unique_ptr<CFXJSE_Value> lpPropValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ lpPropValue->ForceSetValue(value);
+ lpPropertyInfo->setProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
+}
+
+void V8ConstructorCallback_Wrapper(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ if (!info.IsConstructCall())
+ return;
+
+ const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
+ static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpClassDefinition)
+ return;
+
+ ASSERT(info.This()->InternalFieldCount());
+ info.This()->SetAlignedPointerInInternalField(0, nullptr);
+}
+
+void Context_GlobalObjToString(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpClass)
+ return;
+
+ if (info.This() == info.Holder() && lpClass->name) {
+ CFX_ByteString szStringVal;
+ szStringVal.Format("[object %s]", lpClass->name);
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(
+ info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString,
+ szStringVal.GetLength()));
+ return;
+ }
+ v8::Local<v8::String> local_str =
+ info.This()
+ ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::String>());
+ info.GetReturnValue().Set(local_str);
+}
+
+void DynPropGetterAdapter_MethodCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
+ FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ hCallBackInfo->GetAlignedPointerFromInternalField(0));
+ v8::Local<v8::String> hPropName =
+ hCallBackInfo->GetInternalField(1).As<v8::String>();
+ ASSERT(lpClass && !hPropName.IsEmpty());
+ v8::String::Utf8Value szPropName(hPropName);
+ CFX_ByteStringC szFxPropName = *szPropName;
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
+ if (!lpRetValue->DirectGetValue().IsEmpty())
+ info.GetReturnValue().Set(lpRetValue->DirectGetValue());
+}
+
+void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* pValue) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType == FXJSE_ClassPropType_Property) {
+ if (lpClass->dynPropGetter)
+ lpClass->dynPropGetter(pObject, szPropName, pValue);
+ } else if (nPropType == FXJSE_ClassPropType_Method) {
+ if (lpClass->dynMethodCall && pValue) {
+ v8::Isolate* pIsolate = pValue->GetIsolate();
+ v8::HandleScope hscope(pIsolate);
+ v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate =
+ v8::ObjectTemplate::New(pIsolate);
+ hCallBackInfoTemplate->SetInternalFieldCount(2);
+ v8::Local<v8::Object> hCallBackInfo =
+ hCallBackInfoTemplate->NewInstance();
+ hCallBackInfo->SetAlignedPointerInInternalField(
+ 0, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClass));
+ hCallBackInfo->SetInternalField(
+ 1, v8::String::NewFromUtf8(
+ pIsolate, reinterpret_cast<const char*>(szPropName.raw_str()),
+ v8::String::kNormalString, szPropName.GetLength()));
+ pValue->ForceSetValue(
+ v8::Function::New(pValue->GetIsolate()->GetCurrentContext(),
+ DynPropGetterAdapter_MethodCallback, hCallBackInfo,
+ 0, v8::ConstructorBehavior::kThrow)
+ .ToLocalChecked());
+ }
+ }
+}
+
+void DynPropSetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* pValue) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType != FXJSE_ClassPropType_Method) {
+ if (lpClass->dynPropSetter)
+ lpClass->dynPropSetter(pObject, szPropName, pValue);
+ }
+}
+
+FX_BOOL DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, TRUE);
+ return nPropType != FXJSE_ClassPropType_None;
+}
+
+FX_BOOL DynPropDeleterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType != FXJSE_ClassPropType_Method) {
+ if (lpClass->dynPropDeleter)
+ return lpClass->dynPropDeleter(pObject, szPropName);
+ return nPropType == FXJSE_ClassPropType_Property ? FALSE : TRUE;
+ }
+ return FALSE;
+}
+
+void NamedPropertyQueryCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Integer>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::HandleScope scope(pIsolate);
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ if (DynPropQueryAdapter(lpClass, lpThisValue.get(), szFxPropName)) {
+ info.GetReturnValue().Set(v8::DontDelete);
+ return;
+ }
+ const int32_t iV8Absent = 64;
+ info.GetReturnValue().Set(iV8Absent);
+}
+
+void NamedPropertyDeleterCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::HandleScope scope(pIsolate);
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ info.GetReturnValue().Set(
+ !!DynPropDeleterAdapter(lpClass, lpThisValue.get(), szFxPropName));
+}
+
+void NamedPropertyGetterCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
+ DynPropGetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
+ lpNewValue.get());
+ info.GetReturnValue().Set(lpNewValue->DirectGetValue());
+}
+
+void NamedPropertySetterCallback(
+ v8::Local<v8::Name> property,
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+
+ CFXJSE_Value* lpNewValue = new CFXJSE_Value(info.GetIsolate());
+ lpNewValue->ForceSetValue(value);
+ DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName, lpNewValue);
+ info.GetReturnValue().Set(value);
+}
+
+void NamedPropertyEnumeratorCallback(
+ const v8::PropertyCallbackInfo<v8::Array>& info) {
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum);
+ for (int i = 0; i < lpClass->propNum; i++) {
+ newArray->Set(
+ i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name));
+ }
+ info.GetReturnValue().Set(newArray);
+}
+
+} // namespace
+
+// static
+CFXJSE_Class* CFXJSE_Class::Create(
+ CFXJSE_Context* lpContext,
+ const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition,
+ FX_BOOL bIsJSGlobal) {
+ if (!lpContext || !lpClassDefinition)
+ return nullptr;
+
+ CFXJSE_Class* pClass =
+ GetClassFromContext(lpContext, lpClassDefinition->name);
+ if (pClass)
+ return pClass;
+
+ v8::Isolate* pIsolate = lpContext->m_pIsolate;
+ pClass = new CFXJSE_Class(lpContext);
+ pClass->m_szClassName = lpClassDefinition->name;
+ pClass->m_lpClassDefinition = lpClassDefinition;
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
+ v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New(
+ pIsolate, bIsJSGlobal ? 0 : V8ConstructorCallback_Wrapper,
+ v8::External::New(
+ pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
+ hFunctionTemplate->SetClassName(
+ v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name));
+ hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1);
+ v8::Local<v8::ObjectTemplate> hObjectTemplate =
+ hFunctionTemplate->InstanceTemplate();
+ SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition);
+
+ if (lpClassDefinition->propNum) {
+ for (int32_t i = 0; i < lpClassDefinition->propNum; i++) {
+ hObjectTemplate->SetNativeDataProperty(
+ v8::String::NewFromUtf8(pIsolate,
+ lpClassDefinition->properties[i].name),
+ lpClassDefinition->properties[i].getProc ? V8GetterCallback_Wrapper
+ : nullptr,
+ lpClassDefinition->properties[i].setProc ? V8SetterCallback_Wrapper
+ : nullptr,
+ v8::External::New(pIsolate, const_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
+ lpClassDefinition->properties + i)),
+ static_cast<v8::PropertyAttribute>(v8::DontDelete));
+ }
+ }
+ if (lpClassDefinition->methNum) {
+ for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, V8FunctionCallback_Wrapper,
+ v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
+ lpClassDefinition->methods + i)));
+ fun->RemovePrototype();
+ hObjectTemplate->Set(
+ v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name),
+ fun,
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+ }
+ }
+ if (lpClassDefinition->constructor) {
+ if (bIsJSGlobal) {
+ hObjectTemplate->Set(
+ v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
+ v8::FunctionTemplate::New(
+ pIsolate, V8ClassGlobalConstructorCallback_Wrapper,
+ v8::External::New(pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ lpClassDefinition))),
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+ } else {
+ v8::Local<v8::Context> hLocalContext =
+ v8::Local<v8::Context>::New(pIsolate, lpContext->m_hContext);
+ FXJSE_GetGlobalObjectFromContext(hLocalContext)
+ ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
+ v8::Function::New(
+ pIsolate, V8ClassGlobalConstructorCallback_Wrapper,
+ v8::External::New(pIsolate,
+ const_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ lpClassDefinition))));
+ }
+ }
+ if (bIsJSGlobal) {
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, Context_GlobalObjToString,
+ v8::External::New(
+ pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
+ fun->RemovePrototype();
+ hObjectTemplate->Set(v8::String::NewFromUtf8(pIsolate, "toString"), fun);
+ }
+ pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate);
+ lpContext->m_rgClasses.push_back(std::unique_ptr<CFXJSE_Class>(pClass));
+ return pClass;
+}
+
+// static
+CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext,
+ const CFX_ByteStringC& szName) {
+ for (const auto& pClass : pContext->m_rgClasses) {
+ if (pClass->m_szClassName == szName)
+ return pClass.get();
+ }
+ return nullptr;
+}
+
+// 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,
+ lpClassDefinition->dynPropDeleter ? NamedPropertyDeleterCallback : 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() {}
diff --git a/fxjse/context.cpp b/fxjs/cfxjse_context.cpp
index 9c43830997..4b0d0f67f7 100644
--- a/fxjse/context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -1,14 +1,13 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fxjse/context.h"
+#include "fxjs/include/cfxjse_context.h"
-#include "fxjse/include/cfxjse_class.h"
-#include "fxjse/include/cfxjse_value.h"
-#include "fxjse/scope_inline.h"
+#include "fxjs/include/cfxjse_class.h"
+#include "fxjs/include/cfxjse_value.h"
namespace {
@@ -41,6 +40,34 @@ const FX_CHAR szCompatibleModeScript[] =
} // namespace
+// Note, not in the anonymous namespace due to the friend call
+// in cfxjse_context.h
+// TODO(dsinclair): Remove the friending, use public methods.
+class CFXJSE_ScopeUtil_IsolateHandleContext {
+ public:
+ explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext)
+ : m_context(pContext),
+ m_parent(pContext->m_pIsolate),
+ m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate,
+ pContext->m_hContext)) {}
+ v8::Isolate* GetIsolate() { return m_context->m_pIsolate; }
+ v8::Local<v8::Context> GetLocalContext() {
+ return v8::Local<v8::Context>::New(m_context->m_pIsolate,
+ m_context->m_hContext);
+ }
+
+ private:
+ CFXJSE_ScopeUtil_IsolateHandleContext(
+ const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete;
+ void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+
+ CFXJSE_Context* m_context;
+ CFXJSE_ScopeUtil_IsolateHandle m_parent;
+ v8::Context::Scope m_cscope;
+};
+
v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext(
const v8::Local<v8::Context>& hContext) {
return hContext->Global()->GetPrototype().As<v8::Object>();
@@ -58,27 +85,25 @@ CFXJSE_HostObject* FXJSE_RetrieveObjectBinding(
const v8::Local<v8::Object>& hJSObject,
CFXJSE_Class* lpClass) {
ASSERT(!hJSObject.IsEmpty());
- if (!hJSObject->IsObject()) {
+ if (!hJSObject->IsObject())
return nullptr;
- }
+
v8::Local<v8::Object> hObject = hJSObject;
if (hObject->InternalFieldCount() == 0) {
v8::Local<v8::Value> hProtoObject = hObject->GetPrototype();
- if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) {
+ if (hProtoObject.IsEmpty() || !hProtoObject->IsObject())
return nullptr;
- }
+
hObject = hProtoObject.As<v8::Object>();
- if (hObject->InternalFieldCount() == 0) {
+ if (hObject->InternalFieldCount() == 0)
return nullptr;
- }
}
if (lpClass) {
v8::Local<v8::FunctionTemplate> hClass =
v8::Local<v8::FunctionTemplate>::New(
lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate());
- if (!hClass->HasInstance(hObject)) {
+ if (!hClass->HasInstance(hObject))
return nullptr;
- }
}
return static_cast<CFXJSE_HostObject*>(
hObject->GetAlignedPointerFromInternalField(0));
@@ -94,18 +119,17 @@ v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
v8::Local<v8::Value> hValue;
hValue = hException.As<v8::Object>()->Get(
v8::String::NewFromUtf8(pIsolate, "name"));
- if (hValue->IsString() || hValue->IsStringObject()) {
+ if (hValue->IsString() || hValue->IsStringObject())
hReturnValue->Set(0, hValue);
- } else {
+ else
hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error"));
- }
+
hValue = hException.As<v8::Object>()->Get(
v8::String::NewFromUtf8(pIsolate, "message"));
- if (hValue->IsString() || hValue->IsStringObject()) {
+ if (hValue->IsString() || hValue->IsStringObject())
hReturnValue->Set(1, hValue);
- } else {
+ else
hReturnValue->Set(1, hMessage->Get());
- }
} else {
hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error"));
hReturnValue->Set(1, hMessage->Get());
@@ -122,13 +146,14 @@ v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
return hReturnValue;
}
+// static
CFXJSE_Context* CFXJSE_Context::Create(
v8::Isolate* pIsolate,
const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass,
CFXJSE_HostObject* lpGlobalObject) {
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate);
- CFXJSE_Class* lpGlobalClassObj = NULL;
+ CFXJSE_Class* lpGlobalClassObj = nullptr;
v8::Local<v8::ObjectTemplate> hObjectTemplate;
if (lpGlobalClass) {
lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE);
@@ -146,7 +171,7 @@ CFXJSE_Context* CFXJSE_Context::Create(
v8::String::NewFromUtf8(pIsolate, "global", v8::NewStringType::kNormal)
.ToLocalChecked());
v8::Local<v8::Context> hNewContext =
- v8::Context::New(pIsolate, NULL, hObjectTemplate);
+ v8::Context::New(pIsolate, nullptr, hObjectTemplate);
v8::Local<v8::Context> hRootContext = v8::Local<v8::Context>::New(
pIsolate, CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext);
hNewContext->SetSecurityToken(hRootContext->GetSecurityToken());
@@ -184,7 +209,7 @@ FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript,
v8::TryCatch trycatch(m_pIsolate);
v8::Local<v8::String> hScriptString =
v8::String::NewFromUtf8(m_pIsolate, szScript);
- if (lpNewThisObject == NULL) {
+ if (!lpNewThisObject) {
v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString);
if (!trycatch.HasCaught()) {
v8::Local<v8::Value> hValue = hScript->Run();
diff --git a/fxjs/cfxjse_isolatetracker.cpp b/fxjs/cfxjse_isolatetracker.cpp
new file mode 100644
index 0000000000..9594df3109
--- /dev/null
+++ b/fxjs/cfxjse_isolatetracker.cpp
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/cfxjse_isolatetracker.h"
+
+#include <algorithm>
+
+CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {}
+
+CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {}
+
+void CFXJSE_IsolateTracker::Append(v8::Isolate* pIsolate) {
+ m_OwnedIsolates.push_back(pIsolate);
+}
+
+void CFXJSE_IsolateTracker::Remove(
+ v8::Isolate* pIsolate,
+ CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
+ auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate);
+ bool bFound = it != m_OwnedIsolates.end();
+ if (bFound)
+ m_OwnedIsolates.erase(it);
+ lpfnDisposeCallback(pIsolate, bFound);
+}
+
+void CFXJSE_IsolateTracker::RemoveAll(
+ CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
+ for (v8::Isolate* pIsolate : m_OwnedIsolates)
+ lpfnDisposeCallback(pIsolate, true);
+
+ m_OwnedIsolates.clear();
+}
diff --git a/fxjse/scope_inline.h b/fxjs/cfxjse_isolatetracker.h
index 64eb6a79bf..7558416a14 100644
--- a/fxjse/scope_inline.h
+++ b/fxjs/cfxjse_isolatetracker.h
@@ -1,14 +1,17 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_SCOPE_INLINE_H_
-#define FXJSE_SCOPE_INLINE_H_
+#ifndef FXJS_CFXJSE_ISOLATETRACKER_H_
+#define FXJS_CFXJSE_ISOLATETRACKER_H_
-#include "fxjse/context.h"
-#include "fxjse/runtime.h"
+#include <vector>
+
+#include "v8/include/v8.h"
+
+#include "fxjs/cfxjse_runtimedata.h"
class CFXJSE_ScopeUtil_IsolateHandle {
public:
@@ -47,29 +50,21 @@ class CFXJSE_ScopeUtil_IsolateHandleRootContext {
v8::Context::Scope m_cscope;
};
-class CFXJSE_ScopeUtil_IsolateHandleContext {
+class CFXJSE_IsolateTracker {
public:
- explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext)
- : m_context(pContext),
- m_parent(pContext->m_pIsolate),
- m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate,
- pContext->m_hContext)) {}
- v8::Isolate* GetIsolate() { return m_context->m_pIsolate; }
- v8::Local<v8::Context> GetLocalContext() {
- return v8::Local<v8::Context>::New(m_context->m_pIsolate,
- m_context->m_hContext);
- }
+ typedef void (*DisposeCallback)(v8::Isolate*, bool bOwnedIsolate);
- private:
- CFXJSE_ScopeUtil_IsolateHandleContext(
- const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete;
- void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete;
- void* operator new(size_t size) = delete;
- void operator delete(void*, size_t) = delete;
+ CFXJSE_IsolateTracker();
+ ~CFXJSE_IsolateTracker();
- CFXJSE_Context* m_context;
- CFXJSE_ScopeUtil_IsolateHandle m_parent;
- v8::Context::Scope m_cscope;
+ void Append(v8::Isolate* pIsolate);
+ void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback);
+ void RemoveAll(DisposeCallback lpfnDisposeCallback);
+
+ static CFXJSE_IsolateTracker* g_pInstance;
+
+ protected:
+ std::vector<v8::Isolate*> m_OwnedIsolates;
};
-#endif // FXJSE_SCOPE_INLINE_H_
+#endif // FXJS_CFXJSE_ISOLATETRACKER_H_
diff --git a/fxjse/runtime.cpp b/fxjs/cfxjse_runtimedata.cpp
index b5f2f33a75..f58f5f852d 100644
--- a/fxjse/runtime.cpp
+++ b/fxjs/cfxjse_runtimedata.cpp
@@ -1,15 +1,15 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fxjse/runtime.h"
-
-#include <algorithm>
+#include "fxjs/cfxjse_runtimedata.h"
#include "fpdfsdk/jsapi/include/fxjs_v8.h"
-#include "fxjse/scope_inline.h"
+#include "fxjs/cfxjse_isolatetracker.h"
+
+namespace {
// Duplicates fpdfsdk's cjs_runtime.h, but keeps XFA from depending on it.
// TODO(tsepez): make a single version of this.
@@ -19,10 +19,21 @@ class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void Free(void* data, size_t length) override { free(data); }
};
-static void FXJSE_KillV8() {
+void Runtime_DisposeCallback(v8::Isolate* pIsolate, bool bOwned) {
+ if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) {
+ delete pData->m_pFXJSERuntimeData;
+ pData->m_pFXJSERuntimeData = nullptr;
+ }
+ if (bOwned)
+ pIsolate->Dispose();
+}
+
+void KillV8() {
v8::V8::Dispose();
}
+} // namespace
+
void FXJSE_Initialize() {
if (!CFXJSE_IsolateTracker::g_pInstance)
CFXJSE_IsolateTracker::g_pInstance = new CFXJSE_IsolateTracker;
@@ -32,23 +43,14 @@ void FXJSE_Initialize() {
return;
bV8Initialized = TRUE;
- atexit(FXJSE_KillV8);
-}
-
-static void FXJSE_Runtime_DisposeCallback(v8::Isolate* pIsolate, bool bOwned) {
- if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) {
- delete pData->m_pFXJSERuntimeData;
- pData->m_pFXJSERuntimeData = nullptr;
- }
- if (bOwned)
- pIsolate->Dispose();
+ atexit(KillV8);
}
void FXJSE_Finalize() {
if (!CFXJSE_IsolateTracker::g_pInstance)
return;
- CFXJSE_IsolateTracker::g_pInstance->RemoveAll(FXJSE_Runtime_DisposeCallback);
+ CFXJSE_IsolateTracker::g_pInstance->RemoveAll(Runtime_DisposeCallback);
delete CFXJSE_IsolateTracker::g_pInstance;
CFXJSE_IsolateTracker::g_pInstance = nullptr;
}
@@ -65,8 +67,7 @@ v8::Isolate* FXJSE_Runtime_Create_Own() {
void FXJSE_Runtime_Release(v8::Isolate* pIsolate) {
if (!pIsolate)
return;
- CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate,
- FXJSE_Runtime_DisposeCallback);
+ CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate, Runtime_DisposeCallback);
}
CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate)
@@ -102,29 +103,3 @@ CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
}
CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr;
-
-CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {}
-
-CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {}
-
-void CFXJSE_IsolateTracker::Append(v8::Isolate* pIsolate) {
- m_OwnedIsolates.push_back(pIsolate);
-}
-
-void CFXJSE_IsolateTracker::Remove(
- v8::Isolate* pIsolate,
- CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
- auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate);
- bool bFound = it != m_OwnedIsolates.end();
- if (bFound)
- m_OwnedIsolates.erase(it);
- lpfnDisposeCallback(pIsolate, bFound);
-}
-
-void CFXJSE_IsolateTracker::RemoveAll(
- CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) {
- for (v8::Isolate* pIsolate : m_OwnedIsolates)
- lpfnDisposeCallback(pIsolate, true);
-
- m_OwnedIsolates.clear();
-}
diff --git a/fxjse/runtime.h b/fxjs/cfxjse_runtimedata.h
index ff3be3a521..34f8f32d92 100644
--- a/fxjse/runtime.h
+++ b/fxjs/cfxjse_runtimedata.h
@@ -1,15 +1,12 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_RUNTIME_H_
-#define FXJSE_RUNTIME_H_
+#ifndef FXJS_CFXJSE_RUNTIMEDATA_H_
+#define FXJS_CFXJSE_RUNTIMEDATA_H_
-#include <vector>
-
-#include "core/fxcrt/include/fx_basic.h"
#include "v8/include/v8.h"
class CFXJSE_RuntimeList;
@@ -34,21 +31,4 @@ class CFXJSE_RuntimeData {
CFXJSE_RuntimeData& operator=(const CFXJSE_RuntimeData&) = delete;
};
-class CFXJSE_IsolateTracker {
- public:
- typedef void (*DisposeCallback)(v8::Isolate*, bool bOwnedIsolate);
-
- CFXJSE_IsolateTracker();
- ~CFXJSE_IsolateTracker();
-
- void Append(v8::Isolate* pIsolate);
- void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback);
- void RemoveAll(DisposeCallback lpfnDisposeCallback);
-
- static CFXJSE_IsolateTracker* g_pInstance;
-
- protected:
- std::vector<v8::Isolate*> m_OwnedIsolates;
-};
-
-#endif // FXJSE_RUNTIME_H_
+#endif // FXJS_CFXJSE_RUNTIMEDATA_H_
diff --git a/fxjse/value.cpp b/fxjs/cfxjse_value.cpp
index aba640210a..b1fc0784e8 100644
--- a/fxjse/value.cpp
+++ b/fxjs/cfxjse_value.cpp
@@ -4,16 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#include <math.h>
-#include "fxjse/context.h"
-#include "fxjse/include/cfxjse_class.h"
+#include "fxjs/include/cfxjse_class.h"
+#include "fxjs/include/cfxjse_context.h"
namespace {
-double FXJSE_ftod(FX_FLOAT fNumber) {
+double ftod(FX_FLOAT fNumber) {
static_assert(sizeof(FX_FLOAT) == 4, "FX_FLOAT of incorrect size");
uint32_t nFloatBits = (uint32_t&)fNumber;
@@ -124,7 +124,7 @@ void CFXJSE_Value::SetDate(double dDouble) {
void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) {
CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> pValue = v8::Number::New(m_pIsolate, FXJSE_ftod(fFloat));
+ v8::Local<v8::Value> pValue = v8::Number::New(m_pIsolate, ftod(fFloat));
m_hValue.Reset(m_pIsolate, pValue);
}
@@ -346,3 +346,174 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver,
}
return bRetValue;
}
+
+FX_BOOL CFXJSE_Value::IsUndefined() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsUndefined();
+}
+
+FX_BOOL CFXJSE_Value::IsNull() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsNull();
+}
+
+FX_BOOL CFXJSE_Value::IsBoolean() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsBoolean();
+}
+
+FX_BOOL CFXJSE_Value::IsString() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsString();
+}
+
+FX_BOOL CFXJSE_Value::IsNumber() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsNumber();
+}
+
+FX_BOOL CFXJSE_Value::IsInteger() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsInt32();
+}
+
+FX_BOOL CFXJSE_Value::IsObject() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsObject();
+}
+
+FX_BOOL CFXJSE_Value::IsArray() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsArray();
+}
+
+FX_BOOL CFXJSE_Value::IsFunction() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsFunction();
+}
+
+FX_BOOL CFXJSE_Value::IsDate() const {
+ if (m_hValue.IsEmpty())
+ return FALSE;
+
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return hValue->IsDate();
+}
+
+FX_BOOL CFXJSE_Value::ToBoolean() const {
+ ASSERT(!m_hValue.IsEmpty());
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return static_cast<FX_BOOL>(hValue->BooleanValue());
+}
+
+FX_FLOAT CFXJSE_Value::ToFloat() const {
+ ASSERT(!m_hValue.IsEmpty());
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return static_cast<FX_FLOAT>(hValue->NumberValue());
+}
+
+double CFXJSE_Value::ToDouble() const {
+ ASSERT(!m_hValue.IsEmpty());
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return static_cast<double>(hValue->NumberValue());
+}
+
+int32_t CFXJSE_Value::ToInteger() const {
+ ASSERT(!m_hValue.IsEmpty());
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ return static_cast<int32_t>(hValue->NumberValue());
+}
+
+CFX_ByteString CFXJSE_Value::ToString() const {
+ ASSERT(!m_hValue.IsEmpty());
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
+ v8::Local<v8::String> hString = hValue->ToString();
+ v8::String::Utf8Value hStringVal(hString);
+ return CFX_ByteString(*hStringVal);
+}
+
+void CFXJSE_Value::SetUndefined() {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetNull() {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Null(m_pIsolate);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetBoolean(FX_BOOL bBoolean) {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Boolean::New(m_pIsolate, bBoolean != FALSE);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetInteger(int32_t nInteger) {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetDouble(double dDouble) {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetString(const CFX_ByteStringC& szString) {
+ CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::String::NewFromUtf8(
+ m_pIsolate, reinterpret_cast<const char*>(szString.raw_str()),
+ v8::String::kNormalString, szString.GetLength());
+ m_hValue.Reset(m_pIsolate, hValue);
+}
+
+void CFXJSE_Value::SetJSObject() {
+ CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
+ v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate);
+ m_hValue.Reset(m_pIsolate, hValue);
+}
diff --git a/fxjse/include/cfxjse_arguments.h b/fxjs/include/cfxjse_arguments.h
index 0f9bddaa87..e6c8659732 100644
--- a/fxjse/include/cfxjse_arguments.h
+++ b/fxjs/include/cfxjse_arguments.h
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_INCLUDE_CFXJSE_ARGUMENTS_H_
-#define FXJSE_INCLUDE_CFXJSE_ARGUMENTS_H_
+#ifndef FXJS_INCLUDE_CFXJSE_ARGUMENTS_H_
+#define FXJS_INCLUDE_CFXJSE_ARGUMENTS_H_
#include <memory>
-#include "fxjse/include/fxjse.h"
+#include "fxjs/include/fxjse.h"
class CFXJSE_Class;
@@ -35,4 +35,4 @@ class CFXJSE_Arguments {
CFXJSE_Value* m_pRetValue;
};
-#endif // FXJSE_INCLUDE_CFXJSE_ARGUMENTS_H_
+#endif // FXJS_INCLUDE_CFXJSE_ARGUMENTS_H_
diff --git a/fxjse/include/cfxjse_class.h b/fxjs/include/cfxjse_class.h
index b4953d21d3..13eb1adb7d 100644
--- a/fxjse/include/cfxjse_class.h
+++ b/fxjs/include/cfxjse_class.h
@@ -4,11 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_INCLUDE_CFXJSE_CLASS_H_
-#define FXJSE_INCLUDE_CFXJSE_CLASS_H_
+#ifndef FXJS_INCLUDE_CFXJSE_CLASS_H_
+#define FXJS_INCLUDE_CFXJSE_CLASS_H_
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/fxjse.h"
+#include "fxjs/include/cfxjse_arguments.h"
+#include "fxjs/include/fxjse.h"
#include "v8/include/v8.h"
class CFXJSE_Context;
@@ -16,8 +16,6 @@ class CFXJSE_Value;
class CFXJSE_Class {
public:
- ~CFXJSE_Class();
-
static CFXJSE_Class* Create(CFXJSE_Context* pContext,
const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion,
FX_BOOL bIsJSGlobal = FALSE);
@@ -28,6 +26,8 @@ class CFXJSE_Class {
v8::Local<v8::ObjectTemplate>& hObjectTemplate,
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition);
+ ~CFXJSE_Class();
+
CFXJSE_Context* GetContext() { return m_pContext; }
v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
@@ -42,4 +42,4 @@ class CFXJSE_Class {
friend class CFXJSE_Value;
};
-#endif // FXJSE_INCLUDE_CFXJSE_CLASS_H_
+#endif // FXJS_INCLUDE_CFXJSE_CLASS_H_
diff --git a/fxjse/context.h b/fxjs/include/cfxjse_context.h
index 3cc7123f55..882258fe57 100644
--- a/fxjse/context.h
+++ b/fxjs/include/cfxjse_context.h
@@ -1,17 +1,17 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_CONTEXT_H_
-#define FXJSE_CONTEXT_H_
+#ifndef FXJS_INCLUDE_CFXJSE_CONTEXT_H_
+#define FXJS_INCLUDE_CFXJSE_CONTEXT_H_
#include <memory>
#include <vector>
#include "core/fxcrt/include/fx_basic.h"
-#include "fxjse/include/fxjse.h"
+#include "fxjs/include/fxjse.h"
#include "v8/include/v8.h"
class CFXJSE_Class;
@@ -24,6 +24,7 @@ class CFXJSE_Context {
v8::Isolate* pIsolate,
const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr,
CFXJSE_HostObject* lpGlobalObject = nullptr);
+
~CFXJSE_Context();
v8::Isolate* GetRuntime() { return m_pIsolate; }
@@ -34,17 +35,18 @@ class CFXJSE_Context {
CFXJSE_Value* lpNewThisObject = nullptr);
protected:
+ friend class CFXJSE_Class;
+ friend class CFXJSE_ScopeUtil_IsolateHandleContext;
+
CFXJSE_Context();
CFXJSE_Context(const CFXJSE_Context&);
explicit CFXJSE_Context(v8::Isolate* pIsolate);
+
CFXJSE_Context& operator=(const CFXJSE_Context&);
v8::Global<v8::Context> m_hContext;
v8::Isolate* m_pIsolate;
std::vector<std::unique_ptr<CFXJSE_Class>> m_rgClasses;
-
- friend class CFXJSE_Class;
- friend class CFXJSE_ScopeUtil_IsolateHandleContext;
};
v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
@@ -60,4 +62,4 @@ CFXJSE_HostObject* FXJSE_RetrieveObjectBinding(
const v8::Local<v8::Object>& hJSObject,
CFXJSE_Class* lpClass = nullptr);
-#endif // FXJSE_CONTEXT_H_
+#endif // FXJS_INCLUDE_CFXJSE_CONTEXT_H_
diff --git a/fxjs/include/cfxjse_value.h b/fxjs/include/cfxjse_value.h
new file mode 100644
index 0000000000..7bb2c2d235
--- /dev/null
+++ b/fxjs/include/cfxjse_value.h
@@ -0,0 +1,102 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_INCLUDE_CFXJSE_VALUE_H_
+#define FXJS_INCLUDE_CFXJSE_VALUE_H_
+
+#include "v8/include/v8.h"
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "fxjs/cfxjse_isolatetracker.h"
+#include "fxjs/cfxjse_runtimedata.h"
+
+class CFXJSE_Class;
+class CFXJSE_HostObject;
+
+class CFXJSE_Value {
+ public:
+ explicit CFXJSE_Value(v8::Isolate* pIsolate);
+ ~CFXJSE_Value();
+
+ FX_BOOL IsUndefined() const;
+ FX_BOOL IsNull() const;
+ FX_BOOL IsBoolean() const;
+ FX_BOOL IsString() const;
+ FX_BOOL IsNumber() const;
+ FX_BOOL IsInteger() const;
+ FX_BOOL IsObject() const;
+ FX_BOOL IsArray() const;
+ FX_BOOL IsFunction() const;
+ FX_BOOL IsDate() const;
+ FX_BOOL ToBoolean() const;
+ FX_FLOAT ToFloat() const;
+ double ToDouble() const;
+ int32_t ToInteger() const;
+ CFX_ByteString ToString() const;
+ CFX_WideString ToWideString() const {
+ return CFX_WideString::FromUTF8(ToString().AsStringC());
+ }
+ CFXJSE_HostObject* ToHostObject(CFXJSE_Class* lpClass) const;
+
+ void SetUndefined();
+ void SetNull();
+ void SetBoolean(FX_BOOL bBoolean);
+ void SetInteger(int32_t nInteger);
+ void SetDouble(double dDouble);
+ void SetString(const CFX_ByteStringC& szString);
+ void SetFloat(FX_FLOAT fFloat);
+ void SetJSObject();
+
+ void SetObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* pClass);
+ void SetHostObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* lpClass);
+ void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues);
+ void SetDate(double dDouble);
+
+ FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* lpPropValue);
+ FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* lpPropValue);
+ FX_BOOL GetObjectPropertyByIdx(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
+ FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
+ FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName);
+ FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName,
+ FX_BOOL bUseTypeGetter);
+ FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* lpPropValue);
+ FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis);
+ FX_BOOL Call(CFXJSE_Value* lpReceiver,
+ CFXJSE_Value* lpRetValue,
+ uint32_t nArgCount,
+ CFXJSE_Value** lpArgs);
+
+ v8::Isolate* GetIsolate() const { return m_pIsolate; }
+ const v8::Global<v8::Value>& DirectGetValue() const { return m_hValue; }
+ void ForceSetValue(v8::Local<v8::Value> hValue) {
+ m_hValue.Reset(m_pIsolate, hValue);
+ }
+ void Assign(const CFXJSE_Value* lpValue) {
+ ASSERT(lpValue);
+ if (lpValue) {
+ m_hValue.Reset(m_pIsolate, lpValue->m_hValue);
+ } else {
+ m_hValue.Reset();
+ }
+ }
+
+ private:
+ friend class CFXJSE_Class;
+ friend class CFXJSE_Context;
+
+ CFXJSE_Value();
+ CFXJSE_Value(const CFXJSE_Value&);
+ CFXJSE_Value& operator=(const CFXJSE_Value&);
+
+ v8::Isolate* m_pIsolate;
+ v8::Global<v8::Value> m_hValue;
+};
+
+#endif // FXJS_INCLUDE_CFXJSE_VALUE_H_
diff --git a/fxjse/include/fxjse.h b/fxjs/include/fxjse.h
index f9d6a67e02..79c32b053a 100644
--- a/fxjse/include/fxjse.h
+++ b/fxjs/include/fxjse.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FXJSE_INCLUDE_FXJSE_H_
-#define FXJSE_INCLUDE_FXJSE_H_
+#ifndef FXJS_INCLUDE_FXJSE_H_
+#define FXJS_INCLUDE_FXJSE_H_
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
@@ -71,4 +71,4 @@ void FXJSE_Runtime_Release(v8::Isolate* pIsolate);
void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message);
-#endif // FXJSE_INCLUDE_FXJSE_H_
+#endif // FXJS_INCLUDE_FXJSE_H_
diff --git a/fxjse/class.cpp b/fxjse/class.cpp
deleted file mode 100644
index a4ed0916bd..0000000000
--- a/fxjse/class.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fxjse/include/cfxjse_class.h"
-
-#include "fxjse/context.h"
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/cfxjse_value.h"
-#include "fxjse/scope_inline.h"
-
-static void FXJSE_V8ConstructorCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info);
-static void FXJSE_V8FunctionCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info);
-static void FXJSE_V8GetterCallback_Wrapper(
- v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
-static void FXJSE_V8SetterCallback_Wrapper(
- v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info);
-
-static void FXJSE_V8FunctionCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- const FXJSE_FUNCTION_DESCRIPTOR* lpFunctionInfo =
- static_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpFunctionInfo) {
- return;
- }
- CFX_ByteStringC szFunctionName(lpFunctionInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(info.This());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_Arguments impl(&info, lpRetValue.get());
- lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty()) {
- info.GetReturnValue().Set(lpRetValue->DirectGetValue());
- }
-}
-
-static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
- static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpClassDefinition) {
- return;
- }
- CFX_ByteStringC szFunctionName(lpClassDefinition->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(info.This());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_Arguments impl(&info, lpRetValue.get());
- lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty()) {
- info.GetReturnValue().Set(lpRetValue->DirectGetValue());
- }
-}
-
-static void FXJSE_V8GetterCallback_Wrapper(
- v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
- static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpPropertyInfo) {
- return;
- }
- CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- std::unique_ptr<CFXJSE_Value> lpPropValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(info.This());
- lpPropertyInfo->getProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
- info.GetReturnValue().Set(lpPropValue->DirectGetValue());
-}
-
-static void FXJSE_V8SetterCallback_Wrapper(
- v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info) {
- const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
- static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpPropertyInfo) {
- return;
- }
- CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- std::unique_ptr<CFXJSE_Value> lpPropValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(info.This());
- lpPropValue->ForceSetValue(value);
- lpPropertyInfo->setProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
-}
-
-static void FXJSE_V8ConstructorCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- if (!info.IsConstructCall()) {
- return;
- }
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
- static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpClassDefinition) {
- return;
- }
- ASSERT(info.This()->InternalFieldCount());
- info.This()->SetAlignedPointerInInternalField(0, NULL);
-}
-
-v8::Isolate* CFXJSE_Arguments::GetRuntime() const {
- return m_pRetValue->GetIsolate();
-}
-
-int32_t CFXJSE_Arguments::GetLength() const {
- return m_pInfo->Length();
-}
-
-std::unique_ptr<CFXJSE_Value> CFXJSE_Arguments::GetValue(int32_t index) const {
- std::unique_ptr<CFXJSE_Value> lpArgValue(
- new CFXJSE_Value(v8::Isolate::GetCurrent()));
- lpArgValue->ForceSetValue((*m_pInfo)[index]);
- return lpArgValue;
-}
-
-FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const {
- return (*m_pInfo)[index]->BooleanValue();
-}
-
-int32_t CFXJSE_Arguments::GetInt32(int32_t index) const {
- return static_cast<int32_t>((*m_pInfo)[index]->NumberValue());
-}
-
-FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const {
- return static_cast<FX_FLOAT>((*m_pInfo)[index]->NumberValue());
-}
-
-CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const {
- v8::Local<v8::String> hString = (*m_pInfo)[index]->ToString();
- v8::String::Utf8Value szStringVal(hString);
- return CFX_ByteString(*szStringVal);
-}
-
-CFXJSE_HostObject* CFXJSE_Arguments::GetObject(int32_t index,
- CFXJSE_Class* pClass) const {
- v8::Local<v8::Value> hValue = (*m_pInfo)[index];
- ASSERT(!hValue.IsEmpty());
- if (!hValue->IsObject())
- return nullptr;
- return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
-}
-
-CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
- return m_pRetValue;
-}
-
-static void FXJSE_Context_GlobalObjToString(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- if (!lpClass) {
- return;
- }
- if (info.This() == info.Holder() && lpClass->name) {
- CFX_ByteString szStringVal;
- szStringVal.Format("[object %s]", lpClass->name);
- info.GetReturnValue().Set(v8::String::NewFromUtf8(
- info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString,
- szStringVal.GetLength()));
- } else {
- v8::Local<v8::String> local_str =
- info.This()
- ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext())
- .FromMaybe(v8::Local<v8::String>());
- info.GetReturnValue().Set(local_str);
- }
-}
-
-CFXJSE_Class* CFXJSE_Class::Create(
- CFXJSE_Context* lpContext,
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition,
- FX_BOOL bIsJSGlobal) {
- if (!lpContext || !lpClassDefinition) {
- return NULL;
- }
- CFXJSE_Class* pClass =
- GetClassFromContext(lpContext, lpClassDefinition->name);
- if (pClass) {
- return pClass;
- }
- v8::Isolate* pIsolate = lpContext->m_pIsolate;
- pClass = new CFXJSE_Class(lpContext);
- pClass->m_szClassName = lpClassDefinition->name;
- pClass->m_lpClassDefinition = lpClassDefinition;
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
- v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New(
- pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper,
- v8::External::New(
- pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
- hFunctionTemplate->SetClassName(
- v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name));
- hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1);
- v8::Local<v8::ObjectTemplate> hObjectTemplate =
- hFunctionTemplate->InstanceTemplate();
- SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition);
-
- if (lpClassDefinition->propNum) {
- for (int32_t i = 0; i < lpClassDefinition->propNum; i++) {
- hObjectTemplate->SetNativeDataProperty(
- v8::String::NewFromUtf8(pIsolate,
- lpClassDefinition->properties[i].name),
- lpClassDefinition->properties[i].getProc
- ? FXJSE_V8GetterCallback_Wrapper
- : NULL,
- lpClassDefinition->properties[i].setProc
- ? FXJSE_V8SetterCallback_Wrapper
- : NULL,
- v8::External::New(pIsolate, const_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
- lpClassDefinition->properties + i)),
- static_cast<v8::PropertyAttribute>(v8::DontDelete));
- }
- }
- if (lpClassDefinition->methNum) {
- for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
- v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8FunctionCallback_Wrapper,
- v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
- lpClassDefinition->methods + i)));
- fun->RemovePrototype();
- hObjectTemplate->Set(
- v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name),
- fun,
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
- }
- }
- if (lpClassDefinition->constructor) {
- if (bIsJSGlobal) {
- hObjectTemplate->Set(
- v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
- v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(
- lpClassDefinition))),
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
- } else {
- v8::Local<v8::Context> hLocalContext =
- v8::Local<v8::Context>::New(pIsolate, lpContext->m_hContext);
- FXJSE_GetGlobalObjectFromContext(hLocalContext)
- ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
- v8::Function::New(
- pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper,
- v8::External::New(pIsolate,
- const_cast<FXJSE_CLASS_DESCRIPTOR*>(
- lpClassDefinition))));
- }
- }
- if (bIsJSGlobal) {
- v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
- pIsolate, FXJSE_Context_GlobalObjToString,
- v8::External::New(
- pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
- fun->RemovePrototype();
- hObjectTemplate->Set(v8::String::NewFromUtf8(pIsolate, "toString"), fun);
- }
- pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate);
- lpContext->m_rgClasses.push_back(std::unique_ptr<CFXJSE_Class>(pClass));
- return pClass;
-}
-
-CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext)
- : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
-
-CFXJSE_Class::~CFXJSE_Class() {}
-
-CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext,
- const CFX_ByteStringC& szName) {
- for (const auto& pClass : pContext->m_rgClasses) {
- if (pClass->m_szClassName == szName)
- return pClass.get();
- }
- return nullptr;
-}
diff --git a/fxjse/dynprop.cpp b/fxjse/dynprop.cpp
deleted file mode 100644
index 836cd5f25a..0000000000
--- a/fxjse/dynprop.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/cfxjse_class.h"
-#include "fxjse/include/cfxjse_value.h"
-
-static void FXJSE_DynPropGetterAdapter_MethodCallback(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
- FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- hCallBackInfo->GetAlignedPointerFromInternalField(0));
- v8::Local<v8::String> hPropName =
- hCallBackInfo->GetInternalField(1).As<v8::String>();
- ASSERT(lpClass && !hPropName.IsEmpty());
- v8::String::Utf8Value szPropName(hPropName);
- CFX_ByteStringC szFxPropName = *szPropName;
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(info.This());
- std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_Arguments impl(&info, lpRetValue.get());
- lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty()) {
- info.GetReturnValue().Set(lpRetValue->DirectGetValue());
- }
-}
-
-static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
- CFXJSE_Value* pObject,
- const CFX_ByteStringC& szPropName,
- CFXJSE_Value* pValue) {
- ASSERT(lpClass);
- int32_t nPropType =
- lpClass->dynPropTypeGetter == nullptr
- ? FXJSE_ClassPropType_Property
- : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
- if (nPropType == FXJSE_ClassPropType_Property) {
- if (lpClass->dynPropGetter) {
- lpClass->dynPropGetter(pObject, szPropName, pValue);
- }
- } else if (nPropType == FXJSE_ClassPropType_Method) {
- if (lpClass->dynMethodCall && pValue) {
- v8::Isolate* pIsolate = pValue->GetIsolate();
- v8::HandleScope hscope(pIsolate);
- v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate =
- v8::ObjectTemplate::New(pIsolate);
- hCallBackInfoTemplate->SetInternalFieldCount(2);
- v8::Local<v8::Object> hCallBackInfo =
- hCallBackInfoTemplate->NewInstance();
- hCallBackInfo->SetAlignedPointerInInternalField(
- 0, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClass));
- hCallBackInfo->SetInternalField(
- 1, v8::String::NewFromUtf8(
- pIsolate, reinterpret_cast<const char*>(szPropName.raw_str()),
- v8::String::kNormalString, szPropName.GetLength()));
- pValue->ForceSetValue(
- v8::Function::New(pValue->GetIsolate()->GetCurrentContext(),
- FXJSE_DynPropGetterAdapter_MethodCallback,
- hCallBackInfo, 0, v8::ConstructorBehavior::kThrow)
- .ToLocalChecked());
- }
- }
-}
-
-static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
- CFXJSE_Value* pObject,
- const CFX_ByteStringC& szPropName,
- CFXJSE_Value* pValue) {
- ASSERT(lpClass);
- int32_t nPropType =
- lpClass->dynPropTypeGetter == nullptr
- ? FXJSE_ClassPropType_Property
- : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
- if (nPropType != FXJSE_ClassPropType_Method) {
- if (lpClass->dynPropSetter) {
- lpClass->dynPropSetter(pObject, szPropName, pValue);
- }
- }
-}
-
-static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
- CFXJSE_Value* pObject,
- const CFX_ByteStringC& szPropName) {
- ASSERT(lpClass);
- int32_t nPropType =
- lpClass->dynPropTypeGetter == nullptr
- ? FXJSE_ClassPropType_Property
- : lpClass->dynPropTypeGetter(pObject, szPropName, TRUE);
- return nPropType != FXJSE_ClassPropType_None;
-}
-
-static FX_BOOL FXJSE_DynPropDeleterAdapter(
- const FXJSE_CLASS_DESCRIPTOR* lpClass,
- CFXJSE_Value* pObject,
- const CFX_ByteStringC& szPropName) {
- ASSERT(lpClass);
- int32_t nPropType =
- lpClass->dynPropTypeGetter == nullptr
- ? FXJSE_ClassPropType_Property
- : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
- if (nPropType != FXJSE_ClassPropType_Method) {
- if (lpClass->dynPropDeleter) {
- return lpClass->dynPropDeleter(pObject, szPropName);
- } else {
- return nPropType == FXJSE_ClassPropType_Property ? FALSE : TRUE;
- }
- }
- return FALSE;
-}
-
-static void FXJSE_V8_GenericNamedPropertyQueryCallback(
- v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Integer>& info) {
- v8::Local<v8::Object> thisObject = info.This();
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- v8::String::Utf8Value szPropName(property);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(thisObject);
- if (FXJSE_DynPropQueryAdapter(lpClass, lpThisValue.get(), szFxPropName)) {
- info.GetReturnValue().Set(v8::DontDelete);
- } else {
- const int32_t iV8Absent = 64;
- info.GetReturnValue().Set(iV8Absent);
- }
-}
-
-static void FXJSE_V8_GenericNamedPropertyDeleterCallback(
- v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Boolean>& info) {
- v8::Local<v8::Object> thisObject = info.This();
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- v8::String::Utf8Value szPropName(property);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(thisObject);
- info.GetReturnValue().Set(
- !!FXJSE_DynPropDeleterAdapter(lpClass, lpThisValue.get(), szFxPropName));
-}
-
-static void FXJSE_V8_GenericNamedPropertyGetterCallback(
- v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> thisObject = info.This();
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- v8::String::Utf8Value szPropName(property);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(thisObject);
- std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
- FXJSE_DynPropGetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
- lpNewValue.get());
- info.GetReturnValue().Set(lpNewValue->DirectGetValue());
-}
-
-static void FXJSE_V8_GenericNamedPropertySetterCallback(
- v8::Local<v8::Name> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> thisObject = info.This();
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- v8::String::Utf8Value szPropName(property);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- std::unique_ptr<CFXJSE_Value> lpThisValue(
- new CFXJSE_Value(info.GetIsolate()));
- lpThisValue->ForceSetValue(thisObject);
-
- CFXJSE_Value* lpNewValue = new CFXJSE_Value(info.GetIsolate());
- lpNewValue->ForceSetValue(value);
- FXJSE_DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
- lpNewValue);
- info.GetReturnValue().Set(value);
-}
-
-static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback(
- const v8::PropertyCallbackInfo<v8::Array>& info) {
- const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
- info.Data().As<v8::External>()->Value());
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum);
- for (int i = 0; i < lpClass->propNum; i++) {
- newArray->Set(
- i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name));
- }
- info.GetReturnValue().Set(newArray);
-}
-
-void CFXJSE_Class::SetUpNamedPropHandler(
- v8::Isolate* pIsolate,
- v8::Local<v8::ObjectTemplate>& hObjectTemplate,
- const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition) {
- v8::NamedPropertyHandlerConfiguration configuration(
- lpClassDefinition->dynPropGetter
- ? FXJSE_V8_GenericNamedPropertyGetterCallback
- : 0,
- lpClassDefinition->dynPropSetter
- ? FXJSE_V8_GenericNamedPropertySetterCallback
- : 0,
- lpClassDefinition->dynPropTypeGetter
- ? FXJSE_V8_GenericNamedPropertyQueryCallback
- : 0,
- lpClassDefinition->dynPropDeleter
- ? FXJSE_V8_GenericNamedPropertyDeleterCallback
- : 0,
- FXJSE_V8_GenericNamedPropertyEnumeratorCallback,
- v8::External::New(pIsolate,
- const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)),
- v8::PropertyHandlerFlags::kNonMasking);
- hObjectTemplate->SetHandler(configuration);
-}
diff --git a/fxjse/include/cfxjse_value.h b/fxjse/include/cfxjse_value.h
deleted file mode 100644
index 6e14d48f8f..0000000000
--- a/fxjse/include/cfxjse_value.h
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FXJSE_INCLUDE_CFXJSE_VALUE_H_
-#define FXJSE_INCLUDE_CFXJSE_VALUE_H_
-
-#include "fxjse/scope_inline.h"
-
-class CFXJSE_Value {
- public:
- explicit CFXJSE_Value(v8::Isolate* pIsolate);
- ~CFXJSE_Value();
-
- FX_BOOL IsUndefined() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsUndefined();
- }
- FX_BOOL IsNull() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsNull();
- }
- FX_BOOL IsBoolean() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsBoolean();
- }
- FX_BOOL IsString() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsString();
- }
- FX_BOOL IsNumber() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsNumber();
- }
- FX_BOOL IsInteger() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsInt32();
- }
- FX_BOOL IsObject() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsObject();
- }
- FX_BOOL IsArray() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsArray();
- }
- FX_BOOL IsFunction() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsFunction();
- }
- FX_BOOL IsDate() const {
- if (m_hValue.IsEmpty()) {
- return FALSE;
- }
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return hValue->IsDate();
- }
-
- FX_BOOL ToBoolean() const {
- ASSERT(!m_hValue.IsEmpty());
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return static_cast<FX_BOOL>(hValue->BooleanValue());
- }
- FX_FLOAT ToFloat() const {
- ASSERT(!m_hValue.IsEmpty());
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return static_cast<FX_FLOAT>(hValue->NumberValue());
- }
- double ToDouble() const {
- ASSERT(!m_hValue.IsEmpty());
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return static_cast<double>(hValue->NumberValue());
- }
- int32_t ToInteger() const {
- ASSERT(!m_hValue.IsEmpty());
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- return static_cast<int32_t>(hValue->NumberValue());
- }
- CFX_ByteString ToString() const {
- ASSERT(!m_hValue.IsEmpty());
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
- v8::Local<v8::String> hString = hValue->ToString();
- v8::String::Utf8Value hStringVal(hString);
- return CFX_ByteString(*hStringVal);
- }
- CFX_WideString ToWideString() const {
- return CFX_WideString::FromUTF8(ToString().AsStringC());
- }
- CFXJSE_HostObject* ToHostObject(CFXJSE_Class* lpClass) const;
-
- void SetUndefined() {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate);
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetNull() {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::Null(m_pIsolate);
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetBoolean(FX_BOOL bBoolean) {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Boolean::New(m_pIsolate, bBoolean != FALSE);
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetInteger(int32_t nInteger) {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger);
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetDouble(double dDouble) {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble);
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetString(const CFX_ByteStringC& szString) {
- CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::String::NewFromUtf8(
- m_pIsolate, reinterpret_cast<const char*>(szString.raw_str()),
- v8::String::kNormalString, szString.GetLength());
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void SetFloat(FX_FLOAT fFloat);
- void SetJSObject() {
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate);
- m_hValue.Reset(m_pIsolate, hValue);
- }
-
- void SetObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* pClass);
- void SetHostObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* lpClass);
- void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues);
- void SetDate(double dDouble);
-
- FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName,
- CFXJSE_Value* lpPropValue);
- FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName,
- CFXJSE_Value* lpPropValue);
- FX_BOOL GetObjectPropertyByIdx(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
- FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
- FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName);
- FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName,
- FX_BOOL bUseTypeGetter);
- FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName,
- CFXJSE_Value* lpPropValue);
- FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis);
- FX_BOOL Call(CFXJSE_Value* lpReceiver,
- CFXJSE_Value* lpRetValue,
- uint32_t nArgCount,
- CFXJSE_Value** lpArgs);
-
- v8::Isolate* GetIsolate() const { return m_pIsolate; }
- const v8::Global<v8::Value>& DirectGetValue() const { return m_hValue; }
- void ForceSetValue(v8::Local<v8::Value> hValue) {
- m_hValue.Reset(m_pIsolate, hValue);
- }
- void Assign(const CFXJSE_Value* lpValue) {
- ASSERT(lpValue);
- if (lpValue) {
- m_hValue.Reset(m_pIsolate, lpValue->m_hValue);
- } else {
- m_hValue.Reset();
- }
- }
-
- private:
- friend class CFXJSE_Class;
- friend class CFXJSE_Context;
-
- CFXJSE_Value();
- CFXJSE_Value(const CFXJSE_Value&);
- CFXJSE_Value& operator=(const CFXJSE_Value&);
-
- v8::Isolate* m_pIsolate;
- v8::Global<v8::Value> m_hValue;
-};
-
-#endif // FXJSE_INCLUDE_CFXJSE_VALUE_H_
diff --git a/xfa.gyp b/xfa.gyp
index c223ba61d7..92ae06a000 100644
--- a/xfa.gyp
+++ b/xfa.gyp
@@ -37,18 +37,19 @@
'<(DEPTH)/v8/src/v8.gyp:v8',
],
"sources":[
- "fxjse/class.cpp",
- "fxjse/context.cpp",
- "fxjse/context.h",
- "fxjse/dynprop.cpp",
- "fxjse/include/cfxjse_arguments.h",
- "fxjse/include/cfxjse_class.h",
- "fxjse/include/cfxjse_value.h",
- "fxjse/include/fxjse.h",
- "fxjse/runtime.cpp",
- "fxjse/runtime.h",
- "fxjse/scope_inline.h",
- "fxjse/value.cpp",
+ "fxjs/cfxjse_arguments.cpp",
+ "fxjs/cfxjse_class.cpp",
+ "fxjs/cfxjse_context.cpp",
+ "fxjs/cfxjse_isolatetracker.cpp",
+ "fxjs/cfxjse_isolatetracker.h",
+ "fxjs/cfxjse_runtimedata.cpp",
+ "fxjs/cfxjse_runtimedata.h",
+ "fxjs/cfxjse_value.cpp",
+ "fxjs/include/cfxjse_arguments.h",
+ "fxjs/include/cfxjse_class.h",
+ "fxjs/include/cfxjse_context.h",
+ "fxjs/include/cfxjse_value.h",
+ "fxjs/include/fxjse.h",
"xfa/fde/cfde_path.cpp",
"xfa/fde/cfde_path.h",
"xfa/fde/cfde_txtedtbuf.cpp",
diff --git a/xfa/fxfa/DEPS b/xfa/fxfa/DEPS
index 19fdfab516..589b532e2c 100644
--- a/xfa/fxfa/DEPS
+++ b/xfa/fxfa/DEPS
@@ -1,3 +1,3 @@
include_rules = [
- '+fxjse/include',
+ '+fxjs/include',
]
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index d8c32f9ed9..be8268a9d4 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fxfa/app/xfa_ffbarcode.h"
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
#include "xfa/fxfa/app/xfa_ffchoicelist.h"
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index dabb31610a..fec0c20c58 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -9,7 +9,7 @@
#include <algorithm>
#include <memory>
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 6826094b1d..b5bc6757c4 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -9,9 +9,9 @@
#include <time.h>
#include "core/fxcrt/include/fx_ext.h"
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/cfxjse_class.h"
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_class.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fgas/localization/fgas_locale.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_program.h"
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
index 344c4bcda8..fc98dbbd4a 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
@@ -7,7 +7,8 @@
#ifndef XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_
#define XFA_FXFA_FM2JS_XFA_FM2JSCONTEXT_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_context.h"
#include "xfa/fxfa/parser/xfa_script.h"
class CXFA_FM2JSContext : public CFXJSE_HostObject {
diff --git a/xfa/fxfa/include/fxfa_basic.h b/xfa/fxfa/include/fxfa_basic.h
index 9fe2650ffc..2a379736e5 100644
--- a/xfa/fxfa/include/fxfa_basic.h
+++ b/xfa/fxfa/include/fxfa_basic.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_INCLUDE_FXFA_BASIC_H_
#define XFA_FXFA_INCLUDE_FXFA_BASIC_H_
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/fxjse.h"
+#include "fxjs/include/cfxjse_arguments.h"
+#include "fxjs/include/fxjse.h"
class CXFA_Measurement;
enum class XFA_ObjectType;
diff --git a/xfa/fxfa/parser/cxfa_valuearray.h b/xfa/fxfa/parser/cxfa_valuearray.h
index 3907b4dbbd..4bc59c79d2 100644
--- a/xfa/fxfa/parser/cxfa_valuearray.h
+++ b/xfa/fxfa/parser/cxfa_valuearray.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
#define XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fxfa/include/fxfa.h"
class CXFA_ValueArray : public CFX_ArrayTemplate<CFXJSE_Value*> {
diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h
index a838b17578..268d5c4c79 100644
--- a/xfa/fxfa/parser/xfa_object.h
+++ b/xfa/fxfa/parser/xfa_object.h
@@ -9,7 +9,7 @@
#include <unordered_set>
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fde/xml/fde_xml.h"
#include "xfa/fxfa/parser/xfa_utils.h"
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index 871286d24e..e3d9f6bcdf 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -9,7 +9,7 @@
#include <memory>
#include "core/fxcrt/include/fx_ext.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
diff --git a/xfa/fxfa/parser/xfa_script.h b/xfa/fxfa/parser/xfa_script.h
index 020e809881..038d2dbdd3 100644
--- a/xfa/fxfa/parser/xfa_script.h
+++ b/xfa/fxfa/parser/xfa_script.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_H_
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fxfa/include/fxfa.h"
#include "xfa/fxfa/parser/cxfa_valuearray.h"
diff --git a/xfa/fxfa/parser/xfa_script_datawindow.cpp b/xfa/fxfa/parser/xfa_script_datawindow.cpp
index 8e37e00911..e953206c4d 100644
--- a/xfa/fxfa/parser/xfa_script_datawindow.cpp
+++ b/xfa/fxfa/parser/xfa_script_datawindow.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/parser/xfa_script_datawindow.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/xfa/fxfa/parser/xfa_script_datawindow.h b/xfa/fxfa/parser/xfa_script_datawindow.h
index 05ecf8dc53..ea8e6ad242 100644
--- a/xfa/fxfa/parser/xfa_script_datawindow.h
+++ b/xfa/fxfa/parser/xfa_script_datawindow.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_DATAWINDOW_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_object.h"
class CScript_DataWindow : public CXFA_Object {
diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
index ef724e49f2..507aef3c6a 100644
--- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/parser/xfa_script_eventpseudomodel.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/include/cxfa_eventparam.h"
#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.h b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
index 9eb3912e9e..c52d3ce5fa 100644
--- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
+++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_EVENTPSEUDOMODEL_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_object.h"
enum class XFA_Event {
diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
index 37ed181714..8bc71699b4 100644
--- a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/parser/xfa_script_hostpseudomodel.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.h b/xfa/fxfa/parser/xfa_script_hostpseudomodel.h
index e131b6fe7e..cabaabca4a 100644
--- a/xfa/fxfa/parser/xfa_script_hostpseudomodel.h
+++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_HOSTPSEUDOMODEL_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp
index 95298e4799..e426c1ecf7 100644
--- a/xfa/fxfa/parser/xfa_script_imp.cpp
+++ b/xfa/fxfa/parser/xfa_script_imp.cpp
@@ -7,9 +7,9 @@
#include "xfa/fxfa/parser/xfa_script_imp.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/cfxjse_class.h"
-#include "fxjse/include/cfxjse_value.h"
+#include "fxjs/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_class.h"
+#include "fxjs/include/cfxjse_value.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/include/cxfa_eventparam.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h
index c6bb14862e..5356679636 100644
--- a/xfa/fxfa/parser/xfa_script_imp.h
+++ b/xfa/fxfa/parser/xfa_script_imp.h
@@ -11,7 +11,7 @@
#include <memory>
#include <vector>
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
#include "xfa/fxfa/include/cxfa_eventparam.h"
#include "xfa/fxfa/parser/xfa_document.h"
diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
index 3567a5a138..977b83ff03 100644
--- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
@@ -8,7 +8,7 @@
#include <set>
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h
index 0977f32a94..1e61c42064 100644
--- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h
+++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_LAYOUTPSEUDOMODEL_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_object.h"
diff --git a/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
index 800a8059d5..57909cdd79 100644
--- a/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/parser/xfa_script_logpseudomodel.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/xfa/fxfa/parser/xfa_script_logpseudomodel.h b/xfa/fxfa/parser/xfa_script_logpseudomodel.h
index d344fd5157..917bbdcf0d 100644
--- a/xfa/fxfa/parser/xfa_script_logpseudomodel.h
+++ b/xfa/fxfa/parser/xfa_script_logpseudomodel.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_LOGPSEUDOMODEL_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_object.h"
class CScript_LogPseudoModel : public CXFA_Object {
diff --git a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
index 45c0f7c0d0..0341fc12de 100644
--- a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxfa/parser/xfa_script_signaturepseudomodel.h"
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
diff --git a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h
index 0ced36c841..56f5e5de43 100644
--- a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h
+++ b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_SIGNATUREPSEUDOMODEL_H_
-#include "fxjse/include/cfxjse_arguments.h"
+#include "fxjs/include/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_object.h"
class CScript_SignaturePseudoModel : public CXFA_Object {