Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #pragma once | 1 #pragma once |
2 | 2 |
3 #include <emscripten.h> | 3 #include <emscripten.h> |
4 | 4 |
5 #include "Filter.h" | 5 #include "Filter.h" |
6 #include "StringMap.h" | 6 #include "StringMap.h" |
7 | 7 |
8 #define FILTER_PROPERTY(type, name, getter, setter) \ | 8 #define FILTER_PROPERTY(type, name, getter, setter) \ |
9 private:\ | 9 private:\ |
10 type name;\ | 10 type name;\ |
11 public:\ | 11 public:\ |
12 type EMSCRIPTEN_KEEPALIVE getter() const\ | 12 type EMSCRIPTEN_KEEPALIVE getter() const\ |
13 {\ | 13 {\ |
14 return name;\ | 14 return name;\ |
15 }\ | 15 }\ |
16 void EMSCRIPTEN_KEEPALIVE setter(type value)\ | 16 void EMSCRIPTEN_KEEPALIVE setter(type value)\ |
17 {\ | 17 {\ |
18 if (name != value)\ | 18 if (name != value)\ |
19 {\ | 19 {\ |
20 type oldvalue = name;\ | 20 type oldvalue = name;\ |
21 name = value;\ | 21 name = value;\ |
22 String action(u"filter."_str #name);\ | 22 DependentString action(u"filter."_str #name);\ |
23 EM_ASM_ARGS({\ | 23 EM_ASM_ARGS({\ |
24 var filter = new (exports[Filter_mapping[$2]])($1);\ | 24 var filter = new (exports[Filter_mapping[$2]])($1);\ |
25 FilterNotifier.triggerListeners(getStringData($0), filter, $3, $4);\ | 25 FilterNotifier.triggerListeners(readString($0), filter, $3, $4);\ |
sergei
2016/02/17 12:54:31
Why do we need to instantiate a new `filter` and c
Wladimir Palant
2016/02/18 16:06:38
What is `this`? That's JavaScript code, all it got
sergei
2016/02/22 12:45:33
Acknowledged, sorry, overlooked it.
| |
26 }, &action, this, GetType(), value, oldvalue);\ | 26 }, &action, this, mType, value, oldvalue);\ |
27 }\ | 27 }\ |
28 } | 28 } |
29 | 29 |
30 class ActiveFilter : public Filter | 30 class ActiveFilter : public Filter |
31 { | 31 { |
32 protected: | 32 protected: |
33 typedef StringMap<bool> DomainMap; | 33 typedef StringMap<bool> DomainMap; |
34 typedef StringSet SitekeySet; | 34 typedef StringSet SitekeySet; |
35 void ParseDomains(const String& domains, char16_t separator) const; | 35 void ParseDomains(const String& domains, String::value_type separator) const; |
sergei
2016/02/17 12:54:29
`String::value_type` instead of `char16_t` would b
Wladimir Palant
2016/02/18 16:06:31
Done.
| |
36 void AddSitekey(const String& sitekey) const; | 36 void AddSitekey(const String& sitekey) const; |
sergei
2016/02/17 12:54:30
I have removed const on the methods above, `mutabl
Wladimir Palant
2016/02/18 16:06:32
I'm not really sure how you've done that. If AddSi
sergei
2016/02/22 12:45:35
Yeah, I did it using const_cast, it's difficult to
sergei
2016/06/16 21:16:08
Actually there is another option with only one mut
| |
37 virtual DomainMap* GetDomains() const; | 37 virtual DomainMap* GetDomains() const; |
38 virtual SitekeySet* GetSitekeys() const; | 38 virtual SitekeySet* GetSitekeys() const; |
39 mutable std::unique_ptr<DomainMap> mDomains; | 39 mutable std::unique_ptr<DomainMap> mDomains; |
40 mutable std::unique_ptr<SitekeySet> mSitekeys; | 40 mutable std::unique_ptr<SitekeySet> mSitekeys; |
41 private: | 41 private: |
42 bool mIgnoreTrailingDot; | 42 bool mIgnoreTrailingDot; |
43 public: | 43 public: |
44 ActiveFilter(const String& text, bool ignoreTrailingDot); | 44 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); |
45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); | 45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); |
46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); | 46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); |
47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); | 47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); |
48 static void ToLower(String& str, String::size_type start, | |
49 String::size_type end); | |
50 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, | 48 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, |
51 const String& sitekey) const; | 49 const String& sitekey) const; |
52 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; | 50 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; |
53 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; | 51 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; |
54 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; | 52 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; |
55 }; | 53 }; |
LEFT | RIGHT |