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

Side by Side Diff: fxjs/cfxjse_context.cpp

Issue 2471353002: Remove FX_BOOL entirely. (Closed)
Patch Set: 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
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 }
220 return TRUE; 220 return true;
221 } 221 }
222 } 222 }
223 if (lpRetValue) { 223 if (lpRetValue) {
224 lpRetValue->m_hValue.Reset(m_pIsolate, 224 lpRetValue->m_hValue.Reset(m_pIsolate,
225 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); 225 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
226 } 226 }
227 return FALSE; 227 return false;
228 } else { 228 } else {
Lei Zhang 2016/11/02 23:13:09 For later - else after return.
Tom Sepez 2016/11/02 23:17:50 Done.
229 v8::Local<v8::Value> hNewThis = 229 v8::Local<v8::Value> hNewThis =
230 v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue); 230 v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue);
231 ASSERT(!hNewThis.IsEmpty()); 231 ASSERT(!hNewThis.IsEmpty());
232 v8::Local<v8::Script> hWrapper = 232 v8::Local<v8::Script> hWrapper =
233 v8::Script::Compile(v8::String::NewFromUtf8( 233 v8::Script::Compile(v8::String::NewFromUtf8(
234 m_pIsolate, "(function () { return eval(arguments[0]); })")); 234 m_pIsolate, "(function () { return eval(arguments[0]); })"));
235 v8::Local<v8::Value> hWrapperValue = hWrapper->Run(); 235 v8::Local<v8::Value> hWrapperValue = hWrapper->Run();
236 ASSERT(hWrapperValue->IsFunction()); 236 ASSERT(hWrapperValue->IsFunction());
237 v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>(); 237 v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>();
238 if (!trycatch.HasCaught()) { 238 if (!trycatch.HasCaught()) {
239 v8::Local<v8::Value> rgArgs[] = {hScriptString}; 239 v8::Local<v8::Value> rgArgs[] = {hScriptString};
240 v8::Local<v8::Value> hValue = 240 v8::Local<v8::Value> hValue =
241 hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs); 241 hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs);
242 if (!trycatch.HasCaught()) { 242 if (!trycatch.HasCaught()) {
243 if (lpRetValue) { 243 if (lpRetValue) {
244 lpRetValue->m_hValue.Reset(m_pIsolate, hValue); 244 lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
245 } 245 }
246 return TRUE; 246 return true;
247 } 247 }
248 } 248 }
249 if (lpRetValue) { 249 if (lpRetValue) {
250 lpRetValue->m_hValue.Reset(m_pIsolate, 250 lpRetValue->m_hValue.Reset(m_pIsolate,
251 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); 251 FXJSE_CreateReturnValue(m_pIsolate, trycatch));
252 } 252 }
253 return FALSE; 253 return false;
254 } 254 }
255 } 255 }
OLDNEW
« fxjs/cfxjse_class.cpp ('K') | « fxjs/cfxjse_context.h ('k') | fxjs/cfxjse_runtimedata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698