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