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

Delta Between Two Patch Sets: compiled/bindings.cpp

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Optimized hash lookup performance a bit Created Feb. 8, 2016, 7:11 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.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/WhitelistFilter.cpp ('k') | compiled/bindings.ipp » ('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 #include "bindings.h" 1 #include "bindings.ipp"
2 #include "Filter.h" 2 #include "Filter.h"
3 #include "InvalidFilter.h" 3 #include "InvalidFilter.h"
4 #include "CommentFilter.h" 4 #include "CommentFilter.h"
5 #include "ActiveFilter.h" 5 #include "ActiveFilter.h"
6 #include "RegExpFilter.h" 6 #include "RegExpFilter.h"
7 #include "BlockingFilter.h"
7 #include "WhitelistFilter.h" 8 #include "WhitelistFilter.h"
8 #include "ElemHideBase.h" 9 #include "ElemHideBase.h"
9 #include "ElemHideFilter.h" 10 #include "ElemHideFilter.h"
10 #include "ElemHideException.h" 11 #include "ElemHideException.h"
11 #include "CSSPropertyFilter.h" 12 #include "CSSPropertyFilter.h"
12 13
13 EMSCRIPTEN_BINDINGS 14 EMSCRIPTEN_BINDINGS
14 { 15 {
15 class_<Filter>("Filter") 16 class_<Filter>("Filter")
16 .property("text", &Filter::GetText) 17 .property("text", &Filter::GetText)
17 .function("serialize", &Filter::Serialize) 18 .function("serialize", &Filter::Serialize)
18 .class_function("fromText", &Filter::FromText) 19 .class_function("fromText", &Filter::FromText)
19 .class_function("getKnownFilter", &Filter::GetKnownFilter) 20 .subclass_differentiator(&Filter::mType, {
20 .subclass_differentiator(&Filter::GetType, {
21 {Filter::Type::INVALID, "InvalidFilter"}, 21 {Filter::Type::INVALID, "InvalidFilter"},
22 {Filter::Type::COMMENT, "CommentFilter"}, 22 {Filter::Type::COMMENT, "CommentFilter"},
23 {Filter::Type::BLOCKING, "RegExpFilter"}, 23 {Filter::Type::BLOCKING, "BlockingFilter"},
24 {Filter::Type::WHITELIST, "WhitelistFilter"}, 24 {Filter::Type::WHITELIST, "WhitelistFilter"},
25 {Filter::Type::ELEMHIDE, "ElemHideFilter"}, 25 {Filter::Type::ELEMHIDE, "ElemHideFilter"},
26 {Filter::Type::ELEMHIDEEXCEPTION, "ElemHideException"}, 26 {Filter::Type::ELEMHIDEEXCEPTION, "ElemHideException"},
27 {Filter::Type::CSSPROPERTY, "CSSPropertyFilter"}, 27 {Filter::Type::CSSPROPERTY, "CSSPropertyFilter"},
28 }); 28 });
29 29
30 class_<InvalidFilter,Filter>("InvalidFilter") 30 class_<InvalidFilter,Filter>("InvalidFilter")
31 .class_property("type", "'invalid'") 31 .class_property("type", "'invalid'")
32 .property("reason", &InvalidFilter::GetReason); 32 .property("reason", &InvalidFilter::GetReason);
33 33
34 class_<CommentFilter,Filter>("CommentFilter") 34 class_<CommentFilter,Filter>("CommentFilter")
35 .class_property("type", "'comment'"); 35 .class_property("type", "'comment'");
36 36
37 class_<ActiveFilter,Filter>("ActiveFilter") 37 class_<ActiveFilter,Filter>("ActiveFilter")
38 .property("disabled", &ActiveFilter::GetDisabled, &ActiveFilter::SetDisabl ed) 38 .property("disabled", &ActiveFilter::GetDisabled, &ActiveFilter::SetDisabl ed)
39 .property("hitCount", &ActiveFilter::GetHitCount, &ActiveFilter::SetHitCou nt) 39 .property("hitCount", &ActiveFilter::GetHitCount, &ActiveFilter::SetHitCou nt)
40 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHit) 40 .property("lastHit", &ActiveFilter::GetLastHit, &ActiveFilter::SetLastHit)
41 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain) 41 .function("isActiveOnDomain", &ActiveFilter::IsActiveOnDomain)
42 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain) 42 .function("isActiveOnlyOnDomain", &ActiveFilter::IsActiveOnlyOnDomain)
43 .function("isGeneric", &ActiveFilter::IsGeneric) 43 .function("isGeneric", &ActiveFilter::IsGeneric)
44 .function("serialize", &ActiveFilter::Serialize); 44 .function("serialize", &ActiveFilter::Serialize);
45 45
46 class_<RegExpFilter,ActiveFilter>("RegExpFilter") 46 class_<RegExpFilter,ActiveFilter>("RegExpFilter")
47 .class_property("type", "'blocking'")
48 .function("matches", &RegExpFilter::Matches) 47 .function("matches", &RegExpFilter::Matches)
49 .class_initializer(&RegExpFilter::InitJSTypes); 48 .class_initializer(&RegExpFilter::InitJSTypes);
49
50 class_<BlockingFilter,RegExpFilter>("BlockingFilter")
51 .class_property("type", "'blocking'");
50 52
51 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter") 53 class_<WhitelistFilter,RegExpFilter>("WhitelistFilter")
52 .class_property("type", "'whitelist'"); 54 .class_property("type", "'whitelist'");
53 55
54 class_<ElemHideBase,ActiveFilter>("ElemHideBase") 56 class_<ElemHideBase,ActiveFilter>("ElemHideBase")
55 .property("selector", &ElemHideBase::GetSelector) 57 .property("selector", &ElemHideBase::GetSelector)
56 .property("selectorDomain", &ElemHideBase::GetSelectorDomain); 58 .property("selectorDomain", &ElemHideBase::GetSelectorDomain);
57 59
58 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter") 60 class_<ElemHideFilter,ElemHideBase>("ElemHideFilter")
59 .class_property("type", "'elemhide'"); 61 .class_property("type", "'elemhide'");
60 62
61 class_<ElemHideException,ElemHideBase>("ElemHideException") 63 class_<ElemHideException,ElemHideBase>("ElemHideException")
62 .class_property("type", "'elemhideexception'"); 64 .class_property("type", "'elemhideexception'");
63 65
64 class_<CSSPropertyFilter,ElemHideBase>("CSSPropertyFilter") 66 class_<CSSPropertyFilter,ElemHideBase>("CSSPropertyFilter")
65 .class_property("type", "'cssproperty'") 67 .class_property("type", "'cssproperty'")
66 .property("regexpString", &CSSPropertyFilter::GetRegExpString) 68 .property("regexpString", &CSSPropertyFilter::GetRegExpString)
67 .property("selectorPrefix", &CSSPropertyFilter::GetSelectorPrefix) 69 .property("selectorPrefix", &CSSPropertyFilter::GetSelectorPrefix)
68 .property("selectorSuffix", &CSSPropertyFilter::GetSelectorSuffix); 70 .property("selectorSuffix", &CSSPropertyFilter::GetSelectorSuffix);
69 } 71 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld