| 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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but | 
| 8 // than including V8 headers directly. | 8 // has no knowledge of PDF-specific native objects. It could in theory be used | 
|  | 9 // to implement other sets of native objects. | 
|  | 10 | 
|  | 11 // PDFium code should include this file rather than including V8 headers | 
|  | 12 // directly. | 
| 9 | 13 | 
| 10 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 14 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 
| 11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 15 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 
| 12 | 16 | 
| 13 #include <v8.h> | 17 #include <v8.h> | 
| 14 #include "../../../core/include/fxcrt/fx_basic.h" | 18 #include "../../../core/include/fxcrt/fx_basic.h" | 
| 15 | 19 | 
| 16 // FXJS_V8 places no interpretation on these two classes; it merely | 20 // FXJS_V8 places no interpretation on these two classes; it merely | 
| 17 // passes them on to the caller-provided FXJS_CONSTRUCTORs. | 21 // passes them on to the caller-provided FXJS_CONSTRUCTORs. | 
| 18 class IFXJS_Context; | 22 class IJS_Context; | 
| 19 class IFXJS_Runtime; | 23 class IJS_Runtime; | 
| 20 | 24 | 
| 21 enum FXJSOBJTYPE { | 25 enum FXJSOBJTYPE { | 
| 22   FXJSOBJTYPE_DYNAMIC = 0,  // Created by native method and returned to JS. | 26   FXJSOBJTYPE_DYNAMIC = 0,  // Created by native method and returned to JS. | 
| 23   FXJSOBJTYPE_STATIC,       // Created by init and hung off of global object. | 27   FXJSOBJTYPE_STATIC,       // Created by init and hung off of global object. | 
| 24   FXJSOBJTYPE_GLOBAL,       // The global object itself (may only appear once). | 28   FXJSOBJTYPE_GLOBAL,       // The global object itself (may only appear once). | 
| 25 }; | 29 }; | 
| 26 | 30 | 
| 27 struct FXJSErr { | 31 struct FXJSErr { | 
| 28   const wchar_t* message; | 32   const wchar_t* message; | 
| 29   const wchar_t* srcline; | 33   const wchar_t* srcline; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 50 extern const wchar_t kFXJSValueNameNull[]; | 54 extern const wchar_t kFXJSValueNameNull[]; | 
| 51 extern const wchar_t kFXJSValueNameUndefined[]; | 55 extern const wchar_t kFXJSValueNameUndefined[]; | 
| 52 | 56 | 
| 53 | 57 | 
| 54 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 58 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 
| 55   void* Allocate(size_t length) override; | 59   void* Allocate(size_t length) override; | 
| 56   void* AllocateUninitialized(size_t length) override; | 60   void* AllocateUninitialized(size_t length) override; | 
| 57   void Free(void* data, size_t length) override; | 61   void Free(void* data, size_t length) override; | 
| 58 }; | 62 }; | 
| 59 | 63 | 
| 60 using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc, v8::Local<v8::Object> obj); | 64 using FXJS_CONSTRUCTOR = void (*)(IJS_Context* cc, v8::Local<v8::Object> obj); | 
| 61 using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); | 65 using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); | 
| 62 | 66 | 
| 63 // Call before making FXJS_PrepareIsolate call. | 67 // Call before making FXJS_PrepareIsolate call. | 
| 64 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); | 68 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); | 
| 65 void FXJS_Release(); | 69 void FXJS_Release(); | 
| 66 | 70 | 
| 67 // Gets the global isolate set by FXJS_Initialize(), or makes a new one each | 71 // Gets the global isolate set by FXJS_Initialize(), or makes a new one each | 
| 68 // time if there is no such isolate. Returns true if a new isolate had to be | 72 // time if there is no such isolate. Returns true if a new isolate had to be | 
| 69 // created. | 73 // created. | 
| 70 bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); | 74 bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108                          v8::Local<v8::Value> pDefault); | 112                          v8::Local<v8::Value> pDefault); | 
| 109 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, | 113 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, | 
| 110                              const wchar_t* sMethodName, | 114                              const wchar_t* sMethodName, | 
| 111                              v8::FunctionCallback pMethodCall); | 115                              v8::FunctionCallback pMethodCall); | 
| 112 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, | 116 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, | 
| 113                             const wchar_t* sConstName, | 117                             const wchar_t* sConstName, | 
| 114                             v8::Local<v8::Value> pDefault); | 118                             v8::Local<v8::Value> pDefault); | 
| 115 | 119 | 
| 116 // Called after FXJS_Define* calls made. | 120 // Called after FXJS_Define* calls made. | 
| 117 void FXJS_InitializeRuntime(v8::Isolate* pIsolate, | 121 void FXJS_InitializeRuntime(v8::Isolate* pIsolate, | 
| 118                             IFXJS_Runtime* pFXRuntime, | 122                             IJS_Runtime* pFXRuntime, | 
| 119                             IFXJS_Context* context, | 123                             IJS_Context* context, | 
| 120                             v8::Global<v8::Context>& v8PersistentContext); | 124                             v8::Global<v8::Context>& v8PersistentContext); | 
| 121 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 125 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 
| 122                          v8::Global<v8::Context>& v8PersistentContext); | 126                          v8::Global<v8::Context>& v8PersistentContext); | 
| 123 IFXJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); | 127 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); | 
| 124 | 128 | 
| 125 // Called after FXJS_InitializeRuntime call made. | 129 // Called after FXJS_InitializeRuntime call made. | 
| 126 int FXJS_Execute(v8::Isolate* pIsolate, | 130 int FXJS_Execute(v8::Isolate* pIsolate, | 
| 127                  IFXJS_Context* pJSContext, | 131                  IJS_Context* pJSContext, | 
| 128                  const wchar_t* script, | 132                  const wchar_t* script, | 
| 129                  long length, | 133                  long length, | 
| 130                  FXJSErr* perror); | 134                  FXJSErr* perror); | 
| 131 | 135 | 
| 132 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, | 136 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, | 
| 133                                            IFXJS_Context* pJSContext, | 137                                            IJS_Context* pJSContext, | 
| 134                                            int nObjDefnID); | 138                                            int nObjDefnID); | 
| 135 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); | 139 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); | 
| 136 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); | 140 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); | 
| 137 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj); | 141 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj); | 
| 138 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); | 142 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); | 
| 139 | 143 | 
| 140 void FXJS_SetPrivate(v8::Isolate* pIsolate, | 144 void FXJS_SetPrivate(v8::Isolate* pIsolate, | 
| 141                      v8::Local<v8::Object> pObj, | 145                      v8::Local<v8::Object> pObj, | 
| 142                      void* p); | 146                      void* p); | 
| 143 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); | 147 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 215 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 
| 212 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 216 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 
| 213                                     v8::Local<v8::Value> pValue); | 217                                     v8::Local<v8::Value> pValue); | 
| 214 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 218 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 
| 215                              v8::Local<v8::Value> pValue); | 219                              v8::Local<v8::Value> pValue); | 
| 216 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 220 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 
| 217                                   v8::Local<v8::Value> pValue); | 221                                   v8::Local<v8::Value> pValue); | 
| 218 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 222 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 
| 219 | 223 | 
| 220 #endif  // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 224 #endif  // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 
| OLD | NEW | 
|---|