OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 JsValue JsValue::Call(std::vector<v8::Handle<v8::Value>>& args, v8::Local<v8::Ob
ject> thisObj) const | 278 JsValue JsValue::Call(std::vector<v8::Handle<v8::Value>>& args, v8::Local<v8::Ob
ject> thisObj) const |
279 { | 279 { |
280 if (!IsFunction()) | 280 if (!IsFunction()) |
281 throw std::runtime_error("Attempting to call a non-function"); | 281 throw std::runtime_error("Attempting to call a non-function"); |
282 if (!thisObj->IsObject()) | 282 if (!thisObj->IsObject()) |
283 throw std::runtime_error("`this` pointer has to be an object"); | 283 throw std::runtime_error("`this` pointer has to be an object"); |
284 | 284 |
285 const JsContext context(*jsEngine); | 285 const JsContext context(*jsEngine); |
286 | 286 |
287 const v8::TryCatch tryCatch; | 287 const v8::TryCatch tryCatch(jsEngine->GetIsolate()); |
288 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); | 288 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); |
289 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), | 289 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), |
290 args.size() ? &args[0] : nullptr); | 290 args.size() ? &args[0] : nullptr); |
291 | 291 |
292 if (tryCatch.HasCaught()) | 292 if (tryCatch.HasCaught()) |
293 throw JsError(tryCatch.Exception(), tryCatch.Message()); | 293 throw JsError(tryCatch.Exception(), tryCatch.Message()); |
294 | 294 |
295 return JsValue(jsEngine, result); | 295 return JsValue(jsEngine, result); |
296 } | 296 } |
OLD | NEW |