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

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8.cpp

Issue 1386173002: Rename IFXJS_Runtime and IFXJS_Context to IJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Comment in fxjs_v8.h Created 5 years, 2 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 | « fpdfsdk/src/javascript/util.cpp ('k') | no next file » | 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 "../../include/jsapi/fxjs_v8.h" 7 #include "../../include/jsapi/fxjs_v8.h"
8 8
9 #include "../../../core/include/fxcrt/fx_basic.h" 9 #include "../../../core/include/fxcrt/fx_basic.h"
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 v8::Isolate::Scope isolate_scope(pIsolate); 266 v8::Isolate::Scope isolate_scope(pIsolate);
267 v8::HandleScope handle_scope(pIsolate); 267 v8::HandleScope handle_scope(pIsolate);
268 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); 268 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
269 GetGlobalObjectTemplate(pIsolate)->Set( 269 GetGlobalObjectTemplate(pIsolate)->Set(
270 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), 270 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
271 v8::NewStringType::kNormal).ToLocalChecked(), 271 v8::NewStringType::kNormal).ToLocalChecked(),
272 pDefault, v8::ReadOnly); 272 pDefault, v8::ReadOnly);
273 } 273 }
274 274
275 void FXJS_InitializeRuntime(v8::Isolate* pIsolate, 275 void FXJS_InitializeRuntime(v8::Isolate* pIsolate,
276 IFXJS_Runtime* pFXRuntime, 276 IJS_Runtime* pFXRuntime,
277 IFXJS_Context* context, 277 IJS_Context* context,
278 v8::Global<v8::Context>& v8PersistentContext) { 278 v8::Global<v8::Context>& v8PersistentContext) {
279 if (pIsolate == g_isolate) 279 if (pIsolate == g_isolate)
280 ++g_isolate_ref_count; 280 ++g_isolate_ref_count;
281 281
282 v8::Isolate::Scope isolate_scope(pIsolate); 282 v8::Isolate::Scope isolate_scope(pIsolate);
283 v8::HandleScope handle_scope(pIsolate); 283 v8::HandleScope handle_scope(pIsolate);
284 v8::Local<v8::Context> v8Context = 284 v8::Local<v8::Context> v8Context =
285 v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); 285 v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate));
286 v8::Context::Scope context_scope(v8Context); 286 v8::Context::Scope context_scope(v8Context);
287 287
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 pObjDef->m_pDestructor(pObj); 343 pObjDef->m_pDestructor(pObj);
344 FXJS_FreePrivate(pObj); 344 FXJS_FreePrivate(pObj);
345 } 345 }
346 delete pObjDef; 346 delete pObjDef;
347 } 347 }
348 348
349 pIsolate->SetData(g_embedderDataSlot, nullptr); 349 pIsolate->SetData(g_embedderDataSlot, nullptr);
350 delete pData; 350 delete pData;
351 } 351 }
352 352
353 IFXJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate) { 353 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate) {
354 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 354 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
355 return static_cast<IFXJS_Runtime*>( 355 return static_cast<IJS_Runtime*>(
356 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex)); 356 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
357 } 357 }
358 358
359 int FXJS_Execute(v8::Isolate* pIsolate, 359 int FXJS_Execute(v8::Isolate* pIsolate,
360 IFXJS_Context* pJSContext, 360 IJS_Context* pJSContext,
361 const wchar_t* script, 361 const wchar_t* script,
362 long length, 362 long length,
363 FXJSErr* pError) { 363 FXJSErr* pError) {
364 v8::Isolate::Scope isolate_scope(pIsolate); 364 v8::Isolate::Scope isolate_scope(pIsolate);
365 v8::TryCatch try_catch(pIsolate); 365 v8::TryCatch try_catch(pIsolate);
366 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); 366 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode();
367 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 367 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
368 v8::Local<v8::Script> compiled_script; 368 v8::Local<v8::Script> compiled_script;
369 if (!v8::Script::Compile( 369 if (!v8::Script::Compile(
370 context, v8::String::NewFromUtf8( 370 context, v8::String::NewFromUtf8(
371 pIsolate, bsScript.c_str(), v8::NewStringType::kNormal, 371 pIsolate, bsScript.c_str(), v8::NewStringType::kNormal,
372 bsScript.GetLength()).ToLocalChecked()) 372 bsScript.GetLength()).ToLocalChecked())
373 .ToLocal(&compiled_script)) { 373 .ToLocal(&compiled_script)) {
374 v8::String::Utf8Value error(try_catch.Exception()); 374 v8::String::Utf8Value error(try_catch.Exception());
375 // TODO(tsepez): return error via pError->message. 375 // TODO(tsepez): return error via pError->message.
376 return -1; 376 return -1;
377 } 377 }
378 378
379 v8::Local<v8::Value> result; 379 v8::Local<v8::Value> result;
380 if (!compiled_script->Run(context).ToLocal(&result)) { 380 if (!compiled_script->Run(context).ToLocal(&result)) {
381 v8::String::Utf8Value error(try_catch.Exception()); 381 v8::String::Utf8Value error(try_catch.Exception());
382 // TODO(tsepez): return error via pError->message. 382 // TODO(tsepez): return error via pError->message.
383 return -1; 383 return -1;
384 } 384 }
385 return 0; 385 return 0;
386 } 386 }
387 387
388 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, 388 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,
389 IFXJS_Context* pJSContext, 389 IJS_Context* pJSContext,
390 int nObjDefnID) { 390 int nObjDefnID) {
391 v8::Isolate::Scope isolate_scope(pIsolate); 391 v8::Isolate::Scope isolate_scope(pIsolate);
392 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 392 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
393 if (nObjDefnID == -1) { 393 if (nObjDefnID == -1) {
394 v8::Local<v8::ObjectTemplate> objTempl = v8::ObjectTemplate::New(pIsolate); 394 v8::Local<v8::ObjectTemplate> objTempl = v8::ObjectTemplate::New(pIsolate);
395 v8::Local<v8::Object> obj; 395 v8::Local<v8::Object> obj;
396 if (!objTempl->NewInstance(context).ToLocal(&obj)) 396 if (!objTempl->NewInstance(context).ToLocal(&obj))
397 return v8::Local<v8::Object>(); 397 return v8::Local<v8::Object>();
398 return obj; 398 return obj;
399 } 399 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return v8::Local<v8::Array>(); 748 return v8::Local<v8::Array>();
749 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 749 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
750 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 750 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
751 } 751 }
752 752
753 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 753 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
754 pTo = pFrom; 754 pTo = pFrom;
755 } 755 }
756 756
757 757
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/util.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698