| OLD | NEW | 
|---|
| 1 #include <algorithm> | 1 #include <algorithm> | 
| 2 #include <cctype> | 2 #include <cctype> | 
| 3 #include <functional> | 3 #include <functional> | 
|  | 4 #include <string> | 
| 4 | 5 | 
| 5 #include <AdblockPlus.h> | 6 #include <AdblockPlus.h> | 
| 6 | 7 | 
| 7 using namespace AdblockPlus; | 8 using namespace AdblockPlus; | 
| 8 | 9 | 
| 9 extern const char* jsSources[]; | 10 extern std::string jsSources[]; | 
| 10 | 11 | 
| 11 Filter::Filter(JsValuePtr value) | 12 Filter::Filter(JsValuePtr value) | 
| 12     : JsValue(value) | 13     : JsValue(value) | 
| 13 { | 14 { | 
| 14   if (!IsObject()) | 15   if (!IsObject()) | 
| 15     throw std::runtime_error("JavaScript value is not an object"); | 16     throw std::runtime_error("JavaScript value is not an object"); | 
| 16 } | 17 } | 
| 17 | 18 | 
| 18 Filter::Type Filter::GetType() | 19 Filter::Type Filter::GetType() | 
| 19 { | 20 { | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109   return result->AsBool(); | 110   return result->AsBool(); | 
| 110 } | 111 } | 
| 111 | 112 | 
| 112 bool Subscription::operator==(const Subscription& subscription) const | 113 bool Subscription::operator==(const Subscription& subscription) const | 
| 113 { | 114 { | 
| 114   return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
     ring(); | 115   return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
     ring(); | 
| 115 } | 116 } | 
| 116 | 117 | 
| 117 FilterEngine::FilterEngine(JsEnginePtr jsEngine) : jsEngine(jsEngine) | 118 FilterEngine::FilterEngine(JsEnginePtr jsEngine) : jsEngine(jsEngine) | 
| 118 { | 119 { | 
| 119   for (int i = 0; jsSources[i] && jsSources[i + 1]; i += 2) | 120   for (int i = 0; !jsSources[i].empty(); i += 2) | 
| 120     jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 121     jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 
| 121 } | 122 } | 
| 122 | 123 | 
| 123 FilterPtr FilterEngine::GetFilter(const std::string& text) | 124 FilterPtr FilterEngine::GetFilter(const std::string& text) | 
| 124 { | 125 { | 
| 125   JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); | 126   JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); | 
| 126   JsValueList params; | 127   JsValueList params; | 
| 127   params.push_back(jsEngine->NewValue(text)); | 128   params.push_back(jsEngine->NewValue(text)); | 
| 128   return FilterPtr(new Filter(func->Call(params))); | 129   return FilterPtr(new Filter(func->Call(params))); | 
| 129 } | 130 } | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 186 { | 187 { | 
| 187   JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 188   JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 
| 188   JsValueList params; | 189   JsValueList params; | 
| 189   params.push_back(jsEngine->NewValue(domain)); | 190   params.push_back(jsEngine->NewValue(domain)); | 
| 190   JsValueList result = func->Call(params)->AsList(); | 191   JsValueList result = func->Call(params)->AsList(); | 
| 191   std::vector<std::string> selectors; | 192   std::vector<std::string> selectors; | 
| 192   for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) | 193   for (JsValueList::iterator it = result.begin(); it != result.end(); ++it) | 
| 193     selectors.push_back((*it)->AsString()); | 194     selectors.push_back((*it)->AsString()); | 
| 194   return selectors; | 195   return selectors; | 
| 195 } | 196 } | 
| OLD | NEW | 
|---|