 Issue 29426559:
  Issue 5137 - [emscripten] Added basic filter storage implementation  (Closed) 
  Base URL: https://hg.adblockplus.org/adblockpluscore
    
  
    Issue 29426559:
  Issue 5137 - [emscripten] Added basic filter storage implementation  (Closed) 
  Base URL: https://hg.adblockplus.org/adblockpluscore| Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH | 
| 4 * | 4 * | 
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as | 
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. | 
| 8 * | 8 * | 
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, | 
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. | 
| 13 * | 13 * | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 .function("serializeFilters", &Subscription::SerializeFilters) | 104 .function("serializeFilters", &Subscription::SerializeFilters) | 
| 105 .class_function("fromURL", &Subscription::FromID) | 105 .class_function("fromURL", &Subscription::FromID) | 
| 106 .subclass_differentiator(&Subscription::mType, { | 106 .subclass_differentiator(&Subscription::mType, { | 
| 107 {Subscription::Type::USERDEFINED, "SpecialSubscription"}, | 107 {Subscription::Type::USERDEFINED, "SpecialSubscription"}, | 
| 108 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"}, | 108 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"}, | 
| 109 }); | 109 }); | 
| 110 | 110 | 
| 111 class_<UserDefinedSubscription,Subscription>("SpecialSubscription") | 111 class_<UserDefinedSubscription,Subscription>("SpecialSubscription") | 
| 112 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor) | 112 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor) | 
| 113 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor) | 113 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor) | 
| 114 .function("isGeneric", &UserDefinedSubscription::IsGeneric) | 114 .function("isGeneric", &UserDefinedSubscription::IsGeneric) | 
| 
Wladimir Palant
2017/05/01 14:47:25
I need to add unit tests for this.
 | |
| 115 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt) | 115 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt) | 
| 116 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt) | 116 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt) | 
| 117 .function("serialize", &UserDefinedSubscription::Serialize); | 117 .function("serialize", &UserDefinedSubscription::Serialize); | 
| 118 | 118 | 
| 119 class_<DownloadableSubscription,Subscription>("DownloadableSubscription") | 119 class_<DownloadableSubscription,Subscription>("DownloadableSubscription") | 
| 120 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle) | 120 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle) | 
| 121 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage) | 121 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage) | 
| 122 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) | 122 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) | 
| 123 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration) | 123 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration) | 
| 124 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) | 124 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) | 
| 125 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) | 125 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) | 
| 126 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) | 126 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) | 
| 127 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) | 127 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) | 
| 128 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount) | 128 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount) | 
| 129 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision) | 129 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision) | 
| 130 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) | 130 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) | 
| 131 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount) | 131 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount) | 
| 132 .function("serialize", &DownloadableSubscription::Serialize); | 132 .function("serialize", &DownloadableSubscription::Serialize); | 
| 133 | 133 | 
| 134 namespace_("FilterStorage") | 134 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance) | 
| 135 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount) | 135 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount) | 
| 136 .function("subscriptionAt", &FilterStorage::SubscriptionAt) | 136 .function("subscriptionAt", &FilterStorage::SubscriptionAt) | 
| 137 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription) | 137 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription) | 
| 138 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter) | 138 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter) | 
| 
Wladimir Palant
2017/05/01 14:47:25
Note that the original name is getGroupForFilter -
 | |
| 139 .function("addSubscription", &FilterStorage::AddSubscription) | 139 .function("addSubscription", &FilterStorage::AddSubscription) | 
| 140 .function("removeSubscription", &FilterStorage::RemoveSubscription) | 140 .function("removeSubscription", &FilterStorage::RemoveSubscription) | 
| 141 .function("moveSubscription", &FilterStorage::MoveSubscription); | 141 .function("moveSubscription", &FilterStorage::MoveSubscription); | 
| 142 | 142 | 
| 143 printBindings(); | 143 printBindings(); | 
| 144 RegExpFilter::GenerateCustomBindings(); | 144 RegExpFilter::GenerateCustomBindings(); | 
| 145 FilterNotifier::GenerateCustomBindings(); | 145 FilterNotifier::GenerateCustomBindings(); | 
| 146 | 146 | 
| 147 return 0; | 147 return 0; | 
| 148 } | 148 } | 
| 149 catch (const std::exception& e) | 149 catch (const std::exception& e) | 
| 150 { | 150 { | 
| 151 EM_ASM_ARGS( | 151 EM_ASM_ARGS( | 
| 152 console.error("Error occurred generating JavaScript bindings: " + | 152 console.error("Error occurred generating JavaScript bindings: " + | 
| 153 Module.AsciiToString($0)), e.what() | 153 Module.AsciiToString($0)), e.what() | 
| 154 ); | 154 ); | 
| 155 return 1; | 155 return 1; | 
| 156 } | 156 } | 
| 157 } | 157 } | 
| LEFT | RIGHT |