summaryrefslogtreecommitdiff
path: root/fpdfsdk/include
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h163
-rw-r--r--fpdfsdk/include/javascript/JS_Runtime.h2
-rw-r--r--fpdfsdk/include/javascript/JS_Value.h35
-rw-r--r--fpdfsdk/include/jsapi/fxjs_v8.h318
4 files changed, 263 insertions, 255 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 7cade587b5..1addca5cec 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -83,12 +83,12 @@ void JSPropGetter(const char* prop_name_string,
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_PropValue value(isolate);
value.StartGetting();
- CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder());
+ CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, value, sError)) {
- JS_Error(isolate,
- JSFormatErrorString(class_name_string, prop_name_string, sError));
+ FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string,
+ sError));
return;
}
info.GetReturnValue().Set((v8::Local<v8::Value>)value);
@@ -104,14 +104,14 @@ void JSPropSetter(const char* prop_name_string,
v8::Isolate* isolate = info.GetIsolate();
IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
- CJS_PropValue propValue(CJS_Value(isolate, value, VT_unknown));
+ CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown));
propValue.StartSetting();
- CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder());
+ CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, propValue, sError)) {
- JS_Error(isolate,
- JSFormatErrorString(class_name_string, prop_name_string, sError));
+ FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string,
+ sError));
}
}
@@ -145,15 +145,15 @@ void JSMethod(const char* method_name_string,
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_Parameters parameters;
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
- parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));
+ parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown));
}
CJS_Value valueRes(isolate);
- CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate, info.Holder());
+ CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
CFX_WideString sError;
if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) {
- JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string,
- sError));
+ FXJS_Error(isolate, JSFormatErrorString(class_name_string,
+ method_name_string, sError));
return;
}
info.GetReturnValue().Set(valueRes.ToV8Value());
@@ -186,36 +186,36 @@ void JSMethod(const char* method_name_string,
static JSMethodSpec JS_Class_Methods[]; \
static const wchar_t* m_pClassName
-#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
- const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
- void js_class_name::JSConstructor(IFXJS_Context* cc, \
- v8::Local<v8::Object> obj, \
- v8::Local<v8::Object> global) { \
- CJS_Object* pObj = new js_class_name(obj); \
- pObj->SetEmbedObject(new class_alternate(pObj)); \
- JS_SetPrivate(NULL, obj, (void*)pObj); \
- pObj->InitInstance(cc); \
- } \
- \
- void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
- js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \
- pObj->ExitInstance(); \
- delete pObj; \
- } \
- \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
- FXJSOBJTYPE eObjType) { \
- int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, JSConstructor, JSDestructor); \
- for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
- JS_DefineObjProperty(pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
- JS_Class_Properties[i].pPropGet, \
- JS_Class_Properties[i].pPropPut); \
- } \
- for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
- JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
- JS_Class_Methods[i].pMethodCall); \
- } \
+#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
+ const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
+ void js_class_name::JSConstructor(IFXJS_Context* cc, \
+ v8::Local<v8::Object> obj, \
+ v8::Local<v8::Object> global) { \
+ CJS_Object* pObj = new js_class_name(obj); \
+ pObj->SetEmbedObject(new class_alternate(pObj)); \
+ FXJS_SetPrivate(NULL, obj, (void*)pObj); \
+ pObj->InitInstance(cc); \
+ } \
+ \
+ void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
+ js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \
+ pObj->ExitInstance(); \
+ delete pObj; \
+ } \
+ \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
+ FXJSOBJTYPE eObjType) { \
+ int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
+ eObjType, JSConstructor, JSDestructor); \
+ for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
+ FXJS_DefineObjProperty( \
+ pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
+ JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \
+ } \
+ for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
+ FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
+ JS_Class_Methods[i].pMethodCall); \
+ } \
}
#define IMPLEMENT_JS_CLASS(js_class_name, class_name) \
@@ -229,19 +229,19 @@ void JSMethod(const char* method_name_string,
static JSConstSpec JS_Class_Consts[]; \
static const wchar_t* m_pClassName
-#define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
- const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
- FXJSOBJTYPE eObjType) { \
- int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, NULL, NULL); \
- for (int i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
- JS_DefineObjConst( \
- pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \
- JS_Class_Consts[i].t == 0 \
- ? JS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
- : JS_NewString(pIsolate, JS_Class_Consts[i].string)); \
- } \
+#define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
+ const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
+ FXJSOBJTYPE eObjType) { \
+ int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
+ eObjType, NULL, NULL); \
+ for (int i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
+ FXJS_DefineObjConst( \
+ pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \
+ JS_Class_Consts[i].t == 0 \
+ ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
+ : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \
+ } \
}
/* ===================================== SPECIAL JS CLASS
@@ -256,7 +256,7 @@ void JSSpecialPropQuery(const char*,
CFX_WideString propname =
CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
CJS_Object* pJSObj =
- reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
+ reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
FX_BOOL bRet = pObj->QueryProperty(propname.c_str());
info.GetReturnValue().Set(bRet ? 4 : 0);
@@ -271,7 +271,7 @@ void JSSpecialPropGet(const char* class_name,
IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_Object* pJSObj =
- reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
+ reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname =
@@ -280,7 +280,7 @@ void JSSpecialPropGet(const char* class_name,
CJS_PropValue value(isolate);
value.StartGetting();
if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) {
- JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
+ FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
return;
}
info.GetReturnValue().Set((v8::Local<v8::Value>)value);
@@ -296,16 +296,16 @@ void JSSpecialPropPut(const char* class_name,
IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_Object* pJSObj =
- reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
+ reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname =
CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
CFX_WideString sError;
- CJS_PropValue PropValue(CJS_Value(isolate, value, VT_unknown));
+ CJS_PropValue PropValue(CJS_Value(isolate, value, CJS_Value::VT_unknown));
PropValue.StartSetting();
if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) {
- JS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError));
+ FXJS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError));
}
}
@@ -318,7 +318,7 @@ void JSSpecialPropDel(const char* class_name,
IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_Object* pJSObj =
- reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
+ reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
CFX_WideString propname =
@@ -327,7 +327,7 @@ void JSSpecialPropDel(const char* class_name,
if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
CFX_ByteString cbName;
cbName.Format("%s.%s", class_name, "DelProperty");
- // Probably a missing call to JS_Error().
+ // Probably a missing call to JSFX_Error().
}
}
@@ -380,12 +380,12 @@ void JSSpecialPropDel(const char* class_name,
v8::Local<v8::Object> global) { \
CJS_Object* pObj = new js_class_name(obj); \
pObj->SetEmbedObject(new class_alternate(pObj)); \
- JS_SetPrivate(NULL, obj, (void*)pObj); \
+ FXJS_SetPrivate(NULL, obj, (void*)pObj); \
pObj->InitInstance(cc); \
} \
\
void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
- js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \
+ js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \
ASSERT(pObj != NULL); \
pObj->ExitInstance(); \
delete pObj; \
@@ -393,19 +393,19 @@ void JSSpecialPropDel(const char* class_name,
\
void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
FXJSOBJTYPE eObjType) { \
- int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, JSConstructor, JSDestructor); \
+ int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
+ eObjType, JSConstructor, JSDestructor); \
for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
- JS_DefineObjProperty(pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
- JS_Class_Properties[i].pPropGet, \
- JS_Class_Properties[i].pPropPut); \
+ FXJS_DefineObjProperty( \
+ pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
+ JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \
} \
\
for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
- JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
- JS_Class_Methods[i].pMethodCall); \
+ FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
+ JS_Class_Methods[i].pMethodCall); \
} \
- JS_DefineObjAllProperties( \
+ FXJS_DefineObjAllProperties( \
pIsolate, nObjDefnID, \
js_class_name::queryprop_##js_class_name##_static, \
js_class_name::getprop_##js_class_name##_static, \
@@ -425,12 +425,12 @@ void JSGlobalFunc(const char* func_name_string,
IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
CJS_Parameters parameters;
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
- parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));
+ parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown));
}
CJS_Value valueRes(isolate);
CFX_WideString sError;
if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) {
- JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
+ FXJS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
return;
}
info.GetReturnValue().Set(valueRes.ToV8Value());
@@ -453,14 +453,15 @@ void JSGlobalFunc(const char* func_name_string,
#define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
-#define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \
- for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
- JS_DefineGlobalMethod(pIsolate, js_class_name::global_methods[i].pName, \
- js_class_name::global_methods[i].pMethodCall); \
- } \
+#define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \
+ for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
+ FXJS_DefineGlobalMethod(pIsolate, \
+ js_class_name::global_methods[i].pName, \
+ js_class_name::global_methods[i].pMethodCall); \
+ } \
}
-FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p);
+CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p);
#endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h
index f0285b271c..b53e50e6ce 100644
--- a/fpdfsdk/include/javascript/JS_Runtime.h
+++ b/fpdfsdk/include/javascript/JS_Runtime.h
@@ -64,7 +64,7 @@ class CJS_Runtime : public IFXJS_Runtime {
CJS_FieldEvent* m_pFieldEventPath;
v8::Isolate* m_isolate;
bool m_isolateManaged;
- nonstd::unique_ptr<JS_ArrayBufferAllocator> m_pArrayBufferAllocator;
+ nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator;
v8::Global<v8::Context> m_context;
};
diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h
index 771214d968..384e772572 100644
--- a/fpdfsdk/include/javascript/JS_Value.h
+++ b/fpdfsdk/include/javascript/JS_Value.h
@@ -17,8 +17,20 @@ class CJS_Object;
class CJS_Value {
public:
+ enum Type {
+ VT_unknown,
+ VT_string,
+ VT_number,
+ VT_boolean,
+ VT_date,
+ VT_object,
+ VT_fxobject,
+ VT_null,
+ VT_undefined
+ };
+
CJS_Value(v8::Isolate* isolate);
- CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue, FXJSVALUETYPE t);
+ CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue, Type t);
CJS_Value(v8::Isolate* isolate, const int& iValue);
CJS_Value(v8::Isolate* isolate, const double& dValue);
CJS_Value(v8::Isolate* isolate, const float& fValue);
@@ -33,10 +45,11 @@ class CJS_Value {
~CJS_Value();
void SetNull();
- void Attach(v8::Local<v8::Value> pValue, FXJSVALUETYPE t);
+ void Attach(v8::Local<v8::Value> pValue, Type t);
void Attach(CJS_Value* pValue);
void Detach();
+ Type GetType() const;
int ToInt() const;
bool ToBool() const;
double ToDouble() const;
@@ -63,16 +76,14 @@ class CJS_Value {
FX_BOOL IsArrayObject() const;
FX_BOOL IsDateObject() const;
- FXJSVALUETYPE GetType() const;
-
FX_BOOL ConvertToArray(CJS_Array&) const;
FX_BOOL ConvertToDate(CJS_Date&) const;
v8::Isolate* GetIsolate() { return m_isolate; }
protected:
+ Type m_eType;
v8::Local<v8::Value> m_pValue;
- FXJSVALUETYPE m_eType;
v8::Isolate* m_isolate;
};
@@ -190,4 +201,18 @@ class CJS_Date {
v8::Isolate* m_isolate;
};
+double JS_GetDateTime();
+int JS_GetYearFromTime(double dt);
+int JS_GetMonthFromTime(double dt);
+int JS_GetDayFromTime(double dt);
+int JS_GetHourFromTime(double dt);
+int JS_GetMinFromTime(double dt);
+int JS_GetSecFromTime(double dt);
+double JS_DateParse(const wchar_t* string);
+double JS_MakeDay(int nYear, int nMonth, int nDay);
+double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
+double JS_MakeDate(double day, double time);
+bool JS_PortIsNan(double d);
+double JS_LocalTime(double d);
+
#endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h
index 6e4fc6f7a7..3499bfbfea 100644
--- a/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/fpdfsdk/include/jsapi/fxjs_v8.h
@@ -14,20 +14,8 @@
#include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString
enum FXJSOBJTYPE {
- JS_DYNAMIC = 0,
- JS_STATIC = 1,
-};
-
-enum FXJSVALUETYPE {
- VT_unknown,
- VT_string,
- VT_number,
- VT_boolean,
- VT_date,
- VT_object,
- VT_fxobject,
- VT_null,
- VT_undefined
+ FXJS_DYNAMIC = 0,
+ FXJS_STATIC = 1,
};
struct FXJSErr {
@@ -46,20 +34,28 @@ extern const wchar_t kFXJSValueNameNull[];
extern const wchar_t kFXJSValueNameUndefined[];
// FXJS_V8 places no interpretation on these two classes; it merely
-// passes them on to the caller-provided LP_CONSTRUCTORs.
+// passes them on to the caller-provided FXJS_CONSTRUCTORs.
class IFXJS_Context;
class IFXJS_Runtime;
-class JS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void* Allocate(size_t length) override;
void* AllocateUninitialized(size_t length) override;
void Free(void* data, size_t length) override;
};
-typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc,
- v8::Local<v8::Object> obj,
- v8::Local<v8::Object> global);
-typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj);
+using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc,
+ v8::Local<v8::Object> obj,
+ v8::Local<v8::Object> global);
+using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj);
+
+// Call before making FXJS_PrepareIsolate call.
+void FXJS_Initialize(unsigned int embedderDataSlot);
+void FXJS_Release();
+
+// Call before making FXJS_Define* calls. Resources allocated here are cleared
+// as part of FXJS_ReleaseRuntime().
+void FXJS_PrepareIsolate(v8::Isolate* pIsolate);
// Call before making JS_PrepareIsolate call.
void JS_Initialize(unsigned int embedderDataSlot);
@@ -70,156 +66,142 @@ void JS_Release();
void JS_PrepareIsolate(v8::Isolate* pIsolate);
// Always returns a valid, newly-created objDefnID.
-int JS_DefineObj(v8::Isolate* pIsolate,
- const wchar_t* sObjName,
- FXJSOBJTYPE eObjType,
- LP_CONSTRUCTOR pConstructor,
- LP_DESTRUCTOR pDestructor);
-
-void JS_DefineObjMethod(v8::Isolate* pIsolate,
- int nObjDefnID,
- const wchar_t* sMethodName,
- v8::FunctionCallback pMethodCall);
-void JS_DefineObjProperty(v8::Isolate* pIsolate,
+int FXJS_DefineObj(v8::Isolate* pIsolate,
+ const wchar_t* sObjName,
+ FXJSOBJTYPE eObjType,
+ FXJS_CONSTRUCTOR pConstructor,
+ FXJS_DESTRUCTOR pDestructor);
+
+void FXJS_DefineObjMethod(v8::Isolate* pIsolate,
int nObjDefnID,
- const wchar_t* sPropName,
- v8::AccessorGetterCallback pPropGet,
- v8::AccessorSetterCallback pPropPut);
-void JS_DefineObjAllProperties(v8::Isolate* pIsolate,
- int nObjDefnID,
- v8::NamedPropertyQueryCallback pPropQurey,
- v8::NamedPropertyGetterCallback pPropGet,
- v8::NamedPropertySetterCallback pPropPut,
- v8::NamedPropertyDeleterCallback pPropDel);
-void JS_DefineObjConst(v8::Isolate* pIsolate,
- int nObjDefnID,
- const wchar_t* sConstName,
- v8::Local<v8::Value> pDefault);
-void JS_DefineGlobalMethod(v8::Isolate* pIsolate,
- const wchar_t* sMethodName,
- v8::FunctionCallback pMethodCall);
-void JS_DefineGlobalConst(v8::Isolate* pIsolate,
- const wchar_t* sConstName,
- v8::Local<v8::Value> pDefault);
-
-// Called after JS_Define* calls made.
-void JS_InitializeRuntime(v8::Isolate* pIsolate,
- IFXJS_Runtime* pFXRuntime,
- IFXJS_Context* context,
- v8::Global<v8::Context>& v8PersistentContext);
-void JS_ReleaseRuntime(v8::Isolate* pIsolate,
- v8::Global<v8::Context>& v8PersistentContext);
-
-// Called after JS_InitializeRuntime call made.
-int JS_Execute(v8::Isolate* pIsolate,
- IFXJS_Context* pJSContext,
- const wchar_t* script,
- long length,
- FXJSErr* perror);
-
-v8::Local<v8::Object> JS_NewFxDynamicObj(v8::Isolate* pIsolate,
- IFXJS_Context* pJSContext,
- int nObjDefnID);
-v8::Local<v8::Object> JS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID);
-v8::Local<v8::Object> JS_GetThisObj(v8::Isolate* pIsolate);
-int JS_GetObjDefnID(v8::Local<v8::Object> pObj);
-v8::Isolate* JS_GetRuntime(v8::Local<v8::Object> pObj);
-int JS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName);
-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::Local<v8::Value> pObj);
-void JS_SetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj, void* p);
-void* JS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj);
-void JS_SetPrivate(v8::Local<v8::Object> pObj, void* p);
-void* JS_GetPrivate(v8::Local<v8::Object> pObj);
-void JS_FreePrivate(void* p);
-void JS_FreePrivate(v8::Local<v8::Object> pObj);
-v8::Local<v8::Value> JS_GetObjectValue(v8::Local<v8::Object> pObj);
-v8::Local<v8::Value> JS_GetObjectElement(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName);
-v8::Local<v8::Array> JS_GetObjectElementNames(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj);
-void JS_PutObjectString(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- const wchar_t* sValue);
-void JS_PutObjectNumber(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- int nValue);
-void JS_PutObjectNumber(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- float fValue);
-void JS_PutObjectNumber(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- double dValue);
-void JS_PutObjectBoolean(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- bool bValue);
-void JS_PutObjectObject(v8::Isolate* pIsolate,
+ const wchar_t* sMethodName,
+ v8::FunctionCallback pMethodCall);
+void FXJS_DefineObjProperty(v8::Isolate* pIsolate,
+ int nObjDefnID,
+ const wchar_t* sPropName,
+ v8::AccessorGetterCallback pPropGet,
+ v8::AccessorSetterCallback pPropPut);
+void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate,
+ int nObjDefnID,
+ v8::NamedPropertyQueryCallback pPropQurey,
+ v8::NamedPropertyGetterCallback pPropGet,
+ v8::NamedPropertySetterCallback pPropPut,
+ v8::NamedPropertyDeleterCallback pPropDel);
+void FXJS_DefineObjConst(v8::Isolate* pIsolate,
+ int nObjDefnID,
+ const wchar_t* sConstName,
+ v8::Local<v8::Value> pDefault);
+void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
+ const wchar_t* sMethodName,
+ v8::FunctionCallback pMethodCall);
+void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
+ const wchar_t* sConstName,
+ v8::Local<v8::Value> pDefault);
+
+// Called after FXJS_Define* calls made.
+void FXJS_InitializeRuntime(v8::Isolate* pIsolate,
+ IFXJS_Runtime* pFXRuntime,
+ IFXJS_Context* context,
+ v8::Global<v8::Context>& v8PersistentContext);
+void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
+ v8::Global<v8::Context>& v8PersistentContext);
+
+// Called after FXJS_InitializeRuntime call made.
+int FXJS_Execute(v8::Isolate* pIsolate,
+ IFXJS_Context* pJSContext,
+ const wchar_t* script,
+ long length,
+ FXJSErr* perror);
+
+v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,
+ IFXJS_Context* pJSContext,
+ int nObjDefnID);
+v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate);
+int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj);
+int FXJS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName);
+v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj);
+const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj);
+
+void FXJS_SetPrivate(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ void* p);
+void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p);
+void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj);
+void* FXJS_GetPrivate(v8::Local<v8::Object> pObj);
+void FXJS_FreePrivate(void* p);
+void FXJS_FreePrivate(v8::Local<v8::Object> pObj);
+
+void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message);
+v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
+ const wchar_t* PropertyName,
+ int Len = -1);
+
+v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName);
+v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj);
+
+v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate,
+ v8::Local<v8::Array> pArray,
+ unsigned index);
+unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
+
+void FXJS_PutObjectString(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ const wchar_t* sValue);
+void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ int nValue);
+void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ float fValue);
+void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ double dValue);
+void FXJS_PutObjectBoolean(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ bool bValue);
+void FXJS_PutObjectObject(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const wchar_t* PropertyName,
+ v8::Local<v8::Object> pPut);
+void FXJS_PutObjectNull(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- v8::Local<v8::Object> pPut);
-void JS_PutObjectNull(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName);
-unsigned JS_PutArrayElement(v8::Isolate* pIsolate,
- v8::Local<v8::Array> pArray,
- unsigned index,
- v8::Local<v8::Value> pValue,
- FXJSVALUETYPE eType);
-v8::Local<v8::Value> JS_GetArrayElement(v8::Isolate* pIsolate,
- v8::Local<v8::Array> pArray,
- unsigned index);
-unsigned JS_GetArrayLength(v8::Local<v8::Array> pArray);
-v8::Local<v8::Value> JS_GetListValue(v8::Isolate* pIsolate,
- v8::Local<v8::Value> pList,
- int index);
-
-v8::Local<v8::Array> JS_NewArray(v8::Isolate* pIsolate);
-v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, int number);
-v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, double number);
-v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, float number);
-v8::Local<v8::Value> JS_NewBoolean(v8::Isolate* pIsolate, bool b);
-v8::Local<v8::Value> JS_NewObject(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj);
-v8::Local<v8::Value> JS_NewObject2(v8::Isolate* pIsolate,
- v8::Local<v8::Array> pObj);
-v8::Local<v8::Value> JS_NewString(v8::Isolate* pIsolate, const wchar_t* string);
-v8::Local<v8::Value> JS_NewString(v8::Isolate* pIsolate,
- const wchar_t* string,
- unsigned nLen);
-v8::Local<v8::Value> JS_NewNull();
-v8::Local<v8::Value> JS_NewDate(v8::Isolate* pIsolate, double d);
-v8::Local<v8::Value> JS_NewValue(v8::Isolate* pIsolate);
-
-int JS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
-bool JS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
-double JS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
-v8::Local<v8::Object> JS_ToObject(v8::Isolate* pIsolate,
+ const wchar_t* PropertyName);
+unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate,
+ v8::Local<v8::Array> pArray,
+ unsigned index,
+ v8::Local<v8::Value> pValue);
+
+v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate);
+v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, int number);
+v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, double number);
+v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, float number);
+v8::Local<v8::Value> FXJS_NewBoolean(v8::Isolate* pIsolate, bool b);
+v8::Local<v8::Value> FXJS_NewObject(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj);
+v8::Local<v8::Value> FXJS_NewObject2(v8::Isolate* pIsolate,
+ v8::Local<v8::Array> pObj);
+v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate,
+ const wchar_t* string);
+v8::Local<v8::Value> FXJS_NewNull();
+v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d);
+
+int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
+bool FXJS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
+double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
+v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate,
+ v8::Local<v8::Value> pValue);
+CFX_WideString FXJS_ToString(v8::Isolate* pIsolate,
+ v8::Local<v8::Value> pValue);
+v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
v8::Local<v8::Value> pValue);
-CFX_WideString JS_ToString(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
-v8::Local<v8::Array> JS_ToArray(v8::Isolate* pIsolate,
- v8::Local<v8::Value> pValue);
-void JS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
-
-double JS_GetDateTime();
-int JS_GetYearFromTime(double dt);
-int JS_GetMonthFromTime(double dt);
-int JS_GetDayFromTime(double dt);
-int JS_GetHourFromTime(double dt);
-int JS_GetMinFromTime(double dt);
-int JS_GetSecFromTime(double dt);
-double JS_DateParse(const wchar_t* string);
-double JS_MakeDay(int nYear, int nMonth, int nDay);
-double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
-double JS_MakeDate(double day, double time);
-bool JS_PortIsNan(double d);
-double JS_LocalTime(double d);
+void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
#endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_