OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 * | 51 * |
52 * Creating an object instance | 52 * Creating an object instance |
53 * --------------------------- | 53 * --------------------------- |
54 * | 54 * |
55 * var point = Point2D(5, 10); | 55 * var point = Point2D(5, 10); |
56 * point.rotate(10); | 56 * point.rotate(10); |
57 * Console.log(point.x + ", " + point.y); | 57 * Console.log(point.x + ", " + point.y); |
58 * | 58 * |
59 * The parameters 5 and 10 will be passed to the constructor function defined | 59 * The parameters 5 and 10 will be passed to the constructor function defined |
60 * for this type. | 60 * for this type. |
| 61 * |
| 62 * Type inheritance |
| 63 * ---------------- |
| 64 * |
| 65 * var Point3D = Point2D.extend({ |
| 66 * z: uint32 |
| 67 * }, { |
| 68 * constructor: function(super_, x, y, z) |
| 69 * { |
| 70 * super_(x, y); |
| 71 * ... |
| 72 * } |
| 73 * }); |
| 74 * |
| 75 * Extended types can be used wherever their base type is required. The |
| 76 * parameters taken by type.extend() are the same as parameters of |
| 77 * new ObjectType(), the only difference is that properties and methods |
| 78 * of the original type are taken over. Methods and constructors can be |
| 79 * overwritten, they will then get superclass method/constructor as the first |
| 80 * parameter and can call it. |
| 81 * |
| 82 * Common object methods |
| 83 * --------------------- |
| 84 * |
| 85 * All objects inherit from ObjectBase type implicitly and share its methods. |
| 86 * In particular, object.equals() can be used to compare objects: |
| 87 * |
| 88 * var point1 = Point2D(5, 10); |
| 89 * var point2 = Point2D(6, 12); |
| 90 * console.log(point1.equals(point2)); // false |
| 91 * console.log(point1.equals(point1)); // true |
| 92 * |
| 93 * Note that JavaScript comparison operators == and != won't always produce |
| 94 * correct results for typed objects. |
61 */ | 95 */ |
62 | 96 |
63 function forwardExports(module) | 97 function forwardExports(module) |
64 { | 98 { |
65 let moduleExports = require(module); | 99 let moduleExports = require(module); |
66 for (let key in moduleExports) | 100 for (let key in moduleExports) |
67 exports[key] = moduleExports[key]; | 101 exports[key] = moduleExports[key]; |
68 } | 102 } |
69 | 103 |
70 forwardExports("typedObjects/primitiveTypes"); | 104 forwardExports("typedObjects/primitiveTypes"); |
71 forwardExports("typedObjects/objectTypes"); | 105 forwardExports("typedObjects/objectTypes"); |
OLD | NEW |