• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 class CFXJSE_Class;
10 class CFXJSE_Value;
11 class CFXJSE_Context {
12  protected:
CFXJSE_Context(v8::Isolate * pIsolate)13   CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}
14 
15  public:
16   static CFXJSE_Context* Create(v8::Isolate* pIsolate,
17                                 const FXJSE_CLASS* lpGlobalClass = NULL,
18                                 void* lpGlobalObject = NULL);
19   ~CFXJSE_Context();
GetRuntime(void)20   V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; }
21   void GetGlobalObject(CFXJSE_Value* pValue);
22   FX_BOOL ExecuteScript(const FX_CHAR* szScript,
23                         CFXJSE_Value* lpRetValue,
24                         CFXJSE_Value* lpNewThisObject = NULL);
25 
26  protected:
27   CFXJSE_Context();
28   CFXJSE_Context(const CFXJSE_Context&);
29   CFXJSE_Context& operator=(const CFXJSE_Context&);
30 
31  protected:
32   v8::Global<v8::Context> m_hContext;
33   v8::Isolate* m_pIsolate;
34   CFX_ArrayTemplate<CFXJSE_Class*> m_rgClasses;
35   friend class CFXJSE_Class;
36   friend class CFXJSE_ScopeUtil_IsolateHandleContext;
37   friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext;
38 };
39 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
40                                               v8::TryCatch& trycatch);
41 #endif
42