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

Side by Side Diff: xfa/fxjse/value.cpp

Issue 1857713003: Rename GetCStr and GetPtr to match CFX_ByteString (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 8 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 | « xfa/fxjse/value.h ('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 "xfa/fxjse/value.h" 7 #include "xfa/fxjse/value.h"
8 8
9 #include <math.h> 9 #include <math.h>
10 10
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 reinterpret_cast<CFXJSE_Value*>(hValue)->GetIsolate()); 242 reinterpret_cast<CFXJSE_Value*>(hValue)->GetIsolate());
243 } 243 }
244 244
245 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name, 245 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
246 const CFX_ByteStringC& utf8Message) { 246 const CFX_ByteStringC& utf8Message) {
247 v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); 247 v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
248 ASSERT(pIsolate); 248 ASSERT(pIsolate);
249 249
250 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); 250 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
251 v8::Local<v8::String> hMessage = v8::String::NewFromUtf8( 251 v8::Local<v8::String> hMessage = v8::String::NewFromUtf8(
252 pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, 252 pIsolate, utf8Message.c_str(), v8::String::kNormalString,
253 utf8Message.GetLength()); 253 utf8Message.GetLength());
254 v8::Local<v8::Value> hError; 254 v8::Local<v8::Value> hError;
255 255
256 if (utf8Name == "RangeError") { 256 if (utf8Name == "RangeError") {
257 hError = v8::Exception::RangeError(hMessage); 257 hError = v8::Exception::RangeError(hMessage);
258 } else if (utf8Name == "ReferenceError") { 258 } else if (utf8Name == "ReferenceError") {
259 hError = v8::Exception::ReferenceError(hMessage); 259 hError = v8::Exception::ReferenceError(hMessage);
260 } else if (utf8Name == "SyntaxError") { 260 } else if (utf8Name == "SyntaxError") {
261 hError = v8::Exception::SyntaxError(hMessage); 261 hError = v8::Exception::SyntaxError(hMessage);
262 } else if (utf8Name == "TypeError") { 262 } else if (utf8Name == "TypeError") {
263 hError = v8::Exception::TypeError(hMessage); 263 hError = v8::Exception::TypeError(hMessage);
264 } else { 264 } else {
265 hError = v8::Exception::Error(hMessage); 265 hError = v8::Exception::Error(hMessage);
266 if (utf8Name != "Error" && !utf8Name.IsEmpty()) { 266 if (utf8Name != "Error" && !utf8Name.IsEmpty()) {
267 hError.As<v8::Object>()->Set( 267 hError.As<v8::Object>()->Set(
268 v8::String::NewFromUtf8(pIsolate, "name"), 268 v8::String::NewFromUtf8(pIsolate, "name"),
269 v8::String::NewFromUtf8(pIsolate, utf8Name.GetCStr(), 269 v8::String::NewFromUtf8(pIsolate, utf8Name.c_str(),
270 v8::String::kNormalString, 270 v8::String::kNormalString,
271 utf8Name.GetLength())); 271 utf8Name.GetLength()));
272 } 272 }
273 } 273 }
274 pIsolate->ThrowException(hError); 274 pIsolate->ThrowException(hError);
275 } 275 }
276 276
277 CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { 277 CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) {
278 return new CFXJSE_Value(pIsolate); 278 return new CFXJSE_Value(pIsolate);
279 } 279 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 CFXJSE_Value* lpPropValue) { 371 CFXJSE_Value* lpPropValue) {
372 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 372 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
373 v8::Local<v8::Value> hObject = 373 v8::Local<v8::Value> hObject =
374 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 374 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
375 if (!hObject->IsObject()) 375 if (!hObject->IsObject())
376 return FALSE; 376 return FALSE;
377 377
378 v8::Local<v8::Value> hPropValue = 378 v8::Local<v8::Value> hPropValue =
379 v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue()); 379 v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->DirectGetValue());
380 return (FX_BOOL)hObject.As<v8::Object>()->Set( 380 return (FX_BOOL)hObject.As<v8::Object>()->Set(
381 v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), 381 v8::String::NewFromUtf8(m_pIsolate, szPropName.c_str(),
382 v8::String::kNormalString, 382 v8::String::kNormalString,
383 szPropName.GetLength()), 383 szPropName.GetLength()),
384 hPropValue); 384 hPropValue);
385 } 385 }
386 386
387 FX_BOOL CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName, 387 FX_BOOL CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName,
388 CFXJSE_Value* lpPropValue) { 388 CFXJSE_Value* lpPropValue) {
389 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 389 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
390 v8::Local<v8::Value> hObject = 390 v8::Local<v8::Value> hObject =
391 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 391 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
392 if (!hObject->IsObject()) 392 if (!hObject->IsObject())
393 return FALSE; 393 return FALSE;
394 394
395 v8::Local<v8::Value> hPropValue = 395 v8::Local<v8::Value> hPropValue =
396 hObject.As<v8::Object>()->Get(v8::String::NewFromUtf8( 396 hObject.As<v8::Object>()->Get(v8::String::NewFromUtf8(
397 m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, 397 m_pIsolate, szPropName.c_str(), v8::String::kNormalString,
398 szPropName.GetLength())); 398 szPropName.GetLength()));
399 lpPropValue->ForceSetValue(hPropValue); 399 lpPropValue->ForceSetValue(hPropValue);
400 return TRUE; 400 return TRUE;
401 } 401 }
402 402
403 FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, 403 FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx,
404 CFXJSE_Value* lpPropValue) { 404 CFXJSE_Value* lpPropValue) {
405 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 405 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
406 v8::Local<v8::Value> hObject = 406 v8::Local<v8::Value> hObject =
407 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 407 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
(...skipping 19 matching lines...) Expand all
427 } 427 }
428 428
429 FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { 429 FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) {
430 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 430 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
431 v8::Local<v8::Value> hObject = 431 v8::Local<v8::Value> hObject =
432 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 432 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
433 if (!hObject->IsObject()) 433 if (!hObject->IsObject())
434 return FALSE; 434 return FALSE;
435 435
436 hObject.As<v8::Object>()->Delete(v8::String::NewFromUtf8( 436 hObject.As<v8::Object>()->Delete(v8::String::NewFromUtf8(
437 m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, 437 m_pIsolate, szPropName.c_str(), v8::String::kNormalString,
438 szPropName.GetLength())); 438 szPropName.GetLength()));
439 return TRUE; 439 return TRUE;
440 } 440 }
441 441
442 FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, 442 FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName,
443 FX_BOOL bUseTypeGetter) { 443 FX_BOOL bUseTypeGetter) {
444 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 444 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
445 v8::Local<v8::Value> hObject = 445 v8::Local<v8::Value> hObject =
446 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 446 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
447 if (!hObject->IsObject()) 447 if (!hObject->IsObject())
448 return FALSE; 448 return FALSE;
449 449
450 v8::Local<v8::String> hKey = v8::String::NewFromUtf8( 450 v8::Local<v8::String> hKey = v8::String::NewFromUtf8(
451 m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, 451 m_pIsolate, szPropName.c_str(), v8::String::kNormalString,
452 szPropName.GetLength()); 452 szPropName.GetLength());
453 return hObject.As<v8::Object>()->HasRealNamedProperty(hKey) || 453 return hObject.As<v8::Object>()->HasRealNamedProperty(hKey) ||
454 (bUseTypeGetter && 454 (bUseTypeGetter &&
455 hObject.As<v8::Object>() 455 hObject.As<v8::Object>()
456 ->HasOwnProperty(m_pIsolate->GetCurrentContext(), hKey) 456 ->HasOwnProperty(m_pIsolate->GetCurrentContext(), hKey)
457 .FromMaybe(false)); 457 .FromMaybe(false));
458 } 458 }
459 459
460 FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, 460 FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName,
461 CFXJSE_Value* lpPropValue) { 461 CFXJSE_Value* lpPropValue) {
462 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 462 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
463 v8::Local<v8::Value> hObject = 463 v8::Local<v8::Value> hObject =
464 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 464 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
465 if (!hObject->IsObject()) 465 if (!hObject->IsObject())
466 return FALSE; 466 return FALSE;
467 467
468 v8::Local<v8::Value> hValue = 468 v8::Local<v8::Value> hValue =
469 v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->m_hValue); 469 v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->m_hValue);
470 return hObject.As<v8::Object>() 470 return hObject.As<v8::Object>()
471 ->DefineOwnProperty( 471 ->DefineOwnProperty(
472 m_pIsolate->GetCurrentContext(), 472 m_pIsolate->GetCurrentContext(),
473 v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), 473 v8::String::NewFromUtf8(m_pIsolate, szPropName.c_str(),
474 v8::String::kNormalString, 474 v8::String::kNormalString,
475 szPropName.GetLength()), 475 szPropName.GetLength()),
476 hValue) 476 hValue)
477 .FromMaybe(false); 477 .FromMaybe(false);
478 } 478 }
479 479
480 FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, 480 FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction,
481 CFXJSE_Value* lpNewThis) { 481 CFXJSE_Value* lpNewThis) {
482 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 482 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
483 v8::Local<v8::Value> rgArgs[2]; 483 v8::Local<v8::Value> rgArgs[2];
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 if (lpRetValue) 573 if (lpRetValue)
574 lpRetValue->ForceSetValue(hReturnValue); 574 lpRetValue->ForceSetValue(hReturnValue);
575 575
576 if (lpLocalArgs) { 576 if (lpLocalArgs) {
577 for (uint32_t i = 0; i < nArgCount; i++) 577 for (uint32_t i = 0; i < nArgCount; i++)
578 lpLocalArgs[i].~Local(); 578 lpLocalArgs[i].~Local();
579 FX_Free(lpLocalArgs); 579 FX_Free(lpLocalArgs);
580 } 580 }
581 return bRetValue; 581 return bRetValue;
582 } 582 }
OLDNEW
« no previous file with comments | « xfa/fxjse/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698