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

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

Issue 29548581: Issue 4128, 5138 - Add Parser and Serializer implemented in C++ Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 18, 2017, 5:23 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
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 17 matching lines...) Expand all
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 "../FilterNotifier.h" 37 #include "../FilterNotifier.h"
38 #include "../storage/Parser.h"
39 #include "../storage/Serializer.h"
38 40
39 int main() 41 int main()
40 { 42 {
41 try 43 try
42 { 44 {
43 class_<Filter>("Filter") 45 class_<Filter>("Filter")
44 .property("text", &Filter::GetText) 46 .property("text", &Filter::GetText)
45 .function("serialize", &Filter::Serialize) 47 .function("serialize", &Filter::Serialize)
46 .class_function("fromText", &Filter::FromText) 48 .class_function("fromText", &Filter::FromText)
47 .subclass_differentiator(&Filter::mType, { 49 .subclass_differentiator(&Filter::mType, {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 .class_property("type", "'elemhideemulation'"); 95 .class_property("type", "'elemhideemulation'");
94 96
95 class_<Subscription>("Subscription") 97 class_<Subscription>("Subscription")
96 .property("url", &Subscription::GetID) 98 .property("url", &Subscription::GetID)
97 .property("title", &Subscription::GetTitle, &Subscription::SetTitle) 99 .property("title", &Subscription::GetTitle, &Subscription::SetTitle)
98 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled) 100 .property("disabled", &Subscription::GetDisabled, &Subscription::SetDisa bled)
99 .property("listed", &Subscription::GetListed) 101 .property("listed", &Subscription::GetListed)
100 .property("filterCount", &Subscription::GetFilterCount) 102 .property("filterCount", &Subscription::GetFilterCount)
101 .function("filterAt", &Subscription::FilterAt) 103 .function("filterAt", &Subscription::FilterAt)
102 .function("indexOfFilter", &Subscription::IndexOfFilter) 104 .function("indexOfFilter", &Subscription::IndexOfFilter)
103 .function("serialize", &Subscription::Serialize)
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)
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);
118 117
119 class_<DownloadableSubscription,Subscription>("DownloadableSubscription") 118 class_<DownloadableSubscription,Subscription>("DownloadableSubscription")
120 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle) 119 .property("fixedTitle", &DownloadableSubscription::GetFixedTitle, &Downl oadableSubscription::SetFixedTitle)
121 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage) 120 .property("homepage", &DownloadableSubscription::GetHomepage, &Downloada bleSubscription::SetHomepage)
122 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck) 121 .property("lastCheck", &DownloadableSubscription::GetLastCheck, &Downloa dableSubscription::SetLastCheck)
123 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration) 122 .property("expires", &DownloadableSubscription::GetHardExpiration, &Down loadableSubscription::SetHardExpiration)
124 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration) 123 .property("softExpiration", &DownloadableSubscription::GetSoftExpiration , &DownloadableSubscription::SetSoftExpiration)
125 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload) 124 .property("lastDownload", &DownloadableSubscription::GetLastDownload, &D ownloadableSubscription::SetLastDownload)
126 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus) 125 .property("downloadStatus", &DownloadableSubscription::GetDownloadStatus , &DownloadableSubscription::SetDownloadStatus)
127 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess) 126 .property("lastSuccess", &DownloadableSubscription::GetLastSuccess, &Dow nloadableSubscription::SetLastSuccess)
128 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount) 127 .property("errors", &DownloadableSubscription::GetErrorCount, &Downloada bleSubscription::SetErrorCount)
129 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision) 128 .property("version", &DownloadableSubscription::GetDataRevision, &Downlo adableSubscription::SetDataRevision)
130 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion) 129 .property("requiredVersion", &DownloadableSubscription::GetRequiredVersi on, &DownloadableSubscription::SetRequiredVersion)
131 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount) 130 .property("downloadCount", &DownloadableSubscription::GetDownloadCount, &DownloadableSubscription::SetDownloadCount);
132 .function("serialize", &DownloadableSubscription::Serialize);
133 131
134 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance) 132 singleton<FilterStorage>("FilterStorage", &FilterStorage::GetInstance)
135 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount) 133 .property("subscriptionCount", &FilterStorage::GetSubscriptionCount)
136 .function("subscriptionAt", &FilterStorage::SubscriptionAt) 134 .function("subscriptionAt", &FilterStorage::SubscriptionAt)
137 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription) 135 .function("indexOfSubscription", &FilterStorage::IndexOfSubscription)
138 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter) 136 .function("getSubscriptionForFilter", &FilterStorage::GetSubscriptionFor Filter)
139 .function("addSubscription", &FilterStorage::AddSubscription) 137 .function("addSubscription", &FilterStorage::AddSubscription)
140 .function("removeSubscription", &FilterStorage::RemoveSubscription) 138 .function("removeSubscription", &FilterStorage::RemoveSubscription)
141 .function("moveSubscription", &FilterStorage::MoveSubscription); 139 .function("moveSubscription", &FilterStorage::MoveSubscription);
142 140
141 class_<Parser>("_FilterStorage_Parser")
142 .property("subscriptionCount", &Parser::GetSubscriptionCount)
143 .function("process", &Parser::Process)
144 .function("finalize", &Parser::Finalize)
145 .function("subscriptionAt", &Parser::SubscriptionAt)
146 .class_function("create", &Parser::Create);
147
148 class_<Serializer>("_FilterStorage_Serializer")
149 .property("data", &Serializer::GetData)
150 .function("serialize", &Serializer::Serialize)
151 .class_function("create", &Serializer::Create);
152
143 printBindings(); 153 printBindings();
144 RegExpFilter::GenerateCustomBindings(); 154 RegExpFilter::GenerateCustomBindings();
145 FilterNotifier::GenerateCustomBindings(); 155 FilterNotifier::GenerateCustomBindings();
146 156
147 return 0; 157 return 0;
148 } 158 }
149 catch (const std::exception& e) 159 catch (const std::exception& e)
150 { 160 {
151 EM_ASM_ARGS( 161 EM_ASM_ARGS(
152 console.error("Error occurred generating JavaScript bindings: " + 162 console.error("Error occurred generating JavaScript bindings: " +
153 Module.AsciiToString($0)), e.what() 163 Module.AsciiToString($0)), e.what()
154 ); 164 );
155 return 1; 165 return 1;
156 } 166 }
157 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld