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 copy ctor. Don't use = default. Created April 24, 2017, 3:01 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/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -72,23 +72,39 @@
func.Call(*this);
}
bool Filter::operator==(const Filter& filter) const
{
return GetProperty("text").AsString() == filter.GetProperty("text").AsString();
}
+Subscription::Subscription(const Subscription& subscription)
+ : JsValue(subscription)
+{
+}
+
+Subscription::Subscription(Subscription&& subscription)
+ : JsValue(std::move(subscription))
+{
+}
+
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& subscription)
+{
+ *this = subscription;
+ return *this;
+}
+
bool Subscription::IsListed() const
{
JsValue func = jsEngine->Evaluate("API.isListedSubscription");
return func.Call(*this).AsBool();
}
void Subscription::AddToList()
{
@@ -277,49 +293,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));
}

Powered by Google App Engine
This is Rietveld