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 #include "xfa/fxjse/context.h" | 7 #include "xfa/fxjse/context.h" |
8 | 8 |
9 #include "xfa/fxjse/class.h" | 9 #include "xfa/fxjse/class.h" |
10 #include "xfa/fxjse/scope_inline.h" | 10 #include "xfa/fxjse/scope_inline.h" |
11 #include "xfa/fxjse/util_inline.h" | 11 #include "xfa/fxjse/util_inline.h" |
12 #include "xfa/fxjse/value.h" | 12 #include "xfa/fxjse/value.h" |
13 | 13 |
14 CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, | 14 CFXJSE_Context* FXJSE_Context_Create( |
15 const FXJSE_CLASS* lpGlobalClass, | 15 v8::Isolate* pIsolate, |
16 void* lpGlobalObject) { | 16 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, |
| 17 void* lpGlobalObject) { |
17 return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); | 18 return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); |
18 } | 19 } |
19 | 20 |
20 void FXJSE_Context_Release(CFXJSE_Context* pContext) { | 21 void FXJSE_Context_Release(CFXJSE_Context* pContext) { |
21 delete pContext; | 22 delete pContext; |
22 } | 23 } |
23 | 24 |
24 CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext) { | 25 CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext) { |
25 if (!pContext) | 26 if (!pContext) |
26 return nullptr; | 27 return nullptr; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 hReturnValue->Set(4, hMessage->GetSourceLine()); | 105 hReturnValue->Set(4, hMessage->GetSourceLine()); |
105 v8::Maybe<int32_t> maybe_int = | 106 v8::Maybe<int32_t> maybe_int = |
106 hMessage->GetStartColumn(pIsolate->GetCurrentContext()); | 107 hMessage->GetStartColumn(pIsolate->GetCurrentContext()); |
107 hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); | 108 hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); |
108 maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); | 109 maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); |
109 hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); | 110 hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); |
110 } | 111 } |
111 return hReturnValue; | 112 return hReturnValue; |
112 } | 113 } |
113 | 114 |
114 CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate, | 115 CFXJSE_Context* CFXJSE_Context::Create( |
115 const FXJSE_CLASS* lpGlobalClass, | 116 v8::Isolate* pIsolate, |
116 void* lpGlobalObject) { | 117 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, |
| 118 void* lpGlobalObject) { |
117 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); | 119 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); |
118 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); | 120 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); |
119 CFXJSE_Class* lpGlobalClassObj = NULL; | 121 CFXJSE_Class* lpGlobalClassObj = NULL; |
120 v8::Local<v8::ObjectTemplate> hObjectTemplate; | 122 v8::Local<v8::ObjectTemplate> hObjectTemplate; |
121 if (lpGlobalClass) { | 123 if (lpGlobalClass) { |
122 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); | 124 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); |
123 ASSERT(lpGlobalClassObj); | 125 ASSERT(lpGlobalClassObj); |
124 v8::Local<v8::FunctionTemplate> hFunctionTemplate = | 126 v8::Local<v8::FunctionTemplate> hFunctionTemplate = |
125 v8::Local<v8::FunctionTemplate>::New(pIsolate, | 127 v8::Local<v8::FunctionTemplate>::New(pIsolate, |
126 lpGlobalClassObj->m_hTemplate); | 128 lpGlobalClassObj->m_hTemplate); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return TRUE; | 199 return TRUE; |
198 } | 200 } |
199 } | 201 } |
200 if (lpRetValue) { | 202 if (lpRetValue) { |
201 lpRetValue->m_hValue.Reset(m_pIsolate, | 203 lpRetValue->m_hValue.Reset(m_pIsolate, |
202 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); | 204 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); |
203 } | 205 } |
204 return FALSE; | 206 return FALSE; |
205 } | 207 } |
206 } | 208 } |
OLD | NEW |