Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1247)

Side by Side Diff: fpdfsdk/include/jsapi/fxjs_v8.h

Issue 1477583002: Inflict PDF_ENABLE_XFA ifdefs on XFA fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 // PDFium code should include this file rather than including V8 headers 11 // PDFium code should include this file rather than including V8 headers
12 // directly. 12 // directly.
13 13
14 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 14 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
15 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 15 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
16 16
17 #include <v8.h> 17 #include <v8.h>
18 18
19 #include <vector> 19 #include <vector>
20 20
21 #include "core/include/fxcrt/fx_string.h" 21 #include "core/include/fxcrt/fx_string.h"
22 22
23 class CFXJS_ObjDefinition; 23 class CFXJS_ObjDefinition;
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 // 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
31 // along to XFA. 32 // along to XFA.
32 class CFXJSE_RuntimeData; 33 class CFXJSE_RuntimeData;
33 34
35 #endif
34 enum FXJSOBJTYPE { 36 enum FXJSOBJTYPE {
35 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. 37 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS.
36 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. 38 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object.
37 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). 39 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once).
38 }; 40 };
39 41
40 struct FXJSErr { 42 struct FXJSErr {
41 const wchar_t* message; 43 const wchar_t* message;
42 const wchar_t* srcline; 44 const wchar_t* srcline;
43 unsigned linnum; 45 unsigned linnum;
44 }; 46 };
45 47
46 class FXJS_PerIsolateData { 48 class FXJS_PerIsolateData {
47 public: 49 public:
48 static void SetUp(v8::Isolate* pIsolate); 50 static void SetUp(v8::Isolate* pIsolate);
49 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); 51 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate);
50 52
51 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; 53 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray;
54 #ifdef PDF_ENABLE_XFA
52 CFXJSE_RuntimeData* m_pFXJSERuntimeData; 55 CFXJSE_RuntimeData* m_pFXJSERuntimeData;
56 #endif
53 57
54 protected: 58 protected:
59 #ifndef PDF_ENABLE_XFA
60 FXJS_PerIsolateData() {}
61 #else
55 FXJS_PerIsolateData() : m_pFXJSERuntimeData(nullptr) {} 62 FXJS_PerIsolateData() : m_pFXJSERuntimeData(nullptr) {}
63 #endif
56 }; 64 };
57 65
58 extern const wchar_t kFXJSValueNameString[]; 66 extern const wchar_t kFXJSValueNameString[];
59 extern const wchar_t kFXJSValueNameNumber[]; 67 extern const wchar_t kFXJSValueNameNumber[];
60 extern const wchar_t kFXJSValueNameBoolean[]; 68 extern const wchar_t kFXJSValueNameBoolean[];
61 extern const wchar_t kFXJSValueNameDate[]; 69 extern const wchar_t kFXJSValueNameDate[];
62 extern const wchar_t kFXJSValueNameObject[]; 70 extern const wchar_t kFXJSValueNameObject[];
63 extern const wchar_t kFXJSValueNameFxobj[]; 71 extern const wchar_t kFXJSValueNameFxobj[];
64 extern const wchar_t kFXJSValueNameNull[]; 72 extern const wchar_t kFXJSValueNameNull[];
65 extern const wchar_t kFXJSValueNameUndefined[]; 73 extern const wchar_t kFXJSValueNameUndefined[];
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 136
129 // Called after FXJS_Define* calls made. 137 // Called after FXJS_Define* calls made.
130 void FXJS_InitializeRuntime( 138 void FXJS_InitializeRuntime(
131 v8::Isolate* pIsolate, 139 v8::Isolate* pIsolate,
132 IJS_Runtime* pIRuntime, 140 IJS_Runtime* pIRuntime,
133 v8::Global<v8::Context>* pV8PersistentContext, 141 v8::Global<v8::Context>* pV8PersistentContext,
134 std::vector<v8::Global<v8::Object>*>* pStaticObjects); 142 std::vector<v8::Global<v8::Object>*>* pStaticObjects);
135 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, 143 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
136 v8::Global<v8::Context>* pV8PersistentContext, 144 v8::Global<v8::Context>* pV8PersistentContext,
137 std::vector<v8::Global<v8::Object>*>* pStaticObjects); 145 std::vector<v8::Global<v8::Object>*>* pStaticObjects);
146 #ifdef PDF_ENABLE_XFA
138 147
Lei Zhang 2015/11/25 00:12:02 another silly diff
Tom Sepez 2015/11/25 21:45:29 Will handle in new CL and regenerate afterwards.
148 #endif
139 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); 149 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate);
140 150
151 #ifdef PDF_ENABLE_XFA
141 // Called as part of FXJS_InitializeRuntime, exposed so PDF can make its 152 // Called as part of FXJS_InitializeRuntime, exposed so PDF can make its
142 // own contexts compatible with XFA or vice versa. 153 // own contexts compatible with XFA or vice versa.
143 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, 154 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
144 IJS_Runtime* pIRuntime); 155 IJS_Runtime* pIRuntime);
145 156
157 #endif
146 // Called after FXJS_InitializeRuntime call made. 158 // Called after FXJS_InitializeRuntime call made.
147 int FXJS_Execute(v8::Isolate* pIsolate, 159 int FXJS_Execute(v8::Isolate* pIsolate,
148 IJS_Context* pJSContext, 160 IJS_Context* pJSContext,
149 const wchar_t* script, 161 const wchar_t* script,
150 FXJSErr* perror); 162 FXJSErr* perror);
151 163
152 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, 164 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,
153 IJS_Runtime* pJSContext, 165 IJS_Runtime* pJSContext,
154 int nObjDefnID); 166 int nObjDefnID);
155 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); 167 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); 242 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
231 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, 243 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate,
232 v8::Local<v8::Value> pValue); 244 v8::Local<v8::Value> pValue);
233 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, 245 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate,
234 v8::Local<v8::Value> pValue); 246 v8::Local<v8::Value> pValue);
235 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, 247 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
236 v8::Local<v8::Value> pValue); 248 v8::Local<v8::Value> pValue);
237 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); 249 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
238 250
239 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 251 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698