OLD | NEW |
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj) { | 440 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj) { |
441 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) | 441 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) |
442 return -1; | 442 return -1; |
443 CFXJS_PrivateData* pPrivateData = | 443 CFXJS_PrivateData* pPrivateData = |
444 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); | 444 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); |
445 if (pPrivateData) | 445 if (pPrivateData) |
446 return pPrivateData->ObjDefID; | 446 return pPrivateData->ObjDefID; |
447 return -1; | 447 return -1; |
448 } | 448 } |
449 | 449 |
450 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj) { | |
451 if (pObj.IsEmpty()) | |
452 return NULL; | |
453 v8::Local<v8::Context> context = pObj->CreationContext(); | |
454 if (context.IsEmpty()) | |
455 return NULL; | |
456 return context->GetIsolate(); | |
457 } | |
458 | |
459 void FXJS_Error(v8::Isolate* pIsolate, const CFX_WideString& message) { | 450 void FXJS_Error(v8::Isolate* pIsolate, const CFX_WideString& message) { |
460 // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t | 451 // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t |
461 // wide-strings isn't handled by v8, so use UTF8 as a common | 452 // wide-strings isn't handled by v8, so use UTF8 as a common |
462 // intermediate format. | 453 // intermediate format. |
463 CFX_ByteString utf8_message = message.UTF8Encode(); | 454 CFX_ByteString utf8_message = message.UTF8Encode(); |
464 pIsolate->ThrowException( | 455 pIsolate->ThrowException( |
465 v8::String::NewFromUtf8(pIsolate, utf8_message.c_str(), | 456 v8::String::NewFromUtf8(pIsolate, utf8_message.c_str(), |
466 v8::NewStringType::kNormal).ToLocalChecked()); | 457 v8::NewStringType::kNormal).ToLocalChecked()); |
467 } | 458 } |
468 | 459 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 return v8::Local<v8::Array>(); | 748 return v8::Local<v8::Array>(); |
758 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 749 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
759 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 750 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
760 } | 751 } |
761 | 752 |
762 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) { |
763 pTo = pFrom; | 754 pTo = pFrom; |
764 } | 755 } |
765 | 756 |
766 | 757 |
OLD | NEW |