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 #ifndef XFA_FXJSE_CONTEXT_H_ | 7 #ifndef XFA_FXJSE_CONTEXT_H_ |
8 #define XFA_FXJSE_CONTEXT_H_ | 8 #define XFA_FXJSE_CONTEXT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/fxcrt/include/fx_basic.h" | 13 #include "core/fxcrt/include/fx_basic.h" |
14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
15 #include "xfa/fxjse/include/fxjse.h" | 15 #include "xfa/fxjse/include/fxjse.h" |
16 | 16 |
17 class CFXJSE_Class; | 17 class CFXJSE_Class; |
18 class CFXJSE_Value; | 18 class CFXJSE_Value; |
19 struct FXJSE_CLASS; | 19 struct FXJSE_CLASS_DESCRIPTOR; |
20 | 20 |
21 class CFXJSE_Context { | 21 class CFXJSE_Context { |
22 public: | 22 public: |
23 static CFXJSE_Context* Create(v8::Isolate* pIsolate, | 23 static CFXJSE_Context* Create( |
24 const FXJSE_CLASS* lpGlobalClass = nullptr, | 24 v8::Isolate* pIsolate, |
25 void* lpGlobalObject = nullptr); | 25 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr, |
| 26 void* lpGlobalObject = nullptr); |
26 ~CFXJSE_Context(); | 27 ~CFXJSE_Context(); |
27 | 28 |
28 V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } | 29 V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } |
29 void GetGlobalObject(CFXJSE_Value* pValue); | 30 void GetGlobalObject(CFXJSE_Value* pValue); |
30 FX_BOOL ExecuteScript(const FX_CHAR* szScript, | 31 FX_BOOL ExecuteScript(const FX_CHAR* szScript, |
31 CFXJSE_Value* lpRetValue, | 32 CFXJSE_Value* lpRetValue, |
32 CFXJSE_Value* lpNewThisObject = nullptr); | 33 CFXJSE_Value* lpNewThisObject = nullptr); |
33 | 34 |
34 protected: | 35 protected: |
35 CFXJSE_Context(); | 36 CFXJSE_Context(); |
36 CFXJSE_Context(const CFXJSE_Context&); | 37 CFXJSE_Context(const CFXJSE_Context&); |
37 explicit CFXJSE_Context(v8::Isolate* pIsolate); | 38 explicit CFXJSE_Context(v8::Isolate* pIsolate); |
38 CFXJSE_Context& operator=(const CFXJSE_Context&); | 39 CFXJSE_Context& operator=(const CFXJSE_Context&); |
39 | 40 |
40 v8::Global<v8::Context> m_hContext; | 41 v8::Global<v8::Context> m_hContext; |
41 v8::Isolate* m_pIsolate; | 42 v8::Isolate* m_pIsolate; |
42 std::vector<std::unique_ptr<CFXJSE_Class>> m_rgClasses; | 43 std::vector<std::unique_ptr<CFXJSE_Class>> m_rgClasses; |
43 | 44 |
44 friend class CFXJSE_Class; | 45 friend class CFXJSE_Class; |
45 friend class CFXJSE_ScopeUtil_IsolateHandleContext; | 46 friend class CFXJSE_ScopeUtil_IsolateHandleContext; |
46 friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext; | 47 friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext; |
47 }; | 48 }; |
48 | 49 |
49 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, | 50 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, |
50 v8::TryCatch& trycatch); | 51 v8::TryCatch& trycatch); |
51 | 52 |
52 #endif // XFA_FXJSE_CONTEXT_H_ | 53 #endif // XFA_FXJSE_CONTEXT_H_ |
OLD | NEW |