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

Delta Between Two Patch Sets: compiled/FilterNotifier.h

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Improved logic for Process() Created Dec. 5, 2017, 7:16 a.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 | « no previous file | compiled/StringScanner.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
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 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #pragma once 18 #pragma once
19 19
20 #include <cstdio> 20 #include <cstdio>
21 21
22 #include "base.h"
22 #include "library.h" 23 #include "library.h"
23 #include "String.h" 24 #include "String.h"
25
26 ABP_NS_BEGIN
24 27
25 class Filter; 28 class Filter;
26 class Subscription; 29 class Subscription;
27 30
28 namespace FilterNotifier 31 namespace FilterNotifier
29 { 32 {
30 enum class Topic 33 enum class Topic : int32_t
31 { 34 {
32 NONE, 35 NONE,
33 FILTER_ADDED, 36 FILTER_ADDED,
34 FILTER_REMOVED, 37 FILTER_REMOVED,
35 FILTER_DISABLED, 38 FILTER_DISABLED,
36 FILTER_HITCOUNT, 39 FILTER_HITCOUNT,
37 FILTER_LASTHIT, 40 FILTER_LASTHIT,
38 SUBSCRIPTION_ADDED, 41 SUBSCRIPTION_ADDED,
39 SUBSCRIPTION_REMOVED, 42 SUBSCRIPTION_REMOVED,
40 SUBSCRIPTION_MOVED, 43 SUBSCRIPTION_MOVED,
41 SUBSCRIPTION_TITLE, 44 SUBSCRIPTION_TITLE,
42 SUBSCRIPTION_DISABLED, 45 SUBSCRIPTION_DISABLED,
43 SUBSCRIPTION_FIXEDTITLE, 46 SUBSCRIPTION_FIXEDTITLE,
44 SUBSCRIPTION_BEFORE_FILTERS_REPLACED, 47 SUBSCRIPTION_BEFORE_FILTERS_REPLACED,
45 SUBSCRIPTION_FILTERS_REPLACED, 48 SUBSCRIPTION_FILTERS_REPLACED,
46 SUBSCRIPTION_HOMEPAGE, 49 SUBSCRIPTION_HOMEPAGE,
47 SUBSCRIPTION_LASTCHECK, 50 SUBSCRIPTION_LASTCHECK,
48 SUBSCRIPTION_LASTDOWNLOAD, 51 SUBSCRIPTION_LASTDOWNLOAD,
49 SUBSCRIPTION_DOWNLOADSTATUS, 52 SUBSCRIPTION_DOWNLOADSTATUS,
50 SUBSCRIPTION_ERRORS, 53 SUBSCRIPTION_ERRORS,
51 }; 54 };
52 55
53 inline void GenerateCustomBindings() 56 template<typename T>
57 inline T lexical_cast(Topic);
58
59 template<>
60 inline int32_t lexical_cast<int32_t>(Topic value)
54 { 61 {
55 printf("var FilterNotifier = require('filterNotifier').FilterNotifier;\n"); 62 return static_cast<int32_t>(value);
56 printf("var notifierTopics = new Map([\n"); 63 }
57 printf(" [%i, 'filter.added'],\n", Topic::FILTER_ADDED); 64
58 printf(" [%i, 'filter.removed'],\n", Topic::FILTER_REMOVED); 65 namespace GenerateCustomBindings
59 printf(" [%i, 'filter.disabled'],\n", Topic::FILTER_DISABLED); 66 {
60 printf(" [%i, 'filter.hitCount'],\n", Topic::FILTER_HITCOUNT); 67 inline void printfTopic(const char* format, Topic topic)
61 printf(" [%i, 'filter.lastHit'],\n", Topic::FILTER_LASTHIT); 68 {
62 printf(" [%i, 'subscription.added'],\n", Topic::SUBSCRIPTION_ADDED); 69 ::printf(format, lexical_cast<int32_t>(topic));
63 printf(" [%i, 'subscription.removed'],\n", Topic::SUBSCRIPTION_REMOVED); 70 }
64 printf(" [%i, 'subscription.moved'],\n", Topic::SUBSCRIPTION_MOVED); 71
65 printf(" [%i, 'subscription.title'],\n", Topic::SUBSCRIPTION_TITLE); 72 inline void Generate()
66 printf(" [%i, 'subscription.disabled'],\n", Topic::SUBSCRIPTION_DISABLED); 73 {
67 printf(" [%i, 'subscription.fixedTitle'],\n", Topic::SUBSCRIPTION_FIXEDTITL E); 74 printf("var FilterNotifier = require('filterNotifier').FilterNotifier;\n") ;
68 printf(" [%i, 'subscription.beforefiltersreplaced'],\n", 75 printf("var notifierTopics = new Map([\n");
69 Topic::SUBSCRIPTION_BEFORE_FILTERS_REPLACED); 76 printfTopic(" [%i, 'filter.added'],\n", Topic::FILTER_ADDED);
70 printf(" [%i, 'subscription.filtersreplaced'],\n", 77 printfTopic(" [%i, 'filter.removed'],\n", Topic::FILTER_REMOVED);
71 Topic::SUBSCRIPTION_FILTERS_REPLACED); 78 printfTopic(" [%i, 'filter.disabled'],\n", Topic::FILTER_DISABLED);
72 printf(" [%i, 'subscription.homepage'],\n", Topic::SUBSCRIPTION_HOMEPAGE); 79 printfTopic(" [%i, 'filter.hitCount'],\n", Topic::FILTER_HITCOUNT);
73 printf(" [%i, 'subscription.lastCheck'],\n", Topic::SUBSCRIPTION_LASTCHECK) ; 80 printfTopic(" [%i, 'filter.lastHit'],\n", Topic::FILTER_LASTHIT);
74 printf(" [%i, 'subscription.lastDownload'],\n", Topic::SUBSCRIPTION_LASTDOW NLOAD); 81 printfTopic(" [%i, 'subscription.added'],\n", Topic::SUBSCRIPTION_ADDED);
75 printf(" [%i, 'subscription.downloadStatus'],\n", Topic::SUBSCRIPTION_DOWNL OADSTATUS); 82 printfTopic(" [%i, 'subscription.removed'],\n", Topic::SUBSCRIPTION_REMOV ED);
76 printf(" [%i, 'subscription.errors'],\n", Topic::SUBSCRIPTION_ERRORS); 83 printfTopic(" [%i, 'subscription.moved'],\n", Topic::SUBSCRIPTION_MOVED);
77 printf("]);"); 84 printfTopic(" [%i, 'subscription.title'],\n", Topic::SUBSCRIPTION_TITLE);
85 printfTopic(" [%i, 'subscription.disabled'],\n", Topic::SUBSCRIPTION_DISA BLED);
86 printfTopic(" [%i, 'subscription.fixedTitle'],\n", Topic::SUBSCRIPTION_FI XEDTITLE);
87 printfTopic(" [%i, 'subscription.beforefiltersreplaced'],\n", Topic::SUBS CRIPTION_BEFORE_FILTERS_REPLACED);
88 printfTopic(" [%i, 'subscription.filtersreplaced'],\n", Topic::SUBSCRIPTI ON_FILTERS_REPLACED);
89 printfTopic(" [%i, 'subscription.homepage'],\n", Topic::SUBSCRIPTION_HOME PAGE);
90 printfTopic(" [%i, 'subscription.lastCheck'],\n", Topic::SUBSCRIPTION_LAS TCHECK);
91 printfTopic(" [%i, 'subscription.lastDownload'],\n", Topic::SUBSCRIPTION_ LASTDOWNLOAD);
92 printfTopic(" [%i, 'subscription.downloadStatus'],\n", Topic::SUBSCRIPTIO N_DOWNLOADSTATUS);
93 printfTopic(" [%i, 'subscription.errors'],\n", Topic::SUBSCRIPTION_ERRORS );
94 printf("]);");
95 }
78 } 96 }
79 97
80 inline void FilterChange(Topic topic, Filter& filter, 98 inline void FilterChange(Topic topic, Filter& filter,
81 Subscription* subscription = nullptr, unsigned int position = 0) 99 Subscription* subscription = nullptr, unsigned int position = 0)
82 { 100 {
83 JSNotifyFilterChange(topic, filter, subscription, position); 101 JSNotifyFilterChange(topic, filter, subscription, position);
84 } 102 }
85 103
86 inline void SubscriptionChange(Topic topic, Subscription& subscription) 104 inline void SubscriptionChange(Topic topic, Subscription& subscription)
87 { 105 {
88 JSNotifySubscriptionChange(topic, subscription); 106 JSNotifySubscriptionChange(topic, subscription);
89 } 107 }
90 } 108 }
109
110 ABP_NS_END
LEFTRIGHT

Powered by Google App Engine
This is Rietveld