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

Unified Diff: src/FilterEngine.cpp

Issue 29334678: Issue 3589 - Change return type of AdblockPlus::JsValue::Call from pointer to r-value object. (Closed)
Patch Set: rebase Created March 27, 2017, 9:47 a.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 | « include/AdblockPlus/JsValue.h ('k') | src/JsValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp
index 4fa69715c5d1a84934f301e686f9e0cd610cee0e..5c1a495619c76e0b51a886b9116807789b135c9a 100644
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -57,19 +57,19 @@ Filter::Type Filter::GetType() const
bool Filter::IsListed() const
{
JsValuePtr func = jsEngine->Evaluate("API.isListedFilter");
- return func->Call(shared_from_this())->AsBool();
+ return func->Call(*this).AsBool();
}
void Filter::AddToList()
{
JsValuePtr func = jsEngine->Evaluate("API.addFilterToList");
- func->Call(shared_from_this());
+ func->Call(*this);
}
void Filter::RemoveFromList()
{
JsValuePtr func = jsEngine->Evaluate("API.removeFilterFromList");
- func->Call(shared_from_this());
+ func->Call(*this);
}
bool Filter::operator==(const Filter& filter) const
@@ -87,32 +87,31 @@ Subscription::Subscription(JsValue&& value)
bool Subscription::IsListed() const
{
JsValuePtr func = jsEngine->Evaluate("API.isListedSubscription");
- return func->Call(shared_from_this())->AsBool();
+ return func->Call(*this).AsBool();
}
void Subscription::AddToList()
{
JsValuePtr func = jsEngine->Evaluate("API.addSubscriptionToList");
- func->Call(shared_from_this());
+ func->Call(*this);
}
void Subscription::RemoveFromList()
{
JsValuePtr func = jsEngine->Evaluate("API.removeSubscriptionFromList");
- func->Call(shared_from_this());
+ func->Call(*this);
}
void Subscription::UpdateFilters()
{
JsValuePtr func = jsEngine->Evaluate("API.updateSubscription");
- func->Call(shared_from_this());
+ func->Call(*this);
}
bool Subscription::IsUpdating() const
{
JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating");
- JsValuePtr result = func->Call(shared_from_this());
- return result->AsBool();
+ return func->Call(*this).AsBool();
}
bool Subscription::operator==(const Subscription& subscription) const
@@ -275,19 +274,19 @@ bool FilterEngine::IsFirstRun() const
FilterPtr FilterEngine::GetFilter(const std::string& text) const
{
JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText");
- return FilterPtr(new Filter(std::move(*func->Call(jsEngine->NewValue(text)))));
+ return FilterPtr(new Filter(func->Call(*jsEngine->NewValue(text))));
}
SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const
{
JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
- return SubscriptionPtr(new Subscription(std::move(*func->Call(jsEngine->NewValue(url)))));
+ return SubscriptionPtr(new Subscription(func->Call(*jsEngine->NewValue(url))));
}
std::vector<FilterPtr> FilterEngine::GetListedFilters() const
{
JsValuePtr func = jsEngine->Evaluate("API.getListedFilters");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<FilterPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(FilterPtr(new Filter(std::move(**it))));
@@ -297,7 +296,7 @@ std::vector<FilterPtr> FilterEngine::GetListedFilters() const
std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
{
JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<SubscriptionPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(SubscriptionPtr(new Subscription(std::move(**it))));
@@ -307,7 +306,7 @@ std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const
{
JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
- JsValueList values = func->Call()->AsList();
+ JsValueList values = func->Call().AsList();
std::vector<SubscriptionPtr> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(SubscriptionPtr(new Subscription(std::move(**it))));
@@ -390,9 +389,9 @@ AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url,
params.push_back(jsEngine->NewValue(url));
params.push_back(jsEngine->NewValue(contentTypeMask));
params.push_back(jsEngine->NewValue(documentUrl));
- JsValuePtr result = func->Call(params);
- if (!result->IsNull())
- return FilterPtr(new Filter(std::move(*result)));
+ JsValue result = func->Call(params);
+ if (!result.IsNull())
+ return FilterPtr(new Filter(std::move(result)));
else
return FilterPtr();
}
@@ -400,7 +399,7 @@ AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url,
std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::string& domain) const
{
JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors");
- JsValueList result = func->Call(jsEngine->NewValue(domain))->AsList();
+ JsValueList result = func->Call(*jsEngine->NewValue(domain)).AsList();
std::vector<std::string> selectors;
for (const auto& r: result)
selectors.push_back(r->AsString());
@@ -410,7 +409,7 @@ std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
JsValuePtr FilterEngine::GetPref(const std::string& pref) const
{
JsValuePtr func = jsEngine->Evaluate("API.getPref");
- return func->Call(jsEngine->NewValue(pref));
+ return std::make_shared<JsValue>(func->Call(*jsEngine->NewValue(pref)));
}
void FilterEngine::SetPref(const std::string& pref, JsValuePtr value)
@@ -426,7 +425,7 @@ void FilterEngine::SetPref(const std::string& pref, JsValuePtr value)
std::string FilterEngine::GetHostFromURL(const std::string& url) const
{
JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl");
- return func->Call(jsEngine->NewValue(url))->AsString();
+ return func->Call(*jsEngine->NewValue(url)).AsString();
}
void FilterEngine::SetUpdateAvailableCallback(
@@ -524,7 +523,7 @@ int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
params.push_back(jsEngine->NewValue(v1));
params.push_back(jsEngine->NewValue(v2));
JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
- return func->Call(params)->AsInt();
+ return func->Call(params).AsInt();
}
FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url,
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | src/JsValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld