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

Unified Diff: src/JsEngine.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 12, 2017, 3:24 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
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -181,17 +181,17 @@
}
void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName)
{
std::lock_guard<std::mutex> lock(eventCallbacksMutex);
eventCallbacks.erase(eventName);
}
-void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, const AdblockPlus::JsValueList& params)
+void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, const AdblockPlus::JsConstValueList& params)
{
EventCallback callback;
{
std::lock_guard<std::mutex> lock(eventCallbacksMutex);
auto it = eventCallbacks.find(eventName);
if (it == eventCallbacks.end())
return;
callback = it->second;
@@ -251,20 +251,20 @@
std::weak_ptr<JsEngine>* data =
static_cast<std::weak_ptr<JsEngine>*>(external->Value());
JsEnginePtr result = data->lock();
if (!result)
throw std::runtime_error("Oops, our JsEngine is gone, how did that happen?");
return result;
}
-AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Arguments& arguments)
+AdblockPlus::JsConstValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Arguments& arguments)
{
const JsContext context(shared_from_this());
- JsValueList list;
+ JsConstValueList list;
for (int i = 0; i < arguments.Length(); i++)
list.push_back(JsValuePtr(new JsValue(shared_from_this(), arguments[i])));
return list;
}
AdblockPlus::FileSystemPtr AdblockPlus::JsEngine::GetFileSystem() const
{
return fileSystem;
@@ -321,15 +321,15 @@
if (!val)
throw std::runtime_error("LogSystem cannot be null");
logSystem = val;
}
void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
- const AdblockPlus::JsValuePtr& value)
+ const AdblockPlus::JsValue& value)
{
auto global = GetGlobalObject();
if (!global)
throw std::runtime_error("Global object cannot be null");
global->SetProperty(name, value);
}
« src/FilterEngine.cpp ('K') | « src/GlobalJsObject.cpp ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld