| Left: | ||
| Right: |
| 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 23 matching lines...) Expand all Loading... | |
| 34 AdblockPlus::JsValue::JsValue(AdblockPlus::JsValue&& src) | 34 AdblockPlus::JsValue::JsValue(AdblockPlus::JsValue&& src) |
| 35 : jsEngine(src.jsEngine), | 35 : jsEngine(src.jsEngine), |
| 36 value(std::move(src.value)) | 36 value(std::move(src.value)) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 AdblockPlus::JsValue::JsValue(const JsValue& src) | 40 AdblockPlus::JsValue::JsValue(const JsValue& src) |
| 41 : jsEngine(src.jsEngine) | 41 : jsEngine(src.jsEngine) |
| 42 { | 42 { |
| 43 const JsContext context(src.jsEngine); | 43 const JsContext context(src.jsEngine); |
| 44 value.reset(new v8::Persistent<v8::Value>(src.jsEngine->GetIsolate(), *src.val ue)); | 44 value.reset(new v8::Persistent<v8::Value>(src.jsEngine->GetIsolate(), *src.val ue)); |
|
hub
2017/04/19 17:57:22
Here I wonder if we shouldn't change JsValue::valu
sergei
2017/04/19 18:56:52
I would not like to change it to std::shared_ptr,
hub
2017/04/19 21:56:49
ok.
| |
| 45 } | 45 } |
| 46 | 46 |
| 47 AdblockPlus::JsValue::~JsValue() | 47 AdblockPlus::JsValue::~JsValue() |
| 48 { | 48 { |
| 49 if (value) | 49 if (value) |
| 50 { | 50 { |
| 51 value->Dispose(); | 51 value->Dispose(); |
| 52 value.reset(); | 52 value.reset(); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 JsValue& AdblockPlus::JsValue::operator=(const JsValue& src) | 56 JsValue& AdblockPlus::JsValue::operator=(const JsValue& src) |
| 57 { | 57 { |
| 58 const JsContext context(src.jsEngine); | |
| 58 if (value) | 59 if (value) |
| 59 value->Dispose(); | 60 value->Dispose(); |
|
sergei
2017/04/19 18:56:52
actually, the lock (JsContext) should be acquired
hub
2017/04/19 21:56:49
ah ok. Will fix this and the destructor.
| |
| 60 jsEngine = src.jsEngine; | 61 jsEngine = src.jsEngine; |
| 61 const JsContext context(src.jsEngine); | |
| 62 value.reset(new v8::Persistent<v8::Value>(src.jsEngine->GetIsolate(), *src.val ue)); | 62 value.reset(new v8::Persistent<v8::Value>(src.jsEngine->GetIsolate(), *src.val ue)); |
| 63 | 63 |
| 64 return *this; | 64 return *this; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool AdblockPlus::JsValue::IsUndefined() const | 67 bool AdblockPlus::JsValue::IsUndefined() const |
| 68 { | 68 { |
| 69 const JsContext context(jsEngine); | 69 const JsContext context(jsEngine); |
| 70 return UnwrapValue()->IsUndefined(); | 70 return UnwrapValue()->IsUndefined(); |
| 71 } | 71 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 const v8::TryCatch tryCatch; | 261 const v8::TryCatch tryCatch; |
| 262 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); | 262 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); |
| 263 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), | 263 v8::Local<v8::Value> result = func->Call(thisObj, args.size(), |
| 264 args.size() ? &args[0] : nullptr); | 264 args.size() ? &args[0] : nullptr); |
| 265 | 265 |
| 266 if (tryCatch.HasCaught()) | 266 if (tryCatch.HasCaught()) |
| 267 throw JsError(tryCatch.Exception(), tryCatch.Message()); | 267 throw JsError(tryCatch.Exception(), tryCatch.Message()); |
| 268 | 268 |
| 269 return JsValue(jsEngine, result); | 269 return JsValue(jsEngine, result); |
| 270 } | 270 } |
| LEFT | RIGHT |