| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 // PDFium wrapper around V8 APIs. PDFium code should include this file rather | 7 // PDFium wrapper around V8 APIs. PDFium code should include this file rather |
| 8 // than including V8 headers directly. | 8 // than including V8 headers directly. |
| 9 | 9 |
| 10 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 10 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 extern const wchar_t kFXJSValueNameString[]; | 39 extern const wchar_t kFXJSValueNameString[]; |
| 40 extern const wchar_t kFXJSValueNameNumber[]; | 40 extern const wchar_t kFXJSValueNameNumber[]; |
| 41 extern const wchar_t kFXJSValueNameBoolean[]; | 41 extern const wchar_t kFXJSValueNameBoolean[]; |
| 42 extern const wchar_t kFXJSValueNameDate[]; | 42 extern const wchar_t kFXJSValueNameDate[]; |
| 43 extern const wchar_t kFXJSValueNameObject[]; | 43 extern const wchar_t kFXJSValueNameObject[]; |
| 44 extern const wchar_t kFXJSValueNameFxobj[]; | 44 extern const wchar_t kFXJSValueNameFxobj[]; |
| 45 extern const wchar_t kFXJSValueNameNull[]; | 45 extern const wchar_t kFXJSValueNameNull[]; |
| 46 extern const wchar_t kFXJSValueNameUndefined[]; | 46 extern const wchar_t kFXJSValueNameUndefined[]; |
| 47 | 47 |
| 48 // FXJS_V8 places no interpretation on these two classes; it merely |
| 49 // passes them on to the caller-provided LP_CONSTRUCTORs. |
| 48 class IFXJS_Context; | 50 class IFXJS_Context; |
| 49 class IFXJS_Runtime; | 51 class IFXJS_Runtime; |
| 50 | 52 |
| 53 class JS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 54 void* Allocate(size_t length) override; |
| 55 void* AllocateUninitialized(size_t length) override; |
| 56 void Free(void* data, size_t length) override; |
| 57 }; |
| 58 |
| 51 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, | 59 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, |
| 52 v8::Local<v8::Object> obj, | 60 v8::Local<v8::Object> obj, |
| 53 v8::Local<v8::Object> global); | 61 v8::Local<v8::Object> global); |
| 54 typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj); | 62 typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj); |
| 55 | 63 |
| 64 // Call before making JS_PrepareIsolate call. |
| 65 void JS_Initialize(unsigned int embedderDataSlot); |
| 66 void JS_Release(); |
| 67 |
| 68 // Call before making JS_Define* calls. Resources allocated here are cleared |
| 69 // as part of JS_ReleaseRuntime(). |
| 70 void JS_PrepareIsolate(v8::Isolate* pIsolate); |
| 71 |
| 56 // Always returns a valid, newly-created objDefnID. | 72 // Always returns a valid, newly-created objDefnID. |
| 57 int JS_DefineObj(v8::Isolate* pIsolate, | 73 int JS_DefineObj(v8::Isolate* pIsolate, |
| 58 const wchar_t* sObjName, | 74 const wchar_t* sObjName, |
| 59 FXJSOBJTYPE eObjType, | 75 FXJSOBJTYPE eObjType, |
| 60 LP_CONSTRUCTOR pConstructor, | 76 LP_CONSTRUCTOR pConstructor, |
| 61 LP_DESTRUCTOR pDestructor); | 77 LP_DESTRUCTOR pDestructor); |
| 62 | 78 |
| 63 void JS_DefineObjMethod(v8::Isolate* pIsolate, | 79 void JS_DefineObjMethod(v8::Isolate* pIsolate, |
| 64 int nObjDefnID, | 80 int nObjDefnID, |
| 65 const wchar_t* sMethodName, | 81 const wchar_t* sMethodName, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 int nObjDefnID, | 95 int nObjDefnID, |
| 80 const wchar_t* sConstName, | 96 const wchar_t* sConstName, |
| 81 v8::Local<v8::Value> pDefault); | 97 v8::Local<v8::Value> pDefault); |
| 82 void JS_DefineGlobalMethod(v8::Isolate* pIsolate, | 98 void JS_DefineGlobalMethod(v8::Isolate* pIsolate, |
| 83 const wchar_t* sMethodName, | 99 const wchar_t* sMethodName, |
| 84 v8::FunctionCallback pMethodCall); | 100 v8::FunctionCallback pMethodCall); |
| 85 void JS_DefineGlobalConst(v8::Isolate* pIsolate, | 101 void JS_DefineGlobalConst(v8::Isolate* pIsolate, |
| 86 const wchar_t* sConstName, | 102 const wchar_t* sConstName, |
| 87 v8::Local<v8::Value> pDefault); | 103 v8::Local<v8::Value> pDefault); |
| 88 | 104 |
| 89 void JS_InitialRuntime(v8::Isolate* pIsolate, | 105 // Called after JS_Define* calls made. |
| 90 IFXJS_Runtime* pFXRuntime, | 106 void JS_InitializeRuntime(v8::Isolate* pIsolate, |
| 91 IFXJS_Context* context, | 107 IFXJS_Runtime* pFXRuntime, |
| 92 v8::Global<v8::Context>& v8PersistentContext); | 108 IFXJS_Context* context, |
| 109 v8::Global<v8::Context>& v8PersistentContext); |
| 93 void JS_ReleaseRuntime(v8::Isolate* pIsolate, | 110 void JS_ReleaseRuntime(v8::Isolate* pIsolate, |
| 94 v8::Global<v8::Context>& v8PersistentContext); | 111 v8::Global<v8::Context>& v8PersistentContext); |
| 95 void JS_Initial(unsigned int embedderDataSlot); | 112 |
| 96 void JS_Release(); | 113 // Called after JS_InitializeRuntime call made. |
| 97 int JS_Execute(v8::Isolate* pIsolate, | 114 int JS_Execute(v8::Isolate* pIsolate, |
| 98 IFXJS_Context* pJSContext, | 115 IFXJS_Context* pJSContext, |
| 99 const wchar_t* script, | 116 const wchar_t* script, |
| 100 long length, | 117 long length, |
| 101 FXJSErr* perror); | 118 FXJSErr* perror); |
| 119 |
| 102 v8::Local<v8::Object> JS_NewFxDynamicObj(v8::Isolate* pIsolate, | 120 v8::Local<v8::Object> JS_NewFxDynamicObj(v8::Isolate* pIsolate, |
| 103 IFXJS_Context* pJSContext, | 121 IFXJS_Context* pJSContext, |
| 104 int nObjDefnID); | 122 int nObjDefnID); |
| 105 v8::Local<v8::Object> JS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID); | 123 v8::Local<v8::Object> JS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID); |
| 106 v8::Local<v8::Object> JS_GetThisObj(v8::Isolate* pIsolate); | 124 v8::Local<v8::Object> JS_GetThisObj(v8::Isolate* pIsolate); |
| 107 int JS_GetObjDefnID(v8::Local<v8::Object> pObj); | 125 int JS_GetObjDefnID(v8::Local<v8::Object> pObj); |
| 108 v8::Isolate* JS_GetRuntime(v8::Local<v8::Object> pObj); | 126 v8::Isolate* JS_GetRuntime(v8::Local<v8::Object> pObj); |
| 109 int JS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName); | 127 int JS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName); |
| 110 void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); | 128 void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); |
| 111 unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); | 129 unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 int JS_GetMinFromTime(double dt); | 216 int JS_GetMinFromTime(double dt); |
| 199 int JS_GetSecFromTime(double dt); | 217 int JS_GetSecFromTime(double dt); |
| 200 double JS_DateParse(const wchar_t* string); | 218 double JS_DateParse(const wchar_t* string); |
| 201 double JS_MakeDay(int nYear, int nMonth, int nDay); | 219 double JS_MakeDay(int nYear, int nMonth, int nDay); |
| 202 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); | 220 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); |
| 203 double JS_MakeDate(double day, double time); | 221 double JS_MakeDate(double day, double time); |
| 204 bool JS_PortIsNan(double d); | 222 bool JS_PortIsNan(double d); |
| 205 double JS_LocalTime(double d); | 223 double JS_LocalTime(double d); |
| 206 | 224 |
| 207 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 225 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
| OLD | NEW |