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

Side by Side Diff: compiled/shell.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Replaced shared_ptr by boost-like intrusive_ptr Created Jan. 28, 2016, 7:50 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
« no previous file with comments | « compiled/intrusive_ptr.h ('k') | lib/filterClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 "Compiled from https://hg.adblockplus.org/adblockplus/ with Emscripten {{{EMSCRI PTEN_VERSION}}}";
2
3 var sizeofString = 0;
4 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
53 var regexps =
54 {
55 _data: Object.create(null),
56 _counter: 0,
57
58 create: function(source, matchCase)
59 {
60 var id = ++this._counter;
61 try
62 {
63 this._data[id] = new RegExp(getStringData(source), matchCase ? "" : "i");
64 }
65 catch (e)
66 {
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;
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 }
87 },
88
89 delete: function(id)
90 {
91 delete this._data[id];
92 },
93
94 test: function(id, str)
95 {
96 return this._data[id].test(getStringData(str));
97 }
98 };
99
100 var Module =
101 {
102 preRun: [],
103 postRun: [],
104 print: console.log.bind(console),
105 printErr: console.error.bind(console),
106
107 getMemoryLayout: function()
108 {
109 return {
110 'static_base': STATIC_BASE,
111 'static_top': STATICTOP,
112 'stack_base': STACK_BASE,
113 'stack_top': STACKTOP,
114 'stack_max': STACK_MAX,
115 'dynamic_base': DYNAMIC_BASE,
116 'dynamic_top': DYNAMICTOP,
117 'total_memory': TOTAL_MEMORY
118 };
119 }
120 };
121 var ENVIRONMENT_IS_WEB = false, ENVIRONMENT_IS_NODE = false,
122 ENVIRONMENT_IS_WORKER = false, ENVIRONMENT_IS_SHELL = true;
123
124 {{BODY}}
125
126 Object.assign(exports, Module);
OLDNEW
« no previous file with comments | « compiled/intrusive_ptr.h ('k') | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld