Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/JsValue.cpp

Issue 29391775: Issue 5013 - Improve some const-correctness (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Removed GetType() const-ness change Created March 23, 2017, 12:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | src/Notification.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsValue.cpp
===================================================================
--- a/src/JsValue.cpp
+++ b/src/JsValue.cpp
@@ -134,18 +134,18 @@ std::vector<std::string> AdblockPlus::Js
{
if (!IsObject())
throw new std::runtime_error("Attempting to get propert list for a non-object");
const JsContext context(jsEngine);
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(UnwrapValue());
JsValueList properties = JsValuePtr(new JsValue(jsEngine, object->GetOwnPropertyNames()))->AsList();
std::vector<std::string> result;
- for (JsValueList::iterator it = properties.begin(); it != properties.end(); ++it)
- result.push_back((*it)->AsString());
+ for (const auto& property : properties)
+ result.push_back(property->AsString());
return result;
}
AdblockPlus::JsValuePtr AdblockPlus::JsValue::GetProperty(const std::string& name) const
{
if (!IsObject())
throw new std::runtime_error("Attempting to get property of a non-object");
@@ -217,18 +217,18 @@ AdblockPlus::JsValuePtr AdblockPlus::JsV
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());
« no previous file with comments | « src/FilterEngine.cpp ('k') | src/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld