dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 1 | // Copyright 2016 PDFium Authors. All rights reserved. |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 7 | #include "fxjs/cfxjse_context.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 8 | |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 9 | #include <utility> |
| 10 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 11 | #include "fxjs/cfxjse_class.h" |
| 12 | #include "fxjs/cfxjse_value.h" |
Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 13 | #include "third_party/base/ptr_util.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 14 | |
tsepez | fb2a824 | 2016-06-01 16:10:41 -0700 | [diff] [blame] | 15 | namespace { |
| 16 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 17 | const char szCompatibleModeScript[] = |
tsepez | fb2a824 | 2016-06-01 16:10:41 -0700 | [diff] [blame] | 18 | "(function(global, list) {\n" |
| 19 | " 'use strict';\n" |
| 20 | " var objname;\n" |
| 21 | " for (objname in list) {\n" |
| 22 | " var globalobj = global[objname];\n" |
| 23 | " if (globalobj) {\n" |
| 24 | " list[objname].forEach(function(name) {\n" |
| 25 | " if (!globalobj[name]) {\n" |
| 26 | " Object.defineProperty(globalobj, name, {\n" |
| 27 | " writable: true,\n" |
| 28 | " enumerable: false,\n" |
| 29 | " value: (function(obj) {\n" |
| 30 | " if (arguments.length === 0) {\n" |
| 31 | " throw new TypeError('missing argument 0 when calling " |
| 32 | " function ' + objname + '.' + name);\n" |
| 33 | " }\n" |
| 34 | " return globalobj.prototype[name].apply(obj, " |
| 35 | " Array.prototype.slice.call(arguments, 1));\n" |
| 36 | " })\n" |
| 37 | " });\n" |
| 38 | " }\n" |
| 39 | " });\n" |
| 40 | " }\n" |
| 41 | " }\n" |
| 42 | "}(this, {String: ['substr', 'toUpperCase']}));"; |
| 43 | |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 44 | wchar_t g_FXJSETagString[] = L"FXJSE_HostObject"; |
| 45 | |
tsepez | fb2a824 | 2016-06-01 16:10:41 -0700 | [diff] [blame] | 46 | } // namespace |
| 47 | |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 48 | // Note, not in the anonymous namespace due to the friend call |
| 49 | // in cfxjse_context.h |
| 50 | // TODO(dsinclair): Remove the friending, use public methods. |
| 51 | class CFXJSE_ScopeUtil_IsolateHandleContext { |
| 52 | public: |
| 53 | explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext) |
| 54 | : m_context(pContext), |
| 55 | m_parent(pContext->m_pIsolate), |
| 56 | m_cscope(v8::Local<v8::Context>::New(pContext->m_pIsolate, |
| 57 | pContext->m_hContext)) {} |
| 58 | v8::Isolate* GetIsolate() { return m_context->m_pIsolate; } |
| 59 | v8::Local<v8::Context> GetLocalContext() { |
| 60 | return v8::Local<v8::Context>::New(m_context->m_pIsolate, |
| 61 | m_context->m_hContext); |
| 62 | } |
| 63 | |
| 64 | private: |
| 65 | CFXJSE_ScopeUtil_IsolateHandleContext( |
| 66 | const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; |
| 67 | void operator=(const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; |
| 68 | void* operator new(size_t size) = delete; |
| 69 | void operator delete(void*, size_t) = delete; |
| 70 | |
| 71 | CFXJSE_Context* m_context; |
| 72 | CFXJSE_ScopeUtil_IsolateHandle m_parent; |
| 73 | v8::Context::Scope m_cscope; |
| 74 | }; |
| 75 | |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 76 | v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( |
| 77 | const v8::Local<v8::Context>& hContext) { |
| 78 | return hContext->Global()->GetPrototype().As<v8::Object>(); |
| 79 | } |
| 80 | |
| 81 | void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 82 | CFXJSE_HostObject* lpNewBinding) { |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 83 | ASSERT(!hObject.IsEmpty()); |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 84 | ASSERT(hObject->InternalFieldCount() == 2); |
| 85 | hObject->SetAlignedPointerInInternalField(0, g_FXJSETagString); |
| 86 | hObject->SetAlignedPointerInInternalField(1, lpNewBinding); |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 87 | } |
| 88 | |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 89 | CFXJSE_HostObject* FXJSE_RetrieveObjectBinding( |
| 90 | const v8::Local<v8::Object>& hJSObject, |
| 91 | CFXJSE_Class* lpClass) { |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 92 | ASSERT(!hJSObject.IsEmpty()); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 93 | if (!hJSObject->IsObject()) |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 94 | return nullptr; |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 95 | |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 96 | v8::Local<v8::Object> hObject = hJSObject; |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 97 | if (hObject->InternalFieldCount() != 2) { |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 98 | v8::Local<v8::Value> hProtoObject = hObject->GetPrototype(); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 99 | if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 100 | return nullptr; |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 101 | |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 102 | hObject = hProtoObject.As<v8::Object>(); |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 103 | if (hObject->InternalFieldCount() != 2) |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 104 | return nullptr; |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 105 | } |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 106 | if (hObject->GetAlignedPointerFromInternalField(0) != g_FXJSETagString) |
| 107 | return nullptr; |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 108 | if (lpClass) { |
| 109 | v8::Local<v8::FunctionTemplate> hClass = |
| 110 | v8::Local<v8::FunctionTemplate>::New( |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 111 | lpClass->GetContext()->GetIsolate(), lpClass->GetTemplate()); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 112 | if (!hClass->HasInstance(hObject)) |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 113 | return nullptr; |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 114 | } |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 115 | return static_cast<CFXJSE_HostObject*>( |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 116 | hObject->GetAlignedPointerFromInternalField(1)); |
tsepez | 3a005f2 | 2016-05-27 17:45:00 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 119 | v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, |
| 120 | v8::TryCatch& trycatch) { |
| 121 | v8::Local<v8::Object> hReturnValue = v8::Object::New(pIsolate); |
| 122 | if (trycatch.HasCaught()) { |
| 123 | v8::Local<v8::Value> hException = trycatch.Exception(); |
| 124 | v8::Local<v8::Message> hMessage = trycatch.Message(); |
| 125 | if (hException->IsObject()) { |
| 126 | v8::Local<v8::Value> hValue; |
| 127 | hValue = hException.As<v8::Object>()->Get( |
| 128 | v8::String::NewFromUtf8(pIsolate, "name")); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 129 | if (hValue->IsString() || hValue->IsStringObject()) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 130 | hReturnValue->Set(0, hValue); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 131 | else |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 132 | hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 133 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 134 | hValue = hException.As<v8::Object>()->Get( |
| 135 | v8::String::NewFromUtf8(pIsolate, "message")); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 136 | if (hValue->IsString() || hValue->IsStringObject()) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 137 | hReturnValue->Set(1, hValue); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 138 | else |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 139 | hReturnValue->Set(1, hMessage->Get()); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 140 | } else { |
| 141 | hReturnValue->Set(0, v8::String::NewFromUtf8(pIsolate, "Error")); |
| 142 | hReturnValue->Set(1, hMessage->Get()); |
| 143 | } |
| 144 | hReturnValue->Set(2, hException); |
| 145 | hReturnValue->Set(3, v8::Integer::New(pIsolate, hMessage->GetLineNumber())); |
| 146 | hReturnValue->Set(4, hMessage->GetSourceLine()); |
| 147 | v8::Maybe<int32_t> maybe_int = |
| 148 | hMessage->GetStartColumn(pIsolate->GetCurrentContext()); |
| 149 | hReturnValue->Set(5, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); |
| 150 | maybe_int = hMessage->GetEndColumn(pIsolate->GetCurrentContext()); |
| 151 | hReturnValue->Set(6, v8::Integer::New(pIsolate, maybe_int.FromMaybe(0))); |
| 152 | } |
| 153 | return hReturnValue; |
| 154 | } |
| 155 | |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 156 | // static |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 157 | std::unique_ptr<CFXJSE_Context> CFXJSE_Context::Create( |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 158 | v8::Isolate* pIsolate, |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 159 | const FXJSE_CLASS_DESCRIPTOR* pGlobalClass, |
| 160 | CFXJSE_HostObject* pGlobalObject) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 161 | CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 162 | auto pContext = pdfium::MakeUnique<CFXJSE_Context>(pIsolate); |
| 163 | CFXJSE_Class* pGlobalClassObj = nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 164 | v8::Local<v8::ObjectTemplate> hObjectTemplate; |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 165 | if (pGlobalClass) { |
| 166 | pGlobalClassObj = CFXJSE_Class::Create(pContext.get(), pGlobalClass, true); |
| 167 | ASSERT(pGlobalClassObj); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 168 | v8::Local<v8::FunctionTemplate> hFunctionTemplate = |
| 169 | v8::Local<v8::FunctionTemplate>::New(pIsolate, |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 170 | pGlobalClassObj->m_hTemplate); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 171 | hObjectTemplate = hFunctionTemplate->InstanceTemplate(); |
| 172 | } else { |
| 173 | hObjectTemplate = v8::ObjectTemplate::New(pIsolate); |
Tom Sepez | 336544a | 2017-04-24 16:38:51 -0700 | [diff] [blame^] | 174 | hObjectTemplate->SetInternalFieldCount(2); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 175 | } |
jochen | 7e6a848 | 2016-07-06 11:02:27 -0700 | [diff] [blame] | 176 | hObjectTemplate->Set( |
| 177 | v8::Symbol::GetToStringTag(pIsolate), |
| 178 | v8::String::NewFromUtf8(pIsolate, "global", v8::NewStringType::kNormal) |
| 179 | .ToLocalChecked()); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 180 | v8::Local<v8::Context> hNewContext = |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 181 | v8::Context::New(pIsolate, nullptr, hObjectTemplate); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 182 | v8::Local<v8::Context> hRootContext = v8::Local<v8::Context>::New( |
| 183 | pIsolate, CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext); |
| 184 | hNewContext->SetSecurityToken(hRootContext->GetSecurityToken()); |
| 185 | v8::Local<v8::Object> hGlobalObject = |
| 186 | FXJSE_GetGlobalObjectFromContext(hNewContext); |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 187 | FXJSE_UpdateObjectBinding(hGlobalObject, pGlobalObject); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 188 | pContext->m_hContext.Reset(pIsolate, hNewContext); |
| 189 | return pContext; |
| 190 | } |
| 191 | |
tsepez | 56286b3 | 2016-05-17 16:24:34 -0700 | [diff] [blame] | 192 | CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} |
dsinclair | 769b137 | 2016-06-08 13:12:41 -0700 | [diff] [blame] | 193 | |
tsepez | 56286b3 | 2016-05-17 16:24:34 -0700 | [diff] [blame] | 194 | CFXJSE_Context::~CFXJSE_Context() {} |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 195 | |
dsinclair | 3cace32 | 2016-06-09 11:49:22 -0700 | [diff] [blame] | 196 | std::unique_ptr<CFXJSE_Value> CFXJSE_Context::GetGlobalObject() { |
Dan Sinclair | 0bb1333 | 2017-03-30 16:12:02 -0400 | [diff] [blame] | 197 | auto pValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 198 | CFXJSE_ScopeUtil_IsolateHandleContext scope(this); |
| 199 | v8::Local<v8::Context> hContext = |
| 200 | v8::Local<v8::Context>::New(m_pIsolate, m_hContext); |
| 201 | v8::Local<v8::Object> hGlobalObject = hContext->Global(); |
| 202 | pValue->ForceSetValue(hGlobalObject); |
dsinclair | 3cace32 | 2016-06-09 11:49:22 -0700 | [diff] [blame] | 203 | return pValue; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 204 | } |
| 205 | |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 206 | v8::Local<v8::Context> CFXJSE_Context::GetContext() { |
| 207 | return v8::Local<v8::Context>::New(m_pIsolate, m_hContext); |
| 208 | } |
| 209 | |
| 210 | void CFXJSE_Context::AddClass(std::unique_ptr<CFXJSE_Class> pClass) { |
| 211 | m_rgClasses.push_back(std::move(pClass)); |
| 212 | } |
| 213 | |
| 214 | CFXJSE_Class* CFXJSE_Context::GetClassByName( |
| 215 | const CFX_ByteStringC& szName) const { |
| 216 | auto pClass = |
| 217 | std::find_if(m_rgClasses.begin(), m_rgClasses.end(), |
| 218 | [szName](const std::unique_ptr<CFXJSE_Class>& item) { |
| 219 | return szName == item->m_szClassName; |
| 220 | }); |
| 221 | return pClass != m_rgClasses.end() ? pClass->get() : nullptr; |
| 222 | } |
| 223 | |
dsinclair | 769b137 | 2016-06-08 13:12:41 -0700 | [diff] [blame] | 224 | void CFXJSE_Context::EnableCompatibleMode() { |
| 225 | ExecuteScript(szCompatibleModeScript, nullptr, nullptr); |
| 226 | } |
| 227 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 228 | bool CFXJSE_Context::ExecuteScript(const char* szScript, |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 229 | CFXJSE_Value* lpRetValue, |
| 230 | CFXJSE_Value* lpNewThisObject) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 231 | CFXJSE_ScopeUtil_IsolateHandleContext scope(this); |
| 232 | v8::TryCatch trycatch(m_pIsolate); |
| 233 | v8::Local<v8::String> hScriptString = |
| 234 | v8::String::NewFromUtf8(m_pIsolate, szScript); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 235 | if (!lpNewThisObject) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 236 | v8::Local<v8::Script> hScript = v8::Script::Compile(hScriptString); |
| 237 | if (!trycatch.HasCaught()) { |
| 238 | v8::Local<v8::Value> hValue = hScript->Run(); |
| 239 | if (!trycatch.HasCaught()) { |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 240 | if (lpRetValue) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 241 | lpRetValue->m_hValue.Reset(m_pIsolate, hValue); |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 242 | return true; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | if (lpRetValue) { |
| 246 | lpRetValue->m_hValue.Reset(m_pIsolate, |
| 247 | FXJSE_CreateReturnValue(m_pIsolate, trycatch)); |
| 248 | } |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 249 | return false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 250 | } |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 251 | |
| 252 | v8::Local<v8::Value> hNewThis = |
| 253 | v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue); |
| 254 | ASSERT(!hNewThis.IsEmpty()); |
| 255 | v8::Local<v8::Script> hWrapper = v8::Script::Compile(v8::String::NewFromUtf8( |
| 256 | m_pIsolate, "(function () { return eval(arguments[0]); })")); |
| 257 | v8::Local<v8::Value> hWrapperValue = hWrapper->Run(); |
| 258 | ASSERT(hWrapperValue->IsFunction()); |
| 259 | v8::Local<v8::Function> hWrapperFn = hWrapperValue.As<v8::Function>(); |
| 260 | if (!trycatch.HasCaught()) { |
| 261 | v8::Local<v8::Value> rgArgs[] = {hScriptString}; |
| 262 | v8::Local<v8::Value> hValue = |
| 263 | hWrapperFn->Call(hNewThis.As<v8::Object>(), 1, rgArgs); |
| 264 | if (!trycatch.HasCaught()) { |
| 265 | if (lpRetValue) |
| 266 | lpRetValue->m_hValue.Reset(m_pIsolate, hValue); |
| 267 | return true; |
| 268 | } |
| 269 | } |
| 270 | if (lpRetValue) { |
| 271 | lpRetValue->m_hValue.Reset(m_pIsolate, |
| 272 | FXJSE_CreateReturnValue(m_pIsolate, trycatch)); |
| 273 | } |
| 274 | return false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 275 | } |