Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: xfa/fxjse/context.cpp

Issue 2013963005: Replace FXJSE_HCONTEXT with CFXJSE_Context* (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxjse/context.h ('k') | xfa/fxjse/include/fxjse.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 namespace { 14 CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate,
15 15 const FXJSE_CLASS* lpGlobalClass,
16 CFXJSE_Context* CFXContextFromHContext(FXJSE_HCONTEXT hContext) { 16 void* lpGlobalObject) {
17 return reinterpret_cast<CFXJSE_Context*>(hContext); 17 return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject);
18 } 18 }
19 19
20 } // namespace 20 void FXJSE_Context_Release(CFXJSE_Context* pContext) {
21 21 delete pContext;
22 FXJSE_HCONTEXT FXJSE_Context_Create(v8::Isolate* pIsolate,
23 const FXJSE_CLASS* lpGlobalClass,
24 void* lpGlobalObject) {
25 CFXJSE_Context* pContext =
26 CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject);
27 return reinterpret_cast<FXJSE_HCONTEXT>(pContext);
28 } 22 }
29 23
30 void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) { 24 FXJSE_HVALUE FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext) {
31 delete CFXContextFromHContext(hContext);
32 }
33
34 FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) {
35 CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
36 if (!pContext) 25 if (!pContext)
37 return nullptr; 26 return nullptr;
38 27
39 CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime()); 28 CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime());
40 ASSERT(lpValue); 29 ASSERT(lpValue);
41 pContext->GetGlobalObject(lpValue); 30 pContext->GetGlobalObject(lpValue);
42 return reinterpret_cast<FXJSE_HVALUE>(lpValue); 31 return reinterpret_cast<FXJSE_HVALUE>(lpValue);
43 } 32 }
44 33
45 static const FX_CHAR* szCompatibleModeScripts[] = { 34 static const FX_CHAR* szCompatibleModeScripts[] = {
(...skipping 15 matching lines...) Expand all
61 " }\n" 50 " }\n"
62 " return globalobj.prototype[name].apply(obj, " 51 " return globalobj.prototype[name].apply(obj, "
63 " Array.prototype.slice.call(arguments, 1));\n" 52 " Array.prototype.slice.call(arguments, 1));\n"
64 " })\n" 53 " })\n"
65 " });\n" 54 " });\n"
66 " }\n" 55 " }\n"
67 " });\n" 56 " });\n"
68 " }\n" 57 " }\n"
69 " }\n" 58 " }\n"
70 "}(this, {String: ['substr', 'toUpperCase']}));"}; 59 "}(this, {String: ['substr', 'toUpperCase']}));"};
71 void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext, 60 void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext,
72 uint32_t dwCompatibleFlags) { 61 uint32_t dwCompatibleFlags) {
73 for (uint32_t i = 0; i < (uint32_t)FXJSE_COMPATIBLEMODEFLAGCOUNT; i++) { 62 for (uint32_t i = 0; i < (uint32_t)FXJSE_COMPATIBLEMODEFLAGCOUNT; i++) {
74 if (dwCompatibleFlags & (1 << i)) { 63 if (dwCompatibleFlags & (1 << i)) {
75 FXJSE_ExecuteScript(hContext, szCompatibleModeScripts[i], NULL, NULL); 64 FXJSE_ExecuteScript(pContext, szCompatibleModeScripts[i], NULL, NULL);
76 } 65 }
77 } 66 }
78 } 67 }
79 68
80 FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext, 69 FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext,
81 const FX_CHAR* szScript, 70 const FX_CHAR* szScript,
82 FXJSE_HVALUE hRetValue, 71 FXJSE_HVALUE hRetValue,
83 FXJSE_HVALUE hNewThisObject) { 72 FXJSE_HVALUE hNewThisObject) {
84 CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
85 return pContext->ExecuteScript( 73 return pContext->ExecuteScript(
86 szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue), 74 szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue),
87 reinterpret_cast<CFXJSE_Value*>(hNewThisObject)); 75 reinterpret_cast<CFXJSE_Value*>(hNewThisObject));
88 } 76 }
89 77
90 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, 78 v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
91 v8::TryCatch& trycatch) { 79 v8::TryCatch& trycatch) {
92 v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate); 80 v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate);
93 if (trycatch.HasCaught()) { 81 if (trycatch.HasCaught()) {
94 v8::Local<v8::Value> hException = trycatch.Exception(); 82 v8::Local<v8::Value> hException = trycatch.Exception();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return TRUE; 199 return TRUE;
212 } 200 }
213 } 201 }
214 if (lpRetValue) { 202 if (lpRetValue) {
215 lpRetValue->m_hValue.Reset(m_pIsolate, 203 lpRetValue->m_hValue.Reset(m_pIsolate,
216 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); 204 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
217 } 205 }
218 return FALSE; 206 return FALSE;
219 } 207 }
220 } 208 }
OLDNEW
« no previous file with comments | « xfa/fxjse/context.h ('k') | xfa/fxjse/include/fxjse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698