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

Side by Side Diff: lib/typedObjects/utils.js

Issue 29324295: Noissue - Add missing semicolons (Closed)
Patch Set: Created Aug. 19, 2015, 10:19 a.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 | « lib/typedObjects/stringType.js ('k') | test/tests/typedObjects.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 /** 90 /**
91 * Creates a wrapper function for a setter that will call the watcher function 91 * Creates a wrapper function for a setter that will call the watcher function
92 * with the new value of the property before executing the actual setter. 92 * with the new value of the property before executing the actual setter.
93 */ 93 */
94 function watchSetter(/**Function*/ setter, /**Function*/ watcher) /**Function*/ 94 function watchSetter(/**Function*/ setter, /**Function*/ watcher) /**Function*/
95 { 95 {
96 return function(value) 96 return function(value)
97 { 97 {
98 setter.call(this, watcher.call(this, value)); 98 setter.call(this, watcher.call(this, value));
99 } 99 };
100 } 100 }
101 101
102 /** 102 /**
103 * Creates a parameter-less wrapper function around a getter that will get 103 * Creates a parameter-less wrapper function around a getter that will get
104 * bufferIndex and byteOffset parameters from object properties. 104 * bufferIndex and byteOffset parameters from object properties.
105 */ 105 */
106 function wrapGetter(/**Function*/ getter) /**Function*/ 106 function wrapGetter(/**Function*/ getter) /**Function*/
107 { 107 {
108 return function() 108 return function()
109 { 109 {
110 return getter.call(this, this.bufferIndex, this.byteOffset); 110 return getter.call(this, this.bufferIndex, this.byteOffset);
111 } 111 };
112 } 112 }
113 113
114 /** 114 /**
115 * Creates a wrapper function around a setter with value as the only parameter, 115 * Creates a wrapper function around a setter with value as the only parameter,
116 * the bufferIndex and byteOffset parameters will be retrieved from object 116 * the bufferIndex and byteOffset parameters will be retrieved from object
117 * properties. 117 * properties.
118 */ 118 */
119 function wrapSetter(/**Function*/ setter) /**Function*/ 119 function wrapSetter(/**Function*/ setter) /**Function*/
120 { 120 {
121 return function(value) 121 return function(value)
122 { 122 {
123 return setter.call(this, this.bufferIndex, this.byteOffset, value); 123 return setter.call(this, this.bufferIndex, this.byteOffset, value);
124 } 124 };
125 } 125 }
126 126
127 /** 127 /**
128 * Defines properties with given name and type on an object. 128 * Defines properties with given name and type on an object.
129 * 129 *
130 * @param obj object to define properties on 130 * @param obj object to define properties on
131 * @param properties object mapping property names to their respective types 131 * @param properties object mapping property names to their respective types
132 * @param viewTypes see getViewsForType() 132 * @param viewTypes see getViewsForType()
133 * @param views see getViewsForType() 133 * @param views see getViewsForType()
134 * @param [offset] byte array offset at which the properties should start 134 * @param [offset] byte array offset at which the properties should start
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 * @param {Array} views existing buffer views (will be modified) 187 * @param {Array} views existing buffer views (will be modified)
188 * @result {Integer} index of the buffer created 188 * @result {Integer} index of the buffer created
189 */ 189 */
190 let addBuffer = exports.addBuffer = function(byteSize, buffers, viewTypes, views ) 190 let addBuffer = exports.addBuffer = function(byteSize, buffers, viewTypes, views )
191 { 191 {
192 let buffer = new ArrayBuffer(byteSize | 0); 192 let buffer = new ArrayBuffer(byteSize | 0);
193 buffers.push(buffer); 193 buffers.push(buffer);
194 for (let i = 0, l = viewTypes.length | 0; i < l; i++) 194 for (let i = 0, l = viewTypes.length | 0; i < l; i++)
195 views[i].push(new viewTypes[i](buffer)); 195 views[i].push(new viewTypes[i](buffer));
196 return (buffers.length | 0) - 1; 196 return (buffers.length | 0) - 1;
197 } 197 };
198 198
199 /** 199 /**
200 * Releases an array buffer. 200 * Releases an array buffer.
201 * 201 *
202 * @param {Integer} bufferIndex index of the buffer to be released. 202 * @param {Integer} bufferIndex index of the buffer to be released.
203 * @param {Array} buffers existing buffers (will be modified) 203 * @param {Array} buffers existing buffers (will be modified)
204 * @param {Array} views existing buffer views (will be modified) 204 * @param {Array} views existing buffer views (will be modified)
205 */ 205 */
206 exports.removeBuffer = function(bufferIndex, buffers, views) 206 exports.removeBuffer = function(bufferIndex, buffers, views)
207 { 207 {
208 delete buffers[bufferIndex]; 208 delete buffers[bufferIndex];
209 for (let i = 0, l = views.length | 0; i < l; i++) 209 for (let i = 0, l = views.length | 0; i < l; i++)
210 delete views[i][bufferIndex]; 210 delete views[i][bufferIndex];
211 } 211 };
212 212
213 /** 213 /**
214 * Allocates a new fixed-size element. It will return the first available free 214 * Allocates a new fixed-size element. It will return the first available free
215 * block or create a new buffer if the existing ones have no space left. 215 * block or create a new buffer if the existing ones have no space left.
216 * 216 *
217 * @param {TypedReference} firstFree head of the linked list pointing to unallo cated elements 217 * @param {TypedReference} firstFree head of the linked list pointing to unallo cated elements
218 * @param {Integer} byteLength size of an element 218 * @param {Integer} byteLength size of an element
219 * @param {Integer} bufferSize number of elements in a buffer 219 * @param {Integer} bufferSize number of elements in a buffer
220 * @param {Array} buffers existing buffers (might be modified in necessary) 220 * @param {Array} buffers existing buffers (might be modified in necessary)
221 * @param {Array} viewTypes view types for the buffers 221 * @param {Array} viewTypes view types for the buffers
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 */ 267 */
268 exports.dealloc = function(firstFree, bufferIndex, byteOffset) 268 exports.dealloc = function(firstFree, bufferIndex, byteOffset)
269 { 269 {
270 let oldFreeBufferIndex = firstFree.bufferIndex | 0; 270 let oldFreeBufferIndex = firstFree.bufferIndex | 0;
271 let oldFreeByteOffset = firstFree.byteOffset | 0; 271 let oldFreeByteOffset = firstFree.byteOffset | 0;
272 272
273 firstFree.bufferIndex = bufferIndex | 0; 273 firstFree.bufferIndex = bufferIndex | 0;
274 firstFree.byteOffset = byteOffset | 0; 274 firstFree.byteOffset = byteOffset | 0;
275 firstFree.targetBufferIndex = oldFreeBufferIndex; 275 firstFree.targetBufferIndex = oldFreeBufferIndex;
276 firstFree.targetByteOffset = oldFreeByteOffset; 276 firstFree.targetByteOffset = oldFreeByteOffset;
277 } 277 };
OLDNEW
« no previous file with comments | « lib/typedObjects/stringType.js ('k') | test/tests/typedObjects.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld