| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef FXJSE_CONTEXT_H_ | |
| 8 #define FXJSE_CONTEXT_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "core/fxcrt/include/fx_basic.h" | |
| 14 #include "fxjse/include/fxjse.h" | |
| 15 #include "v8/include/v8.h" | |
| 16 | |
| 17 class CFXJSE_Class; | |
| 18 class CFXJSE_Value; | |
| 19 struct FXJSE_CLASS_DESCRIPTOR; | |
| 20 | |
| 21 class CFXJSE_Context { | |
| 22 public: | |
| 23 static CFXJSE_Context* Create( | |
| 24 v8::Isolate* pIsolate, | |
| 25 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr, | |
| 26 CFXJSE_HostObject* lpGlobalObject = nullptr); | |
| 27 ~CFXJSE_Context(); | |
| 28 | |
| 29 v8::Isolate* GetRuntime() { return m_pIsolate; } | |
| 30 std::unique_ptr<CFXJSE_Value> GetGlobalObject(); | |
| 31 void EnableCompatibleMode(); | |
| 32 FX_BOOL ExecuteScript(const FX_CHAR* szScript, | |
| 33 CFXJSE_Value* lpRetValue, | |
| 34 CFXJSE_Value* lpNewThisObject = nullptr); | |
| 35 | |
| 36 protected: | |
| 37 CFXJSE_Context(); | |
| 38 CFXJSE_Context(const CFXJSE_Context&); | |
| 39 explicit CFXJSE_Context(v8::Isolate* pIsolate); | |
| 40 CFXJSE_Context& operator=(const CFXJSE_Context&); | |
| 41 | |
| 42 v8::Global<v8::Context> m_hContext; | |
| 43 v8::Isolate* m_pIsolate; | |
| 44 std::vector<std::unique_ptr<CFXJSE_Class>> m_rgClasses; | |
| 45 | |
| 46 friend class CFXJSE_Class; | |
| 47 friend class CFXJSE_ScopeUtil_IsolateHandleContext; | |
| 48 }; | |
| 49 | |
| 50 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, | |
| 51 v8::TryCatch& trycatch); | |
| 52 | |
| 53 v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( | |
| 54 const v8::Local<v8::Context>& hContext); | |
| 55 | |
| 56 void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, | |
| 57 CFXJSE_HostObject* lpNewBinding = nullptr); | |
| 58 | |
| 59 CFXJSE_HostObject* FXJSE_RetrieveObjectBinding( | |
| 60 const v8::Local<v8::Object>& hJSObject, | |
| 61 CFXJSE_Class* lpClass = nullptr); | |
| 62 | |
| 63 #endif // FXJSE_CONTEXT_H_ | |
| OLD | NEW |