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

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

Issue 5665229014827008: Issue 150 - [Typed objects] Implement string type (Closed)
Patch Set: Created May 19, 2014, 3:15 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 | « lib/typedObjects.js ('k') | lib/typedObjects/stringType.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 230
231 let firstFree = []; 231 let firstFree = [];
232 for (let i = minElements; i < bufferSize; i <<= 1) 232 for (let i = minElements; i < bufferSize; i <<= 1)
233 firstFree[i] = new TypedReference(-1, typedReferenceViews); 233 firstFree[i] = new TypedReference(-1, typedReferenceViews);
234 234
235 let {int16, uint32} = require("typedObjects/primitiveTypes"); 235 let {int16, uint32} = require("typedObjects/primitiveTypes");
236 typeDescriptor = Object.create(typeDescriptor || {}); 236 typeDescriptor = Object.create(typeDescriptor || {});
237 typeDescriptor.arrayBufferIndex = int16; 237 typeDescriptor.arrayBufferIndex = int16;
238 typeDescriptor.arrayByteOffset = uint32; 238 typeDescriptor.arrayByteOffset = uint32;
239 typeDescriptor.getArrayBuffer = function()
240 {
241 return this.arrayBufferIndex >= 0 ? buffers[this.arrayBufferIndex] : null;
242 };
239 typeDescriptor.length = uint32; 243 typeDescriptor.length = uint32;
240 typeDescriptor.size = uint32; 244 typeDescriptor.size = uint32;
241 245
242 let elementShift = ilog2(elementType.referenceLength | 0); 246 let elementShift = ilog2(elementType.referenceLength | 0);
243 typeDescriptor.get = createGetter(elementGetter, elementShift); 247 typeDescriptor.get = createGetter(elementGetter, elementShift);
244 typeDescriptor.set = createSetter(elementSetter, elementShift); 248 typeDescriptor.set = createSetter(elementSetter, elementShift);
245 249
246 if (meta.hasOwnProperty("constructor") && typeof meta.constructor == "function ") 250 if (meta.hasOwnProperty("constructor") && typeof meta.constructor == "function ")
247 meta.constructor = createCombinedConstructor(meta.constructor); 251 meta.constructor = createCombinedConstructor(meta.constructor);
248 else 252 else
249 meta.constructor = defaultArrayConstructor; 253 meta.constructor = defaultArrayConstructor;
250 254
251 if (meta.hasOwnProperty("destructor") && typeof meta.destructor == "function") 255 if (meta.hasOwnProperty("destructor") && typeof meta.destructor == "function")
252 meta.destructor = createCombinedDestructor(meta.destructor); 256 meta.destructor = createCombinedDestructor(meta.destructor);
253 else 257 else
254 meta.destructor = defaultArrayDestructor; 258 meta.destructor = defaultArrayDestructor;
255 259
256 if (!meta.watch || typeof meta.watch != "object") 260 if (!meta.watch || typeof meta.watch != "object")
257 meta.watch = {}; 261 meta.watch = {};
258 262
259 meta.watch.length = createLengthWatcher(elementType, elementSetter); 263 meta.watch.length = createLengthWatcher(elementType, elementSetter);
260 meta.watch.size = createSizeWatcher(elementType, minElements, bufferSize, buff ers, viewTypes, views, firstFree); 264 meta.watch.size = createSizeWatcher(elementType, minElements, bufferSize, buff ers, viewTypes, views, firstFree);
261 265
262 let {ObjectBase} = require("typedObjects/objectTypes"); 266 let {ObjectBase} = require("typedObjects/objectTypes");
263 return ObjectBase.extend(typeDescriptor, meta); 267 return ObjectBase.extend(typeDescriptor, meta);
264 } 268 }
265 269
266 exports.createArrayType = createArrayType; 270 exports.createArrayType = createArrayType;
OLDNEW
« no previous file with comments | « lib/typedObjects.js ('k') | lib/typedObjects/stringType.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld