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_ |
11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
12 | 12 |
13 #include <v8.h> | 13 #include <v8.h> |
14 #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString | 14 #include "../../../core/include/fxcrt/fx_basic.h" |
| 15 |
| 16 // FXJS_V8 places no interpretation on these two classes; it merely |
| 17 // passes them on to the caller-provided FXJS_CONSTRUCTORs. |
| 18 class IFXJS_Context; |
| 19 class IFXJS_Runtime; |
| 20 |
| 21 // FXJS_V8 places no interpreation on this calass; it merely passes it |
| 22 // along to XFA. |
| 23 class CFXJSE_RuntimeData; |
15 | 24 |
16 enum FXJSOBJTYPE { | 25 enum FXJSOBJTYPE { |
17 FXJS_DYNAMIC = 0, | 26 FXJS_DYNAMIC = 0, |
18 FXJS_STATIC = 1, | 27 FXJS_STATIC = 1, |
19 }; | 28 }; |
20 | 29 |
21 struct FXJSErr { | 30 struct FXJSErr { |
22 const wchar_t* message; | 31 const wchar_t* message; |
23 const wchar_t* srcline; | 32 const wchar_t* srcline; |
24 unsigned linnum; | 33 unsigned linnum; |
25 }; | 34 }; |
26 | 35 |
| 36 class FXJS_PerIsolateData { |
| 37 public: |
| 38 static void SetUp(v8::Isolate* pIsolate); |
| 39 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
| 40 |
| 41 CFX_PtrArray m_ObjectDefnArray; |
| 42 IFXJS_Runtime* m_pFXJSRuntime; |
| 43 CFXJSE_RuntimeData* m_pFXJSERuntimeData; |
| 44 |
| 45 protected: |
| 46 FXJS_PerIsolateData() |
| 47 : m_pFXJSRuntime(nullptr), m_pFXJSERuntimeData(nullptr) {} |
| 48 }; |
| 49 |
27 extern const wchar_t kFXJSValueNameString[]; | 50 extern const wchar_t kFXJSValueNameString[]; |
28 extern const wchar_t kFXJSValueNameNumber[]; | 51 extern const wchar_t kFXJSValueNameNumber[]; |
29 extern const wchar_t kFXJSValueNameBoolean[]; | 52 extern const wchar_t kFXJSValueNameBoolean[]; |
30 extern const wchar_t kFXJSValueNameDate[]; | 53 extern const wchar_t kFXJSValueNameDate[]; |
31 extern const wchar_t kFXJSValueNameObject[]; | 54 extern const wchar_t kFXJSValueNameObject[]; |
32 extern const wchar_t kFXJSValueNameFxobj[]; | 55 extern const wchar_t kFXJSValueNameFxobj[]; |
33 extern const wchar_t kFXJSValueNameNull[]; | 56 extern const wchar_t kFXJSValueNameNull[]; |
34 extern const wchar_t kFXJSValueNameUndefined[]; | 57 extern const wchar_t kFXJSValueNameUndefined[]; |
35 | 58 |
36 // FXJS_V8 places no interpretation on these two classes; it merely | |
37 // passes them on to the caller-provided FXJS_CONSTRUCTORs. | |
38 class IFXJS_Context; | |
39 class IFXJS_Runtime; | |
40 | 59 |
41 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 60 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
42 void* Allocate(size_t length) override; | 61 void* Allocate(size_t length) override; |
43 void* AllocateUninitialized(size_t length) override; | 62 void* AllocateUninitialized(size_t length) override; |
44 void Free(void* data, size_t length) override; | 63 void Free(void* data, size_t length) override; |
45 }; | 64 }; |
46 | 65 |
47 using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc, | 66 using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc, |
48 v8::Local<v8::Object> obj, | 67 v8::Local<v8::Object> obj, |
49 v8::Local<v8::Object> global); | 68 v8::Local<v8::Object> global); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 215 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
197 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 216 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
198 v8::Local<v8::Value> pValue); | 217 v8::Local<v8::Value> pValue); |
199 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 218 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
200 v8::Local<v8::Value> pValue); | 219 v8::Local<v8::Value> pValue); |
201 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 220 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
202 v8::Local<v8::Value> pValue); | 221 v8::Local<v8::Value> pValue); |
203 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); |
204 | 223 |
205 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 224 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
OLD | NEW |