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

Delta Between Two Patch Sets: lib/filterClassesNew.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Fixed some bugs and exposed/tested more properties Created Jan. 15, 2016, 3:40 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 | « lib/filterClasses.js ('k') | lib/filterNotifier.js » ('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 "use strict"; 1 "use strict";
2 2
3 let { 3 let compiled = require("compiled");
4 _Filter_FromText, _Filter_Normalize, _Filter_get_text, _Filter_get_type, 4 for (let cls of ["Filter", "InvalidFilter", "CommentFilter", "ActiveFilter",
5 _InvalidFilter_get_reason, 5 "RegExpFilter", "BlockingFilter", "WhitelistFilter", "ElemHideBase",
6 _ActiveFilter_get_disabled, _ActiveFilter_set_disabled, 6 "ElemHideFilter", "ElemHideException", "CSSPropertyFilter"])
7 _ActiveFilter_get_hitCount, _ActiveFilter_set_hitCount,
8 _ActiveFilter_get_lastHit, _ActiveFilter_set_lastHit
9 } = require("./compiled");
10
11 let {
12 createClass, wrapCall, stringArg, stringResult, defineProperty,
13 defineStringProperty
14 } = require("./compiledTools");
15
16 let constructors = Object.create(null);
17
18 function filterResult(call)
19 { 7 {
20 return function() 8 exports[cls] = compiled[cls];
21 {
22 let result = call.apply(this, arguments);
23 let type = _Filter_get_type(result);
24 if (type in constructors)
25 return new (constructors[type])(result);
26 else
27 throw new Error("Unexpected filter type " + type);
28 };
29 } 9 }
30
31 function createFilterClass(superclass, type, typeId)
32 {
33 let result = createClass(superclass);
34 if (type)
35 Object.defineProperty(result.prototype, "type", {get: () => type, enumerable : true});
36 if (typeId)
37 constructors[typeId] = result;
38 return result;
39 }
40
41 exports.Filter = createFilterClass();
42 exports.Filter.fromText = wrapCall(filterResult(stringArg(0, _Filter_FromText))) ;
43 exports.Filter.normalize = wrapCall(stringResult(stringArg(0, _Filter_Normalize) ));
44 defineStringProperty(exports.Filter, "text", _Filter_get_text);
45
46 exports.InvalidFilter = createFilterClass(exports.Filter, "invalid", 1);
47 defineStringProperty(exports.InvalidFilter, "text", _InvalidFilter_get_reason);
48
49 exports.CommentFilter = createFilterClass(exports.Filter, "comment", 2);
50
51 exports.ActiveFilter = createFilterClass(exports.Filter);
52 defineProperty(exports.ActiveFilter, "disabled", _ActiveFilter_get_disabled, _Ac tiveFilter_set_disabled);
53 defineProperty(exports.ActiveFilter, "hitCount", _ActiveFilter_get_hitCount, _Ac tiveFilter_set_hitCount);
54 defineProperty(exports.ActiveFilter, "lastHit", _ActiveFilter_get_lastHit, _Acti veFilter_set_lastHit);
55
56 exports.RegExpFilter = createFilterClass(exports.ActiveFilter, "blocking", 3);
57 exports.WhiteListFilter = createFilterClass(exports.RegExpFilter, "whitelist", 4 );
58 exports.ElemHideBase = createFilterClass(exports.ActiveFilter);
59 exports.ElemHideFilter = createFilterClass(exports.ElemHideBase, "elemhide", 5);
60 exports.ElemHideException = createFilterClass(exports.ElemHideBase, "elemhideexc eption", 6);
61 exports.CSSPropertyFilter = createFilterClass(exports.ElemHideBase, "cssproperty ", 7);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld