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

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

Issue 2031653003: Get rid of NULLs in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_core
Patch Set: rebase 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 | « fpdfsdk/javascript/global.cpp ('k') | fpdfsdk/pdfwindow/PWL_Caret.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 "fpdfsdk/jsapi/include/fxjs_v8.h" 7 #include "fpdfsdk/jsapi/include/fxjs_v8.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 v8::Isolate* pIsolate, 307 v8::Isolate* pIsolate,
308 IJS_Runtime* pIRuntime, 308 IJS_Runtime* pIRuntime,
309 v8::Global<v8::Context>* pV8PersistentContext, 309 v8::Global<v8::Context>* pV8PersistentContext,
310 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 310 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
311 if (pIsolate == g_isolate) 311 if (pIsolate == g_isolate)
312 ++g_isolate_ref_count; 312 ++g_isolate_ref_count;
313 313
314 v8::Isolate::Scope isolate_scope(pIsolate); 314 v8::Isolate::Scope isolate_scope(pIsolate);
315 v8::HandleScope handle_scope(pIsolate); 315 v8::HandleScope handle_scope(pIsolate);
316 v8::Local<v8::Context> v8Context = 316 v8::Local<v8::Context> v8Context =
317 v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); 317 v8::Context::New(pIsolate, nullptr, GetGlobalObjectTemplate(pIsolate));
318 v8::Context::Scope context_scope(v8Context); 318 v8::Context::Scope context_scope(v8Context);
319 319
320 FXJS_PerIsolateData::SetUp(pIsolate); 320 FXJS_PerIsolateData::SetUp(pIsolate);
321 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); 321 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
322 if (!pData) 322 if (!pData)
323 return; 323 return;
324 pData->CreateDynamicObjsMap(pIsolate); 324 pData->CreateDynamicObjsMap(pIsolate);
325 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); 325 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime);
326 326
327 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); 327 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // intermediate format. 506 // intermediate format.
507 CFX_ByteString utf8_message = message.UTF8Encode(); 507 CFX_ByteString utf8_message = message.UTF8Encode();
508 pIsolate->ThrowException(v8::String::NewFromUtf8(pIsolate, 508 pIsolate->ThrowException(v8::String::NewFromUtf8(pIsolate,
509 utf8_message.c_str(), 509 utf8_message.c_str(),
510 v8::NewStringType::kNormal) 510 v8::NewStringType::kNormal)
511 .ToLocalChecked()); 511 .ToLocalChecked());
512 } 512 }
513 513
514 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) { 514 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) {
515 if (pObj.IsEmpty()) 515 if (pObj.IsEmpty())
516 return NULL; 516 return nullptr;
517 if (pObj->IsString()) 517 if (pObj->IsString())
518 return kFXJSValueNameString; 518 return kFXJSValueNameString;
519 if (pObj->IsNumber()) 519 if (pObj->IsNumber())
520 return kFXJSValueNameNumber; 520 return kFXJSValueNameNumber;
521 if (pObj->IsBoolean()) 521 if (pObj->IsBoolean())
522 return kFXJSValueNameBoolean; 522 return kFXJSValueNameBoolean;
523 if (pObj->IsDate()) 523 if (pObj->IsDate())
524 return kFXJSValueNameDate; 524 return kFXJSValueNameDate;
525 if (pObj->IsObject()) 525 if (pObj->IsObject())
526 return kFXJSValueNameObject; 526 return kFXJSValueNameObject;
527 if (pObj->IsNull()) 527 if (pObj->IsNull())
528 return kFXJSValueNameNull; 528 return kFXJSValueNameNull;
529 if (pObj->IsUndefined()) 529 if (pObj->IsUndefined())
530 return kFXJSValueNameUndefined; 530 return kFXJSValueNameUndefined;
531 return NULL; 531 return nullptr;
532 } 532 }
533 533
534 void FXJS_SetPrivate(v8::Isolate* pIsolate, 534 void FXJS_SetPrivate(v8::Isolate* pIsolate,
535 v8::Local<v8::Object> pObj, 535 v8::Local<v8::Object> pObj,
536 void* p) { 536 void* p) {
537 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 537 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
538 return; 538 return;
539 CFXJS_PerObjectData* pPerObjectData = static_cast<CFXJS_PerObjectData*>( 539 CFXJS_PerObjectData* pPerObjectData = static_cast<CFXJS_PerObjectData*>(
540 pObj->GetAlignedPointerFromInternalField(0)); 540 pObj->GetAlignedPointerFromInternalField(0));
541 if (!pPerObjectData) 541 if (!pPerObjectData)
(...skipping 23 matching lines...) Expand all
565 } 565 }
566 566
567 void FXJS_FreePrivate(void* pPerObjectData) { 567 void FXJS_FreePrivate(void* pPerObjectData) {
568 delete static_cast<CFXJS_PerObjectData*>(pPerObjectData); 568 delete static_cast<CFXJS_PerObjectData*>(pPerObjectData);
569 } 569 }
570 570
571 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) { 571 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) {
572 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 572 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
573 return; 573 return;
574 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); 574 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0));
575 pObj->SetAlignedPointerInInternalField(0, NULL); 575 pObj->SetAlignedPointerInInternalField(0, nullptr);
576 } 576 }
577 577
578 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, 578 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
579 const CFX_WideString& wsPropertyName) { 579 const CFX_WideString& wsPropertyName) {
580 CFX_ByteString bs = wsPropertyName.UTF8Encode(); 580 CFX_ByteString bs = wsPropertyName.UTF8Encode();
581 if (!pIsolate) 581 if (!pIsolate)
582 pIsolate = v8::Isolate::GetCurrent(); 582 pIsolate = v8::Isolate::GetCurrent();
583 return v8::String::NewFromUtf8(pIsolate, bs.c_str(), 583 return v8::String::NewFromUtf8(pIsolate, bs.c_str(),
584 v8::NewStringType::kNormal, bs.GetLength()) 584 v8::NewStringType::kNormal, bs.GetLength())
585 .ToLocalChecked(); 585 .ToLocalChecked();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 v8::Local<v8::Value> pValue) { 807 v8::Local<v8::Value> pValue) {
808 if (pValue.IsEmpty()) 808 if (pValue.IsEmpty())
809 return v8::Local<v8::Array>(); 809 return v8::Local<v8::Array>();
810 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 810 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
811 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 811 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
812 } 812 }
813 813
814 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 814 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
815 pTo = pFrom; 815 pTo = pFrom;
816 } 816 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/global.cpp ('k') | fpdfsdk/pdfwindow/PWL_Caret.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698