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

Delta Between Two Patch Sets: compiled/subscription/Subscription.h

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Replace subscriptionClasses.js properly instead of creating a new file Created March 27, 2017, 9:06 a.m.
Right Patch Set: Addressed comments Created April 13, 2017, 1:02 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/subscription/DownloadableSubscription.cpp ('k') | compiled/subscription/Subscription.cpp » ('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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 <type_traits>
20 #include <vector> 21 #include <vector>
21 22
22 #include "../filter/Filter.h" 23 #include "../filter/Filter.h"
23 #include "../String.h" 24 #include "../String.h"
24 #include "../intrusive_ptr.h" 25 #include "../intrusive_ptr.h"
25 #include "../debug.h" 26 #include "../debug.h"
26 27
27 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \ 28 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \
29 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\
28 private:\ 30 private:\
29 type name;\ 31 type name;\
30 public:\ 32 public:\
31 type EMSCRIPTEN_KEEPALIVE getter() const\ 33 type EMSCRIPTEN_KEEPALIVE getter() const\
32 {\ 34 {\
33 return name;\ 35 return name;\
34 }\ 36 }\
35 void EMSCRIPTEN_KEEPALIVE setter(type value)\ 37 void EMSCRIPTEN_KEEPALIVE setter(type value)\
36 {\ 38 {\
37 if (name != value)\ 39 if (name != value)\
38 {\ 40 {\
39 type oldvalue = name;\ 41 type oldvalue = name;\
40 name = value;\ 42 name = value;\
41 DependentString action(u"subscription."_str #name);\ 43 DependentString action(u"subscription."_str #name);\
42 EM_ASM_ARGS({\ 44 if (sizeof(type) <= 4)\
43 var subscription = new (exports[Subscription_mapping[$2]])($1);\ 45 {\
44 FilterNotifier.triggerListeners(readString($0), subscription, $3, $4 );\ 46 EM_ASM_ARGS({\
45 }, &action, this, mType, value, oldvalue);\ 47 var subscription = new (exports[Subscription_mapping[$2]])($1);\
48 FilterNotifier.triggerListeners(readString($0), subscription, $3, $4);\
49 }, &action, this, mType, value, oldvalue);\
50 }\
51 else\
52 {\
53 EM_ASM_ARGS({\
54 var subscription = new (exports[Subscription_mapping[$2]])($1);\
55 FilterNotifier.triggerListeners(readString($0), subscription, $3, $4);\
56 }, &action, this, mType, (double)value, (double)oldvalue);\
57 }\
46 }\ 58 }\
47 } 59 }
48 60
49 #define SUBSCRIPTION_STRING_PROPERTY(name, getter, setter) \ 61 #define SUBSCRIPTION_STRING_PROPERTY(name, getter, setter) \
50 private:\ 62 private:\
51 OwnedString name;\ 63 OwnedString name;\
52 public:\ 64 public:\
53 const String& EMSCRIPTEN_KEEPALIVE getter() const\ 65 const String& EMSCRIPTEN_KEEPALIVE getter() const\
54 {\ 66 {\
55 return name;\ 67 return name;\
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle); 107 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle);
96 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); 108 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
97 109
98 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; 110 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const;
99 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; 111 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const;
100 112
101 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); 113 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id);
102 }; 114 };
103 115
104 typedef intrusive_ptr<Subscription> SubscriptionPtr; 116 typedef intrusive_ptr<Subscription> SubscriptionPtr;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld