diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-17 15:25:23 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-17 15:25:23 -0700 |
commit | 39bfe122b4867601051c56562a5ab9cf6be644ad (patch) | |
tree | 73ea2387759b2ba2a80ab344da69dc063fc69172 /fpdfsdk/include/jsapi/fxjs_v8.h | |
parent | 4babdcf9c7abc9edefb179e5ed23db8e7a5840f7 (diff) | |
download | pdfium-39bfe122b4867601051c56562a5ab9cf6be644ad.tar.xz |
Merge to XFA: Ensure functions in FXJS_V8 are prefixed by FXJS_.
Manual edits:
fpdfsdk/include/javascript/JS_Define.h
fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
fpdfsdk/src/javascript/Document.cpp
fpdfsdk/src/javascript/JS_Runtime.cpp
fpdfsdk/src/jsapi/fxjs_v8.cpp
(cherry picked from commit 506df426d5d64d68e9dc27ffebcf56f6c6a1bccf)
Original Review URL: https://codereview.chromium.org/1347833002 .
(cherry picked from commit 455019ca48f60bd285e043986471f51f17c69a0d)
Original Review URL: https://codereview.chromium.org/1349783003 .
(cherry picked from commit 1af240cc45480520b447be767686e73a29c48f9e)
Original Review URL: https://codereview.chromium.org/1348693003 .
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1356563003 .
Diffstat (limited to 'fpdfsdk/include/jsapi/fxjs_v8.h')
-rw-r--r-- | fpdfsdk/include/jsapi/fxjs_v8.h | 318 |
1 files changed, 150 insertions, 168 deletions
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_ |