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

Side by Side Diff: compiled/bindings/main.cpp

Issue 29426559: Issue 5137 - [emscripten] Added basic filter storage implementation (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Fixed bogus assert Created Aug. 31, 2017, 12:44 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/bindings/generator.cpp ('k') | compiled/library.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 #include "../filter/RegExpFilter.h" 26 #include "../filter/RegExpFilter.h"
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 "../FilterNotifier.h" 37 #include "../FilterNotifier.h"
37 38
38 int main() 39 int main()
39 { 40 {
40 try 41 try
41 { 42 {
42 class_<Filter>("Filter") 43 class_<Filter>("Filter")
43 .property("text", &Filter::GetText) 44 .property("text", &Filter::GetText)
44 .function("serialize", &Filter::Serialize) 45 .function("serialize", &Filter::Serialize)
45 .class_function("fromText", &Filter::FromText) 46 .class_function("fromText", &Filter::FromText)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 class_<ElemHideException,ElemHideBase>("ElemHideException") 89 class_<ElemHideException,ElemHideBase>("ElemHideException")
89 .class_property("type", "'elemhideexception'"); 90 .class_property("type", "'elemhideexception'");
90 91
91 class_<ElemHideEmulationFilter,ElemHideBase>("ElemHideEmulationFilter") 92 class_<ElemHideEmulationFilter,ElemHideBase>("ElemHideEmulationFilter")
92 .class_property("type", "'elemhideemulation'"); 93 .class_property("type", "'elemhideemulation'");
93 94
94 class_<Subscription>("Subscription") 95 class_<Subscription>("Subscription")
95 .property("url", &Subscription::GetID) 96 .property("url", &Subscription::GetID)
96 .property("title", &Subscription::GetTitle, &Subscription::SetTitle) 97 .property("title", &Subscription::GetTitle, &Subscription::SetTitle)
97 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled) 98 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled)
99 .property("listed", &Subscription::GetListed)
98 .property("filterCount", &Subscription::GetFilterCount) 100 .property("filterCount", &Subscription::GetFilterCount)
99 .function("filterAt", &Subscription::FilterAt) 101 .function("filterAt", &Subscription::FilterAt)
100 .function("indexOfFilter", &Subscription::IndexOfFilter) 102 .function("indexOfFilter", &Subscription::IndexOfFilter)
101 .function("serialize", &Subscription::Serialize) 103 .function("serialize", &Subscription::Serialize)
102 .function("serializeFilters", &Subscription::SerializeFilters) 104 .function("serializeFilters", &Subscription::SerializeFilters)
103 .class_function("fromURL", &Subscription::FromID) 105 .class_function("fromURL", &Subscription::FromID)
104 .subclass_differentiator(&Subscription::mType, { 106 .subclass_differentiator(&Subscription::mType, {
105 {Subscription::Type::USERDEFINED, "SpecialSubscription"}, 107 {Subscription::Type::USERDEFINED, "SpecialSubscription"},
106 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"}, 108 {Subscription::Type::DOWNLOADABLE, "DownloadableSubscription"},
107 }); 109 });
108 110
109 class_<UserDefinedSubscription,Subscription>("SpecialSubscription") 111 class_<UserDefinedSubscription,Subscription>("SpecialSubscription")
110 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor) 112 .function("isDefaultFor", &UserDefinedSubscription::IsDefaultFor)
111 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor) 113 .function("makeDefaultFor", &UserDefinedSubscription::MakeDefaultFor)
114 .function("isGeneric", &UserDefinedSubscription::IsGeneric)
112 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt) 115 .function("insertFilterAt", &UserDefinedSubscription::InsertFilterAt)
113 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt) 116 .function("removeFilterAt", &UserDefinedSubscription::RemoveFilterAt)
114 .function("serialize", &UserDefinedSubscription::Serialize); 117 .function("serialize", &UserDefinedSubscription::Serialize);
115 118
116 class_<DownloadableSubscription,Subscription>("DownloadableSubscription") 119 class_<DownloadableSubscription,Subscription>("DownloadableSubscription")
117 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle) 120 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle)
118 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage) 121 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage)
119 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) 122 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck)
120 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration) 123 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration)
121 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) 124 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration)
122 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) 125 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload)
123 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) 126 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus)
124 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) 127 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess)
125 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount) 128 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount)
126 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision) 129 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision)
127 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) 130 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion)
128 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount) 131 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount)
129 .function("serialize", &DownloadableSubscription::Serialize); 132 .function("serialize", &DownloadableSubscription::Serialize);
130 133
134 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance)
135 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount)
136 .function("subscriptionAt", &FilterStorage::SubscriptionAt)
137 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription)
138 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter)
139 .function("addSubscription", &FilterStorage::AddSubscription)
140 .function("removeSubscription", &FilterStorage::RemoveSubscription)
141 .function("moveSubscription", &FilterStorage::MoveSubscription);
142
131 printBindings(); 143 printBindings();
132 RegExpFilter::GenerateCustomBindings(); 144 RegExpFilter::GenerateCustomBindings();
133 FilterNotifier::GenerateCustomBindings(); 145 FilterNotifier::GenerateCustomBindings();
134 146
135 return 0; 147 return 0;
136 } 148 }
137 catch (const std::exception& e) 149 catch (const std::exception& e)
138 { 150 {
139 EM_ASM_ARGS( 151 EM_ASM_ARGS(
140 console.error("Error occurred generating JavaScript bindings: " + 152 console.error("Error occurred generating JavaScript bindings: " +
141 Module.AsciiToString($0)), e.what() 153 Module.AsciiToString($0)), e.what()
142 ); 154 );
143 return 1; 155 return 1;
144 } 156 }
145 } 157 }
OLDNEW
« no previous file with comments | « compiled/bindings/generator.cpp ('k') | compiled/library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld