summaryrefslogtreecommitdiff
path: root/xfa/fxjse
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-06-08 13:12:41 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-08 13:12:41 -0700
commit769b137a435fd53a419ebbd1deb8617771b73ef6 (patch)
tree4b4a525a939349e30719b29a7cf1b9f8d78de6aa /xfa/fxjse
parentbc85eecc6cbac54e4b69fe202f802047d2979bf1 (diff)
downloadpdfium-769b137a435fd53a419ebbd1deb8617771b73ef6.tar.xz
Remove more FXJSE c-method wrappers.
This Cl cleans up a bunch of the FXJSE_* methods and moves others into the classes where they most make sense. Review-Url: https://codereview.chromium.org/2045883004
Diffstat (limited to 'xfa/fxjse')
-rw-r--r--xfa/fxjse/cfxjse_arguments.h4
-rw-r--r--xfa/fxjse/class.cpp6
-rw-r--r--xfa/fxjse/context.cpp36
-rw-r--r--xfa/fxjse/context.h1
-rw-r--r--xfa/fxjse/include/fxjse.h30
-rw-r--r--xfa/fxjse/value.cpp56
6 files changed, 13 insertions, 120 deletions
diff --git a/xfa/fxjse/cfxjse_arguments.h b/xfa/fxjse/cfxjse_arguments.h
index 3028d39def..fd83f8e7f4 100644
--- a/xfa/fxjse/cfxjse_arguments.h
+++ b/xfa/fxjse/cfxjse_arguments.h
@@ -7,8 +7,12 @@
#ifndef XFA_FXJSE_CFXJSE_ARGUMENTS_H_
#define XFA_FXJSE_CFXJSE_ARGUMENTS_H_
+#include <memory>
+
#include "xfa/fxjse/include/fxjse.h"
+class CFXJSE_Class;
+
class CFXJSE_Arguments {
public:
CFXJSE_Arguments(const v8::FunctionCallbackInfo<v8::Value>* pInfo,
diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp
index e7e061b5a3..bd589453f2 100644
--- a/xfa/fxjse/class.cpp
+++ b/xfa/fxjse/class.cpp
@@ -23,12 +23,6 @@ static void FXJSE_V8SetterCallback_Wrapper(
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info);
-CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext,
- const FXJSE_CLASS_DESCRIPTOR* lpClass) {
- ASSERT(pContext);
- return CFXJSE_Class::Create(pContext, lpClass, FALSE);
-}
-
static void FXJSE_V8FunctionCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
const FXJSE_FUNCTION_DESCRIPTOR* lpFunctionInfo =
diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp
index 75be76d673..8eacc77a74 100644
--- a/xfa/fxjse/context.cpp
+++ b/xfa/fxjse/context.cpp
@@ -84,37 +84,6 @@ CFXJSE_HostObject* FXJSE_RetrieveObjectBinding(
hObject->GetAlignedPointerFromInternalField(0));
}
-CFXJSE_Context* FXJSE_Context_Create(
- v8::Isolate* pIsolate,
- const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass,
- CFXJSE_HostObject* lpGlobalObject) {
- return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject);
-}
-
-void FXJSE_Context_Release(CFXJSE_Context* pContext) {
- delete pContext;
-}
-
-CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext) {
- if (!pContext)
- return nullptr;
-
- CFXJSE_Value* lpValue = new CFXJSE_Value(pContext->GetRuntime());
- pContext->GetGlobalObject(lpValue);
- return lpValue;
-}
-
-void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext) {
- FXJSE_ExecuteScript(pContext, szCompatibleModeScript, nullptr, nullptr);
-}
-
-FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext,
- const FX_CHAR* szScript,
- CFXJSE_Value* pRetValue,
- CFXJSE_Value* pNewThisObject) {
- return pContext->ExecuteScript(szScript, pRetValue, pNewThisObject);
-}
-
v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
v8::TryCatch& trycatch) {
v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate);
@@ -185,6 +154,7 @@ CFXJSE_Context* CFXJSE_Context::Create(
}
CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}
+
CFXJSE_Context::~CFXJSE_Context() {}
void CFXJSE_Context::GetGlobalObject(CFXJSE_Value* pValue) {
@@ -196,6 +166,10 @@ void CFXJSE_Context::GetGlobalObject(CFXJSE_Value* pValue) {
pValue->ForceSetValue(hGlobalObject);
}
+void CFXJSE_Context::EnableCompatibleMode() {
+ ExecuteScript(szCompatibleModeScript, nullptr, nullptr);
+}
+
FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript,
CFXJSE_Value* lpRetValue,
CFXJSE_Value* lpNewThisObject) {
diff --git a/xfa/fxjse/context.h b/xfa/fxjse/context.h
index 6737619511..4219713ece 100644
--- a/xfa/fxjse/context.h
+++ b/xfa/fxjse/context.h
@@ -28,6 +28,7 @@ class CFXJSE_Context {
V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; }
void GetGlobalObject(CFXJSE_Value* pValue);
+ void EnableCompatibleMode();
FX_BOOL ExecuteScript(const FX_CHAR* szScript,
CFXJSE_Value* lpRetValue,
CFXJSE_Value* lpNewThisObject = nullptr);
diff --git a/xfa/fxjse/include/fxjse.h b/xfa/fxjse/include/fxjse.h
index 835d5de9ba..d7c85f54e8 100644
--- a/xfa/fxjse/include/fxjse.h
+++ b/xfa/fxjse/include/fxjse.h
@@ -12,8 +12,6 @@
#include "v8/include/v8.h"
class CFXJSE_Arguments;
-class CFXJSE_Class;
-class CFXJSE_Context;
class CFXJSE_Value;
class CFXJSE_HostObject {}; // C++ object which can be wrapped by CFXJSE_value.
@@ -67,32 +65,6 @@ void FXJSE_Finalize();
v8::Isolate* FXJSE_Runtime_Create_Own();
void FXJSE_Runtime_Release(v8::Isolate* pIsolate);
-CFXJSE_Context* FXJSE_Context_Create(
- v8::Isolate* pIsolate,
- const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass,
- CFXJSE_HostObject* lpGlobalObject);
-void FXJSE_Context_Release(CFXJSE_Context* pContext);
-CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext);
-void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext);
-
-CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext,
- const FXJSE_CLASS_DESCRIPTOR* lpClass);
-
-FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsBoolean(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsUTF8String(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsNumber(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsObject(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsArray(CFXJSE_Value* pValue);
-FX_BOOL FXJSE_Value_IsFunction(CFXJSE_Value* pValue);
-
-FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext,
- const FX_CHAR* szScript,
- CFXJSE_Value* pRetValue,
- CFXJSE_Value* pNewThisObject = nullptr);
-
-void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
- const CFX_ByteStringC& utf8Message);
+void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message);
#endif // XFA_FXJSE_INCLUDE_FXJSE_H_
diff --git a/xfa/fxjse/value.cpp b/xfa/fxjse/value.cpp
index 64a10f348e..af73a19ead 100644
--- a/xfa/fxjse/value.cpp
+++ b/xfa/fxjse/value.cpp
@@ -11,40 +11,7 @@
#include "xfa/fxjse/class.h"
#include "xfa/fxjse/context.h"
-FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue) {
- return pValue && pValue->IsUndefined();
-}
-
-FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue) {
- return pValue && pValue->IsNull();
-}
-
-FX_BOOL FXJSE_Value_IsBoolean(CFXJSE_Value* pValue) {
- return pValue && pValue->IsBoolean();
-}
-
-FX_BOOL FXJSE_Value_IsUTF8String(CFXJSE_Value* pValue) {
- return pValue && pValue->IsString();
-}
-
-FX_BOOL FXJSE_Value_IsNumber(CFXJSE_Value* pValue) {
- return pValue && pValue->IsNumber();
-}
-
-FX_BOOL FXJSE_Value_IsObject(CFXJSE_Value* pValue) {
- return pValue && pValue->IsObject();
-}
-
-FX_BOOL FXJSE_Value_IsArray(CFXJSE_Value* pValue) {
- return pValue && pValue->IsArray();
-}
-
-FX_BOOL FXJSE_Value_IsFunction(CFXJSE_Value* pValue) {
- return pValue && pValue->IsFunction();
-}
-
-void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
- const CFX_ByteStringC& utf8Message) {
+void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message) {
v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
ASSERT(pIsolate);
@@ -52,26 +19,7 @@ void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
v8::Local<v8::String> hMessage = v8::String::NewFromUtf8(
pIsolate, utf8Message.c_str(), v8::String::kNormalString,
utf8Message.GetLength());
- v8::Local<v8::Value> hError;
-
- if (utf8Name == "RangeError") {
- hError = v8::Exception::RangeError(hMessage);
- } else if (utf8Name == "ReferenceError") {
- hError = v8::Exception::ReferenceError(hMessage);
- } else if (utf8Name == "SyntaxError") {
- hError = v8::Exception::SyntaxError(hMessage);
- } else if (utf8Name == "TypeError") {
- hError = v8::Exception::TypeError(hMessage);
- } else {
- hError = v8::Exception::Error(hMessage);
- if (utf8Name != "Error" && !utf8Name.IsEmpty()) {
- hError.As<v8::Object>()->Set(
- v8::String::NewFromUtf8(pIsolate, "name"),
- v8::String::NewFromUtf8(pIsolate, utf8Name.c_str(),
- v8::String::kNormalString,
- utf8Name.GetLength()));
- }
- }
+ v8::Local<v8::Value> hError = v8::Exception::Error(hMessage);
pIsolate->ThrowException(hError);
}