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

Side by Side Diff: fxjs/cfxjse_context.cpp

Issue 2471353002: Remove FX_BOOL entirely. (Closed)
Patch Set: Fix nits now rather than later Created 4 years, 1 month 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 | « fxjs/cfxjse_context.h ('k') | fxjs/cfxjse_runtimedata.cpp » ('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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "fxjs/cfxjse_context.h" 7 #include "fxjs/cfxjse_context.h"
8 8
9 #include "fxjs/cfxjse_class.h" 9 #include "fxjs/cfxjse_class.h"
10 #include "fxjs/cfxjse_value.h" 10 #include "fxjs/cfxjse_value.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // static 149 // static
150 CFXJSE_Context* CFXJSE_Context::Create( 150 CFXJSE_Context* CFXJSE_Context::Create(
151 v8::Isolate* pIsolate, 151 v8::Isolate* pIsolate,
152 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, 152 const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass,
153 CFXJSE_HostObject* lpGlobalObject) { 153 CFXJSE_HostObject* lpGlobalObject) {
154 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); 154 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
155 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); 155 CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate);
156 CFXJSE_Class* lpGlobalClassObj = nullptr; 156 CFXJSE_Class* lpGlobalClassObj = nullptr;
157 v8::Local<v8::ObjectTemplate> hObjectTemplate; 157 v8::Local<v8::ObjectTemplate> hObjectTemplate;
158 if (lpGlobalClass) { 158 if (lpGlobalClass) {
159 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, TRUE); 159 lpGlobalClassObj = CFXJSE_Class::Create(pContext, lpGlobalClass, true);
160 ASSERT(lpGlobalClassObj); 160 ASSERT(lpGlobalClassObj);
161 v8::Local<v8::FunctionTemplate> hFunctionTemplate = 161 v8::Local<v8::FunctionTemplate> hFunctionTemplate =
162 v8::Local<v8::FunctionTemplate>::New(pIsolate, 162 v8::Local<v8::FunctionTemplate>::New(pIsolate,
163 lpGlobalClassObj->m_hTemplate); 163 lpGlobalClassObj->m_hTemplate);
164 hObjectTemplate = hFunctionTemplate->InstanceTemplate(); 164 hObjectTemplate = hFunctionTemplate->InstanceTemplate();
165 } else { 165 } else {
166 hObjectTemplate = v8::ObjectTemplate::New(pIsolate); 166 hObjectTemplate = v8::ObjectTemplate::New(pIsolate);
167 hObjectTemplate->SetInternalFieldCount(1); 167 hObjectTemplate->SetInternalFieldCount(1);
168 } 168 }
169 hObjectTemplate->Set( 169 hObjectTemplate->Set(
(...skipping 25 matching lines...) Expand all
195 v8::Local<v8::Object> hGlobalObject = hContext->Global(); 195 v8::Local<v8::Object> hGlobalObject = hContext->Global();
196 pValue->ForceSetValue(hGlobalObject); 196 pValue->ForceSetValue(hGlobalObject);
197 197
198 return pValue; 198 return pValue;
199 } 199 }
200 200
201 void CFXJSE_Context::EnableCompatibleMode() { 201 void CFXJSE_Context::EnableCompatibleMode() {
202 ExecuteScript(szCompatibleModeScript, nullptr, nullptr); 202 ExecuteScript(szCompatibleModeScript, nullptr, nullptr);
203 } 203 }
204 204
205 FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript, 205 bool CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript,
206 CFXJSE_Value* lpRetValue, 206 CFXJSE_Value* lpRetValue,
207 CFXJSE_Value* lpNewThisObject) { 207 CFXJSE_Value* lpNewThisObject) {
208 CFXJSE_ScopeUtil_IsolateHandleContext scope(this); 208 CFXJSE_ScopeUtil_IsolateHandleContext scope(this);
209 v8::TryCatch trycatch(m_pIsolate); 209 v8::TryCatch trycatch(m_pIsolate);
210 v8::Local<v8::String> hScriptString = 210 v8::Local<v8::String> hScriptString =
211 v8::String::NewFromUtf8(m_pIsolate, szScript); 211 v8::String::NewFromUtf8(m_pIsolate, szScript);
212 if (!lpNewThisObject) { 212 if (!lpNewThisObject) {
213 v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString); 213 v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString);
214 if (!trycatch.HasCaught()) { 214 if (!trycatch.HasCaught()) {
215 v8::Local<v8::Value> hValue = hScript->Run(); 215 v8::Local<v8::Value> hValue = hScript->Run();
216 if (!trycatch.HasCaught()) { 216 if (!trycatch.HasCaught()) {
217 if (lpRetValue) { 217 if (lpRetValue)
218 lpRetValue->m_hValue.Reset(m_pIsolate, hValue); 218 lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
219 } 219 return true;
220 return TRUE;
221 } 220 }
222 } 221 }
223 if (lpRetValue) { 222 if (lpRetValue) {
224 lpRetValue->m_hValue.Reset(m_pIsolate, 223 lpRetValue->m_hValue.Reset(m_pIsolate,
225 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); 224 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
226 } 225 }
227 return FALSE; 226 return false;
228 } else { 227 }
229 v8::Local<v8::Value> hNewThis = 228
230 v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue); 229 v8::Local<v8::Value> hNewThis =
231 ASSERT(!hNewThis.IsEmpty()); 230 v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue);
232 v8::Local<v8::Script> hWrapper = 231 ASSERT(!hNewThis.IsEmpty());
233 v8::Script::Compile(v8::String::NewFromUtf8( 232 v8::Local<v8::Script> hWrapper = v8::Script::Compile(v8::String::NewFromUtf8(
234 m_pIsolate, "(function () { return eval(arguments[0]); })")); 233 m_pIsolate, "(function () { return eval(arguments[0]); })"));
235 v8::Local<v8::Value> hWrapperValue = hWrapper->Run(); 234 v8::Local<v8::Value> hWrapperValue = hWrapper->Run();
236 ASSERT(hWrapperValue->IsFunction()); 235 ASSERT(hWrapperValue->IsFunction());
237 v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>(); 236 v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>();
237 if (!trycatch.HasCaught()) {
238 v8::Local<v8::Value> rgArgs[] = {hScriptString};
239 v8::Local<v8::Value> hValue =
240 hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs);
238 if (!trycatch.HasCaught()) { 241 if (!trycatch.HasCaught()) {
239 v8::Local<v8::Value> rgArgs[] = {hScriptString}; 242 if (lpRetValue)
240 v8::Local<v8::Value> hValue = 243 lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
241 hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs); 244 return true;
242 if (!trycatch.HasCaught()) {
243 if (lpRetValue) {
244 lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
245 }
246 return TRUE;
247 }
248 } 245 }
249 if (lpRetValue) {
250 lpRetValue->m_hValue.Reset(m_pIsolate,
251 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
252 }
253 return FALSE;
254 } 246 }
247 if (lpRetValue) {
248 lpRetValue->m_hValue.Reset(m_pIsolate,
249 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
250 }
251 return false;
255 } 252 }
OLDNEW
« no previous file with comments | « fxjs/cfxjse_context.h ('k') | fxjs/cfxjse_runtimedata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698