Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxjse / src / context.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef FXJSE_CONTEXT_H_\r
8 #define FXJSE_CONTEXT_H_\r
9 class CFXJSE_Class;\r
10 class CFXJSE_Value;\r
11 class CFXJSE_Context : public CFX_Object\r
12 {\r
13 protected:\r
14     CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}\r
15 public:\r
16     static CFXJSE_Context* Create(v8::Isolate* pIsolate, const FXJSE_CLASS* lpGlobalClass = NULL, FX_LPVOID lpGlobalObject = NULL);\r
17     ~CFXJSE_Context();\r
18     V8_INLINE v8::Isolate* GetRuntime(void)\r
19     {\r
20         return m_pIsolate;\r
21     }\r
22     void GetGlobalObject(CFXJSE_Value* pValue);\r
23     FX_BOOL     ExecuteScript(FX_LPCSTR szScript, CFXJSE_Value* lpRetValue, CFXJSE_Value* lpNewThisObject = NULL);\r
24 protected:\r
25     CFXJSE_Context();\r
26     CFXJSE_Context(const CFXJSE_Context&);\r
27     CFXJSE_Context& operator = (const CFXJSE_Context&);\r
28 protected:\r
29     v8::Persistent<v8::Context>                 m_hContext;\r
30     v8::Isolate*                                                m_pIsolate;\r
31     CFX_ArrayTemplate<CFXJSE_Class*>    m_rgClasses;\r
32     friend class CFXJSE_Class;\r
33     friend class CFXJSE_ScopeUtil_IsolateHandleContext;\r
34     friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext;\r
35 };\r
36 v8::Handle<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, v8::TryCatch& trycatch);\r
37 #endif\r