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

Side by Side Diff: lib/typedObjects.js

Issue 4827963358969856: Issue 147 - [Typed objects] Implement object types (Closed)
Patch Set: Created April 4, 2014, 10:28 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 | « no previous file | lib/typedObjects/objectTypes.js » ('j') | lib/typedObjects/objectTypes.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 "use strict";
19
20 /**
21 * @fileOverview
22 * This is an implementation of typed objects similar to the ECMAScript Harmony
23 * proposal (http://wiki.ecmascript.org/doku.php?id=harmony:typed_objects).
24 * The main difference is that it allows creating actual objects rather than
25 * merely structured data.
26 *
27 * Defining a type
28 * ---------------
29 *
30 * const Point2D = new ObjectType({
31 * x: uint32,
32 * y: uint32,
33 * rotate: function() { ... }
34 * }, {
35 * constructor: function(x, y) { ... },
36 * bufferSize: 16
37 * });
38 *
39 * The first parameter to ObjectType defines object properties and methods. A
40 * name can either be associted with a type (property) or function (method).
41 * Numeric value types from the ECMAScript Harmony proposal are predefined as
42 * well as "boolean" which is an alias for uint8. In addition to that, already
43 * defined object types can be used.
44 *
45 * The optional second parameter sets type metadata:
46 *
47 * constructor: function that will be called whenever an object of the type i s
48 * created.
49 * bufferSize: number of objects that should be placed into a single typed
50 * buffer (by default 128).
51 *
52 * Creating an object instance
53 * ---------------------------
54 *
55 * var point = Point2D(5, 10);
56 * point.rotate(10);
57 * Console.log(point.x + ", " + point.y);
58 *
59 * The parameters 5 and 10 will be passed to the constructor function defined
60 * for this type.
61 */
62
63 function forwardExports(module)
64 {
65 let moduleExports = require(module);
66 for (let key in moduleExports)
67 exports[key] = moduleExports[key];
68 }
69
70 forwardExports("typedObjects/primitiveTypes");
71 forwardExports("typedObjects/objectTypes");
OLDNEW
« no previous file with comments | « no previous file | lib/typedObjects/objectTypes.js » ('j') | lib/typedObjects/objectTypes.js » ('J')

Powered by Google App Engine
This is Rietveld