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

Unified Diff: src/FilterEngine.cpp

Issue 29419623: Issue 5165 - Remove SubscriptionPtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added move assignment operator Created April 24, 2017, 7:08 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 | « shell/src/SubscriptionsCommand.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -72,23 +72,45 @@
func.Call(*this);
}
bool Filter::operator==(const Filter& filter) const
{
return GetProperty("text").AsString() == filter.GetProperty("text").AsString();
}
+Subscription::Subscription(const Subscription& src)
+ : JsValue(src)
+{
+}
+
+Subscription::Subscription(Subscription&& src)
+ : JsValue(std::move(src))
+{
+}
+
Subscription::Subscription(JsValue&& value)
: JsValue(std::move(value))
{
if (!IsObject())
throw std::runtime_error("JavaScript value is not an object");
}
+Subscription& Subscription::operator=(const Subscription& src)
+{
+ *this = src;
+ return *this;
+}
+
+Subscription& Subscription::operator=(Subscription&& src)
+{
+ *this = std::move(src);
+ return *this;
+}
+
bool Subscription::IsListed() const
{
JsValue func = jsEngine->Evaluate("API.isListedSubscription");
return func.Call(*this).AsBool();
}
void Subscription::AddToList()
{
@@ -277,49 +299,49 @@
}
Filter FilterEngine::GetFilter(const std::string& text) const
{
JsValue func = jsEngine->Evaluate("API.getFilterFromText");
return Filter(func.Call(jsEngine->NewValue(text)));
}
-SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const
+Subscription FilterEngine::GetSubscription(const std::string& url) const
{
JsValue func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
- return SubscriptionPtr(new Subscription(func.Call(jsEngine->NewValue(url))));
+ return Subscription(func.Call(jsEngine->NewValue(url)));
}
std::vector<Filter> FilterEngine::GetListedFilters() const
{
JsValue func = jsEngine->Evaluate("API.getListedFilters");
JsValueList values = func.Call().AsList();
std::vector<Filter> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
result.push_back(Filter(std::move(*it)));
return result;
}
-std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const
+std::vector<Subscription> FilterEngine::GetListedSubscriptions() const
{
JsValue func = jsEngine->Evaluate("API.getListedSubscriptions");
JsValueList values = func.Call().AsList();
- std::vector<SubscriptionPtr> result;
+ std::vector<Subscription> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
- result.push_back(SubscriptionPtr(new Subscription(std::move(*it))));
+ result.push_back(Subscription(std::move(*it)));
return result;
}
-std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const
+std::vector<Subscription> FilterEngine::FetchAvailableSubscriptions() const
{
JsValue func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
JsValueList values = func.Call().AsList();
- std::vector<SubscriptionPtr> result;
+ std::vector<Subscription> result;
for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
- result.push_back(SubscriptionPtr(new Subscription(std::move(*it))));
+ result.push_back(Subscription(std::move(*it)));
return result;
}
void FilterEngine::SetAAEnabled(bool enabled)
{
jsEngine->Evaluate("API.setAASubscriptionEnabled").Call(jsEngine->NewValue(enabled));
}
« no previous file with comments | « shell/src/SubscriptionsCommand.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld