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

Unified Diff: src/ConsoleJsObject.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/ConsoleJsObject.cpp
===================================================================
--- a/src/ConsoleJsObject.cpp
+++ b/src/ConsoleJsObject.cpp
@@ -25,17 +25,17 @@
namespace
{
v8::Handle<v8::Value> DoLog(AdblockPlus::LogSystem::LogLevel logLevel,
const v8::Arguments& arguments)
{
AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments);
const AdblockPlus::JsContext context(jsEngine);
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
+ AdblockPlus::JsConstValueList converted = jsEngine->ConvertArguments(arguments);
std::stringstream message;
for (size_t i = 0; i < converted.size(); i++)
{
if (i > 0)
message << " ";
message << converted[i]->AsString();
}
@@ -74,17 +74,17 @@
{
return DoLog(AdblockPlus::LogSystem::LOG_LEVEL_ERROR, arguments);
}
v8::Handle<v8::Value> TraceCallback(const v8::Arguments& arguments)
{
AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments);
const AdblockPlus::JsContext context(jsEngine);
- AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments);
+ AdblockPlus::JsConstValueList converted = jsEngine->ConvertArguments(arguments);
std::stringstream traceback;
v8::Local<v8::StackTrace> frames = v8::StackTrace::CurrentStackTrace(100);
for (int i = 0, l = frames->GetFrameCount(); i < l; i++)
{
v8::Local<v8::StackFrame> frame = frames->GetFrame(i);
traceback << (i + 1) << ": ";
std::string name = AdblockPlus::Utils::FromV8String(frame->GetFunctionName());
@@ -99,19 +99,19 @@
}
AdblockPlus::LogSystemPtr callback = jsEngine->GetLogSystem();
(*callback)(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), "");
return v8::Undefined();
}
}
-AdblockPlus::JsValuePtr AdblockPlus::ConsoleJsObject::Setup(
- AdblockPlus::JsEngine& jsEngine, const AdblockPlus::JsValuePtr& obj)
+AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup(
+ AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
{
- obj->SetProperty("log", jsEngine.NewCallback(::LogCallback));
- obj->SetProperty("debug", jsEngine.NewCallback(::DebugCallback));
- obj->SetProperty("info", jsEngine.NewCallback(::InfoCallback));
- obj->SetProperty("warn", jsEngine.NewCallback(::WarnCallback));
- obj->SetProperty("error", jsEngine.NewCallback(::ErrorCallback));
- obj->SetProperty("trace", jsEngine.NewCallback(::TraceCallback));
+ obj.SetProperty("log", *jsEngine.NewCallback(::LogCallback));
+ obj.SetProperty("debug", *jsEngine.NewCallback(::DebugCallback));
+ obj.SetProperty("info", *jsEngine.NewCallback(::InfoCallback));
+ obj.SetProperty("warn", *jsEngine.NewCallback(::WarnCallback));
+ obj.SetProperty("error", *jsEngine.NewCallback(::ErrorCallback));
+ obj.SetProperty("trace", *jsEngine.NewCallback(::TraceCallback));
return obj;
}

Powered by Google App Engine
This is Rietveld