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

Unified Diff: shell/src/PrefsCommand.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added value test for copy ctor Created April 20, 2017, 12:40 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: shell/src/PrefsCommand.cpp
===================================================================
--- a/shell/src/PrefsCommand.cpp
+++ b/shell/src/PrefsCommand.cpp
@@ -36,53 +36,53 @@
return;
}
if (action == "show")
{
std::string pref;
argumentStream >> pref;
- AdblockPlus::JsValuePtr value = filterEngine.GetPref(pref);
- if (value->IsUndefined())
+ auto value = filterEngine.GetPref(pref);
+ if (value.IsUndefined())
std::cout << "No such preference" << std::endl;
else
{
- if (value->IsString())
+ if (value.IsString())
std::cout << "(string) ";
- else if (value->IsNumber())
+ else if (value.IsNumber())
std::cout << "(number) ";
- else if (value->IsBool())
+ else if (value.IsBool())
std::cout << "(bool) ";
else
std::cout << "(unknown type) ";
- std::cout << value->AsString() << std::endl;
+ std::cout << value.AsString() << std::endl;
}
}
else if (action == "set")
{
std::string pref;
argumentStream >> pref;
- AdblockPlus::JsValuePtr current = filterEngine.GetPref(pref);
- if (current->IsUndefined())
+ auto current = filterEngine.GetPref(pref);
+ if (current.IsUndefined())
std::cout << "No such preference" << std::endl;
- else if (current->IsString())
+ else if (current.IsString())
{
std::string value;
std::getline(argumentStream, value);
filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value));
}
- else if (current->IsNumber())
+ else if (current.IsNumber())
{
int64_t value;
argumentStream >> value;
filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value));
}
- else if (current->IsBool())
+ else if (current.IsBool())
{
bool value;
argumentStream >> value;
filterEngine.SetPref(pref, filterEngine.GetJsEngine()->NewValue(value));
}
else
std::cout << "Cannot set a preference of unknown type" << std::endl;
}
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | src/ConsoleJsObject.cpp » ('j') | test/JsEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld