| Left: | ||
| Right: |
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 const JsContext context(jsEngine); | 177 const JsContext context(jsEngine); |
| 178 SetProperty(name, v8::Number::New(val)); | 178 SetProperty(name, v8::Number::New(val)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr & val) | 181 void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValuePtr & val) |
| 182 { | 182 { |
| 183 const JsContext context(jsEngine); | 183 const JsContext context(jsEngine); |
| 184 SetProperty(name, val->UnwrapValue()); | 184 SetProperty(name, val->UnwrapValue()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void AdblockPlus::JsValue::Push(const JsValuePtr& value) | |
| 188 { | |
| 189 const JsContext context(jsEngine); | |
| 190 auto jsArray = v8::Local<v8::Array>::Cast(UnwrapValue()); | |
| 191 jsArray->Set(jsArray->Length(), value->UnwrapValue()); | |
|
Wladimir Palant
2015/01/22 15:19:51
That method is unused now. You might argue that it
sergei
2015/01/22 16:15:11
Sure, removed
| |
| 192 } | |
| 193 | |
| 187 void AdblockPlus::JsValue::SetProperty(const std::string& name, bool val) | 194 void AdblockPlus::JsValue::SetProperty(const std::string& name, bool val) |
| 188 { | 195 { |
| 189 const JsContext context(jsEngine); | 196 const JsContext context(jsEngine); |
| 190 SetProperty(name, v8::Boolean::New(val)); | 197 SetProperty(name, v8::Boolean::New(val)); |
| 191 } | 198 } |
| 192 | 199 |
| 193 std::string AdblockPlus::JsValue::GetClass() const | 200 std::string AdblockPlus::JsValue::GetClass() const |
| 194 { | 201 { |
| 195 if (!IsObject()) | 202 if (!IsObject()) |
| 196 throw new std::runtime_error("Cannot get constructor of a non-object"); | 203 throw new std::runtime_error("Cannot get constructor of a non-object"); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 222 const v8::TryCatch tryCatch; | 229 const v8::TryCatch tryCatch; |
| 223 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); | 230 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); |
| 224 v8::Local<v8::Value> result = func->Call(thisObj, argv.size(), | 231 v8::Local<v8::Value> result = func->Call(thisObj, argv.size(), |
| 225 argv.size() ? &argv.front() : 0); | 232 argv.size() ? &argv.front() : 0); |
| 226 | 233 |
| 227 if (tryCatch.HasCaught()) | 234 if (tryCatch.HasCaught()) |
| 228 throw JsError(tryCatch.Exception(), tryCatch.Message()); | 235 throw JsError(tryCatch.Exception(), tryCatch.Message()); |
| 229 | 236 |
| 230 return JsValuePtr(new JsValue(jsEngine, result)); | 237 return JsValuePtr(new JsValue(jsEngine, result)); |
| 231 } | 238 } |
| OLD | NEW |