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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but | 7 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but |
8 // has no knowledge of PDF-specific native objects. It could in theory be used | 8 // has no knowledge of PDF-specific native objects. It could in theory be used |
9 // to implement other sets of native objects. | 9 // to implement other sets of native objects. |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 // FXJS_V8 places no restrictions on these two classes; it merely passes them | 25 // FXJS_V8 places no restrictions on these two classes; it merely passes them |
26 // on to caller-provided methods. | 26 // on to caller-provided methods. |
27 class IJS_Context; // A description of the event that caused JS execution. | 27 class IJS_Context; // A description of the event that caused JS execution. |
28 class IJS_Runtime; // A native runtime, typically owns the v8::Context. | 28 class IJS_Runtime; // A native runtime, typically owns the v8::Context. |
29 | 29 |
30 #ifdef PDF_ENABLE_XFA | 30 #ifdef PDF_ENABLE_XFA |
31 // FXJS_V8 places no interpreation on this calass; it merely passes it | 31 // FXJS_V8 places no interpreation on this calass; it merely passes it |
32 // along to XFA. | 32 // along to XFA. |
33 class CFXJSE_RuntimeData; | 33 class CFXJSE_RuntimeData; |
| 34 #endif // PDF_ENABLE_XFA |
34 | 35 |
35 #endif | |
36 enum FXJSOBJTYPE { | 36 enum FXJSOBJTYPE { |
37 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. | 37 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. |
38 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. | 38 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. |
39 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). | 39 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). |
40 }; | 40 }; |
41 | 41 |
42 struct FXJSErr { | 42 struct FXJSErr { |
43 const wchar_t* message; | 43 const wchar_t* message; |
44 const wchar_t* srcline; | 44 const wchar_t* srcline; |
45 unsigned linnum; | 45 unsigned linnum; |
46 }; | 46 }; |
47 | 47 |
48 class FXJS_PerIsolateData { | 48 class FXJS_PerIsolateData { |
49 public: | 49 public: |
50 static void SetUp(v8::Isolate* pIsolate); | 50 static void SetUp(v8::Isolate* pIsolate); |
51 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); | 51 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
52 | 52 |
53 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; | 53 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; |
54 #ifdef PDF_ENABLE_XFA | 54 #ifdef PDF_ENABLE_XFA |
55 CFXJSE_RuntimeData* m_pFXJSERuntimeData; | 55 CFXJSE_RuntimeData* m_pFXJSERuntimeData; |
56 #endif | 56 #endif // PDF_ENABLE_XFA |
57 | 57 |
58 protected: | 58 protected: |
59 #ifndef PDF_ENABLE_XFA | 59 #ifndef PDF_ENABLE_XFA |
60 FXJS_PerIsolateData() {} | 60 FXJS_PerIsolateData() {} |
61 #else | 61 #else // PDF_ENABLE_XFA |
62 FXJS_PerIsolateData() : m_pFXJSERuntimeData(nullptr) {} | 62 FXJS_PerIsolateData() : m_pFXJSERuntimeData(nullptr) {} |
63 #endif | 63 #endif // PDF_ENABLE_XFA |
64 }; | 64 }; |
65 | 65 |
66 extern const wchar_t kFXJSValueNameString[]; | 66 extern const wchar_t kFXJSValueNameString[]; |
67 extern const wchar_t kFXJSValueNameNumber[]; | 67 extern const wchar_t kFXJSValueNameNumber[]; |
68 extern const wchar_t kFXJSValueNameBoolean[]; | 68 extern const wchar_t kFXJSValueNameBoolean[]; |
69 extern const wchar_t kFXJSValueNameDate[]; | 69 extern const wchar_t kFXJSValueNameDate[]; |
70 extern const wchar_t kFXJSValueNameObject[]; | 70 extern const wchar_t kFXJSValueNameObject[]; |
71 extern const wchar_t kFXJSValueNameFxobj[]; | 71 extern const wchar_t kFXJSValueNameFxobj[]; |
72 extern const wchar_t kFXJSValueNameNull[]; | 72 extern const wchar_t kFXJSValueNameNull[]; |
73 extern const wchar_t kFXJSValueNameUndefined[]; | 73 extern const wchar_t kFXJSValueNameUndefined[]; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 143 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, |
144 v8::Global<v8::Context>* pV8PersistentContext, | 144 v8::Global<v8::Context>* pV8PersistentContext, |
145 std::vector<v8::Global<v8::Object>*>* pStaticObjects); | 145 std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
146 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); | 146 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); |
147 | 147 |
148 #ifdef PDF_ENABLE_XFA | 148 #ifdef PDF_ENABLE_XFA |
149 // Called as part of FXJS_InitializeRuntime, exposed so PDF can make its | 149 // Called as part of FXJS_InitializeRuntime, exposed so PDF can make its |
150 // own contexts compatible with XFA or vice versa. | 150 // own contexts compatible with XFA or vice versa. |
151 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, | 151 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, |
152 IJS_Runtime* pIRuntime); | 152 IJS_Runtime* pIRuntime); |
| 153 #endif // PDF_ENABLE_XFA |
153 | 154 |
154 #endif | |
155 // Called after FXJS_InitializeRuntime call made. | 155 // Called after FXJS_InitializeRuntime call made. |
156 int FXJS_Execute(v8::Isolate* pIsolate, | 156 int FXJS_Execute(v8::Isolate* pIsolate, |
157 IJS_Context* pJSContext, | 157 IJS_Context* pJSContext, |
158 const wchar_t* script, | 158 const wchar_t* script, |
159 FXJSErr* perror); | 159 FXJSErr* perror); |
160 | 160 |
161 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, | 161 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, |
162 IJS_Runtime* pJSContext, | 162 IJS_Runtime* pJSContext, |
163 int nObjDefnID); | 163 int nObjDefnID); |
164 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); | 164 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 239 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
240 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 240 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
241 v8::Local<v8::Value> pValue); | 241 v8::Local<v8::Value> pValue); |
242 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 242 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
243 v8::Local<v8::Value> pValue); | 243 v8::Local<v8::Value> pValue); |
244 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 244 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
245 v8::Local<v8::Value> pValue); | 245 v8::Local<v8::Value> pValue); |
246 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 246 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); |
247 | 247 |
248 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 248 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
OLD | NEW |