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

Delta Between Two Patch Sets: compiled/bindings/main.cpp

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Nov. 13, 2017, 10:25 p.m.
Right Patch Set: Removed Md5sum and associated code Created Aug. 14, 2018, 12:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/StringScanner.h ('k') | compiled/storage/FilterStorage.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present 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
(...skipping 20 matching lines...) Expand all
31 #include "../filter/ElemHideException.h" 31 #include "../filter/ElemHideException.h"
32 #include "../filter/ElemHideEmulationFilter.h" 32 #include "../filter/ElemHideEmulationFilter.h"
33 #include "../subscription/Subscription.h" 33 #include "../subscription/Subscription.h"
34 #include "../subscription/DownloadableSubscription.h" 34 #include "../subscription/DownloadableSubscription.h"
35 #include "../subscription/UserDefinedSubscription.h" 35 #include "../subscription/UserDefinedSubscription.h"
36 #include "../storage/FilterStorage.h" 36 #include "../storage/FilterStorage.h"
37 #include "../ElemHide.h" 37 #include "../ElemHide.h"
38 #include "../ElemHideEmulation.h" 38 #include "../ElemHideEmulation.h"
39 #include "../FilterNotifier.h" 39 #include "../FilterNotifier.h"
40 40
41 ABP_NS_USING
42
41 int main() 43 int main()
42 { 44 {
43 try 45 try
44 { 46 {
45 class_<Filter>("Filter") 47 class_<Filter>("Filter")
46 .property("text", &Filter::GetText) 48 .property("text", &Filter::GetText)
47 .function("serialize", &Filter::Serialize) 49 .function("serialize", &Filter::Serialize)
48 .class_function("fromText", &Filter::FromText) 50 .class_function("fromText", &Filter::FromText)
49 .subclass_differentiator(&Filter::mType, { 51 .subclass_differentiator(&Filter::mType, {
50 {Filter::Type::INVALID, "InvalidFilter"}, 52 {Filter::Type::INVALID, "InvalidFilter"},
(...skipping 18 matching lines...) Expand all
69 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHi t) 71 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHi t)
70 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain) 72 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain)
71 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain) 73 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain)
72 .function("isGeneric", &ActiveFilter::IsGeneric) 74 .function("isGeneric", &ActiveFilter::IsGeneric)
73 .function("serialize", &ActiveFilter::Serialize); 75 .function("serialize", &ActiveFilter::Serialize);
74 76
75 class_<RegExpFilter,ActiveFilter>("RegExpFilter") 77 class_<RegExpFilter,ActiveFilter>("RegExpFilter")
76 .function("matches", &RegExpFilter::Matches); 78 .function("matches", &RegExpFilter::Matches);
77 79
78 class_<BlockingFilter,RegExpFilter>("BlockingFilter") 80 class_<BlockingFilter,RegExpFilter>("BlockingFilter")
79 .class_property("type", "'blocking'"); 81 .class_property("type", "'blocking'")
82 .property("collapse", &BlockingFilter::GetCollapse);
83
80 84
81 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter") 85 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter")
82 .class_property("type", "'whitelist'"); 86 .class_property("type", "'whitelist'");
83 87
84 class_<ElemHideBase,ActiveFilter>("ElemHideBase") 88 class_<ElemHideBase,ActiveFilter>("ElemHideBase")
85 .property("selector", &ElemHideBase::GetSelector) 89 .property("selector", &ElemHideBase::GetSelector)
86 .property("selectorDomain", &ElemHideBase::GetSelectorDomain); 90 .property("selectorDomain", &ElemHideBase::GetSelectorDomain);
87 91
88 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter") 92 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter")
89 .class_property("type", "'elemhide'"); 93 .class_property("type", "'elemhide'");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) 128 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck)
125 .property("hardExpiration", &DownloadableSubscription::GetHardExpiration , &DownloadableSubscription::SetHardExpiration) 129 .property("hardExpiration", &DownloadableSubscription::GetHardExpiration , &DownloadableSubscription::SetHardExpiration)
126 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) 130 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration)
127 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) 131 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload)
128 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) 132 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus)
129 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) 133 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess)
130 .property("errorCount", &DownloadableSubscription::GetErrorCount, &Downl oadableSubscription::SetErrorCount) 134 .property("errorCount", &DownloadableSubscription::GetErrorCount, &Downl oadableSubscription::SetErrorCount)
131 .property("dataRevision", &DownloadableSubscription::GetDataRevision, &D ownloadableSubscription::SetDataRevision) 135 .property("dataRevision", &DownloadableSubscription::GetDataRevision, &D ownloadableSubscription::SetDataRevision)
132 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) 136 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion)
133 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount) 137 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount)
134 .function("parseDownload", &DownloadableSubscription::ParseDownload) 138 .class_function("parseDownload", &DownloadableSubscription::ParseDownloa d)
135 .function("serialize", &DownloadableSubscription::Serialize); 139 .function("serialize", &DownloadableSubscription::Serialize);
136 140
137 class_<_DownloadableSubscription_Parser>("_DownloadableSubscription_Parser") 141 class_<DownloadableSubscription_Parser>("DownloadableSubscription_Parser")
138 .property("redirect", &_DownloadableSubscription_Parser::GetRedirect) 142 .property("redirect", &DownloadableSubscription_Parser::GetRedirect)
139 .property("homepage", &_DownloadableSubscription_Parser::GetHomepage) 143 .property("homepage", &DownloadableSubscription_Parser::GetHomepage)
140 .function("process", &_DownloadableSubscription_Parser::Process) 144 .function("process", &DownloadableSubscription_Parser::Process)
141 .function("finalize", &_DownloadableSubscription_Parser::Finalize); 145 .function("finalize", &DownloadableSubscription_Parser::Finalize);
142 146
143 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance) 147 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance)
144 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount) 148 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount)
145 .function("subscriptionAt", &FilterStorage::SubscriptionAt) 149 .function("subscriptionAt", &FilterStorage::SubscriptionAt)
146 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription) 150 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription)
147 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter) 151 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter)
148 .function("addSubscription", &FilterStorage::AddSubscription) 152 .function("addSubscription", &FilterStorage::AddSubscription)
149 .function("removeSubscription", &FilterStorage::RemoveSubscription) 153 .function("removeSubscription", &FilterStorage::RemoveSubscription)
150 .function("moveSubscription", &FilterStorage::MoveSubscription); 154 .function("moveSubscription", &FilterStorage::MoveSubscription)
155 .function("clearSubscriptionFilters", &FilterStorage::ClearSubscriptionF ilters);
151 156
152 class_<_ElemHide_SelectorList>("_ElemHide_SelectorList") 157 class_<ElemHide_SelectorList>("ElemHide_SelectorList")
153 .property("selectorCount", &_ElemHide_SelectorList::GetSelectorCount) 158 .property("selectorCount", &ElemHide_SelectorList::GetSelectorCount)
154 .function("selectorAt", &_ElemHide_SelectorList::SelectorAt) 159 .function("selectorAt", &ElemHide_SelectorList::SelectorAt)
155 .function("filterKeyAt", &_ElemHide_SelectorList::FilterKeyAt); 160 .function("filterKeyAt", &ElemHide_SelectorList::FilterKeyAt);
156 161
157 singleton<ElemHide>("ElemHide", &ElemHide::GetInstance) 162 class_<ElemHide>("ElemHide")
163 .class_function("create", &ElemHide::Create)
158 .function("add", &ElemHide::Add) 164 .function("add", &ElemHide::Add)
159 .function("remove", &ElemHide::Remove) 165 .function("remove", &ElemHide::Remove)
160 .function("clear", &ElemHide::Clear) 166 .function("clear", &ElemHide::Clear)
161 .function("getSelectorsForDomain", &ElemHide::GetSelectorsForDomain) 167 .function("getSelectorsForDomain", &ElemHide::GetSelectorsForDomain)
162 .function("getUnconditionalSelectors", &ElemHide::GetUnconditionalSelect ors); 168 .function("getUnconditionalSelectors", &ElemHide::GetUnconditionalSelect ors);
163 169
164 class_<_ElemHideEmulation_FilterList>("_ElemHideEmulation_FilterList") 170 class_<ElemHideEmulation_FilterList>("ElemHideEmulation_FilterList")
165 .property("filterCount", &_ElemHideEmulation_FilterList::GetFilterCount) 171 .property("filterCount", &ElemHideEmulation_FilterList::GetFilterCount)
166 .function("filterAt", &_ElemHideEmulation_FilterList::FilterAt); 172 .function("filterAt", &ElemHideEmulation_FilterList::FilterAt);
167 173
168 singleton<ElemHideEmulation>("ElemHideEmulation", &ElemHideEmulation::GetIns tance) 174 class_<ElemHideEmulation>("ElemHideEmulation")
175 .class_function("create", &ElemHideEmulation::Create)
169 .function("add", &ElemHideEmulation::Add) 176 .function("add", &ElemHideEmulation::Add)
170 .function("remove", &ElemHideEmulation::Remove) 177 .function("remove", &ElemHideEmulation::Remove)
171 .function("clear", &ElemHideEmulation::Clear) 178 .function("clear", &ElemHideEmulation::Clear)
172 .function("getRulesForDomain", &ElemHideEmulation::GetRulesForDomain); 179 .function("getRulesForDomain", &ElemHideEmulation::GetRulesForDomain);
173 180
174 printBindings(); 181 printBindings();
175 RegExpFilter::GenerateCustomBindings(); 182 RegExpFilter::GenerateCustomBindings();
176 FilterNotifier::GenerateCustomBindings(); 183 FilterNotifier::GenerateCustomBindings::Generate();
177 184
178 return 0; 185 return 0;
179 } 186 }
180 catch (const std::exception& e) 187 catch (const std::exception& e)
181 { 188 {
182 EM_ASM_ARGS( 189 EM_ASM_ARGS(
183 console.error("Error occurred generating JavaScript bindings: " + 190 console.error("Error occurred generating JavaScript bindings: " +
184 Module.AsciiToString($0)), e.what() 191 Module.AsciiToString($0)), e.what()
185 ); 192 );
186 return 1; 193 return 1;
187 } 194 }
188 } 195 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld