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

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

Issue 29548581: Issue 4128, 5138 - Add Parser and Serializer implemented in C++ Base URL: https://github.com/adblockplus/adblockpluscore.git
Left Patch Set: Created Sept. 18, 2017, 5:23 p.m.
Right Patch Set: rebase Created March 7, 2018, 12:01 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 | « no previous file | compiled/storage/Parser.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 16 matching lines...) Expand all
27 #include "../filter/BlockingFilter.h" 27 #include "../filter/BlockingFilter.h"
28 #include "../filter/WhitelistFilter.h" 28 #include "../filter/WhitelistFilter.h"
29 #include "../filter/ElemHideBase.h" 29 #include "../filter/ElemHideBase.h"
30 #include "../filter/ElemHideFilter.h" 30 #include "../filter/ElemHideFilter.h"
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"
38 #include "../ElemHideEmulation.h"
37 #include "../FilterNotifier.h" 39 #include "../FilterNotifier.h"
38 #include "../storage/Parser.h" 40 #include "../storage/Parser.h"
39 #include "../storage/Serializer.h" 41 #include "../storage/Serializer.h"
42
43 ABP_NS_USING
40 44
41 int main() 45 int main()
42 { 46 {
43 try 47 try
44 { 48 {
45 class_<Filter>("Filter") 49 class_<Filter>("Filter")
46 .property("text", &Filter::GetText) 50 .property("text", &Filter::GetText)
47 .function("serialize", &Filter::Serialize) 51 .function("serialize", &Filter::Serialize)
48 .class_function("fromText", &Filter::FromText) 52 .class_function("fromText", &Filter::FromText)
49 .subclass_differentiator(&Filter::mType, { 53 .subclass_differentiator(&Filter::mType, {
(...skipping 19 matching lines...) Expand all
69 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHi t) 73 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHi t)
70 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain) 74 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain)
71 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain) 75 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain)
72 .function("isGeneric", &ActiveFilter::IsGeneric) 76 .function("isGeneric", &ActiveFilter::IsGeneric)
73 .function("serialize", &ActiveFilter::Serialize); 77 .function("serialize", &ActiveFilter::Serialize);
74 78
75 class_<RegExpFilter,ActiveFilter>("RegExpFilter") 79 class_<RegExpFilter,ActiveFilter>("RegExpFilter")
76 .function("matches", &RegExpFilter::Matches); 80 .function("matches", &RegExpFilter::Matches);
77 81
78 class_<BlockingFilter,RegExpFilter>("BlockingFilter") 82 class_<BlockingFilter,RegExpFilter>("BlockingFilter")
79 .class_property("type", "'blocking'"); 83 .class_property("type", "'blocking'")
84 .property("collapse", &BlockingFilter::GetCollapse);
85
80 86
81 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter") 87 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter")
82 .class_property("type", "'whitelist'"); 88 .class_property("type", "'whitelist'");
83 89
84 class_<ElemHideBase,ActiveFilter>("ElemHideBase") 90 class_<ElemHideBase,ActiveFilter>("ElemHideBase")
85 .property("selector", &ElemHideBase::GetSelector) 91 .property("selector", &ElemHideBase::GetSelector)
86 .property("selectorDomain", &ElemHideBase::GetSelectorDomain); 92 .property("selectorDomain", &ElemHideBase::GetSelectorDomain);
87 93
88 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter") 94 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter")
89 .class_property("type", "'elemhide'"); 95 .class_property("type", "'elemhide'");
90 96
91 class_<ElemHideException,ElemHideBase>("ElemHideException") 97 class_<ElemHideException,ElemHideBase>("ElemHideException")
92 .class_property("type", "'elemhideexception'"); 98 .class_property("type", "'elemhideexception'");
93 99
94 class_<ElemHideEmulationFilter,ElemHideBase>("ElemHideEmulationFilter") 100 class_<ElemHideEmulationFilter,ElemHideBase>("ElemHideEmulationFilter")
95 .class_property("type", "'elemhideemulation'"); 101 .class_property("type", "'elemhideemulation'");
96 102
97 class_<Subscription>("Subscription") 103 class_<Subscription>("Subscription")
98 .property("url", &Subscription::GetID) 104 .property("url", &Subscription::GetID)
99 .property("title", &Subscription::GetTitle, &Subscription::SetTitle) 105 .property("title", &Subscription::GetTitle, &Subscription::SetTitle)
100 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled) 106 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled)
101 .property("listed", &Subscription::GetListed) 107 .property("listed", &Subscription::GetListed)
102 .property("filterCount", &Subscription::GetFilterCount) 108 .property("filterCount", &Subscription::GetFilterCount)
103 .function("filterAt", &Subscription::FilterAt) 109 .function("filterAt", &Subscription::FilterAt)
104 .function("indexOfFilter", &Subscription::IndexOfFilter) 110 .function("indexOfFilter", &Subscription::IndexOfFilter)
105 .class_function("fromURL", &Subscription::FromID) 111 .class_function("fromURL", &Subscription::FromID)
106 .subclass_differentiator(&Subscription::mType, { 112 .subclass_differentiator(&Subscription::mType, {
107 {Subscription::Type::USERDEFINED, "SpecialSubscription"}, 113 {Subscription::Type::USERDEFINED, "UserDefinedSubscription"},
108 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"}, 114 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"},
109 }); 115 });
110 116
111 class_<UserDefinedSubscription,Subscription>("SpecialSubscription") 117 class_<UserDefinedSubscription,Subscription>("UserDefinedSubscription")
112 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor) 118 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor)
113 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor) 119 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor)
114 .function("isGeneric", &UserDefinedSubscription::IsGeneric) 120 .function("isGeneric", &UserDefinedSubscription::IsGeneric)
115 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt) 121 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt)
116 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt); 122 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt);
117 123
118 class_<DownloadableSubscription,Subscription>("DownloadableSubscription") 124 class_<DownloadableSubscription,Subscription>("DownloadableSubscription")
119 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle) 125 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle)
120 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage) 126 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage)
121 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) 127 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck)
122 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration) 128 .property("hardExpiration", &DownloadableSubscription::GetHardExpiration , &DownloadableSubscription::SetHardExpiration)
123 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) 129 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration)
124 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) 130 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload)
125 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) 131 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus)
126 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) 132 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess)
127 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount) 133 .property("errorCount", &DownloadableSubscription::GetErrorCount, &Downl oadableSubscription::SetErrorCount)
128 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision) 134 .property("dataRevision", &DownloadableSubscription::GetDataRevision, &D ownloadableSubscription::SetDataRevision)
129 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) 135 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion)
130 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount); 136 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount);
131 137
132 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance) 138 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance)
133 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount) 139 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount)
134 .function("subscriptionAt", &FilterStorage::SubscriptionAt) 140 .function("subscriptionAt", &FilterStorage::SubscriptionAt)
135 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription) 141 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription)
136 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter) 142 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter)
137 .function("addSubscription", &FilterStorage::AddSubscription) 143 .function("addSubscription", &FilterStorage::AddSubscription)
138 .function("removeSubscription", &FilterStorage::RemoveSubscription) 144 .function("removeSubscription", &FilterStorage::RemoveSubscription)
139 .function("moveSubscription", &FilterStorage::MoveSubscription); 145 .function("moveSubscription", &FilterStorage::MoveSubscription);
146
147 class_<ElemHide_SelectorList>("ElemHide_SelectorList")
148 .property("selectorCount", &ElemHide_SelectorList::GetSelectorCount)
149 .function("selectorAt", &ElemHide_SelectorList::SelectorAt)
150 .function("filterKeyAt", &ElemHide_SelectorList::FilterKeyAt);
151
152 class_<ElemHide>("ElemHide")
153 .class_function("create", &ElemHide::Create)
154 .function("add", &ElemHide::Add)
155 .function("remove", &ElemHide::Remove)
156 .function("clear", &ElemHide::Clear)
157 .function("getSelectorsForDomain", &ElemHide::GetSelectorsForDomain)
158 .function("getUnconditionalSelectors", &ElemHide::GetUnconditionalSelect ors);
159
160 class_<ElemHideEmulation_FilterList>("ElemHideEmulation_FilterList")
161 .property("filterCount", &ElemHideEmulation_FilterList::GetFilterCount)
162 .function("filterAt", &ElemHideEmulation_FilterList::FilterAt);
163
164 class_<ElemHideEmulation>("ElemHideEmulation")
165 .class_function("create", &ElemHideEmulation::Create)
166 .function("add", &ElemHideEmulation::Add)
167 .function("remove", &ElemHideEmulation::Remove)
168 .function("clear", &ElemHideEmulation::Clear)
169 .function("getRulesForDomain", &ElemHideEmulation::GetRulesForDomain);
140 170
141 class_<Parser>("_FilterStorage_Parser") 171 class_<Parser>("_FilterStorage_Parser")
142 .property("subscriptionCount", &Parser::GetSubscriptionCount) 172 .property("subscriptionCount", &Parser::GetSubscriptionCount)
143 .function("process", &Parser::Process) 173 .function("process", &Parser::Process)
144 .function("finalize", &Parser::Finalize) 174 .function("finalize", &Parser::Finalize)
145 .function("subscriptionAt", &Parser::SubscriptionAt) 175 .function("subscriptionAt", &Parser::SubscriptionAt)
146 .class_function("create", &Parser::Create); 176 .class_function("create", &Parser::Create);
147 177
148 class_<Serializer>("_FilterStorage_Serializer") 178 class_<Serializer>("_FilterStorage_Serializer")
149 .property("data", &Serializer::GetData) 179 .property("data", &Serializer::GetData)
150 .function("serialize", &Serializer::Serialize) 180 .function("serialize", &Serializer::Serialize)
151 .class_function("create", &Serializer::Create); 181 .class_function("create", &Serializer::Create);
152 182
153 printBindings(); 183 printBindings();
154 RegExpFilter::GenerateCustomBindings(); 184 RegExpFilter::GenerateCustomBindings();
155 FilterNotifier::GenerateCustomBindings(); 185 FilterNotifier::GenerateCustomBindings::Generate();
156 186
157 return 0; 187 return 0;
158 } 188 }
159 catch (const std::exception& e) 189 catch (const std::exception& e)
160 { 190 {
161 EM_ASM_ARGS( 191 EM_ASM_ARGS(
162 console.error("Error occurred generating JavaScript bindings: " + 192 console.error("Error occurred generating JavaScript bindings: " +
163 Module.AsciiToString($0)), e.what() 193 Module.AsciiToString($0)), e.what()
164 ); 194 );
165 return 1; 195 return 1;
166 } 196 }
167 } 197 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld