| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // patch classes for Int8List ..... Float64List and ByteData implementations. | 5 // patch classes for Int8List ..... Float64List and ByteData implementations. |
| 6 | 6 |
| 7 patch class Int8List { | 7 patch class Int8List { |
| 8 /* patch */ factory Int8List(int length) { | 8 /* patch */ factory Int8List(int length) { |
| 9 return new _Int8Array(length); | 9 return new _Int8Array(length); |
| 10 } | 10 } |
| 11 | 11 |
| 12 /* patch */ factory Int8List.transferable(int length) { |
| 13 return _newTransferable(length); |
| 14 } |
| 15 |
| 12 /* patch */ factory Int8List.fromList(List<int> elements) { | 16 /* patch */ factory Int8List.fromList(List<int> elements) { |
| 13 var result = new _Int8Array(elements.length); | 17 var result = new _Int8Array(elements.length); |
| 14 for (int i = 0; i < elements.length; i++) { | 18 for (int i = 0; i < elements.length; i++) { |
| 15 result[i] = elements[i]; | 19 result[i] = elements[i]; |
| 16 } | 20 } |
| 17 return result; | 21 return result; |
| 18 } | 22 } |
| 19 | 23 |
| 20 /* patch */ factory Int8List.view(ByteBuffer buffer, | 24 /* patch */ factory Int8List.view(ByteBuffer buffer, |
| 21 [int offsetInBytes = 0, int length]) { | 25 [int offsetInBytes = 0, int length]) { |
| 22 return new _Int8ArrayView(buffer, offsetInBytes, length); | 26 return new _Int8ArrayView(buffer, offsetInBytes, length); |
| 23 } | 27 } |
| 28 |
| 29 static _ExternalInt8Array _newTransferable(int length) { |
| 30 return new _ExternalInt8Array(length); |
| 31 } |
| 24 } | 32 } |
| 25 | 33 |
| 26 | 34 |
| 27 patch class Uint8List { | 35 patch class Uint8List { |
| 28 /* patch */ factory Uint8List(int length) { | 36 /* patch */ factory Uint8List(int length) { |
| 29 return new _Uint8Array(length); | 37 return new _Uint8Array(length); |
| 30 } | 38 } |
| 31 | 39 |
| 40 /* patch */ factory Uint8List.transferable(int length) { |
| 41 return _newTransferable(length); |
| 42 } |
| 43 |
| 32 /* patch */ factory Uint8List.fromList(List<int> elements) { | 44 /* patch */ factory Uint8List.fromList(List<int> elements) { |
| 33 var result = new _Uint8Array(elements.length); | 45 var result = new _Uint8Array(elements.length); |
| 34 for (int i = 0; i < elements.length; i++) { | 46 for (int i = 0; i < elements.length; i++) { |
| 35 result[i] = elements[i]; | 47 result[i] = elements[i]; |
| 36 } | 48 } |
| 37 return result; | 49 return result; |
| 38 } | 50 } |
| 39 | 51 |
| 40 /* patch */ factory Uint8List.view(ByteBuffer buffer, | 52 /* patch */ factory Uint8List.view(ByteBuffer buffer, |
| 41 [int offsetInBytes = 0, int length]) { | 53 [int offsetInBytes = 0, int length]) { |
| 42 return new _Uint8ArrayView(buffer, offsetInBytes, length); | 54 return new _Uint8ArrayView(buffer, offsetInBytes, length); |
| 43 } | 55 } |
| 56 |
| 57 static _ExternalUint8Array _newTransferable(int length) { |
| 58 return new _ExternalUint8Array(length); |
| 59 } |
| 44 } | 60 } |
| 45 | 61 |
| 46 | 62 |
| 47 patch class Uint8ClampedList { | 63 patch class Uint8ClampedList { |
| 48 /* patch */ factory Uint8ClampedList(int length) { | 64 /* patch */ factory Uint8ClampedList(int length) { |
| 49 return new _Uint8ClampedArray(length); | 65 return new _Uint8ClampedArray(length); |
| 50 } | 66 } |
| 51 | 67 |
| 68 /* patch */ factory Uint8ClampedList.transferable(int length) { |
| 69 return _newTransferable(length); |
| 70 } |
| 71 |
| 52 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { | 72 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { |
| 53 var result = new _Uint8ClampedArray(elements.length); | 73 var result = new _Uint8ClampedArray(elements.length); |
| 54 for (int i = 0; i < elements.length; i++) { | 74 for (int i = 0; i < elements.length; i++) { |
| 55 result[i] = elements[i]; | 75 result[i] = elements[i]; |
| 56 } | 76 } |
| 57 return result; | 77 return result; |
| 58 } | 78 } |
| 59 | 79 |
| 60 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, | 80 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, |
| 61 [int offsetInBytes = 0, | 81 [int offsetInBytes = 0, |
| 62 int length]) { | 82 int length]) { |
| 63 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | 83 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); |
| 64 } | 84 } |
| 85 |
| 86 static _ExternalUint8ClampedArray _newTransferable(int length) { |
| 87 return new _ExternalUint8ClampedArray(length); |
| 88 } |
| 65 } | 89 } |
| 66 | 90 |
| 67 | 91 |
| 68 patch class Int16List { | 92 patch class Int16List { |
| 69 /* patch */ factory Int16List(int length) { | 93 /* patch */ factory Int16List(int length) { |
| 70 return new _Int16Array(length); | 94 return new _Int16Array(length); |
| 71 } | 95 } |
| 72 | 96 |
| 97 /* patch */ factory Int16List.transferable(int length) { |
| 98 return _newTransferable(length); |
| 99 } |
| 100 |
| 73 /* patch */ factory Int16List.fromList(List<int> elements) { | 101 /* patch */ factory Int16List.fromList(List<int> elements) { |
| 74 var result = new _Int16Array(elements.length); | 102 var result = new _Int16Array(elements.length); |
| 75 for (int i = 0; i < elements.length; i++) { | 103 for (int i = 0; i < elements.length; i++) { |
| 76 result[i] = elements[i]; | 104 result[i] = elements[i]; |
| 77 } | 105 } |
| 78 return result; | 106 return result; |
| 79 } | 107 } |
| 80 | 108 |
| 81 /* patch */ factory Int16List.view(ByteBuffer buffer, | 109 /* patch */ factory Int16List.view(ByteBuffer buffer, |
| 82 [int offsetInBytes = 0, int length]) { | 110 [int offsetInBytes = 0, int length]) { |
| 83 return new _Int16ArrayView(buffer, offsetInBytes, length); | 111 return new _Int16ArrayView(buffer, offsetInBytes, length); |
| 84 } | 112 } |
| 113 |
| 114 static _ExternalInt16Array _newTransferable(int length) { |
| 115 return new _ExternalInt16Array(length); |
| 116 } |
| 85 } | 117 } |
| 86 | 118 |
| 87 | 119 |
| 88 patch class Uint16List { | 120 patch class Uint16List { |
| 89 /* patch */ factory Uint16List(int length) { | 121 /* patch */ factory Uint16List(int length) { |
| 90 return new _Uint16Array(length); | 122 return new _Uint16Array(length); |
| 91 } | 123 } |
| 92 | 124 |
| 125 /* patch */ factory Uint16List.transferable(int length) { |
| 126 return _newTransferable(length); |
| 127 } |
| 128 |
| 93 /* patch */ factory Uint16List.fromList(List<int> elements) { | 129 /* patch */ factory Uint16List.fromList(List<int> elements) { |
| 94 var result = new _Uint16Array(elements.length); | 130 var result = new _Uint16Array(elements.length); |
| 95 for (int i = 0; i < elements.length; i++) { | 131 for (int i = 0; i < elements.length; i++) { |
| 96 result[i] = elements[i]; | 132 result[i] = elements[i]; |
| 97 } | 133 } |
| 98 return result; | 134 return result; |
| 99 } | 135 } |
| 100 | 136 |
| 101 /* patch */ factory Uint16List.view(ByteBuffer buffer, | 137 /* patch */ factory Uint16List.view(ByteBuffer buffer, |
| 102 [int offsetInBytes = 0, int length]) { | 138 [int offsetInBytes = 0, int length]) { |
| 103 return new _Uint16ArrayView(buffer, offsetInBytes, length); | 139 return new _Uint16ArrayView(buffer, offsetInBytes, length); |
| 104 } | 140 } |
| 141 |
| 142 static _ExternalUint16Array _newTransferable(int length) { |
| 143 return new _ExternalUint16Array(length); |
| 144 } |
| 105 } | 145 } |
| 106 | 146 |
| 107 | 147 |
| 108 patch class Int32List { | 148 patch class Int32List { |
| 109 /* patch */ factory Int32List(int length) { | 149 /* patch */ factory Int32List(int length) { |
| 110 return new _Int32Array(length); | 150 return new _Int32Array(length); |
| 111 } | 151 } |
| 112 | 152 |
| 153 /* patch */ factory Int32List.transferable(int length) { |
| 154 return _newTransferable(length); |
| 155 } |
| 156 |
| 113 /* patch */ factory Int32List.fromList(List<int> elements) { | 157 /* patch */ factory Int32List.fromList(List<int> elements) { |
| 114 var result = new _Int32Array(elements.length); | 158 var result = new _Int32Array(elements.length); |
| 115 for (int i = 0; i < elements.length; i++) { | 159 for (int i = 0; i < elements.length; i++) { |
| 116 result[i] = elements[i]; | 160 result[i] = elements[i]; |
| 117 } | 161 } |
| 118 return result; | 162 return result; |
| 119 } | 163 } |
| 120 | 164 |
| 121 /* patch */ factory Int32List.view(ByteBuffer buffer, | 165 /* patch */ factory Int32List.view(ByteBuffer buffer, |
| 122 [int offsetInBytes = 0, int length]) { | 166 [int offsetInBytes = 0, int length]) { |
| 123 return new _Int32ArrayView(buffer, offsetInBytes, length); | 167 return new _Int32ArrayView(buffer, offsetInBytes, length); |
| 124 } | 168 } |
| 169 |
| 170 static _ExternalInt32Array _newTransferable(int length) { |
| 171 return new _ExternalInt32Array(length); |
| 172 } |
| 125 } | 173 } |
| 126 | 174 |
| 127 | 175 |
| 128 patch class Uint32List { | 176 patch class Uint32List { |
| 129 /* patch */ factory Uint32List(int length) { | 177 /* patch */ factory Uint32List(int length) { |
| 130 return new _Uint32Array(length); | 178 return new _Uint32Array(length); |
| 131 } | 179 } |
| 132 | 180 |
| 181 /* patch */ factory Uint32List.transferable(int length) { |
| 182 return _newTransferable(length); |
| 183 } |
| 184 |
| 133 /* patch */ factory Uint32List.fromList(List<int> elements) { | 185 /* patch */ factory Uint32List.fromList(List<int> elements) { |
| 134 var result = new _Uint32Array(elements.length); | 186 var result = new _Uint32Array(elements.length); |
| 135 for (int i = 0; i < elements.length; i++) { | 187 for (int i = 0; i < elements.length; i++) { |
| 136 result[i] = elements[i]; | 188 result[i] = elements[i]; |
| 137 } | 189 } |
| 138 return result; | 190 return result; |
| 139 } | 191 } |
| 140 | 192 |
| 141 /* patch */ factory Uint32List.view(ByteBuffer buffer, | 193 /* patch */ factory Uint32List.view(ByteBuffer buffer, |
| 142 [int offsetInBytes = 0, int length]) { | 194 [int offsetInBytes = 0, int length]) { |
| 143 return new _Uint32ArrayView(buffer, offsetInBytes, length); | 195 return new _Uint32ArrayView(buffer, offsetInBytes, length); |
| 144 } | 196 } |
| 197 |
| 198 static _ExternalUint32Array _newTransferable(int length) { |
| 199 return new _ExternalUint32Array(length); |
| 200 } |
| 145 } | 201 } |
| 146 | 202 |
| 147 | 203 |
| 148 patch class Int64List { | 204 patch class Int64List { |
| 149 /* patch */ factory Int64List(int length) { | 205 /* patch */ factory Int64List(int length) { |
| 150 return new _Int64Array(length); | 206 return new _Int64Array(length); |
| 151 } | 207 } |
| 152 | 208 |
| 209 /* patch */ factory Int64List.transferable(int length) { |
| 210 return _newTransferable(length); |
| 211 } |
| 212 |
| 153 /* patch */ factory Int64List.fromList(List<int> elements) { | 213 /* patch */ factory Int64List.fromList(List<int> elements) { |
| 154 var result = new _Int64Array(elements.length); | 214 var result = new _Int64Array(elements.length); |
| 155 for (int i = 0; i < elements.length; i++) { | 215 for (int i = 0; i < elements.length; i++) { |
| 156 result[i] = elements[i]; | 216 result[i] = elements[i]; |
| 157 } | 217 } |
| 158 return result; | 218 return result; |
| 159 } | 219 } |
| 160 | 220 |
| 161 /* patch */ factory Int64List.view(ByteBuffer buffer, | 221 /* patch */ factory Int64List.view(ByteBuffer buffer, |
| 162 [int offsetInBytes = 0, int length]) { | 222 [int offsetInBytes = 0, int length]) { |
| 163 return new _Int64ArrayView(buffer, offsetInBytes, length); | 223 return new _Int64ArrayView(buffer, offsetInBytes, length); |
| 164 } | 224 } |
| 225 |
| 226 static _ExternalInt64Array _newTransferable(int length) { |
| 227 return new _ExternalInt64Array(length); |
| 228 } |
| 165 } | 229 } |
| 166 | 230 |
| 167 | 231 |
| 168 patch class Uint64List { | 232 patch class Uint64List { |
| 169 /* patch */ factory Uint64List(int length) { | 233 /* patch */ factory Uint64List(int length) { |
| 170 return new _Uint64Array(length); | 234 return new _Uint64Array(length); |
| 171 } | 235 } |
| 172 | 236 |
| 237 /* patch */ factory Uint64List.transferable(int length) { |
| 238 return _newTransferable(length); |
| 239 } |
| 240 |
| 173 /* patch */ factory Uint64List.fromList(List<int> elements) { | 241 /* patch */ factory Uint64List.fromList(List<int> elements) { |
| 174 var result = new _Uint64Array(elements.length); | 242 var result = new _Uint64Array(elements.length); |
| 175 for (int i = 0; i < elements.length; i++) { | 243 for (int i = 0; i < elements.length; i++) { |
| 176 result[i] = elements[i]; | 244 result[i] = elements[i]; |
| 177 } | 245 } |
| 178 return result; | 246 return result; |
| 179 } | 247 } |
| 180 | 248 |
| 181 /* patch */ factory Uint64List.view(ByteBuffer buffer, | 249 /* patch */ factory Uint64List.view(ByteBuffer buffer, |
| 182 [int offsetInBytes = 0, int length]) { | 250 [int offsetInBytes = 0, int length]) { |
| 183 return new _Uint64ArrayView(buffer, offsetInBytes, length); | 251 return new _Uint64ArrayView(buffer, offsetInBytes, length); |
| 184 } | 252 } |
| 253 |
| 254 static _ExternalUint64Array _newTransferable(int length) { |
| 255 return new _ExternalUint64Array(length); |
| 256 } |
| 185 } | 257 } |
| 186 | 258 |
| 187 | 259 |
| 188 patch class Float32List { | 260 patch class Float32List { |
| 189 /* patch */ factory Float32List(int length) { | 261 /* patch */ factory Float32List(int length) { |
| 190 return new _Float32Array(length); | 262 return new _Float32Array(length); |
| 191 } | 263 } |
| 192 | 264 |
| 265 /* patch */ factory Float32List.transferable(int length) { |
| 266 return _newTransferable(length); |
| 267 } |
| 268 |
| 193 /* patch */ factory Float32List.fromList(List<double> elements) { | 269 /* patch */ factory Float32List.fromList(List<double> elements) { |
| 194 var result = new _Float32Array(elements.length); | 270 var result = new _Float32Array(elements.length); |
| 195 for (int i = 0; i < elements.length; i++) { | 271 for (int i = 0; i < elements.length; i++) { |
| 196 result[i] = elements[i]; | 272 result[i] = elements[i]; |
| 197 } | 273 } |
| 198 return result; | 274 return result; |
| 199 } | 275 } |
| 200 | 276 |
| 201 /* patch */ factory Float32List.view(ByteBuffer buffer, | 277 /* patch */ factory Float32List.view(ByteBuffer buffer, |
| 202 [int offsetInBytes = 0, int length]) { | 278 [int offsetInBytes = 0, int length]) { |
| 203 return new _Float32ArrayView(buffer, offsetInBytes, length); | 279 return new _Float32ArrayView(buffer, offsetInBytes, length); |
| 204 } | 280 } |
| 281 |
| 282 static _ExternalFloat32Array _newTransferable(int length) { |
| 283 return new _ExternalFloat32Array(length); |
| 284 } |
| 205 } | 285 } |
| 206 | 286 |
| 207 | 287 |
| 208 patch class Float64List { | 288 patch class Float64List { |
| 209 /* patch */ factory Float64List(int length) { | 289 /* patch */ factory Float64List(int length) { |
| 210 return new _Float64Array(length); | 290 return new _Float64Array(length); |
| 211 } | 291 } |
| 212 | 292 |
| 293 /* patch */ factory Float64List.transferable(int length) { |
| 294 return _newTransferable(length); |
| 295 } |
| 296 |
| 213 /* patch */ factory Float64List.fromList(List<double> elements) { | 297 /* patch */ factory Float64List.fromList(List<double> elements) { |
| 214 var result = new _Float64Array(elements.length); | 298 var result = new _Float64Array(elements.length); |
| 215 for (int i = 0; i < elements.length; i++) { | 299 for (int i = 0; i < elements.length; i++) { |
| 216 result[i] = elements[i]; | 300 result[i] = elements[i]; |
| 217 } | 301 } |
| 218 return result; | 302 return result; |
| 219 } | 303 } |
| 220 | 304 |
| 221 /* patch */ factory Float64List.view(ByteBuffer buffer, | 305 /* patch */ factory Float64List.view(ByteBuffer buffer, |
| 222 [int offsetInBytes = 0, int length]) { | 306 [int offsetInBytes = 0, int length]) { |
| 223 return new _Float64ArrayView(buffer, offsetInBytes, length); | 307 return new _Float64ArrayView(buffer, offsetInBytes, length); |
| 224 } | 308 } |
| 309 |
| 310 static _ExternalFloat64Array _newTransferable(int length) { |
| 311 return new _ExternalFloat64Array(length); |
| 312 } |
| 225 } | 313 } |
| 226 | 314 |
| 227 patch class Float32x4List { | 315 patch class Float32x4List { |
| 228 /* patch */ factory Float32x4List(int length) { | 316 /* patch */ factory Float32x4List(int length) { |
| 229 return new _Float32x4Array(length); | 317 return new _Float32x4Array(length); |
| 230 } | 318 } |
| 231 | 319 |
| 320 /* patch */ factory Float32x4List.transferable(int length) { |
| 321 return _newTransferable(length); |
| 322 } |
| 323 |
| 232 /* patch */ factory Float32x4List.view(ByteBuffer buffer, | 324 /* patch */ factory Float32x4List.view(ByteBuffer buffer, |
| 233 [int offsetInBytes = 0, int length]) { | 325 [int offsetInBytes = 0, int length]) { |
| 234 return new _Float32x4ArrayView(buffer, offsetInBytes, length); | 326 return new _Float32x4ArrayView(buffer, offsetInBytes, length); |
| 235 } | 327 } |
| 328 |
| 329 static _ExternalFloat32x4Array _newTransferable(int length) { |
| 330 return new _ExternalFloat32x4Array(length); |
| 331 } |
| 236 } | 332 } |
| 237 | 333 |
| 238 | 334 |
| 239 patch class Float32x4 { | 335 patch class Float32x4 { |
| 240 /* patch */ factory Float32x4(double x, double y, double z, double w) { | 336 /* patch */ factory Float32x4(double x, double y, double z, double w) { |
| 241 return new _Float32x4(x, y, z, w); | 337 return new _Float32x4(x, y, z, w); |
| 242 } | 338 } |
| 243 /* patch */ factory Float32x4.zero() { | 339 /* patch */ factory Float32x4.zero() { |
| 244 return new _Float32x4.zero(); | 340 return new _Float32x4.zero(); |
| 245 } | 341 } |
| 246 } | 342 } |
| 247 | 343 |
| 248 | 344 |
| 249 patch class Uint32x4 { | 345 patch class Uint32x4 { |
| 250 /* patch */ factory Uint32x4(int x, int y, int z, int w) { | 346 /* patch */ factory Uint32x4(int x, int y, int z, int w) { |
| 251 return new _Uint32x4(x, y, z, w); | 347 return new _Uint32x4(x, y, z, w); |
| 252 } | 348 } |
| 253 /* patch */ factory Uint32x4.bool(bool x, bool y, bool z, bool w) { | 349 /* patch */ factory Uint32x4.bool(bool x, bool y, bool z, bool w) { |
| 254 return new _Uint32x4.bool(x, y, z, w); | 350 return new _Uint32x4.bool(x, y, z, w); |
| 255 } | 351 } |
| 256 } | 352 } |
| 257 | 353 |
| 258 | 354 |
| 259 patch class ByteData { | 355 patch class ByteData { |
| 260 /* patch */ factory ByteData(int length) { | 356 /* patch */ factory ByteData(int length) { |
| 261 var list = new _Uint8Array(length); | 357 var list = new _Uint8Array(length); |
| 262 return new _ByteDataView(list.buffer, 0, length); | 358 return new _ByteDataView(list.buffer, 0, length); |
| 263 } | 359 } |
| 264 | 360 |
| 361 /* patch */ factory ByteData.transferable(int length) { |
| 362 var list = new _Uint8Array.transferable(length); |
| 363 return new _ByteDataView(list.buffer, 0, length); |
| 364 } |
| 365 |
| 265 /* patch */ factory ByteData.view(ByteBuffer buffer, | 366 /* patch */ factory ByteData.view(ByteBuffer buffer, |
| 266 [int offsetInBytes = 0, int length]) { | 367 [int offsetInBytes = 0, int length]) { |
| 267 if (length == null) { | 368 if (length == null) { |
| 268 length = buffer.lengthInBytes - offsetInBytes; | 369 length = buffer.lengthInBytes - offsetInBytes; |
| 269 } | 370 } |
| 270 return new _ByteDataView(buffer, offsetInBytes, length); | 371 return new _ByteDataView(buffer, offsetInBytes, length); |
| 271 } | 372 } |
| 272 } | 373 } |
| 273 | 374 |
| 274 | 375 |
| (...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3074 return value; | 3175 return value; |
| 3075 } | 3176 } |
| 3076 return object; | 3177 return object; |
| 3077 } | 3178 } |
| 3078 | 3179 |
| 3079 | 3180 |
| 3080 void _throwRangeError(int index, int length) { | 3181 void _throwRangeError(int index, int length) { |
| 3081 String message = "$index must be in the range [0..$length)"; | 3182 String message = "$index must be in the range [0..$length)"; |
| 3082 throw new RangeError(message); | 3183 throw new RangeError(message); |
| 3083 } | 3184 } |
| OLD | NEW |