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

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: Fix bad search/replace 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
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // intermediate format. 507 // intermediate format.
508 CFX_ByteString utf8_message = message.UTF8Encode(); 508 CFX_ByteString utf8_message = message.UTF8Encode();
509 pIsolate->ThrowException(v8::String::NewFromUtf8(pIsolate, 509 pIsolate->ThrowException(v8::String::NewFromUtf8(pIsolate,
510 utf8_message.c_str(), 510 utf8_message.c_str(),
511 v8::NewStringType::kNormal) 511 v8::NewStringType::kNormal)
512 .ToLocalChecked()); 512 .ToLocalChecked());
513 } 513 }
514 514
515 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) { 515 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) {
516 if (pObj.IsEmpty()) 516 if (pObj.IsEmpty())
517 return NULL; 517 return nullptr;
518 if (pObj->IsString()) 518 if (pObj->IsString())
519 return kFXJSValueNameString; 519 return kFXJSValueNameString;
520 if (pObj->IsNumber()) 520 if (pObj->IsNumber())
521 return kFXJSValueNameNumber; 521 return kFXJSValueNameNumber;
522 if (pObj->IsBoolean()) 522 if (pObj->IsBoolean())
523 return kFXJSValueNameBoolean; 523 return kFXJSValueNameBoolean;
524 if (pObj->IsDate()) 524 if (pObj->IsDate())
525 return kFXJSValueNameDate; 525 return kFXJSValueNameDate;
526 if (pObj->IsObject()) 526 if (pObj->IsObject())
527 return kFXJSValueNameObject; 527 return kFXJSValueNameObject;
528 if (pObj->IsNull()) 528 if (pObj->IsNull())
529 return kFXJSValueNameNull; 529 return kFXJSValueNameNull;
530 if (pObj->IsUndefined()) 530 if (pObj->IsUndefined())
531 return kFXJSValueNameUndefined; 531 return kFXJSValueNameUndefined;
532 return NULL; 532 return nullptr;
533 } 533 }
534 534
535 void FXJS_SetPrivate(v8::Isolate* pIsolate, 535 void FXJS_SetPrivate(v8::Isolate* pIsolate,
536 v8::Local<v8::Object> pObj, 536 v8::Local<v8::Object> pObj,
537 void* p) { 537 void* p) {
538 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 538 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
539 return; 539 return;
540 CFXJS_PerObjectData* pPerObjectData = static_cast<CFXJS_PerObjectData*>( 540 CFXJS_PerObjectData* pPerObjectData = static_cast<CFXJS_PerObjectData*>(
541 pObj->GetAlignedPointerFromInternalField(0)); 541 pObj->GetAlignedPointerFromInternalField(0));
542 if (!pPerObjectData) 542 if (!pPerObjectData)
(...skipping 23 matching lines...) Expand all
566 } 566 }
567 567
568 void FXJS_FreePrivate(void* pPerObjectData) { 568 void FXJS_FreePrivate(void* pPerObjectData) {
569 delete static_cast<CFXJS_PerObjectData*>(pPerObjectData); 569 delete static_cast<CFXJS_PerObjectData*>(pPerObjectData);
570 } 570 }
571 571
572 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) { 572 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) {
573 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 573 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
574 return; 574 return;
575 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); 575 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0));
576 pObj->SetAlignedPointerInInternalField(0, NULL); 576 pObj->SetAlignedPointerInInternalField(0, nullptr);
577 } 577 }
578 578
579 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, 579 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
580 const CFX_WideString& wsPropertyName) { 580 const CFX_WideString& wsPropertyName) {
581 CFX_ByteString bs = wsPropertyName.UTF8Encode(); 581 CFX_ByteString bs = wsPropertyName.UTF8Encode();
582 if (!pIsolate) 582 if (!pIsolate)
583 pIsolate = v8::Isolate::GetCurrent(); 583 pIsolate = v8::Isolate::GetCurrent();
584 return v8::String::NewFromUtf8(pIsolate, bs.c_str(), 584 return v8::String::NewFromUtf8(pIsolate, bs.c_str(),
585 v8::NewStringType::kNormal, bs.GetLength()) 585 v8::NewStringType::kNormal, bs.GetLength())
586 .ToLocalChecked(); 586 .ToLocalChecked();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 v8::Local<v8::Value> pValue) { 808 v8::Local<v8::Value> pValue) {
809 if (pValue.IsEmpty()) 809 if (pValue.IsEmpty())
810 return v8::Local<v8::Array>(); 810 return v8::Local<v8::Array>();
811 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 811 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
812 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 812 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
813 } 813 }
814 814
815 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 815 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
816 pTo = pFrom; 816 pTo = pFrom;
817 } 817 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698