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

Side by Side Diff: lib/filterClassesNew.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Fixed some bugs and exposed/tested more properties Created Jan. 15, 2016, 3:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 "use strict";
2
3 let {
4 _Filter_FromText, _Filter_Normalize, _Filter_get_text, _Filter_get_type,
5 _InvalidFilter_get_reason,
6 _ActiveFilter_get_disabled, _ActiveFilter_set_disabled,
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 {
20 return function()
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 }
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);
OLDNEW
« compiled/Filter.cpp ('K') | « lib/compiledTools.js ('k') | test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld