summaryrefslogtreecommitdiff
path: root/fpdfsdk/include
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r--fpdfsdk/include/javascript/IJavaScript.h8
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h59
-rw-r--r--fpdfsdk/include/javascript/JS_Object.h5
-rw-r--r--fpdfsdk/include/javascript/resource.h6
-rw-r--r--fpdfsdk/include/jsapi/fxjs_v8.h4
5 files changed, 45 insertions, 37 deletions
diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h
index 91fd9c6afb..b0e21c915a 100644
--- a/fpdfsdk/include/javascript/IJavaScript.h
+++ b/fpdfsdk/include/javascript/IJavaScript.h
@@ -7,6 +7,14 @@
#ifndef _IJAVASCRIPT_H_
#define _IJAVASCRIPT_H_
+#include "../../../core/include/fxcrt/fx_basic.h"
+#include "../../../xfa/include/fxjse/fxjse.h"
+
+class CPDF_Bookmark;
+class CPDF_FormField;
+class CPDFSDK_Annot;
+class CPDFSDK_Document;
+
class IFXJS_Context
{
public:
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index fee16e41f1..7b98ee6dd2 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -7,6 +7,9 @@
#ifndef _JS_DEFINE_H_
#define _JS_DEFINE_H_
+#include "../jsapi/fxjs_v8.h"
+#include "resource.h"
+
typedef v8::Value JSValue;
typedef v8::Handle<v8::Object> JSObject;
typedef v8::Handle<v8::Object> JSFXObject;
@@ -37,11 +40,10 @@ struct JSMethodSpec
unsigned nParamNum;
};
-typedef CFX_WideString JS_ErrorString;
-
#define JS_TRUE (unsigned)1
#define JS_FALSE (unsigned)0
+typedef CFX_WideString JS_ErrorString;
typedef CFX_ArrayTemplate<float> CJS_PointsArray;
typedef CFX_ArrayTemplate<int> CJS_IntArray;
@@ -63,7 +65,7 @@ typedef CFX_ArrayTemplate<int> CJS_IntArray;
/* ======================================== PROP CALLBACK ============================================ */
-template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, JS_ErrorString&)>
+template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)>
void JSPropGetter(const char* prop_name_string,
const char* class_name_string,
v8::Local<v8::String> property,
@@ -75,17 +77,15 @@ void JSPropGetter(const char* prop_name_string,
value.StartGetting();
CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- JS_ErrorString sError;
+ CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, value, sError)) {
- CFX_ByteString cbName;
- cbName.Format("%s.%s", class_name_string, prop_name_string);
- JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);
+ JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError));
return;
}
info.GetReturnValue().Set((v8::Handle<v8::Value>)value);
}
-template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, JS_ErrorString&)>
+template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)>
void JSPropSetter(const char* prop_name_string,
const char* class_name_string,
v8::Local<v8::String> property,
@@ -98,11 +98,9 @@ void JSPropSetter(const char* prop_name_string,
propValue.StartSetting();
CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- JS_ErrorString sError;
+ CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, propValue, sError)) {
- CFX_ByteString cbName;
- cbName.Format("%s.%s", class_name_string, prop_name_string);
- JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);
+ JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError));
}
}
@@ -123,7 +121,7 @@ void JSPropSetter(const char* prop_name_string,
/* ========================================= METHOD CALLBACK =========================================== */
-template <class C, FX_BOOL (C::*M)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, JS_ErrorString&)>
+template <class C, FX_BOOL (C::*M)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
void JSMethod(const char* method_name_string,
const char* class_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -137,11 +135,9 @@ void JSMethod(const char* method_name_string,
CJS_Value valueRes(isolate);
CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- JS_ErrorString sError;
+ CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) {
- CFX_ByteString cbName;
- cbName.Format("%s.%s", class_name_string, method_name_string);
- JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);
+ JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, sError));
return;
}
info.GetReturnValue().Set(valueRes.ToJSValue());
@@ -151,14 +147,14 @@ void JSMethod(const char* method_name_string,
static void method_name##_static( \
const v8::FunctionCallbackInfo<v8::Value>& info) { \
JSMethod<class_name, &class_name::method_name>( \
- #class_name, #method_name, info); \
+ #method_name, #class_name, info); \
}
#define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \
static void method_name##_static( \
const v8::FunctionCallbackInfo<v8::Value>& info) { \
JSMethod<class_alternate, &class_alternate::method_name>( \
- #class_name, #method_name, info); \
+ #method_name, #class_name, info); \
}
/* ===================================== JS CLASS =============================================== */
@@ -267,14 +263,12 @@ void JSSpecialPropGet(const char* class_name,
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
- JS_ErrorString sError;
+ CFX_WideString sError;
CJS_PropValue value(isolate);
value.StartGetting();
if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) {
- CFX_ByteString cbName;
- cbName.Format("%s.%s", class_name, L"GetProperty");
- JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);
- return;
+ JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
+ return;
}
info.GetReturnValue().Set((v8::Handle<v8::Value>)value);
}
@@ -292,13 +286,11 @@ void JSSpecialPropPut(const char* class_name,
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
- JS_ErrorString sError;
+ CFX_WideString sError;
CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));
PropValue.StartSetting();
if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) {
- CFX_ByteString cbName;
- cbName.Format("%s.%s", class_name, "PutProperty");
- JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);
+ JS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError));
}
}
@@ -314,7 +306,7 @@ void JSSpecialPropDel(const char* class_name,
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
- JS_ErrorString sError;
+ CFX_WideString sError;
if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
CFX_ByteString cbName;
cbName.Format("%s.%s", class_name, "DelProperty");
@@ -393,7 +385,7 @@ int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
/* ======================================== GLOBAL METHODS ============================================ */
-template <FX_BOOL (*F)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, JS_ErrorString&)>
+template <FX_BOOL (*F)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
void JSGlobalFunc(const char *func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
@@ -404,10 +396,9 @@ void JSGlobalFunc(const char *func_name_string,
parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));
}
CJS_Value valueRes(isolate);
- JS_ErrorString sError;
- if (!(*F)(pRuntimeContext, parameters, valueRes, sError))
- {
- JS_Error(NULL, JS_WIDESTRING(fun_name), sError);
+ CFX_WideString sError;
+ if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) {
+ JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
return;
}
info.GetReturnValue().Set(valueRes.ToJSValue());
diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h
index 33c1a1ff62..f30bc17ce6 100644
--- a/fpdfsdk/include/javascript/JS_Object.h
+++ b/fpdfsdk/include/javascript/JS_Object.h
@@ -7,6 +7,11 @@
#ifndef _JS_OBJECT_H_
#define _JS_OBJECT_H_
+#include "../fsdk_define.h" // For FX_UINT
+#include "../fsdk_mgr.h" // For CPDFDoc_Environment
+#include "../fx_systemhandler.h" // For IFX_SystemHandler
+
+class CPDFSDK_PageView;
class CJS_Object;
class CJS_Timer;
class CJS_Context;
diff --git a/fpdfsdk/include/javascript/resource.h b/fpdfsdk/include/javascript/resource.h
index 058b5fd893..8f0a25061e 100644
--- a/fpdfsdk/include/javascript/resource.h
+++ b/fpdfsdk/include/javascript/resource.h
@@ -26,8 +26,12 @@ class CJS_Context;
#define IDS_STRING_RUN 25630
#define IDS_STRING_JSPRINT1 25632
#define IDS_STRING_JSPRINT2 25633
-#define IDS_JSPARAM_INCORRECT 25635
+#define IDS_STRING_JSNOGLOBAL 25635
+#define IDS_STRING_JSREADONLY 25636
CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id);
+CFX_WideString JSFormatErrorString(const char* class_name,
+ const char* property_name,
+ const CFX_WideString& details);
#endif // FPDFSDK_INCLUDE_JAVASCRIPT_RESOURCE_H_
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h
index b6ea60be13..c7fdf87747 100644
--- a/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/fpdfsdk/include/jsapi/fxjs_v8.h
@@ -8,6 +8,7 @@
#define FXJSAPI_H
#include <v8.h>
+#include "../../core/include/fxcrt/fx_string.h" // For CFX_WideString
enum FXJSOBJTYPE
{
@@ -66,11 +67,10 @@ v8::Handle<v8::Object> JS_GetThisObj(IJS_Runtime * pJSRuntime);
int JS_GetObjDefnID(v8::Handle<v8::Object> pObj);
IJS_Runtime* JS_GetRuntime(v8::Handle<v8::Object> pObj);
int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName);
-void JS_Error(v8::Value * pError,const wchar_t * main,const wchar_t * sub);
+void JS_Error(v8::Isolate* isolate, const CFX_WideString& message);
unsigned JS_CalcHash(const wchar_t* main, unsigned nLen);
unsigned JS_CalcHash(const wchar_t* main);
const wchar_t* JS_GetTypeof(v8::Handle<v8::Value> pObj);
-const wchar_t* JS_GetClassname(v8::Handle<v8::Object> pObj);
void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle<v8::Object> pObj, void* p);
void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Handle<v8::Object> pObj);
void JS_SetPrivate(v8::Handle<v8::Object> pObj, void* p);