Index: src/JsValue.cpp |
=================================================================== |
--- a/src/JsValue.cpp |
+++ b/src/JsValue.cpp |
@@ -200,46 +200,46 @@ std::string AdblockPlus::JsValue::GetCla |
if (!IsObject()) |
throw new std::runtime_error("Cannot get constructor of a non-object"); |
const JsContext context(jsEngine); |
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(UnwrapValue()); |
return Utils::FromV8String(obj->GetConstructorName()); |
} |
-AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsValueList& params, JsValuePtr thisPtr) const |
+AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsConstValueList& params, JsValuePtr thisPtr) const |
{ |
if (!IsFunction()) |
throw new std::runtime_error("Attempting to call a non-function"); |
const JsContext context(jsEngine); |
if (!thisPtr) |
{ |
v8::Local<v8::Context> localContext = v8::Local<v8::Context>::New( |
jsEngine->GetIsolate(), *jsEngine->context); |
thisPtr = JsValuePtr(new JsValue(jsEngine, localContext->Global())); |
} |
if (!thisPtr->IsObject()) |
throw new std::runtime_error("`this` pointer has to be an object"); |
v8::Local<v8::Object> thisObj = v8::Local<v8::Object>::Cast(thisPtr->UnwrapValue()); |
std::vector<v8::Handle<v8::Value>> argv; |
- for (JsValueList::const_iterator it = params.begin(); it != params.end(); ++it) |
- argv.push_back((*it)->UnwrapValue()); |
+ for (const auto param : params) |
+ argv.push_back(param->UnwrapValue()); |
const v8::TryCatch tryCatch; |
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue()); |
v8::Local<v8::Value> result = func->Call(thisObj, argv.size(), |
argv.size() ? &argv.front() : 0); |
if (tryCatch.HasCaught()) |
throw JsError(tryCatch.Exception(), tryCatch.Message()); |
return JsValuePtr(new JsValue(jsEngine, result)); |
} |
AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsValue& arg) const |
{ |
const JsContext context(jsEngine); |
- JsValueList params; |
+ JsConstValueList params; |
params.push_back(JsValuePtr(new JsValue(arg.jsEngine, arg.UnwrapValue()))); |
return Call(params); |
} |