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

Delta Between Two Patch Sets: compiled/shell.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Fixed annotation for hash buffers Created Jan. 28, 2016, 5:07 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/intrusive_ptr.h ('k') | compiled/traceInit.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 "use strict";
2
1 "Compiled from https://hg.adblockplus.org/adblockplus/ with Emscripten {{{EMSCRI PTEN_VERSION}}}"; 3 "Compiled from https://hg.adblockplus.org/adblockplus/ with Emscripten {{{EMSCRI PTEN_VERSION}}}";
2 4
3 var sizeofString = 0;
4 var FilterNotifier = require("filterNotifier").FilterNotifier; 5 var FilterNotifier = require("filterNotifier").FilterNotifier;
5
6 function copyString(str, buffer)
7 {
8 var length = str.length;
9 for (var i = 0, pointer = (buffer >> 1); i < length; i++, pointer++)
10 HEAP16[pointer] = str.charCodeAt(i);
11 return length;
12 }
13
14 function createString(str)
15 {
16 var length = 0;
17 var buffer = 0;
18 if (str)
19 {
20 buffer = Runtime.stackAlloc(str.length * 2);
21 length = copyString(str, buffer);
22 }
23
24 if (!sizeofString)
25 sizeofString = Module._GetSizeofString();
26 var result = Module.Runtime.stackAlloc(sizeofString);
27 Module._InitString(result, buffer, length);
28 return result;
29 }
30
31 function getStringData(str)
32 {
33 var length = Module._GetStringLength(str);
34 var pointer = Module._GetStringData(str) >> 1;
35 return String.fromCharCode.apply(String, HEAP16.slice(pointer, pointer + lengt h));
36 }
37
38 function createClass(superclass)
39 {
40 var result = function(pointer)
41 {
42 this._pointer = pointer;
43 };
44 if (superclass)
45 result.prototype = Object.create(superclass.prototype);
46 result.prototype.delete = function()
47 {
48 Module._DeletePointer(this._pointer);
49 };
50 return result;
51 }
52 6
53 var regexps = 7 var regexps =
54 { 8 {
55 _data: Object.create(null), 9 _data: Object.create(null),
56 _counter: 0, 10 _counter: 0,
57 11
58 create: function(source, matchCase) 12 create: function(source, matchCase)
59 { 13 {
60 var id = ++this._counter; 14 var id = ++this._counter;
61 try 15 try
62 { 16 {
63 this._data[id] = new RegExp(getStringData(source), matchCase ? "" : "i"); 17 this._data[id] = new RegExp(readString(source), matchCase ? "" : "i");
18 return id;
64 } 19 }
65 catch (e) 20 catch (e)
66 { 21 {
67 this._data[id] = String(e);
68 }
69 return id;
70 },
71
72 getErrorLength: function(id)
73 {
74 if (typeof this._data[id] == "string")
75 return this._data[id].length;
76 else
77 return -1; 22 return -1;
78 },
79
80 getError: function(id, buffer)
81 {
82 if (typeof this._data[id] == "string")
83 {
84 copyString(this._data[id], buffer);
85 delete this._data[id];
86 } 23 }
87 }, 24 },
88 25
89 delete: function(id) 26 delete: function(id)
90 { 27 {
91 delete this._data[id]; 28 delete this._data[id];
92 }, 29 },
93 30
94 test: function(id, str) 31 test: function(id, str)
95 { 32 {
96 return this._data[id].test(getStringData(str)); 33 return this._data[id].test(readString(str));
97 } 34 }
98 }; 35 };
99 36
100 var Module = 37 var Module =
101 { 38 {
102 preRun: [], 39 preRun: [],
103 postRun: [], 40 postRun: [],
104 print: console.log.bind(console), 41 print: console.log.bind(console),
105 printErr: console.error.bind(console), 42 printErr: console.error.bind(console),
106 43
(...skipping 10 matching lines...) Expand all
117 'total_memory': TOTAL_MEMORY 54 'total_memory': TOTAL_MEMORY
118 }; 55 };
119 } 56 }
120 }; 57 };
121 var ENVIRONMENT_IS_WEB = false, ENVIRONMENT_IS_NODE = false, 58 var ENVIRONMENT_IS_WEB = false, ENVIRONMENT_IS_NODE = false,
122 ENVIRONMENT_IS_WORKER = false, ENVIRONMENT_IS_SHELL = true; 59 ENVIRONMENT_IS_WORKER = false, ENVIRONMENT_IS_SHELL = true;
123 60
124 {{BODY}} 61 {{BODY}}
125 62
126 Object.assign(exports, Module); 63 Object.assign(exports, Module);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld