LEFT | RIGHT |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 { | 202 { |
203 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); | 203 return v8::Local<v8::Value>::New(jsEngine->GetIsolate(), *value); |
204 } | 204 } |
205 | 205 |
206 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin
g& val) | 206 void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::strin
g& val) |
207 { | 207 { |
208 const JsContext context(*jsEngine); | 208 const JsContext context(*jsEngine); |
209 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); | 209 SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val)); |
210 } | 210 } |
211 | 211 |
212 void AdblockPlus::JsValue::SetProperty(const std::string& name, const StringBuff
er& val) | 212 void AdblockPlus::JsValue::SetStringBufferProperty(const std::string& name, cons
t StringBuffer& val) |
213 { | 213 { |
214 const JsContext context(*jsEngine); | 214 const JsContext context(*jsEngine); |
215 SetProperty(name, Utils::StringBufferToV8String(jsEngine->GetIsolate(), val)); | 215 SetProperty(name, Utils::StringBufferToV8String(jsEngine->GetIsolate(), val)); |
216 } | 216 } |
217 | 217 |
218 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val) | 218 void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val) |
219 { | 219 { |
220 const JsContext context(*jsEngine); | 220 const JsContext context(*jsEngine); |
221 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val)); | 221 SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val)); |
222 } | 222 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 const v8::TryCatch tryCatch; | 287 const v8::TryCatch tryCatch; |
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 } |
LEFT | RIGHT |