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 // FXJS_V8 places no interpreation on this calass; it merely passes it | 25 // FXJS_V8 places no interpreation on this calass; it merely passes it |
22 // along to XFA. | 26 // along to XFA. |
23 class CFXJSE_RuntimeData; | 27 class CFXJSE_RuntimeData; |
24 | 28 |
25 enum FXJSOBJTYPE { | 29 enum FXJSOBJTYPE { |
26 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. | 30 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. |
27 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. | 31 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. |
28 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). | 32 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). |
29 }; | 33 }; |
(...skipping 25 matching lines...) Expand all Loading... |
55 extern const wchar_t kFXJSValueNameNull[]; | 59 extern const wchar_t kFXJSValueNameNull[]; |
56 extern const wchar_t kFXJSValueNameUndefined[]; | 60 extern const wchar_t kFXJSValueNameUndefined[]; |
57 | 61 |
58 | 62 |
59 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 63 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
60 void* Allocate(size_t length) override; | 64 void* Allocate(size_t length) override; |
61 void* AllocateUninitialized(size_t length) override; | 65 void* AllocateUninitialized(size_t length) override; |
62 void Free(void* data, size_t length) override; | 66 void Free(void* data, size_t length) override; |
63 }; | 67 }; |
64 | 68 |
65 using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc, v8::Local<v8::Object> obj); | 69 using FXJS_CONSTRUCTOR = void (*)(IJS_Context* cc, v8::Local<v8::Object> obj); |
66 using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); | 70 using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); |
67 | 71 |
68 // Call before making FXJS_PrepareIsolate call. | 72 // Call before making FXJS_PrepareIsolate call. |
69 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); | 73 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); |
70 void FXJS_Release(); | 74 void FXJS_Release(); |
71 | 75 |
72 // Gets the global isolate set by FXJS_Initialize(), or makes a new one each | 76 // Gets the global isolate set by FXJS_Initialize(), or makes a new one each |
73 // time if there is no such isolate. Returns true if a new isolate had to be | 77 // time if there is no such isolate. Returns true if a new isolate had to be |
74 // created. | 78 // created. |
75 bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); | 79 bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 v8::Local<v8::Value> pDefault); | 114 v8::Local<v8::Value> pDefault); |
111 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, | 115 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, |
112 const wchar_t* sMethodName, | 116 const wchar_t* sMethodName, |
113 v8::FunctionCallback pMethodCall); | 117 v8::FunctionCallback pMethodCall); |
114 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, | 118 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, |
115 const wchar_t* sConstName, | 119 const wchar_t* sConstName, |
116 v8::Local<v8::Value> pDefault); | 120 v8::Local<v8::Value> pDefault); |
117 | 121 |
118 // Called after FXJS_Define* calls made. | 122 // Called after FXJS_Define* calls made. |
119 void FXJS_InitializeRuntime(v8::Isolate* pIsolate, | 123 void FXJS_InitializeRuntime(v8::Isolate* pIsolate, |
120 IFXJS_Runtime* pFXRuntime, | 124 IJS_Runtime* pFXRuntime, |
121 IFXJS_Context* context, | 125 IJS_Context* context, |
122 v8::Global<v8::Context>& v8PersistentContext); | 126 v8::Global<v8::Context>& v8PersistentContext); |
123 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 127 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, |
124 v8::Global<v8::Context>& v8PersistentContext); | 128 v8::Global<v8::Context>& v8PersistentContext); |
125 IFXJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); | 129 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); |
126 | 130 |
127 // Called after FXJS_InitializeRuntime call made. | 131 // Called after FXJS_InitializeRuntime call made. |
128 int FXJS_Execute(v8::Isolate* pIsolate, | 132 int FXJS_Execute(v8::Isolate* pIsolate, |
129 IFXJS_Context* pJSContext, | 133 IJS_Context* pJSContext, |
130 const wchar_t* script, | 134 const wchar_t* script, |
131 long length, | 135 long length, |
132 FXJSErr* perror); | 136 FXJSErr* perror); |
133 | 137 |
134 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, | 138 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, |
135 IFXJS_Context* pJSContext, | 139 IJS_Context* pJSContext, |
136 int nObjDefnID); | 140 int nObjDefnID); |
137 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); | 141 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); |
138 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); | 142 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); |
139 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj); | 143 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj); |
140 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); | 144 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); |
141 | 145 |
142 void FXJS_SetPrivate(v8::Isolate* pIsolate, | 146 void FXJS_SetPrivate(v8::Isolate* pIsolate, |
143 v8::Local<v8::Object> pObj, | 147 v8::Local<v8::Object> pObj, |
144 void* p); | 148 void* p); |
145 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); | 149 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 217 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
214 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 218 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
215 v8::Local<v8::Value> pValue); | 219 v8::Local<v8::Value> pValue); |
216 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 220 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
217 v8::Local<v8::Value> pValue); | 221 v8::Local<v8::Value> pValue); |
218 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 222 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
219 v8::Local<v8::Value> pValue); | 223 v8::Local<v8::Value> pValue); |
220 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 224 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); |
221 | 225 |
222 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 226 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
OLD | NEW |