| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // patch classes for Int8List ..... Float64List and ByteData implementations. | |
| 6 | |
| 7 patch class Int8List { | |
| 8 /* patch */ factory Int8List(int length) { | |
| 9 return new _Int8Array(length); | |
| 10 } | |
| 11 | |
| 12 /* patch */ factory Int8List.fromList(List<int> elements) { | |
| 13 var result = new _Int8Array(elements.length); | |
| 14 for (int i = 0; i < elements.length; i++) { | |
| 15 result[i] = elements[i]; | |
| 16 } | |
| 17 return result; | |
| 18 } | |
| 19 | |
| 20 /* patch */ factory Int8List.view(ByteBuffer buffer, | |
| 21 [int offsetInBytes = 0, int length]) { | |
| 22 return new _Int8ArrayView(buffer, offsetInBytes, length); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 | |
| 27 patch class Uint8List { | |
| 28 /* patch */ factory Uint8List(int length) { | |
| 29 return new _Uint8Array(length); | |
| 30 } | |
| 31 | |
| 32 /* patch */ factory Uint8List.fromList(List<int> elements) { | |
| 33 var result = new _Uint8Array(elements.length); | |
| 34 for (int i = 0; i < elements.length; i++) { | |
| 35 result[i] = elements[i]; | |
| 36 } | |
| 37 return result; | |
| 38 } | |
| 39 | |
| 40 /* patch */ factory Uint8List.view(ByteBuffer buffer, | |
| 41 [int offsetInBytes = 0, int length]) { | |
| 42 return new _Uint8ArrayView(buffer, offsetInBytes, length); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 | |
| 47 patch class Uint8ClampedList { | |
| 48 /* patch */ factory Uint8ClampedList(int length) { | |
| 49 return new _Uint8ClampedArray(length); | |
| 50 } | |
| 51 | |
| 52 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { | |
| 53 var result = new _Uint8ClampedArray(elements.length); | |
| 54 for (int i = 0; i < elements.length; i++) { | |
| 55 result[i] = elements[i]; | |
| 56 } | |
| 57 return result; | |
| 58 } | |
| 59 | |
| 60 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, | |
| 61 [int offsetInBytes = 0, | |
| 62 int length]) { | |
| 63 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 | |
| 68 patch class Int16List { | |
| 69 /* patch */ factory Int16List(int length) { | |
| 70 return new _Int16Array(length); | |
| 71 } | |
| 72 | |
| 73 /* patch */ factory Int16List.fromList(List<int> elements) { | |
| 74 var result = new _Int16Array(elements.length); | |
| 75 for (int i = 0; i < elements.length; i++) { | |
| 76 result[i] = elements[i]; | |
| 77 } | |
| 78 return result; | |
| 79 } | |
| 80 | |
| 81 /* patch */ factory Int16List.view(ByteBuffer buffer, | |
| 82 [int offsetInBytes = 0, int length]) { | |
| 83 return new _Int16ArrayView(buffer, offsetInBytes, length); | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 | |
| 88 patch class Uint16List { | |
| 89 /* patch */ factory Uint16List(int length) { | |
| 90 return new _Uint16Array(length); | |
| 91 } | |
| 92 | |
| 93 /* patch */ factory Uint16List.fromList(List<int> elements) { | |
| 94 var result = new _Uint16Array(elements.length); | |
| 95 for (int i = 0; i < elements.length; i++) { | |
| 96 result[i] = elements[i]; | |
| 97 } | |
| 98 return result; | |
| 99 } | |
| 100 | |
| 101 /* patch */ factory Uint16List.view(ByteBuffer buffer, | |
| 102 [int offsetInBytes = 0, int length]) { | |
| 103 return new _Uint16ArrayView(buffer, offsetInBytes, length); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 | |
| 108 patch class Int32List { | |
| 109 /* patch */ factory Int32List(int length) { | |
| 110 return new _Int32Array(length); | |
| 111 } | |
| 112 | |
| 113 /* patch */ factory Int32List.fromList(List<int> elements) { | |
| 114 var result = new _Int32Array(elements.length); | |
| 115 for (int i = 0; i < elements.length; i++) { | |
| 116 result[i] = elements[i]; | |
| 117 } | |
| 118 return result; | |
| 119 } | |
| 120 | |
| 121 /* patch */ factory Int32List.view(ByteBuffer buffer, | |
| 122 [int offsetInBytes = 0, int length]) { | |
| 123 return new _Int32ArrayView(buffer, offsetInBytes, length); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 | |
| 128 patch class Uint32List { | |
| 129 /* patch */ factory Uint32List(int length) { | |
| 130 return new _Uint32Array(length); | |
| 131 } | |
| 132 | |
| 133 /* patch */ factory Uint32List.fromList(List<int> elements) { | |
| 134 var result = new _Uint32Array(elements.length); | |
| 135 for (int i = 0; i < elements.length; i++) { | |
| 136 result[i] = elements[i]; | |
| 137 } | |
| 138 return result; | |
| 139 } | |
| 140 | |
| 141 /* patch */ factory Uint32List.view(ByteBuffer buffer, | |
| 142 [int offsetInBytes = 0, int length]) { | |
| 143 return new _Uint32ArrayView(buffer, offsetInBytes, length); | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 | |
| 148 patch class Int64List { | |
| 149 /* patch */ factory Int64List(int length) { | |
| 150 return new _Int64Array(length); | |
| 151 } | |
| 152 | |
| 153 /* patch */ factory Int64List.fromList(List<int> elements) { | |
| 154 var result = new _Int64Array(elements.length); | |
| 155 for (int i = 0; i < elements.length; i++) { | |
| 156 result[i] = elements[i]; | |
| 157 } | |
| 158 return result; | |
| 159 } | |
| 160 | |
| 161 /* patch */ factory Int64List.view(ByteBuffer buffer, | |
| 162 [int offsetInBytes = 0, int length]) { | |
| 163 return new _Int64ArrayView(buffer, offsetInBytes, length); | |
| 164 } | |
| 165 } | |
| 166 | |
| 167 | |
| 168 patch class Uint64List { | |
| 169 /* patch */ factory Uint64List(int length) { | |
| 170 return new _Uint64Array(length); | |
| 171 } | |
| 172 | |
| 173 /* patch */ factory Uint64List.fromList(List<int> elements) { | |
| 174 var result = new _Uint64Array(elements.length); | |
| 175 for (int i = 0; i < elements.length; i++) { | |
| 176 result[i] = elements[i]; | |
| 177 } | |
| 178 return result; | |
| 179 } | |
| 180 | |
| 181 /* patch */ factory Uint64List.view(ByteBuffer buffer, | |
| 182 [int offsetInBytes = 0, int length]) { | |
| 183 return new _Uint64ArrayView(buffer, offsetInBytes, length); | |
| 184 } | |
| 185 } | |
| 186 | |
| 187 | |
| 188 patch class Float32List { | |
| 189 /* patch */ factory Float32List(int length) { | |
| 190 return new _Float32Array(length); | |
| 191 } | |
| 192 | |
| 193 /* patch */ factory Float32List.fromList(List<double> elements) { | |
| 194 var result = new _Float32Array(elements.length); | |
| 195 for (int i = 0; i < elements.length; i++) { | |
| 196 result[i] = elements[i]; | |
| 197 } | |
| 198 return result; | |
| 199 } | |
| 200 | |
| 201 /* patch */ factory Float32List.view(ByteBuffer buffer, | |
| 202 [int offsetInBytes = 0, int length]) { | |
| 203 return new _Float32ArrayView(buffer, offsetInBytes, length); | |
| 204 } | |
| 205 } | |
| 206 | |
| 207 | |
| 208 patch class Float64List { | |
| 209 /* patch */ factory Float64List(int length) { | |
| 210 return new _Float64Array(length); | |
| 211 } | |
| 212 | |
| 213 /* patch */ factory Float64List.fromList(List<double> elements) { | |
| 214 var result = new _Float64Array(elements.length); | |
| 215 for (int i = 0; i < elements.length; i++) { | |
| 216 result[i] = elements[i]; | |
| 217 } | |
| 218 return result; | |
| 219 } | |
| 220 | |
| 221 /* patch */ factory Float64List.view(ByteBuffer buffer, | |
| 222 [int offsetInBytes = 0, int length]) { | |
| 223 return new _Float64ArrayView(buffer, offsetInBytes, length); | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 patch class Float32x4List { | |
| 228 /* patch */ factory Float32x4List(int length) { | |
| 229 return new _Float32x4Array(length); | |
| 230 } | |
| 231 | |
| 232 /* patch */ factory Float32x4List.view(ByteBuffer buffer, | |
| 233 [int offsetInBytes = 0, int length]) { | |
| 234 return new _Float32x4ArrayView(buffer, offsetInBytes, length); | |
| 235 } | |
| 236 } | |
| 237 | |
| 238 | |
| 239 patch class Float32x4 { | |
| 240 /* patch */ factory Float32x4(double x, double y, double z, double w) { | |
| 241 return new _Float32x4(x, y, z, w); | |
| 242 } | |
| 243 /* patch */ factory Float32x4.zero() { | |
| 244 return new _Float32x4.zero(); | |
| 245 } | |
| 246 } | |
| 247 | |
| 248 | |
| 249 patch class Uint32x4 { | |
| 250 /* patch */ factory Uint32x4(int x, int y, int z, int w) { | |
| 251 return new _Uint32x4(x, y, z, w); | |
| 252 } | |
| 253 /* patch */ factory Uint32x4.bool(bool x, bool y, bool z, bool w) { | |
| 254 return new _Uint32x4.bool(x, y, z, w); | |
| 255 } | |
| 256 } | |
| 257 | |
| 258 | |
| 259 patch class ByteData { | |
| 260 /* patch */ factory ByteData(int length) { | |
| 261 var list = new _Uint8Array(length); | |
| 262 return new _ByteDataView(list.buffer, 0, length); | |
| 263 } | |
| 264 | |
| 265 /* patch */ factory ByteData.view(ByteBuffer buffer, | |
| 266 [int offsetInBytes = 0, int length]) { | |
| 267 if (length == null) { | |
| 268 length = buffer.lengthInBytes - offsetInBytes; | |
| 269 } | |
| 270 return new _ByteDataView(buffer, offsetInBytes, length); | |
| 271 } | |
| 272 } | |
| 273 | |
| 274 | |
| 275 // Based class for _TypedList that provides common methods for implementing | |
| 276 // the collection and list interfaces. | |
| 277 | |
| 278 abstract class _TypedListBase { | |
| 279 // Method(s) implementing the Collection interface. | |
| 280 bool contains(element) => IterableMixinWorkaround.contains(this, element); | |
| 281 | |
| 282 void forEach(void f(element)) { | |
| 283 var len = this.length; | |
| 284 for (var i = 0; i < len; i++) { | |
| 285 f(this[i]); | |
| 286 } | |
| 287 } | |
| 288 | |
| 289 Iterable map(f(int element)) { | |
| 290 return IterableMixinWorkaround.mapList(this, f); | |
| 291 } | |
| 292 | |
| 293 String join([String separator = ""]) { | |
| 294 return IterableMixinWorkaround.join(this, separator); | |
| 295 } | |
| 296 | |
| 297 dynamic reduce(dynamic combine(value, element)) { | |
| 298 return IterableMixinWorkaround.reduce(this, combine); | |
| 299 } | |
| 300 | |
| 301 dynamic fold(dynamic initialValue, | |
| 302 dynamic combine(dynamic initialValue, element)) { | |
| 303 return IterableMixinWorkaround.fold(this, initialValue, combine); | |
| 304 } | |
| 305 | |
| 306 Iterable where(bool f(int element)) { | |
| 307 return IterableMixinWorkaround.where(this, f); | |
| 308 } | |
| 309 | |
| 310 Iterable expand(Iterable f(int element)) { | |
| 311 return IterableMixinWorkaround.expand(this, f); | |
| 312 } | |
| 313 | |
| 314 Iterable take(int n) { | |
| 315 return IterableMixinWorkaround.takeList(this, n); | |
| 316 } | |
| 317 | |
| 318 Iterable takeWhile(bool test(int value)) { | |
| 319 return IterableMixinWorkaround.takeWhile(this, test); | |
| 320 } | |
| 321 | |
| 322 Iterable skip(int n) { | |
| 323 return IterableMixinWorkaround.skipList(this, n); | |
| 324 } | |
| 325 | |
| 326 Iterable skipWhile(bool test(int value)) { | |
| 327 return IterableMixinWorkaround.skipWhile(this, test); | |
| 328 } | |
| 329 | |
| 330 bool every(bool f(element)) { | |
| 331 return IterableMixinWorkaround.every(this, f); | |
| 332 } | |
| 333 | |
| 334 bool any(bool f(element)) { | |
| 335 return IterableMixinWorkaround.any(this, f); | |
| 336 } | |
| 337 | |
| 338 int firstWhere(bool test(int value), {int orElse()}) { | |
| 339 return IterableMixinWorkaround.firstWhere(this, test, orElse); | |
| 340 } | |
| 341 | |
| 342 int lastWhere(bool test(int value), {int orElse()}) { | |
| 343 return IterableMixinWorkaround.lastWhereList(this, test, orElse); | |
| 344 } | |
| 345 | |
| 346 int singleWhere(bool test(int value)) { | |
| 347 return IterableMixinWorkaround.singleWhere(this, test); | |
| 348 } | |
| 349 | |
| 350 int elementAt(int index) { | |
| 351 return this[index]; | |
| 352 } | |
| 353 | |
| 354 bool get isEmpty { | |
| 355 return this.length == 0; | |
| 356 } | |
| 357 | |
| 358 | |
| 359 // Method(s) implementing the List interface. | |
| 360 | |
| 361 set length(newLength) { | |
| 362 throw new UnsupportedError( | |
| 363 "Cannot resize a non-extendable array"); | |
| 364 } | |
| 365 | |
| 366 void add(value) { | |
| 367 throw new UnsupportedError( | |
| 368 "Cannot add to a non-extendable array"); | |
| 369 } | |
| 370 | |
| 371 void addAll(Iterable value) { | |
| 372 throw new UnsupportedError( | |
| 373 "Cannot add to a non-extendable array"); | |
| 374 } | |
| 375 | |
| 376 void sort([int compare(var a, var b)]) { | |
| 377 return IterableMixinWorkaround.sortList(this, compare); | |
| 378 } | |
| 379 | |
| 380 int indexOf(element, [int start = 0]) { | |
| 381 return IterableMixinWorkaround.indexOfList(this, element, start); | |
| 382 } | |
| 383 | |
| 384 int lastIndexOf(element, [int start = null]) { | |
| 385 return IterableMixinWorkaround.lastIndexOfList(this, element, start); | |
| 386 } | |
| 387 | |
| 388 void clear() { | |
| 389 throw new UnsupportedError( | |
| 390 "Cannot remove from a non-extendable array"); | |
| 391 } | |
| 392 | |
| 393 int removeLast() { | |
| 394 throw new UnsupportedError( | |
| 395 "Cannot remove from a non-extendable array"); | |
| 396 } | |
| 397 | |
| 398 void remove(Object element) { | |
| 399 throw new UnsupportedError( | |
| 400 "Cannot remove from a non-extendable array"); | |
| 401 } | |
| 402 | |
| 403 void removeAll(Iterable elements) { | |
| 404 throw new UnsupportedError( | |
| 405 "Cannot remove from a non-extendable array"); | |
| 406 } | |
| 407 | |
| 408 void retainAll(Iterable elements) { | |
| 409 throw new UnsupportedError( | |
| 410 "Cannot remove from a non-extendable array"); | |
| 411 } | |
| 412 | |
| 413 void removeWhere(bool test(int element)) { | |
| 414 throw new UnsupportedError( | |
| 415 "Cannot remove from a non-extendable array"); | |
| 416 } | |
| 417 | |
| 418 void retainWhere(bool test(int element)) { | |
| 419 throw new UnsupportedError( | |
| 420 "Cannot remove from a non-extendable array"); | |
| 421 } | |
| 422 | |
| 423 int get first { | |
| 424 if (length > 0) return this[0]; | |
| 425 throw new StateError("No elements"); | |
| 426 } | |
| 427 | |
| 428 int get last { | |
| 429 if (length > 0) return this[length - 1]; | |
| 430 throw new StateError("No elements"); | |
| 431 } | |
| 432 | |
| 433 int get single { | |
| 434 if (length == 1) return this[0]; | |
| 435 if (length == 0) throw new StateError("No elements"); | |
| 436 throw new StateError("More than one element"); | |
| 437 } | |
| 438 | |
| 439 void removeRange(int start, int end) { | |
| 440 throw new UnsupportedError( | |
| 441 "Cannot remove from a non-extendable array"); | |
| 442 } | |
| 443 | |
| 444 void replaceRange(int start, int end, Iterable iterable) { | |
| 445 throw new UnsupportedError( | |
| 446 "Cannot remove from a non-extendable array"); | |
| 447 } | |
| 448 | |
| 449 List toList() { | |
| 450 return new List.from(this); | |
| 451 } | |
| 452 | |
| 453 Set toSet() { | |
| 454 return new Set.from(this); | |
| 455 } | |
| 456 | |
| 457 List sublist(int start, [int end]) { | |
| 458 if (end == null) end = length; | |
| 459 int length = end - start; | |
| 460 _rangeCheck(this.length, start, length); | |
| 461 List result = _createList(length); | |
| 462 result.setRange(0, length, this, start); | |
| 463 return result; | |
| 464 } | |
| 465 | |
| 466 Iterable getRange(int start, [int end]) { | |
| 467 return IterableMixinWorkaround.getRangeList(this, start, end); | |
| 468 } | |
| 469 | |
| 470 void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { | |
| 471 if (!_setRange(start, end - start, iterable, skipCount)) { | |
| 472 IterableMixinWorkaround.setRangeList(this, start, | |
| 473 end, iterable, skipCount); | |
| 474 } | |
| 475 } | |
| 476 | |
| 477 void setAll(int index, Iterable iterable) { | |
| 478 IterableMixinWorkaround.setAllList(this, index, iterable); | |
| 479 } | |
| 480 | |
| 481 void fillRange(int start, int end, [fillValue]) { | |
| 482 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue); | |
| 483 } | |
| 484 | |
| 485 | |
| 486 // Method(s) implementing Object interface. | |
| 487 | |
| 488 String toString() { | |
| 489 return ToString.iterableToString(this); | |
| 490 } | |
| 491 | |
| 492 | |
| 493 // Internal utility methods. | |
| 494 | |
| 495 bool _setRange(int start, int length, Iterable from, int startFrom) | |
| 496 native "TypedData_setRange"; | |
| 497 } | |
| 498 | |
| 499 | |
| 500 abstract class _TypedList extends _TypedListBase implements ByteBuffer { | |
| 501 // Default method implementing parts of the TypedData interface. | |
| 502 int get offsetInBytes { | |
| 503 return 0; | |
| 504 } | |
| 505 | |
| 506 int get lengthInBytes { | |
| 507 return length * elementSizeInBytes; | |
| 508 } | |
| 509 | |
| 510 ByteBuffer get buffer { | |
| 511 return this; | |
| 512 } | |
| 513 | |
| 514 | |
| 515 // Methods implementing the collection interface. | |
| 516 | |
| 517 int get length native "TypedData_length"; | |
| 518 | |
| 519 | |
| 520 // Internal utility methods. | |
| 521 | |
| 522 int _getInt8(int offsetInBytes) native "TypedData_GetInt8"; | |
| 523 void _setInt8(int offsetInBytes, int value) native "TypedData_SetInt8"; | |
| 524 | |
| 525 int _getUint8(int offsetInBytes) native "TypedData_GetUint8"; | |
| 526 void _setUint8(int offsetInBytes, int value) native "TypedData_SetUint8"; | |
| 527 | |
| 528 int _getInt16(int offsetInBytes) native "TypedData_GetInt16"; | |
| 529 void _setInt16(int offsetInBytes, int value) native "TypedData_SetInt16"; | |
| 530 | |
| 531 int _getUint16(int offsetInBytes) native "TypedData_GetUint16"; | |
| 532 void _setUint16(int offsetInBytes, int value) native "TypedData_SetUint16"; | |
| 533 | |
| 534 int _getInt32(int offsetInBytes) native "TypedData_GetInt32"; | |
| 535 void _setInt32(int offsetInBytes, int value) native "TypedData_SetInt32"; | |
| 536 | |
| 537 int _getUint32(int offsetInBytes) native "TypedData_GetUint32"; | |
| 538 void _setUint32(int offsetInBytes, int value) native "TypedData_SetUint32"; | |
| 539 | |
| 540 int _getInt64(int offsetInBytes) native "TypedData_GetInt64"; | |
| 541 void _setInt64(int offsetInBytes, int value) native "TypedData_SetInt64"; | |
| 542 | |
| 543 int _getUint64(int offsetInBytes) native "TypedData_GetUint64"; | |
| 544 void _setUint64(int offsetInBytes, int value) native "TypedData_SetUint64"; | |
| 545 | |
| 546 double _getFloat32(int offsetInBytes) native "TypedData_GetFloat32"; | |
| 547 void _setFloat32(int offsetInBytes, double value) | |
| 548 native "TypedData_SetFloat32"; | |
| 549 | |
| 550 double _getFloat64(int offsetInBytes) native "TypedData_GetFloat64"; | |
| 551 void _setFloat64(int offsetInBytes, double value) | |
| 552 native "TypedData_SetFloat64"; | |
| 553 | |
| 554 Float32x4 _getFloat32x4(int offsetInBytes) native "TypedData_GetFloat32x4"; | |
| 555 void _setFloat32x4(int offsetInBytes, Float32x4 value) | |
| 556 native "TypedData_SetFloat32x4"; | |
| 557 } | |
| 558 | |
| 559 | |
| 560 class _Int8Array extends _TypedList implements Int8List { | |
| 561 // Factory constructors. | |
| 562 | |
| 563 factory _Int8Array(int length) { | |
| 564 if (length < 0) { | |
| 565 String message = "$length must be greater than 0"; | |
| 566 throw new ArgumentError(message); | |
| 567 } | |
| 568 return _new(length); | |
| 569 } | |
| 570 | |
| 571 factory _Int8Array.view(ByteBuffer buffer, | |
| 572 [int offsetInBytes = 0, int length]) { | |
| 573 if (length == null) { | |
| 574 length = buffer.lengthInBytes - offsetInBytes; | |
| 575 } | |
| 576 return new _Int8ArrayView(buffer, offsetInBytes, length); | |
| 577 } | |
| 578 | |
| 579 | |
| 580 // Method(s) implementing List interface. | |
| 581 | |
| 582 int operator[](int index) { | |
| 583 if (index < 0 || index >= length) { | |
| 584 _throwRangeError(index, length); | |
| 585 } | |
| 586 return _getInt8(index); | |
| 587 } | |
| 588 | |
| 589 void operator[]=(int index, int value) { | |
| 590 if (index < 0 || index >= length) { | |
| 591 _throwRangeError(index, length); | |
| 592 } | |
| 593 _setInt8(index, _toInt8(value)); | |
| 594 } | |
| 595 | |
| 596 Iterator<int> get iterator { | |
| 597 return new _TypedListIterator<int>(this); | |
| 598 } | |
| 599 | |
| 600 | |
| 601 // Method(s) implementing TypedData interface. | |
| 602 | |
| 603 int get elementSizeInBytes { | |
| 604 return Int8List.BYTES_PER_ELEMENT; | |
| 605 } | |
| 606 | |
| 607 | |
| 608 // Internal utility methods. | |
| 609 | |
| 610 _Int8Array _createList(int length) { | |
| 611 return _new(length); | |
| 612 } | |
| 613 | |
| 614 static _Int8Array _new(int length) native "TypedData_Int8Array_new"; | |
| 615 } | |
| 616 | |
| 617 | |
| 618 class _Uint8Array extends _TypedList implements Uint8List { | |
| 619 // Factory constructors. | |
| 620 | |
| 621 factory _Uint8Array(int length) { | |
| 622 if (length < 0) { | |
| 623 String message = "$length must be greater than 0"; | |
| 624 throw new ArgumentError(message); | |
| 625 } | |
| 626 return _new(length); | |
| 627 } | |
| 628 | |
| 629 factory _Uint8Array.view(ByteBuffer buffer, | |
| 630 [int offsetInBytes = 0, int length]) { | |
| 631 if (length == null) { | |
| 632 length = buffer.lengthInBytes - offsetInBytes; | |
| 633 } | |
| 634 return new _Uint8ArrayView(buffer, offsetInBytes, length); | |
| 635 } | |
| 636 | |
| 637 | |
| 638 // Methods implementing List interface. | |
| 639 int operator[](int index) { | |
| 640 if (index < 0 || index >= length) { | |
| 641 _throwRangeError(index, length); | |
| 642 } | |
| 643 return _getUint8(index); | |
| 644 } | |
| 645 | |
| 646 void operator[]=(int index, int value) { | |
| 647 if (index < 0 || index >= length) { | |
| 648 _throwRangeError(index, length); | |
| 649 } | |
| 650 _setUint8(index, _toUint8(value)); | |
| 651 } | |
| 652 | |
| 653 Iterator<int> get iterator { | |
| 654 return new _TypedListIterator<int>(this); | |
| 655 } | |
| 656 | |
| 657 | |
| 658 // Methods implementing TypedData interface. | |
| 659 int get elementSizeInBytes { | |
| 660 return Uint8List.BYTES_PER_ELEMENT; | |
| 661 } | |
| 662 | |
| 663 | |
| 664 // Internal utility methods. | |
| 665 | |
| 666 _Uint8Array _createList(int length) { | |
| 667 return _new(length); | |
| 668 } | |
| 669 | |
| 670 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new"; | |
| 671 } | |
| 672 | |
| 673 | |
| 674 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList { | |
| 675 // Factory constructors. | |
| 676 | |
| 677 factory _Uint8ClampedArray(int length) { | |
| 678 if (length < 0) { | |
| 679 String message = "$length must be greater than 0"; | |
| 680 throw new ArgumentError(message); | |
| 681 } | |
| 682 return _new(length); | |
| 683 } | |
| 684 | |
| 685 factory _Uint8ClampedArray.view(ByteBuffer buffer, | |
| 686 [int offsetInBytes = 0, int length]) { | |
| 687 if (length == null) { | |
| 688 length = buffer.lengthInBytes - offsetInBytes; | |
| 689 } | |
| 690 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | |
| 691 } | |
| 692 | |
| 693 | |
| 694 // Methods implementing List interface. | |
| 695 | |
| 696 int operator[](int index) { | |
| 697 if (index < 0 || index >= length) { | |
| 698 _throwRangeError(index, length); | |
| 699 } | |
| 700 return _getUint8(index); | |
| 701 } | |
| 702 | |
| 703 void operator[]=(int index, int value) { | |
| 704 if (index < 0 || index >= length) { | |
| 705 _throwRangeError(index, length); | |
| 706 } | |
| 707 _setUint8(index, _toClampedUint8(value)); | |
| 708 } | |
| 709 | |
| 710 Iterator<int> get iterator { | |
| 711 return new _TypedListIterator<int>(this); | |
| 712 } | |
| 713 | |
| 714 | |
| 715 // Methods implementing TypedData interface. | |
| 716 int get elementSizeInBytes { | |
| 717 return Uint8List.BYTES_PER_ELEMENT; | |
| 718 } | |
| 719 | |
| 720 | |
| 721 // Internal utility methods. | |
| 722 | |
| 723 _Uint8ClampedArray _createList(int length) { | |
| 724 return _new(length); | |
| 725 } | |
| 726 | |
| 727 static _Uint8ClampedArray _new(int length) | |
| 728 native "TypedData_Uint8ClampedArray_new"; | |
| 729 } | |
| 730 | |
| 731 | |
| 732 class _Int16Array extends _TypedList implements Int16List { | |
| 733 // Factory constructors. | |
| 734 | |
| 735 factory _Int16Array(int length) { | |
| 736 if (length < 0) { | |
| 737 String message = "$length must be greater than 0"; | |
| 738 throw new ArgumentError(message); | |
| 739 } | |
| 740 return _new(length); | |
| 741 } | |
| 742 | |
| 743 factory _Int16Array.view(ByteBuffer buffer, | |
| 744 [int offsetInBytes = 0, int length]) { | |
| 745 if (length == null) { | |
| 746 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 747 Int16List.BYTES_PER_ELEMENT; | |
| 748 } | |
| 749 return new _Int16ArrayView(buffer, offsetInBytes, length); | |
| 750 } | |
| 751 | |
| 752 | |
| 753 // Method(s) implementing List interface. | |
| 754 | |
| 755 int operator[](int index) { | |
| 756 if (index < 0 || index >= length) { | |
| 757 _throwRangeError(index, length); | |
| 758 } | |
| 759 return _getIndexedInt16(index); | |
| 760 } | |
| 761 | |
| 762 void operator[]=(int index, int value) { | |
| 763 if (index < 0 || index >= length) { | |
| 764 _throwRangeError(index, length); | |
| 765 } | |
| 766 _setIndexedInt16(index, _toInt16(value)); | |
| 767 } | |
| 768 | |
| 769 Iterator<int> get iterator { | |
| 770 return new _TypedListIterator<int>(this); | |
| 771 } | |
| 772 | |
| 773 | |
| 774 // Method(s) implementing TypedData interface. | |
| 775 | |
| 776 int get elementSizeInBytes { | |
| 777 return Int16List.BYTES_PER_ELEMENT; | |
| 778 } | |
| 779 | |
| 780 | |
| 781 // Internal utility methods. | |
| 782 | |
| 783 _Int16Array _createList(int length) { | |
| 784 return _new(length); | |
| 785 } | |
| 786 | |
| 787 int _getIndexedInt16(int index) { | |
| 788 return _getInt16(index * Int16List.BYTES_PER_ELEMENT); | |
| 789 } | |
| 790 | |
| 791 void _setIndexedInt16(int index, int value) { | |
| 792 _setInt16(index * Int16List.BYTES_PER_ELEMENT, value); | |
| 793 } | |
| 794 | |
| 795 static _Int16Array _new(int length) native "TypedData_Int16Array_new"; | |
| 796 } | |
| 797 | |
| 798 | |
| 799 class _Uint16Array extends _TypedList implements Uint16List { | |
| 800 // Factory constructors. | |
| 801 | |
| 802 factory _Uint16Array(int length) { | |
| 803 if (length < 0) { | |
| 804 String message = "$length must be greater than 0"; | |
| 805 throw new ArgumentError(message); | |
| 806 } | |
| 807 return _new(length); | |
| 808 } | |
| 809 | |
| 810 factory _Uint16Array.view(ByteBuffer buffer, | |
| 811 [int offsetInBytes = 0, int length]) { | |
| 812 if (length == null) { | |
| 813 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 814 Uint16List.BYTES_PER_ELEMENT; | |
| 815 } | |
| 816 return new _Uint16ArrayView(buffer, offsetInBytes, length); | |
| 817 } | |
| 818 | |
| 819 | |
| 820 // Method(s) implementing the List interface. | |
| 821 | |
| 822 int operator[](int index) { | |
| 823 if (index < 0 || index >= length) { | |
| 824 _throwRangeError(index, length); | |
| 825 } | |
| 826 return _getIndexedUint16(index); | |
| 827 } | |
| 828 | |
| 829 void operator[]=(int index, int value) { | |
| 830 if (index < 0 || index >= length) { | |
| 831 _throwRangeError(index, length); | |
| 832 } | |
| 833 _setIndexedUint16(index, _toUint16(value)); | |
| 834 } | |
| 835 | |
| 836 Iterator<int> get iterator { | |
| 837 return new _TypedListIterator<int>(this); | |
| 838 } | |
| 839 | |
| 840 | |
| 841 // Method(s) implementing the TypedData interface. | |
| 842 | |
| 843 int get elementSizeInBytes { | |
| 844 return Uint16List.BYTES_PER_ELEMENT; | |
| 845 } | |
| 846 | |
| 847 | |
| 848 // Internal utility methods. | |
| 849 | |
| 850 _Uint16Array _createList(int length) { | |
| 851 return _new(length); | |
| 852 } | |
| 853 | |
| 854 int _getIndexedUint16(int index) { | |
| 855 return _getUint16(index * Uint16List.BYTES_PER_ELEMENT); | |
| 856 } | |
| 857 | |
| 858 void _setIndexedUint16(int index, int value) { | |
| 859 _setUint16(index * Uint16List.BYTES_PER_ELEMENT, value); | |
| 860 } | |
| 861 | |
| 862 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new"; | |
| 863 } | |
| 864 | |
| 865 | |
| 866 class _Int32Array extends _TypedList implements Int32List { | |
| 867 // Factory constructors. | |
| 868 | |
| 869 factory _Int32Array(int length) { | |
| 870 if (length < 0) { | |
| 871 String message = "$length must be greater than 0"; | |
| 872 throw new ArgumentError(message); | |
| 873 } | |
| 874 return _new(length); | |
| 875 } | |
| 876 | |
| 877 factory _Int32Array.view(ByteBuffer buffer, | |
| 878 [int offsetInBytes = 0, int length]) { | |
| 879 if (length == null) { | |
| 880 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 881 Int32List.BYTES_PER_ELEMENT; | |
| 882 } | |
| 883 return new _Int32ArrayView(buffer, offsetInBytes, length); | |
| 884 } | |
| 885 | |
| 886 | |
| 887 // Method(s) implementing the List interface. | |
| 888 | |
| 889 int operator[](int index) { | |
| 890 if (index < 0 || index >= length) { | |
| 891 _throwRangeError(index, length); | |
| 892 } | |
| 893 return _getIndexedInt32(index); | |
| 894 } | |
| 895 | |
| 896 void operator[]=(int index, int value) { | |
| 897 if (index < 0 || index >= length) { | |
| 898 _throwRangeError(index, length); | |
| 899 } | |
| 900 _setIndexedInt32(index, _toInt32(value)); | |
| 901 } | |
| 902 | |
| 903 Iterator<int> get iterator { | |
| 904 return new _TypedListIterator<int>(this); | |
| 905 } | |
| 906 | |
| 907 | |
| 908 // Method(s) implementing TypedData interface. | |
| 909 | |
| 910 int get elementSizeInBytes { | |
| 911 return Int32List.BYTES_PER_ELEMENT; | |
| 912 } | |
| 913 | |
| 914 | |
| 915 // Internal utility methods. | |
| 916 | |
| 917 _Int32Array _createList(int length) { | |
| 918 return _new(length); | |
| 919 } | |
| 920 | |
| 921 int _getIndexedInt32(int index) { | |
| 922 return _getInt32(index * Int32List.BYTES_PER_ELEMENT); | |
| 923 } | |
| 924 | |
| 925 void _setIndexedInt32(int index, int value) { | |
| 926 _setInt32(index * Int32List.BYTES_PER_ELEMENT, value); | |
| 927 } | |
| 928 | |
| 929 static _Int32Array _new(int length) native "TypedData_Int32Array_new"; | |
| 930 } | |
| 931 | |
| 932 | |
| 933 class _Uint32Array extends _TypedList implements Uint32List { | |
| 934 // Factory constructors. | |
| 935 | |
| 936 factory _Uint32Array(int length) { | |
| 937 if (length < 0) { | |
| 938 String message = "$length must be greater than 0"; | |
| 939 throw new ArgumentError(message); | |
| 940 } | |
| 941 return _new(length); | |
| 942 } | |
| 943 | |
| 944 factory _Uint32Array.view(ByteBuffer buffer, | |
| 945 [int offsetInBytes = 0, int length]) { | |
| 946 if (length == null) { | |
| 947 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 948 Uint32List.BYTES_PER_ELEMENT; | |
| 949 } | |
| 950 return new _Uint32ArrayView(buffer, offsetInBytes, length); | |
| 951 } | |
| 952 | |
| 953 | |
| 954 // Method(s) implementing the List interface. | |
| 955 | |
| 956 int operator[](int index) { | |
| 957 if (index < 0 || index >= length) { | |
| 958 _throwRangeError(index, length); | |
| 959 } | |
| 960 return _getIndexedUint32(index); | |
| 961 } | |
| 962 | |
| 963 void operator[]=(int index, int value) { | |
| 964 if (index < 0 || index >= length) { | |
| 965 _throwRangeError(index, length); | |
| 966 } | |
| 967 _setIndexedUint32(index, _toUint32(value)); | |
| 968 } | |
| 969 | |
| 970 Iterator<int> get iterator { | |
| 971 return new _TypedListIterator<int>(this); | |
| 972 } | |
| 973 | |
| 974 | |
| 975 // Method(s) implementing the TypedData interface. | |
| 976 | |
| 977 int get elementSizeInBytes { | |
| 978 return Uint32List.BYTES_PER_ELEMENT; | |
| 979 } | |
| 980 | |
| 981 | |
| 982 // Internal utility methods. | |
| 983 | |
| 984 _Uint32Array _createList(int length) { | |
| 985 return _new(length); | |
| 986 } | |
| 987 | |
| 988 int _getIndexedUint32(int index) { | |
| 989 return _getUint32(index * Uint32List.BYTES_PER_ELEMENT); | |
| 990 } | |
| 991 | |
| 992 void _setIndexedUint32(int index, int value) { | |
| 993 _setInt32(index * Uint32List.BYTES_PER_ELEMENT, value); | |
| 994 } | |
| 995 | |
| 996 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new"; | |
| 997 } | |
| 998 | |
| 999 | |
| 1000 class _Int64Array extends _TypedList implements Int64List { | |
| 1001 // Factory constructors. | |
| 1002 | |
| 1003 factory _Int64Array(int length) { | |
| 1004 if (length < 0) { | |
| 1005 String message = "$length must be greater than 0"; | |
| 1006 throw new ArgumentError(message); | |
| 1007 } | |
| 1008 return _new(length); | |
| 1009 } | |
| 1010 | |
| 1011 factory _Int64Array.view(ByteBuffer buffer, | |
| 1012 [int offsetInBytes = 0, int length]) { | |
| 1013 if (length == null) { | |
| 1014 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1015 Int32List.BYTES_PER_ELEMENT; | |
| 1016 } | |
| 1017 return new _Int64ArrayView(buffer, offsetInBytes, length); | |
| 1018 } | |
| 1019 | |
| 1020 | |
| 1021 // Method(s) implementing the List interface. | |
| 1022 | |
| 1023 int operator[](int index) { | |
| 1024 if (index < 0 || index >= length) { | |
| 1025 _throwRangeError(index, length); | |
| 1026 } | |
| 1027 return _getIndexedInt64(index); | |
| 1028 } | |
| 1029 | |
| 1030 void operator[]=(int index, int value) { | |
| 1031 if (index < 0 || index >= length) { | |
| 1032 _throwRangeError(index, length); | |
| 1033 } | |
| 1034 _setIndexedInt64(index, _toInt64(value)); | |
| 1035 } | |
| 1036 | |
| 1037 Iterator<int> get iterator { | |
| 1038 return new _TypedListIterator<int>(this); | |
| 1039 } | |
| 1040 | |
| 1041 | |
| 1042 // Method(s) implementing the TypedData interface. | |
| 1043 | |
| 1044 int get elementSizeInBytes { | |
| 1045 return Int64List.BYTES_PER_ELEMENT; | |
| 1046 } | |
| 1047 | |
| 1048 | |
| 1049 // Internal utility methods. | |
| 1050 | |
| 1051 _Int64Array _createList(int length) { | |
| 1052 return _new(length); | |
| 1053 } | |
| 1054 | |
| 1055 int _getIndexedInt64(int index) { | |
| 1056 return _getInt64(index * Int64List.BYTES_PER_ELEMENT); | |
| 1057 } | |
| 1058 | |
| 1059 void _setIndexedInt64(int index, int value) { | |
| 1060 _setInt64(index * Int64List.BYTES_PER_ELEMENT, value); | |
| 1061 } | |
| 1062 | |
| 1063 static _Int64Array _new(int length) native "TypedData_Int64Array_new"; | |
| 1064 } | |
| 1065 | |
| 1066 | |
| 1067 class _Uint64Array extends _TypedList implements Uint64List { | |
| 1068 // Factory constructors. | |
| 1069 | |
| 1070 factory _Uint64Array(int length) { | |
| 1071 if (length < 0) { | |
| 1072 String message = "$length must be greater than 0"; | |
| 1073 throw new ArgumentError(message); | |
| 1074 } | |
| 1075 return _new(length); | |
| 1076 } | |
| 1077 | |
| 1078 factory _Uint64Array.view(ByteBuffer buffer, | |
| 1079 [int offsetInBytes = 0, int length]) { | |
| 1080 if (length == null) { | |
| 1081 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1082 Uint64List.BYTES_PER_ELEMENT; | |
| 1083 } | |
| 1084 return new _Uint64ArrayView(buffer, offsetInBytes, length); | |
| 1085 } | |
| 1086 | |
| 1087 | |
| 1088 // Method(s) implementing the List interface. | |
| 1089 | |
| 1090 int operator[](int index) { | |
| 1091 if (index < 0 || index >= length) { | |
| 1092 _throwRangeError(index, length); | |
| 1093 } | |
| 1094 return _getIndexedUint64(index); | |
| 1095 } | |
| 1096 | |
| 1097 void operator[]=(int index, int value) { | |
| 1098 if (index < 0 || index >= length) { | |
| 1099 _throwRangeError(index, length); | |
| 1100 } | |
| 1101 _setIndexedUint64(index, _toUint64(value)); | |
| 1102 } | |
| 1103 | |
| 1104 Iterator<int> get iterator { | |
| 1105 return new _TypedListIterator<int>(this); | |
| 1106 } | |
| 1107 | |
| 1108 | |
| 1109 // Method(s) implementing the TypedData interface. | |
| 1110 | |
| 1111 int get elementSizeInBytes { | |
| 1112 return Uint64List.BYTES_PER_ELEMENT; | |
| 1113 } | |
| 1114 | |
| 1115 | |
| 1116 // Internal utility methods. | |
| 1117 | |
| 1118 _Uint64Array _createList(int length) { | |
| 1119 return _new(length); | |
| 1120 } | |
| 1121 | |
| 1122 int _getIndexedUint64(int index) { | |
| 1123 return _getUint64(index * Uint64List.BYTES_PER_ELEMENT); | |
| 1124 } | |
| 1125 | |
| 1126 void _setIndexedUint64(int index, int value) { | |
| 1127 _setUint64(index * Uint64List.BYTES_PER_ELEMENT, value); | |
| 1128 } | |
| 1129 | |
| 1130 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new"; | |
| 1131 } | |
| 1132 | |
| 1133 | |
| 1134 class _Float32Array extends _TypedList implements Float32List { | |
| 1135 // Factory constructors. | |
| 1136 | |
| 1137 factory _Float32Array(int length) { | |
| 1138 if (length < 0) { | |
| 1139 String message = "$length must be greater than 0"; | |
| 1140 throw new ArgumentError(message); | |
| 1141 } | |
| 1142 return _new(length); | |
| 1143 } | |
| 1144 | |
| 1145 factory _Float32Array.view(ByteBuffer buffer, | |
| 1146 [int offsetInBytes = 0, int length]) { | |
| 1147 if (length == null) { | |
| 1148 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1149 Float32List.BYTES_PER_ELEMENT; | |
| 1150 } | |
| 1151 return new _Float32ArrayView(buffer, offsetInBytes, length); | |
| 1152 } | |
| 1153 | |
| 1154 | |
| 1155 // Method(s) implementing the List interface. | |
| 1156 | |
| 1157 double operator[](int index) { | |
| 1158 if (index < 0 || index >= length) { | |
| 1159 _throwRangeError(index, length); | |
| 1160 } | |
| 1161 return _getIndexedFloat32(index); | |
| 1162 } | |
| 1163 | |
| 1164 void operator[]=(int index, double value) { | |
| 1165 if (index < 0 || index >= length) { | |
| 1166 _throwRangeError(index, length); | |
| 1167 } | |
| 1168 _setIndexedFloat32(index, value); | |
| 1169 } | |
| 1170 | |
| 1171 Iterator<double> get iterator { | |
| 1172 return new _TypedListIterator<double>(this); | |
| 1173 } | |
| 1174 | |
| 1175 | |
| 1176 // Method(s) implementing the TypedData interface. | |
| 1177 | |
| 1178 int get elementSizeInBytes { | |
| 1179 return Float32List.BYTES_PER_ELEMENT; | |
| 1180 } | |
| 1181 | |
| 1182 | |
| 1183 // Internal utility methods. | |
| 1184 | |
| 1185 _Float32Array _createList(int length) { | |
| 1186 return _new(length); | |
| 1187 } | |
| 1188 | |
| 1189 double _getIndexedFloat32(int index) { | |
| 1190 return _getFloat32(index * Float32List.BYTES_PER_ELEMENT); | |
| 1191 } | |
| 1192 | |
| 1193 void _setIndexedFloat32(int index, double value) { | |
| 1194 _setFloat32(index * Float32List.BYTES_PER_ELEMENT, value); | |
| 1195 } | |
| 1196 | |
| 1197 static _Float32Array _new(int length) native "TypedData_Float32Array_new"; | |
| 1198 } | |
| 1199 | |
| 1200 | |
| 1201 class _Float64Array extends _TypedList implements Float64List { | |
| 1202 // Factory constructors. | |
| 1203 | |
| 1204 factory _Float64Array(int length) { | |
| 1205 if (length < 0) { | |
| 1206 String message = "$length must be greater than 0"; | |
| 1207 throw new ArgumentError(message); | |
| 1208 } | |
| 1209 return _new(length); | |
| 1210 } | |
| 1211 | |
| 1212 factory _Float64Array.view(ByteBuffer buffer, | |
| 1213 [int offsetInBytes = 0, int length]) { | |
| 1214 if (length == null) { | |
| 1215 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1216 Float64List.BYTES_PER_ELEMENT; | |
| 1217 } | |
| 1218 return new _Float64ArrayView(buffer, offsetInBytes, length); | |
| 1219 } | |
| 1220 | |
| 1221 | |
| 1222 // Method(s) implementing the List interface. | |
| 1223 | |
| 1224 double operator[](int index) { | |
| 1225 if (index < 0 || index >= length) { | |
| 1226 _throwRangeError(index, length); | |
| 1227 } | |
| 1228 return _getIndexedFloat64(index); | |
| 1229 } | |
| 1230 | |
| 1231 void operator[]=(int index, double value) { | |
| 1232 if (index < 0 || index >= length) { | |
| 1233 _throwRangeError(index, length); | |
| 1234 } | |
| 1235 _setIndexedFloat64(index, value); | |
| 1236 } | |
| 1237 | |
| 1238 Iterator<double> get iterator { | |
| 1239 return new _TypedListIterator<double>(this); | |
| 1240 } | |
| 1241 | |
| 1242 | |
| 1243 // Method(s) implementing the TypedData interface. | |
| 1244 | |
| 1245 int get elementSizeInBytes { | |
| 1246 return Float64List.BYTES_PER_ELEMENT; | |
| 1247 } | |
| 1248 | |
| 1249 | |
| 1250 // Internal utility methods. | |
| 1251 | |
| 1252 _Float64Array _createList(int length) { | |
| 1253 return _new(length); | |
| 1254 } | |
| 1255 | |
| 1256 double _getIndexedFloat64(int index) { | |
| 1257 return _getFloat64(index * Float64List.BYTES_PER_ELEMENT); | |
| 1258 } | |
| 1259 | |
| 1260 void _setIndexedFloat64(int index, double value) { | |
| 1261 _setFloat64(index * Float64List.BYTES_PER_ELEMENT, value); | |
| 1262 } | |
| 1263 | |
| 1264 static _Float64Array _new(int length) native "TypedData_Float64Array_new"; | |
| 1265 } | |
| 1266 | |
| 1267 class _Float32x4Array extends _TypedList implements Float32x4List { | |
| 1268 // Factory constructors. | |
| 1269 | |
| 1270 factory _Float32x4Array(int length) { | |
| 1271 if (length < 0) { | |
| 1272 String message = "$length must be greater than 0"; | |
| 1273 throw new ArgumentError(message); | |
| 1274 } | |
| 1275 return _new(length); | |
| 1276 } | |
| 1277 | |
| 1278 factory _Float32x4Array.view(ByteBuffer buffer, | |
| 1279 [int offsetInBytes = 0, int length]) { | |
| 1280 if (length == null) { | |
| 1281 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1282 Float32x4List.BYTES_PER_ELEMENT; | |
| 1283 } | |
| 1284 return new _Float32x4ArrayView(buffer, offsetInBytes, length); | |
| 1285 } | |
| 1286 | |
| 1287 | |
| 1288 Float32x4 operator[](int index) { | |
| 1289 if (index < 0 || index >= length) { | |
| 1290 _throwRangeError(index, length); | |
| 1291 } | |
| 1292 return _getIndexedFloat32x4(index); | |
| 1293 } | |
| 1294 | |
| 1295 void operator[]=(int index, Float32x4 value) { | |
| 1296 if (index < 0 || index >= length) { | |
| 1297 _throwRangeError(index, length); | |
| 1298 } | |
| 1299 _setIndexedFloat32x4(index, value); | |
| 1300 } | |
| 1301 | |
| 1302 Iterator<Float32x4> get iterator { | |
| 1303 return new _TypedListIterator<Float32x4>(this); | |
| 1304 } | |
| 1305 | |
| 1306 | |
| 1307 // Method(s) implementing the TypedData interface. | |
| 1308 | |
| 1309 int get elementSizeInBytes { | |
| 1310 return Float32x4List.BYTES_PER_ELEMENT; | |
| 1311 } | |
| 1312 | |
| 1313 | |
| 1314 // Internal utility methods. | |
| 1315 | |
| 1316 _Float32x4Array _createList(int length) { | |
| 1317 return _new(length); | |
| 1318 } | |
| 1319 | |
| 1320 Float32x4 _getIndexedFloat32x4(int index) { | |
| 1321 return _getFloat32x4(index * Float32x4List.BYTES_PER_ELEMENT); | |
| 1322 } | |
| 1323 | |
| 1324 void _setIndexedFloat32x4(int index, Float32x4 value) { | |
| 1325 _setFloat32x4(index * Float32x4List.BYTES_PER_ELEMENT, value); | |
| 1326 } | |
| 1327 | |
| 1328 static _Float32x4Array _new(int length) native "TypedData_Float32x4Array_new"; | |
| 1329 } | |
| 1330 | |
| 1331 | |
| 1332 class _ExternalInt8Array extends _TypedList implements Int8List { | |
| 1333 // Factory constructors. | |
| 1334 | |
| 1335 factory _ExternalInt8Array(int length) { | |
| 1336 if (length < 0) { | |
| 1337 String message = "$length must be greater than 0"; | |
| 1338 throw new ArgumentError(message); | |
| 1339 } | |
| 1340 return _new(length); | |
| 1341 } | |
| 1342 | |
| 1343 | |
| 1344 // Method(s) implementing the List interface. | |
| 1345 int operator[](int index) { | |
| 1346 if (index < 0 || index >= length) { | |
| 1347 _throwRangeError(index, length); | |
| 1348 } | |
| 1349 return _getInt8(index); | |
| 1350 } | |
| 1351 | |
| 1352 void operator[]=(int index, int value) { | |
| 1353 if (index < 0 || index >= length) { | |
| 1354 _throwRangeError(index, length); | |
| 1355 } | |
| 1356 _setInt8(index, value); | |
| 1357 } | |
| 1358 | |
| 1359 Iterator<int> get iterator { | |
| 1360 return new _TypedListIterator<int>(this); | |
| 1361 } | |
| 1362 | |
| 1363 | |
| 1364 // Method(s) implementing the TypedData interface. | |
| 1365 | |
| 1366 int get elementSizeInBytes { | |
| 1367 return Int8List.BYTES_PER_ELEMENT; | |
| 1368 } | |
| 1369 | |
| 1370 | |
| 1371 // Internal utility methods. | |
| 1372 | |
| 1373 Int8List _createList(int length) { | |
| 1374 return new Int8List(length); | |
| 1375 } | |
| 1376 | |
| 1377 static _ExternalInt8Array _new(int length) native | |
| 1378 "ExternalTypedData_Int8Array_new"; | |
| 1379 } | |
| 1380 | |
| 1381 | |
| 1382 class _ExternalUint8Array extends _TypedList implements Uint8List { | |
| 1383 // Factory constructors. | |
| 1384 | |
| 1385 factory _ExternalUint8Array(int length) { | |
| 1386 if (length < 0) { | |
| 1387 String message = "$length must be greater than 0"; | |
| 1388 throw new ArgumentError(message); | |
| 1389 } | |
| 1390 return _new(length); | |
| 1391 } | |
| 1392 | |
| 1393 | |
| 1394 // Method(s) implementing the List interface. | |
| 1395 | |
| 1396 int operator[](int index) { | |
| 1397 if (index < 0 || index >= length) { | |
| 1398 _throwRangeError(index, length); | |
| 1399 } | |
| 1400 return _getUint8(index); | |
| 1401 } | |
| 1402 | |
| 1403 void operator[]=(int index, int value) { | |
| 1404 if (index < 0 || index >= length) { | |
| 1405 _throwRangeError(index, length); | |
| 1406 } | |
| 1407 _setUint8(index, _toUint8(value)); | |
| 1408 } | |
| 1409 | |
| 1410 Iterator<int> get iterator { | |
| 1411 return new _TypedListIterator<int>(this); | |
| 1412 } | |
| 1413 | |
| 1414 | |
| 1415 // Method(s) implementing the TypedData interface. | |
| 1416 | |
| 1417 int get elementSizeInBytes { | |
| 1418 return Uint8List.BYTES_PER_ELEMENT; | |
| 1419 } | |
| 1420 | |
| 1421 | |
| 1422 // Internal utility methods. | |
| 1423 | |
| 1424 Uint8List _createList(int length) { | |
| 1425 return new Uint8List(length); | |
| 1426 } | |
| 1427 | |
| 1428 static _ExternalUint8Array _new(int length) native | |
| 1429 "ExternalTypedData_Uint8Array_new"; | |
| 1430 } | |
| 1431 | |
| 1432 | |
| 1433 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList
{ | |
| 1434 // Factory constructors. | |
| 1435 | |
| 1436 factory _ExternalUint8ClampedArray(int length) { | |
| 1437 if (length < 0) { | |
| 1438 String message = "$length must be greater than 0"; | |
| 1439 throw new ArgumentError(message); | |
| 1440 } | |
| 1441 return _new(length); | |
| 1442 } | |
| 1443 | |
| 1444 | |
| 1445 // Method(s) implementing the List interface. | |
| 1446 | |
| 1447 int operator[](int index) { | |
| 1448 if (index < 0 || index >= length) { | |
| 1449 _throwRangeError(index, length); | |
| 1450 } | |
| 1451 return _getUint8(index); | |
| 1452 } | |
| 1453 | |
| 1454 void operator[]=(int index, int value) { | |
| 1455 if (index < 0 || index >= length) { | |
| 1456 _throwRangeError(index, length); | |
| 1457 } | |
| 1458 _setUint8(index, _toClampedUint8(value)); | |
| 1459 } | |
| 1460 | |
| 1461 Iterator<int> get iterator { | |
| 1462 return new _TypedListIterator<int>(this); | |
| 1463 } | |
| 1464 | |
| 1465 | |
| 1466 // Method(s) implementing the TypedData interface. | |
| 1467 | |
| 1468 int get elementSizeInBytes { | |
| 1469 return Uint8List.BYTES_PER_ELEMENT; | |
| 1470 } | |
| 1471 | |
| 1472 | |
| 1473 // Internal utility methods. | |
| 1474 | |
| 1475 Uint8ClampedList _createList(int length) { | |
| 1476 return new Uint8ClampedList(length); | |
| 1477 } | |
| 1478 | |
| 1479 static _ExternalUint8ClampedArray _new(int length) native | |
| 1480 "ExternalTypedData_Uint8ClampedArray_new"; | |
| 1481 } | |
| 1482 | |
| 1483 | |
| 1484 class _ExternalInt16Array extends _TypedList implements Int16List { | |
| 1485 // Factory constructors. | |
| 1486 | |
| 1487 factory _ExternalInt16Array(int length) { | |
| 1488 if (length < 0) { | |
| 1489 String message = "$length must be greater than 0"; | |
| 1490 throw new ArgumentError(message); | |
| 1491 } | |
| 1492 return _new(length); | |
| 1493 } | |
| 1494 | |
| 1495 | |
| 1496 // Method(s) implementing the List interface. | |
| 1497 | |
| 1498 int operator[](int index) { | |
| 1499 if (index < 0 || index >= length) { | |
| 1500 _throwRangeError(index, length); | |
| 1501 } | |
| 1502 return _getIndexedInt16(index); | |
| 1503 } | |
| 1504 | |
| 1505 void operator[]=(int index, int value) { | |
| 1506 if (index < 0 || index >= length) { | |
| 1507 _throwRangeError(index, length); | |
| 1508 } | |
| 1509 _setIndexedInt16(index, _toInt16(value)); | |
| 1510 } | |
| 1511 | |
| 1512 Iterator<int> get iterator { | |
| 1513 return new _TypedListIterator<int>(this); | |
| 1514 } | |
| 1515 | |
| 1516 | |
| 1517 // Method(s) implementing the TypedData interface. | |
| 1518 | |
| 1519 int get elementSizeInBytes { | |
| 1520 return Int16List.BYTES_PER_ELEMENT; | |
| 1521 } | |
| 1522 | |
| 1523 | |
| 1524 // Internal utility methods. | |
| 1525 | |
| 1526 Int16List _createList(int length) { | |
| 1527 return new Int16List(length); | |
| 1528 } | |
| 1529 | |
| 1530 int _getIndexedInt16(int index) { | |
| 1531 return _getInt16(index * Int16List.BYTES_PER_ELEMENT); | |
| 1532 } | |
| 1533 | |
| 1534 void _setIndexedInt16(int index, int value) { | |
| 1535 _setInt16(index * Int16List.BYTES_PER_ELEMENT, value); | |
| 1536 } | |
| 1537 | |
| 1538 static _ExternalInt16Array _new(int length) native | |
| 1539 "ExternalTypedData_Int16Array_new"; | |
| 1540 } | |
| 1541 | |
| 1542 | |
| 1543 class _ExternalUint16Array extends _TypedList implements Uint16List { | |
| 1544 // Factory constructors. | |
| 1545 | |
| 1546 factory _ExternalUint16Array(int length) { | |
| 1547 if (length < 0) { | |
| 1548 String message = "$length must be greater than 0"; | |
| 1549 throw new ArgumentError(message); | |
| 1550 } | |
| 1551 return _new(length); | |
| 1552 } | |
| 1553 | |
| 1554 | |
| 1555 // Method(s) implementing the List interface. | |
| 1556 | |
| 1557 int operator[](int index) { | |
| 1558 if (index < 0 || index >= length) { | |
| 1559 _throwRangeError(index, length); | |
| 1560 } | |
| 1561 return _getIndexedUint16(index); | |
| 1562 } | |
| 1563 | |
| 1564 void operator[]=(int index, int value) { | |
| 1565 if (index < 0 || index >= length) { | |
| 1566 _throwRangeError(index, length); | |
| 1567 } | |
| 1568 _setIndexedUint16(index, _toUint16(value)); | |
| 1569 } | |
| 1570 | |
| 1571 Iterator<int> get iterator { | |
| 1572 return new _TypedListIterator<int>(this); | |
| 1573 } | |
| 1574 | |
| 1575 | |
| 1576 // Method(s) implementing the TypedData interface. | |
| 1577 | |
| 1578 int get elementSizeInBytes { | |
| 1579 return Uint16List.BYTES_PER_ELEMENT; | |
| 1580 } | |
| 1581 | |
| 1582 | |
| 1583 // Internal utility methods. | |
| 1584 | |
| 1585 Uint16List _createList(int length) { | |
| 1586 return new Uint16List(length); | |
| 1587 } | |
| 1588 | |
| 1589 int _getIndexedUint16(int index) { | |
| 1590 return _getUint16(index * Uint16List.BYTES_PER_ELEMENT); | |
| 1591 } | |
| 1592 | |
| 1593 void _setIndexedUint16(int index, int value) { | |
| 1594 _setUint16(index * Uint16List.BYTES_PER_ELEMENT, value); | |
| 1595 } | |
| 1596 | |
| 1597 static _ExternalUint16Array _new(int length) native | |
| 1598 "ExternalTypedData_Uint16Array_new"; | |
| 1599 } | |
| 1600 | |
| 1601 | |
| 1602 class _ExternalInt32Array extends _TypedList implements Int32List { | |
| 1603 // Factory constructors. | |
| 1604 | |
| 1605 factory _ExternalInt32Array(int length) { | |
| 1606 if (length < 0) { | |
| 1607 String message = "$length must be greater than 0"; | |
| 1608 throw new ArgumentError(message); | |
| 1609 } | |
| 1610 return _new(length); | |
| 1611 } | |
| 1612 | |
| 1613 | |
| 1614 // Method(s) implementing the List interface. | |
| 1615 | |
| 1616 int operator[](int index) { | |
| 1617 if (index < 0 || index >= length) { | |
| 1618 _throwRangeError(index, length); | |
| 1619 } | |
| 1620 return _getIndexedInt32(index); | |
| 1621 } | |
| 1622 | |
| 1623 void operator[]=(int index, int value) { | |
| 1624 if (index < 0 || index >= length) { | |
| 1625 _throwRangeError(index, length); | |
| 1626 } | |
| 1627 _setIndexedInt32(index, _toInt32(value)); | |
| 1628 } | |
| 1629 | |
| 1630 Iterator<int> get iterator { | |
| 1631 return new _TypedListIterator<int>(this); | |
| 1632 } | |
| 1633 | |
| 1634 | |
| 1635 // Method(s) implementing the TypedData interface. | |
| 1636 | |
| 1637 int get elementSizeInBytes { | |
| 1638 return Int32List.BYTES_PER_ELEMENT; | |
| 1639 } | |
| 1640 | |
| 1641 | |
| 1642 // Internal utility methods. | |
| 1643 | |
| 1644 Int32List _createList(int length) { | |
| 1645 return new Int32List(length); | |
| 1646 } | |
| 1647 | |
| 1648 int _getIndexedInt32(int index) { | |
| 1649 return _getInt32(index * Int32List.BYTES_PER_ELEMENT); | |
| 1650 } | |
| 1651 | |
| 1652 void _setIndexedInt32(int index, int value) { | |
| 1653 _setInt32(index * Int32List.BYTES_PER_ELEMENT, value); | |
| 1654 } | |
| 1655 | |
| 1656 static _ExternalInt32Array _new(int length) native | |
| 1657 "ExternalTypedData_Int32Array_new"; | |
| 1658 } | |
| 1659 | |
| 1660 | |
| 1661 class _ExternalUint32Array extends _TypedList implements Uint32List { | |
| 1662 // Factory constructors. | |
| 1663 | |
| 1664 factory _ExternalUint32Array(int length) { | |
| 1665 if (length < 0) { | |
| 1666 String message = "$length must be greater than 0"; | |
| 1667 throw new ArgumentError(message); | |
| 1668 } | |
| 1669 return _new(length); | |
| 1670 } | |
| 1671 | |
| 1672 | |
| 1673 // Method(s) implementing the List interface. | |
| 1674 | |
| 1675 int operator[](int index) { | |
| 1676 if (index < 0 || index >= length) { | |
| 1677 _throwRangeError(index, length); | |
| 1678 } | |
| 1679 return _getIndexedUint32(index); | |
| 1680 } | |
| 1681 | |
| 1682 void operator[]=(int index, int value) { | |
| 1683 if (index < 0 || index >= length) { | |
| 1684 _throwRangeError(index, length); | |
| 1685 } | |
| 1686 _setIndexedUint32(index, _toUint32(value)); | |
| 1687 } | |
| 1688 | |
| 1689 Iterator<int> get iterator { | |
| 1690 return new _TypedListIterator<int>(this); | |
| 1691 } | |
| 1692 | |
| 1693 | |
| 1694 // Method(s) implementing the TypedData interface. | |
| 1695 | |
| 1696 int get elementSizeInBytes { | |
| 1697 return Uint32List.BYTES_PER_ELEMENT; | |
| 1698 } | |
| 1699 | |
| 1700 | |
| 1701 // Internal utility methods. | |
| 1702 | |
| 1703 Uint32List _createList(int length) { | |
| 1704 return new Uint32List(length); | |
| 1705 } | |
| 1706 | |
| 1707 int _getIndexedUint32(int index) { | |
| 1708 return _getUint32(index * Uint32List.BYTES_PER_ELEMENT); | |
| 1709 } | |
| 1710 | |
| 1711 void _setIndexedUint32(int index, int value) { | |
| 1712 _setInt32(index * Uint32List.BYTES_PER_ELEMENT, value); | |
| 1713 } | |
| 1714 | |
| 1715 static _ExternalUint32Array _new(int length) native | |
| 1716 "ExternalTypedData_Uint32Array_new"; | |
| 1717 } | |
| 1718 | |
| 1719 | |
| 1720 class _ExternalInt64Array extends _TypedList implements Int64List { | |
| 1721 // Factory constructors. | |
| 1722 | |
| 1723 factory _ExternalInt64Array(int length) { | |
| 1724 if (length < 0) { | |
| 1725 String message = "$length must be greater than 0"; | |
| 1726 throw new ArgumentError(message); | |
| 1727 } | |
| 1728 return _new(length); | |
| 1729 } | |
| 1730 | |
| 1731 | |
| 1732 // Method(s) implementing the List interface. | |
| 1733 | |
| 1734 int operator[](int index) { | |
| 1735 if (index < 0 || index >= length) { | |
| 1736 _throwRangeError(index, length); | |
| 1737 } | |
| 1738 return _getIndexedInt64(index); | |
| 1739 } | |
| 1740 | |
| 1741 void operator[]=(int index, int value) { | |
| 1742 if (index < 0 || index >= length) { | |
| 1743 _throwRangeError(index, length); | |
| 1744 } | |
| 1745 _setIndexedInt64(index, _toInt64(value)); | |
| 1746 } | |
| 1747 | |
| 1748 Iterator<int> get iterator { | |
| 1749 return new _TypedListIterator<int>(this); | |
| 1750 } | |
| 1751 | |
| 1752 | |
| 1753 // Method(s) implementing the TypedData interface. | |
| 1754 | |
| 1755 int get elementSizeInBytes { | |
| 1756 return Int64List.BYTES_PER_ELEMENT; | |
| 1757 } | |
| 1758 | |
| 1759 | |
| 1760 // Internal utility methods. | |
| 1761 | |
| 1762 Int64List _createList(int length) { | |
| 1763 return new Int64List(length); | |
| 1764 } | |
| 1765 | |
| 1766 int _getIndexedInt64(int index) { | |
| 1767 return _getInt64(index * Int64List.BYTES_PER_ELEMENT); | |
| 1768 } | |
| 1769 | |
| 1770 void _setIndexedInt64(int index, int value) { | |
| 1771 _setInt64(index * Int64List.BYTES_PER_ELEMENT, value); | |
| 1772 } | |
| 1773 | |
| 1774 static _ExternalInt64Array _new(int length) native | |
| 1775 "ExternalTypedData_Int64Array_new"; | |
| 1776 } | |
| 1777 | |
| 1778 | |
| 1779 class _ExternalUint64Array extends _TypedList implements Uint64List { | |
| 1780 // Factory constructors. | |
| 1781 | |
| 1782 factory _ExternalUint64Array(int length) { | |
| 1783 if (length < 0) { | |
| 1784 String message = "$length must be greater than 0"; | |
| 1785 throw new ArgumentError(message); | |
| 1786 } | |
| 1787 return _new(length); | |
| 1788 } | |
| 1789 | |
| 1790 | |
| 1791 // Method(s) implementing the List interface. | |
| 1792 | |
| 1793 int operator[](int index) { | |
| 1794 if (index < 0 || index >= length) { | |
| 1795 _throwRangeError(index, length); | |
| 1796 } | |
| 1797 return _getIndexedUint64(index); | |
| 1798 } | |
| 1799 | |
| 1800 void operator[]=(int index, int value) { | |
| 1801 if (index < 0 || index >= length) { | |
| 1802 _throwRangeError(index, length); | |
| 1803 } | |
| 1804 _setIndexedUint64(index, _toUint64(value)); | |
| 1805 } | |
| 1806 | |
| 1807 Iterator<int> get iterator { | |
| 1808 return new _TypedListIterator<int>(this); | |
| 1809 } | |
| 1810 | |
| 1811 | |
| 1812 // Method(s) implementing the TypedData interface. | |
| 1813 | |
| 1814 int get elementSizeInBytes { | |
| 1815 return Uint64List.BYTES_PER_ELEMENT; | |
| 1816 } | |
| 1817 | |
| 1818 | |
| 1819 // Internal utility methods. | |
| 1820 | |
| 1821 Uint64List _createList(int length) { | |
| 1822 return new Uint64List(length); | |
| 1823 } | |
| 1824 | |
| 1825 int _getIndexedUint64(int index) { | |
| 1826 return _getUint64(index * Uint64List.BYTES_PER_ELEMENT); | |
| 1827 } | |
| 1828 | |
| 1829 void _setIndexedUint64(int index, int value) { | |
| 1830 _setUint64(index * Uint64List.BYTES_PER_ELEMENT, value); | |
| 1831 } | |
| 1832 | |
| 1833 static _ExternalUint64Array _new(int length) native | |
| 1834 "ExternalTypedData_Uint64Array_new"; | |
| 1835 } | |
| 1836 | |
| 1837 | |
| 1838 class _ExternalFloat32Array extends _TypedList implements Float32List { | |
| 1839 // Factory constructors. | |
| 1840 | |
| 1841 factory _ExternalFloat32Array(int length) { | |
| 1842 if (length < 0) { | |
| 1843 String message = "$length must be greater than 0"; | |
| 1844 throw new ArgumentError(message); | |
| 1845 } | |
| 1846 return _new(length); | |
| 1847 } | |
| 1848 | |
| 1849 | |
| 1850 // Method(s) implementing the List interface. | |
| 1851 | |
| 1852 double operator[](int index) { | |
| 1853 if (index < 0 || index >= length) { | |
| 1854 _throwRangeError(index, length); | |
| 1855 } | |
| 1856 return _getIndexedFloat32(index); | |
| 1857 } | |
| 1858 | |
| 1859 void operator[]=(int index, double value) { | |
| 1860 if (index < 0 || index >= length) { | |
| 1861 _throwRangeError(index, length); | |
| 1862 } | |
| 1863 _setIndexedFloat32(index, value); | |
| 1864 } | |
| 1865 | |
| 1866 Iterator<double> get iterator { | |
| 1867 return new _TypedListIterator<double>(this); | |
| 1868 } | |
| 1869 | |
| 1870 | |
| 1871 // Method(s) implementing the TypedData interface. | |
| 1872 | |
| 1873 int get elementSizeInBytes { | |
| 1874 return Float32List.BYTES_PER_ELEMENT; | |
| 1875 } | |
| 1876 | |
| 1877 | |
| 1878 // Internal utility methods. | |
| 1879 | |
| 1880 Float32List _createList(int length) { | |
| 1881 return new Float32List(length); | |
| 1882 } | |
| 1883 | |
| 1884 double _getIndexedFloat32(int index) { | |
| 1885 return _getFloat32(index * Float32List.BYTES_PER_ELEMENT); | |
| 1886 } | |
| 1887 | |
| 1888 void _setIndexedFloat32(int index, double value) { | |
| 1889 _setFloat32(index * Float32List.BYTES_PER_ELEMENT, value); | |
| 1890 } | |
| 1891 | |
| 1892 static _ExternalFloat32Array _new(int length) native | |
| 1893 "ExternalTypedData_Float32Array_new"; | |
| 1894 } | |
| 1895 | |
| 1896 | |
| 1897 class _ExternalFloat64Array extends _TypedList implements Float64List { | |
| 1898 // Factory constructors. | |
| 1899 | |
| 1900 factory _ExternalFloat64Array(int length) { | |
| 1901 if (length < 0) { | |
| 1902 String message = "$length must be greater than 0"; | |
| 1903 throw new ArgumentError(message); | |
| 1904 } | |
| 1905 return _new(length); | |
| 1906 } | |
| 1907 | |
| 1908 | |
| 1909 // Method(s) implementing the List interface. | |
| 1910 | |
| 1911 double operator[](int index) { | |
| 1912 if (index < 0 || index >= length) { | |
| 1913 _throwRangeError(index, length); | |
| 1914 } | |
| 1915 return _getIndexedFloat64(index); | |
| 1916 } | |
| 1917 | |
| 1918 void operator[]=(int index, double value) { | |
| 1919 if (index < 0 || index >= length) { | |
| 1920 _throwRangeError(index, length); | |
| 1921 } | |
| 1922 _setIndexedFloat64(index, value); | |
| 1923 } | |
| 1924 | |
| 1925 Iterator<double> get iterator { | |
| 1926 return new _TypedListIterator<double>(this); | |
| 1927 } | |
| 1928 | |
| 1929 | |
| 1930 // Method(s) implementing the TypedData interface. | |
| 1931 | |
| 1932 int get elementSizeInBytes { | |
| 1933 return Float64List.BYTES_PER_ELEMENT; | |
| 1934 } | |
| 1935 | |
| 1936 | |
| 1937 // Internal utility methods. | |
| 1938 | |
| 1939 Float64List _createList(int length) { | |
| 1940 return new Float64List(length); | |
| 1941 } | |
| 1942 | |
| 1943 double _getIndexedFloat64(int index) { | |
| 1944 return _getFloat64(index * Float64List.BYTES_PER_ELEMENT); | |
| 1945 } | |
| 1946 | |
| 1947 void _setIndexedFloat64(int index, double value) { | |
| 1948 _setFloat64(index * Float64List.BYTES_PER_ELEMENT, value); | |
| 1949 } | |
| 1950 | |
| 1951 static _ExternalFloat64Array _new(int length) native | |
| 1952 "ExternalTypedData_Float64Array_new"; | |
| 1953 } | |
| 1954 | |
| 1955 | |
| 1956 class _ExternalFloat32x4Array extends _TypedList implements Float32x4List { | |
| 1957 // Factory constructors. | |
| 1958 | |
| 1959 factory _ExternalFloat32x4Array(int length) { | |
| 1960 if (length < 0) { | |
| 1961 String message = "$length must be greater than 0"; | |
| 1962 throw new ArgumentError(message); | |
| 1963 } | |
| 1964 return _new(length); | |
| 1965 } | |
| 1966 | |
| 1967 | |
| 1968 // Method(s) implementing the List interface. | |
| 1969 | |
| 1970 Float32x4 operator[](int index) { | |
| 1971 if (index < 0 || index >= length) { | |
| 1972 _throwRangeError(index, length); | |
| 1973 } | |
| 1974 return _getIndexedFloat32x4(index); | |
| 1975 } | |
| 1976 | |
| 1977 void operator[]=(int index, Float32x4 value) { | |
| 1978 if (index < 0 || index >= length) { | |
| 1979 _throwRangeError(index, length); | |
| 1980 } | |
| 1981 _setIndexedFloat32x4(index, value); | |
| 1982 } | |
| 1983 | |
| 1984 Iterator<Float32x4> get iterator { | |
| 1985 return new _TypedListIterator<Float32x4>(this); | |
| 1986 } | |
| 1987 | |
| 1988 | |
| 1989 // Method(s) implementing the TypedData interface. | |
| 1990 | |
| 1991 int get elementSizeInBytes { | |
| 1992 return Float32x4List.BYTES_PER_ELEMENT; | |
| 1993 } | |
| 1994 | |
| 1995 | |
| 1996 // Internal utility methods. | |
| 1997 | |
| 1998 Float32x4List _createList(int length) { | |
| 1999 return new Float32x4List(length); | |
| 2000 } | |
| 2001 | |
| 2002 Float32x4 _getIndexedFloat32x4(int index) { | |
| 2003 return _getFloat32x4(index * Float32x4List.BYTES_PER_ELEMENT); | |
| 2004 } | |
| 2005 | |
| 2006 void _setIndexedFloat32x4(int index, Float32x4 value) { | |
| 2007 _setFloat32x4(index * Float32x4List.BYTES_PER_ELEMENT, value); | |
| 2008 } | |
| 2009 | |
| 2010 static _ExternalFloat32x4Array _new(int length) native | |
| 2011 "ExternalTypedData_Float32x4Array_new"; | |
| 2012 } | |
| 2013 | |
| 2014 | |
| 2015 class _Float32x4 implements Float32x4 { | |
| 2016 factory _Float32x4(double x, double y, double z, double w) | |
| 2017 native "Float32x4_fromDoubles"; | |
| 2018 factory _Float32x4.zero() native "Float32x4_zero"; | |
| 2019 Float32x4 operator +(Float32x4 other) { | |
| 2020 return _add(other); | |
| 2021 } | |
| 2022 Float32x4 _add(Float32x4 other) native "Float32x4_add"; | |
| 2023 Float32x4 operator -() { | |
| 2024 return _negate(); | |
| 2025 } | |
| 2026 Float32x4 _negate() native "Float32x4_negate"; | |
| 2027 Float32x4 operator -(Float32x4 other) { | |
| 2028 return _sub(other); | |
| 2029 } | |
| 2030 Float32x4 _sub(Float32x4 other) native "Float32x4_sub"; | |
| 2031 Float32x4 operator *(Float32x4 other) { | |
| 2032 return _mul(other); | |
| 2033 } | |
| 2034 Float32x4 _mul(Float32x4 other) native "Float32x4_mul"; | |
| 2035 Float32x4 operator /(Float32x4 other) { | |
| 2036 return _div(other); | |
| 2037 } | |
| 2038 Float32x4 _div(Float32x4 other) native "Float32x4_div"; | |
| 2039 Uint32x4 lessThan(Float32x4 other) { | |
| 2040 return _cmplt(other); | |
| 2041 } | |
| 2042 Uint32x4 _cmplt(Float32x4 other) native "Float32x4_cmplt"; | |
| 2043 Uint32x4 lessThanOrEqual(Float32x4 other) { | |
| 2044 return _cmplte(other); | |
| 2045 } | |
| 2046 Uint32x4 _cmplte(Float32x4 other) native "Float32x4_cmplte"; | |
| 2047 Uint32x4 greaterThan(Float32x4 other) { | |
| 2048 return _cmpgt(other); | |
| 2049 } | |
| 2050 Uint32x4 _cmpgt(Float32x4 other) native "Float32x4_cmpgt"; | |
| 2051 Uint32x4 greaterThanOrEqual(Float32x4 other) { | |
| 2052 return _cmpgte(other); | |
| 2053 } | |
| 2054 Uint32x4 _cmpgte(Float32x4 other) native "Float32x4_cmpgte"; | |
| 2055 Uint32x4 equal(Float32x4 other) { | |
| 2056 return _cmpequal(other); | |
| 2057 } | |
| 2058 Uint32x4 _cmpequal(Float32x4 other) | |
| 2059 native "Float32x4_cmpequal"; | |
| 2060 Uint32x4 notEqual(Float32x4 other) { | |
| 2061 return _cmpnequal(other); | |
| 2062 } | |
| 2063 Uint32x4 _cmpnequal(Float32x4 other) | |
| 2064 native "Float32x4_cmpnequal"; | |
| 2065 Float32x4 scale(double s) { | |
| 2066 return _scale(s); | |
| 2067 } | |
| 2068 Float32x4 _scale(double s) native "Float32x4_scale"; | |
| 2069 Float32x4 abs() { | |
| 2070 return _abs(); | |
| 2071 } | |
| 2072 Float32x4 _abs() native "Float32x4_abs"; | |
| 2073 Float32x4 clamp(Float32x4 lowerLimit, | |
| 2074 Float32x4 upperLimit) { | |
| 2075 return _clamp(lowerLimit, upperLimit); | |
| 2076 } | |
| 2077 Float32x4 _clamp(Float32x4 lowerLimit, | |
| 2078 Float32x4 upperLimit) | |
| 2079 native "Float32x4_clamp"; | |
| 2080 double get x native "Float32x4_getX"; | |
| 2081 double get y native "Float32x4_getY"; | |
| 2082 double get z native "Float32x4_getZ"; | |
| 2083 double get w native "Float32x4_getW"; | |
| 2084 Float32x4 get xxxx native "Float32x4_getXXXX"; | |
| 2085 Float32x4 get yyyy native "Float32x4_getYYYY"; | |
| 2086 Float32x4 get zzzz native "Float32x4_getZZZZ"; | |
| 2087 Float32x4 get wwww native "Float32x4_getWWWW"; | |
| 2088 Float32x4 withX(double x) native "Float32x4_setX"; | |
| 2089 Float32x4 withY(double y) native "Float32x4_setY"; | |
| 2090 Float32x4 withZ(double z) native "Float32x4_setZ"; | |
| 2091 Float32x4 withW(double w) native "Float32x4_setW"; | |
| 2092 Float32x4 min(Float32x4 other) { | |
| 2093 return _min(other); | |
| 2094 } | |
| 2095 Float32x4 _min(Float32x4 other) native "Float32x4_min"; | |
| 2096 Float32x4 max(Float32x4 other) { | |
| 2097 return _max(other); | |
| 2098 } | |
| 2099 Float32x4 _max(Float32x4 other) native "Float32x4_max"; | |
| 2100 Float32x4 sqrt() { | |
| 2101 return _sqrt(); | |
| 2102 } | |
| 2103 Float32x4 _sqrt() native "Float32x4_sqrt"; | |
| 2104 Float32x4 reciprocal() { | |
| 2105 return _reciprocal(); | |
| 2106 } | |
| 2107 Float32x4 _reciprocal() native "Float32x4_reciprocal"; | |
| 2108 Float32x4 reciprocalSqrt() { | |
| 2109 return _reciprocalSqrt(); | |
| 2110 } | |
| 2111 Float32x4 _reciprocalSqrt() native "Float32x4_reciprocalSqrt"; | |
| 2112 Uint32x4 toUint32x4() { | |
| 2113 return _toUint32x4(); | |
| 2114 } | |
| 2115 Uint32x4 _toUint32x4() native "Float32x4_toUint32x4"; | |
| 2116 } | |
| 2117 | |
| 2118 | |
| 2119 class _Uint32x4 implements Uint32x4 { | |
| 2120 factory _Uint32x4(int x, int y, int z, int w) | |
| 2121 native "Uint32x4_fromInts"; | |
| 2122 factory _Uint32x4.bool(bool x, bool y, bool z, bool w) | |
| 2123 native "Uint32x4_fromBools"; | |
| 2124 Uint32x4 operator |(Uint32x4 other) { | |
| 2125 return _or(other); | |
| 2126 } | |
| 2127 Uint32x4 _or(Uint32x4 other) native "Uint32x4_or"; | |
| 2128 Uint32x4 operator &(Uint32x4 other) { | |
| 2129 return _and(other); | |
| 2130 } | |
| 2131 Uint32x4 _and(Uint32x4 other) native "Uint32x4_and"; | |
| 2132 Uint32x4 operator ^(Uint32x4 other) { | |
| 2133 return _xor(other); | |
| 2134 } | |
| 2135 Uint32x4 _xor(Uint32x4 other) native "Uint32x4_xor"; | |
| 2136 int get x native "Uint32x4_getX"; | |
| 2137 int get y native "Uint32x4_getY"; | |
| 2138 int get z native "Uint32x4_getZ"; | |
| 2139 int get w native "Uint32x4_getW"; | |
| 2140 Uint32x4 withX(int x) native "Uint32x4_setX"; | |
| 2141 Uint32x4 withY(int y) native "Uint32x4_setY"; | |
| 2142 Uint32x4 withZ(int z) native "Uint32x4_setZ"; | |
| 2143 Uint32x4 withW(int w) native "Uint32x4_setW"; | |
| 2144 bool get flagX native "Uint32x4_getFlagX"; | |
| 2145 bool get flagY native "Uint32x4_getFlagY"; | |
| 2146 bool get flagZ native "Uint32x4_getFlagZ"; | |
| 2147 bool get flagW native "Uint32x4_getFlagW"; | |
| 2148 Uint32x4 withFlagX(bool x) native "Uint32x4_setFlagX"; | |
| 2149 Uint32x4 withFlagY(bool y) native "Uint32x4_setFlagY"; | |
| 2150 Uint32x4 withFlagZ(bool z) native "Uint32x4_setFlagZ"; | |
| 2151 Uint32x4 withFlagW(bool w) native "Uint32x4_setFlagW"; | |
| 2152 Float32x4 select(Float32x4 trueValue, | |
| 2153 Float32x4 falseValue) { | |
| 2154 return _select(trueValue, falseValue); | |
| 2155 } | |
| 2156 Float32x4 _select(Float32x4 trueValue, | |
| 2157 Float32x4 falseValue) | |
| 2158 native "Uint32x4_select"; | |
| 2159 Float32x4 toFloat32x4() { | |
| 2160 return _toFloat32x4(); | |
| 2161 } | |
| 2162 Float32x4 _toFloat32x4() native "Uint32x4_toFloat32x4"; | |
| 2163 } | |
| 2164 | |
| 2165 class _TypedListIterator<E> implements Iterator<E> { | |
| 2166 final List<E> _array; | |
| 2167 final int _length; | |
| 2168 int _position; | |
| 2169 E _current; | |
| 2170 | |
| 2171 _TypedListIterator(List array) | |
| 2172 : _array = array, _length = array.length, _position = -1 { | |
| 2173 assert(array is _TypedList || array is _TypedListView); | |
| 2174 } | |
| 2175 | |
| 2176 bool moveNext() { | |
| 2177 int nextPosition = _position + 1; | |
| 2178 if (nextPosition < _length) { | |
| 2179 _current = _array[nextPosition]; | |
| 2180 _position = nextPosition; | |
| 2181 return true; | |
| 2182 } | |
| 2183 _position = _length; | |
| 2184 _current = null; | |
| 2185 return false; | |
| 2186 } | |
| 2187 | |
| 2188 E get current => _current; | |
| 2189 } | |
| 2190 | |
| 2191 | |
| 2192 class _TypedListView extends _TypedListBase implements TypedData { | |
| 2193 _TypedListView(ByteBuffer _buffer, int _offset, int _length) | |
| 2194 : _typeddata = _buffer, // This assignment is type safe. | |
| 2195 offsetInBytes = _offset, | |
| 2196 length = _length { | |
| 2197 } | |
| 2198 | |
| 2199 | |
| 2200 // Method(s) implementing the TypedData interface. | |
| 2201 | |
| 2202 int get lengthInBytes { | |
| 2203 return length * elementSizeInBytes; | |
| 2204 } | |
| 2205 | |
| 2206 ByteBuffer get buffer { | |
| 2207 return _typeddata.buffer; | |
| 2208 } | |
| 2209 | |
| 2210 final TypedData _typeddata; | |
| 2211 final int offsetInBytes; | |
| 2212 final int length; | |
| 2213 } | |
| 2214 | |
| 2215 | |
| 2216 class _Int8ArrayView extends _TypedListView implements Int8List { | |
| 2217 // Constructor. | |
| 2218 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2219 : super(buffer, _offsetInBytes, | |
| 2220 _defaultIfNull(_length, | |
| 2221 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2222 Int8List.BYTES_PER_ELEMENT))) { | |
| 2223 _rangeCheck(buffer.lengthInBytes, | |
| 2224 _offsetInBytes, | |
| 2225 length * Int8List.BYTES_PER_ELEMENT); | |
| 2226 } | |
| 2227 | |
| 2228 | |
| 2229 // Method(s) implementing List interface. | |
| 2230 | |
| 2231 int operator[](int index) { | |
| 2232 if (index < 0 || index >= length) { | |
| 2233 _throwRangeError(index, length); | |
| 2234 } | |
| 2235 return _typeddata._getInt8(offsetInBytes + | |
| 2236 (index * Int8List.BYTES_PER_ELEMENT)); | |
| 2237 } | |
| 2238 | |
| 2239 void operator[]=(int index, int value) { | |
| 2240 if (index < 0 || index >= length) { | |
| 2241 _throwRangeError(index, length); | |
| 2242 } | |
| 2243 _typeddata._setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), | |
| 2244 _toInt8(value)); | |
| 2245 } | |
| 2246 | |
| 2247 Iterator<int> get iterator { | |
| 2248 return new _TypedListIterator<int>(this); | |
| 2249 } | |
| 2250 | |
| 2251 | |
| 2252 // Method(s) implementing TypedData interface. | |
| 2253 | |
| 2254 int get elementSizeInBytes { | |
| 2255 return Int8List.BYTES_PER_ELEMENT; | |
| 2256 } | |
| 2257 | |
| 2258 | |
| 2259 // Internal utility methods. | |
| 2260 | |
| 2261 Int8List _createList(int length) { | |
| 2262 return new Int8List(length); | |
| 2263 } | |
| 2264 } | |
| 2265 | |
| 2266 | |
| 2267 class _Uint8ArrayView extends _TypedListView implements Uint8List { | |
| 2268 // Constructor. | |
| 2269 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2270 : super(buffer, _offsetInBytes, | |
| 2271 _defaultIfNull(_length, | |
| 2272 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2273 Uint8List.BYTES_PER_ELEMENT))) { | |
| 2274 _rangeCheck(buffer.lengthInBytes, | |
| 2275 _offsetInBytes, | |
| 2276 length * Uint8List.BYTES_PER_ELEMENT); | |
| 2277 } | |
| 2278 | |
| 2279 | |
| 2280 // Method(s) implementing List interface. | |
| 2281 | |
| 2282 int operator[](int index) { | |
| 2283 if (index < 0 || index >= length) { | |
| 2284 _throwRangeError(index, length); | |
| 2285 } | |
| 2286 return _typeddata._getUint8(offsetInBytes + | |
| 2287 (index * Uint8List.BYTES_PER_ELEMENT)); | |
| 2288 } | |
| 2289 | |
| 2290 void operator[]=(int index, int value) { | |
| 2291 if (index < 0 || index >= length) { | |
| 2292 _throwRangeError(index, length); | |
| 2293 } | |
| 2294 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | |
| 2295 _toUint8(value)); | |
| 2296 } | |
| 2297 | |
| 2298 Iterator<int> get iterator { | |
| 2299 return new _TypedListIterator<int>(this); | |
| 2300 } | |
| 2301 | |
| 2302 | |
| 2303 // Method(s) implementing TypedData interface. | |
| 2304 | |
| 2305 int get elementSizeInBytes { | |
| 2306 return Uint8List.BYTES_PER_ELEMENT; | |
| 2307 } | |
| 2308 | |
| 2309 | |
| 2310 // Internal utility methods. | |
| 2311 | |
| 2312 Uint8List _createList(int length) { | |
| 2313 return new Uint8List(length); | |
| 2314 } | |
| 2315 } | |
| 2316 | |
| 2317 | |
| 2318 class _Uint8ClampedArrayView extends _TypedListView implements Uint8ClampedList
{ | |
| 2319 // Constructor. | |
| 2320 _Uint8ClampedArrayView(ByteBuffer buffer, | |
| 2321 [int _offsetInBytes = 0, int _length]) | |
| 2322 : super(buffer, _offsetInBytes, | |
| 2323 _defaultIfNull(_length, | |
| 2324 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2325 Uint8List.BYTES_PER_ELEMENT))) { | |
| 2326 _rangeCheck(buffer.lengthInBytes, | |
| 2327 offsetInBytes, | |
| 2328 length * Uint8List.BYTES_PER_ELEMENT); | |
| 2329 } | |
| 2330 | |
| 2331 | |
| 2332 // Method(s) implementing List interface. | |
| 2333 | |
| 2334 int operator[](int index) { | |
| 2335 if (index < 0 || index >= length) { | |
| 2336 _throwRangeError(index, length); | |
| 2337 } | |
| 2338 return _typeddata._getUint8(offsetInBytes + | |
| 2339 (index * Uint8List.BYTES_PER_ELEMENT)); | |
| 2340 } | |
| 2341 | |
| 2342 void operator[]=(int index, int value) { | |
| 2343 if (index < 0 || index >= length) { | |
| 2344 _throwRangeError(index, length); | |
| 2345 } | |
| 2346 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | |
| 2347 _toClampedUint8(value)); | |
| 2348 } | |
| 2349 | |
| 2350 Iterator<int> get iterator { | |
| 2351 return new _TypedListIterator<int>(this); | |
| 2352 } | |
| 2353 | |
| 2354 | |
| 2355 // Method(s) implementing TypedData interface. | |
| 2356 | |
| 2357 int get elementSizeInBytes { | |
| 2358 return Uint8List.BYTES_PER_ELEMENT; | |
| 2359 } | |
| 2360 | |
| 2361 | |
| 2362 // Internal utility methods. | |
| 2363 | |
| 2364 Uint8ClampedList _createList(int length) { | |
| 2365 return new Uint8ClampedList(length); | |
| 2366 } | |
| 2367 } | |
| 2368 | |
| 2369 | |
| 2370 class _Int16ArrayView extends _TypedListView implements Int16List { | |
| 2371 // Constructor. | |
| 2372 _Int16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2373 : super(buffer, _offsetInBytes, | |
| 2374 _defaultIfNull(_length, | |
| 2375 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2376 Int16List.BYTES_PER_ELEMENT))) { | |
| 2377 _rangeCheck(buffer.lengthInBytes, | |
| 2378 offsetInBytes, | |
| 2379 length * Int16List.BYTES_PER_ELEMENT); | |
| 2380 } | |
| 2381 | |
| 2382 | |
| 2383 // Method(s) implementing List interface. | |
| 2384 | |
| 2385 int operator[](int index) { | |
| 2386 if (index < 0 || index >= length) { | |
| 2387 _throwRangeError(index, length); | |
| 2388 } | |
| 2389 return _typeddata._getInt16(offsetInBytes + | |
| 2390 (index * Int16List.BYTES_PER_ELEMENT)); | |
| 2391 } | |
| 2392 | |
| 2393 void operator[]=(int index, int value) { | |
| 2394 if (index < 0 || index >= length) { | |
| 2395 _throwRangeError(index, length); | |
| 2396 } | |
| 2397 _typeddata._setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), | |
| 2398 _toInt16(value)); | |
| 2399 } | |
| 2400 | |
| 2401 Iterator<int> get iterator { | |
| 2402 return new _TypedListIterator<int>(this); | |
| 2403 } | |
| 2404 | |
| 2405 | |
| 2406 // Method(s) implementing TypedData interface. | |
| 2407 | |
| 2408 int get elementSizeInBytes { | |
| 2409 return Int16List.BYTES_PER_ELEMENT; | |
| 2410 } | |
| 2411 | |
| 2412 | |
| 2413 // Internal utility methods. | |
| 2414 | |
| 2415 Int16List _createList(int length) { | |
| 2416 return new Int16List(length); | |
| 2417 } | |
| 2418 } | |
| 2419 | |
| 2420 | |
| 2421 class _Uint16ArrayView extends _TypedListView implements Uint16List { | |
| 2422 // Constructor. | |
| 2423 _Uint16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2424 : super(buffer, _offsetInBytes, | |
| 2425 _defaultIfNull(_length, | |
| 2426 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2427 Uint16List.BYTES_PER_ELEMENT))) { | |
| 2428 _rangeCheck(buffer.lengthInBytes, | |
| 2429 offsetInBytes, | |
| 2430 length * Uint16List.BYTES_PER_ELEMENT); | |
| 2431 } | |
| 2432 | |
| 2433 | |
| 2434 // Method(s) implementing List interface. | |
| 2435 | |
| 2436 int operator[](int index) { | |
| 2437 if (index < 0 || index >= length) { | |
| 2438 _throwRangeError(index, length); | |
| 2439 } | |
| 2440 return _typeddata._getUint16(offsetInBytes + | |
| 2441 (index * Uint16List.BYTES_PER_ELEMENT)); | |
| 2442 } | |
| 2443 | |
| 2444 void operator[]=(int index, int value) { | |
| 2445 if (index < 0 || index >= length) { | |
| 2446 _throwRangeError(index, length); | |
| 2447 } | |
| 2448 _typeddata._setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT)
, | |
| 2449 _toUint16(value)); | |
| 2450 } | |
| 2451 | |
| 2452 Iterator<int> get iterator { | |
| 2453 return new _TypedListIterator<int>(this); | |
| 2454 } | |
| 2455 | |
| 2456 | |
| 2457 // Method(s) implementing TypedData interface. | |
| 2458 | |
| 2459 int get elementSizeInBytes { | |
| 2460 return Uint16List.BYTES_PER_ELEMENT; | |
| 2461 } | |
| 2462 | |
| 2463 | |
| 2464 // Internal utility methods. | |
| 2465 | |
| 2466 Uint16List _createList(int length) { | |
| 2467 return new Uint16List(length); | |
| 2468 } | |
| 2469 } | |
| 2470 | |
| 2471 | |
| 2472 class _Int32ArrayView extends _TypedListView implements Int32List { | |
| 2473 // Constructor. | |
| 2474 _Int32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2475 : super(buffer, _offsetInBytes, | |
| 2476 _defaultIfNull(_length, | |
| 2477 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2478 Int32List.BYTES_PER_ELEMENT))) { | |
| 2479 _rangeCheck(buffer.lengthInBytes, | |
| 2480 offsetInBytes, | |
| 2481 length * Int32List.BYTES_PER_ELEMENT); | |
| 2482 } | |
| 2483 | |
| 2484 | |
| 2485 // Method(s) implementing List interface. | |
| 2486 | |
| 2487 int operator[](int index) { | |
| 2488 if (index < 0 || index >= length) { | |
| 2489 _throwRangeError(index, length); | |
| 2490 } | |
| 2491 return _typeddata._getInt32(offsetInBytes + | |
| 2492 (index * Int32List.BYTES_PER_ELEMENT)); | |
| 2493 } | |
| 2494 | |
| 2495 void operator[]=(int index, int value) { | |
| 2496 if (index < 0 || index >= length) { | |
| 2497 _throwRangeError(index, length); | |
| 2498 } | |
| 2499 _typeddata._setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), | |
| 2500 _toInt32(value)); | |
| 2501 } | |
| 2502 | |
| 2503 Iterator<int> get iterator { | |
| 2504 return new _TypedListIterator<int>(this); | |
| 2505 } | |
| 2506 | |
| 2507 | |
| 2508 // Method(s) implementing TypedData interface. | |
| 2509 | |
| 2510 int get elementSizeInBytes { | |
| 2511 return Int32List.BYTES_PER_ELEMENT; | |
| 2512 } | |
| 2513 | |
| 2514 | |
| 2515 // Internal utility methods. | |
| 2516 | |
| 2517 Int32List _createList(int length) { | |
| 2518 return new Int32List(length); | |
| 2519 } | |
| 2520 } | |
| 2521 | |
| 2522 | |
| 2523 class _Uint32ArrayView extends _TypedListView implements Uint32List { | |
| 2524 // Constructor. | |
| 2525 _Uint32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2526 : super(buffer, _offsetInBytes, | |
| 2527 _defaultIfNull(_length, | |
| 2528 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2529 Uint32List.BYTES_PER_ELEMENT))) { | |
| 2530 _rangeCheck(buffer.lengthInBytes, | |
| 2531 offsetInBytes, | |
| 2532 length * Uint32List.BYTES_PER_ELEMENT); | |
| 2533 } | |
| 2534 | |
| 2535 | |
| 2536 // Method(s) implementing List interface. | |
| 2537 | |
| 2538 int operator[](int index) { | |
| 2539 if (index < 0 || index >= length) { | |
| 2540 _throwRangeError(index, length); | |
| 2541 } | |
| 2542 return _typeddata._getUint32(offsetInBytes + | |
| 2543 (index * Uint32List.BYTES_PER_ELEMENT)); | |
| 2544 } | |
| 2545 | |
| 2546 void operator[]=(int index, int value) { | |
| 2547 if (index < 0 || index >= length) { | |
| 2548 _throwRangeError(index, length); | |
| 2549 } | |
| 2550 _typeddata._setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT)
, | |
| 2551 _toUint32(value)); | |
| 2552 } | |
| 2553 | |
| 2554 Iterator<int> get iterator { | |
| 2555 return new _TypedListIterator<int>(this); | |
| 2556 } | |
| 2557 | |
| 2558 | |
| 2559 // Method(s) implementing TypedData interface. | |
| 2560 | |
| 2561 int get elementSizeInBytes { | |
| 2562 return Uint32List.BYTES_PER_ELEMENT; | |
| 2563 } | |
| 2564 | |
| 2565 | |
| 2566 // Internal utility methods. | |
| 2567 | |
| 2568 Uint32List _createList(int length) { | |
| 2569 return new Uint32List(length); | |
| 2570 } | |
| 2571 } | |
| 2572 | |
| 2573 | |
| 2574 class _Int64ArrayView extends _TypedListView implements Int64List { | |
| 2575 // Constructor. | |
| 2576 _Int64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2577 : super(buffer, _offsetInBytes, | |
| 2578 _defaultIfNull(_length, | |
| 2579 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2580 Int64List.BYTES_PER_ELEMENT))) { | |
| 2581 _rangeCheck(buffer.lengthInBytes, | |
| 2582 offsetInBytes, | |
| 2583 length * Int64List.BYTES_PER_ELEMENT); | |
| 2584 } | |
| 2585 | |
| 2586 | |
| 2587 // Method(s) implementing List interface. | |
| 2588 | |
| 2589 int operator[](int index) { | |
| 2590 if (index < 0 || index >= length) { | |
| 2591 _throwRangeError(index, length); | |
| 2592 } | |
| 2593 return _typeddata._getInt64(offsetInBytes + | |
| 2594 (index * Int64List.BYTES_PER_ELEMENT)); | |
| 2595 } | |
| 2596 | |
| 2597 void operator[]=(int index, int value) { | |
| 2598 if (index < 0 || index >= length) { | |
| 2599 _throwRangeError(index, length); | |
| 2600 } | |
| 2601 _typeddata._setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), | |
| 2602 _toInt64(value)); | |
| 2603 } | |
| 2604 | |
| 2605 Iterator<int> get iterator { | |
| 2606 return new _TypedListIterator<int>(this); | |
| 2607 } | |
| 2608 | |
| 2609 | |
| 2610 // Method(s) implementing TypedData interface. | |
| 2611 | |
| 2612 int get elementSizeInBytes { | |
| 2613 return Int64List.BYTES_PER_ELEMENT; | |
| 2614 } | |
| 2615 | |
| 2616 | |
| 2617 // Internal utility methods. | |
| 2618 | |
| 2619 Int64List _createList(int length) { | |
| 2620 return new Int64List(length); | |
| 2621 } | |
| 2622 } | |
| 2623 | |
| 2624 | |
| 2625 class _Uint64ArrayView extends _TypedListView implements Uint64List { | |
| 2626 // Constructor. | |
| 2627 _Uint64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2628 : super(buffer, _offsetInBytes, | |
| 2629 _defaultIfNull(_length, | |
| 2630 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2631 Uint64List.BYTES_PER_ELEMENT))) { | |
| 2632 _rangeCheck(buffer.lengthInBytes, | |
| 2633 offsetInBytes, | |
| 2634 length * Uint64List.BYTES_PER_ELEMENT); | |
| 2635 } | |
| 2636 | |
| 2637 | |
| 2638 // Method(s) implementing List interface. | |
| 2639 | |
| 2640 int operator[](int index) { | |
| 2641 if (index < 0 || index >= length) { | |
| 2642 _throwRangeError(index, length); | |
| 2643 } | |
| 2644 return _typeddata._getUint64(offsetInBytes + | |
| 2645 (index * Uint64List.BYTES_PER_ELEMENT)); | |
| 2646 } | |
| 2647 | |
| 2648 void operator[]=(int index, int value) { | |
| 2649 if (index < 0 || index >= length) { | |
| 2650 _throwRangeError(index, length); | |
| 2651 } | |
| 2652 _typeddata._setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT)
, | |
| 2653 _toUint64(value)); | |
| 2654 } | |
| 2655 | |
| 2656 Iterator<int> get iterator { | |
| 2657 return new _TypedListIterator<int>(this); | |
| 2658 } | |
| 2659 | |
| 2660 | |
| 2661 // Method(s) implementing TypedData interface. | |
| 2662 | |
| 2663 int get elementSizeInBytes { | |
| 2664 return Uint64List.BYTES_PER_ELEMENT; | |
| 2665 } | |
| 2666 | |
| 2667 | |
| 2668 // Internal utility methods. | |
| 2669 | |
| 2670 Uint64List _createList(int length) { | |
| 2671 return new Uint64List(length); | |
| 2672 } | |
| 2673 } | |
| 2674 | |
| 2675 | |
| 2676 class _Float32ArrayView extends _TypedListView implements Float32List { | |
| 2677 // Constructor. | |
| 2678 _Float32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2679 : super(buffer, _offsetInBytes, | |
| 2680 _defaultIfNull(_length, | |
| 2681 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2682 Float32List.BYTES_PER_ELEMENT))) { | |
| 2683 _rangeCheck(buffer.lengthInBytes, | |
| 2684 offsetInBytes, | |
| 2685 length * Float32List.BYTES_PER_ELEMENT); | |
| 2686 } | |
| 2687 | |
| 2688 | |
| 2689 // Method(s) implementing List interface. | |
| 2690 | |
| 2691 double operator[](int index) { | |
| 2692 if (index < 0 || index >= length) { | |
| 2693 _throwRangeError(index, length); | |
| 2694 } | |
| 2695 return _typeddata._getFloat32(offsetInBytes + | |
| 2696 (index * Float32List.BYTES_PER_ELEMENT)); | |
| 2697 } | |
| 2698 | |
| 2699 void operator[]=(int index, double value) { | |
| 2700 if (index < 0 || index >= length) { | |
| 2701 _throwRangeError(index, length); | |
| 2702 } | |
| 2703 _typeddata._setFloat32(offsetInBytes + | |
| 2704 (index * Float32List.BYTES_PER_ELEMENT), value); | |
| 2705 } | |
| 2706 | |
| 2707 Iterator<double> get iterator { | |
| 2708 return new _TypedListIterator<double>(this); | |
| 2709 } | |
| 2710 | |
| 2711 | |
| 2712 // Method(s) implementing TypedData interface. | |
| 2713 | |
| 2714 int get elementSizeInBytes { | |
| 2715 return Float32List.BYTES_PER_ELEMENT; | |
| 2716 } | |
| 2717 | |
| 2718 | |
| 2719 // Internal utility methods. | |
| 2720 | |
| 2721 Float32List _createList(int length) { | |
| 2722 return new Float32List(length); | |
| 2723 } | |
| 2724 } | |
| 2725 | |
| 2726 | |
| 2727 class _Float64ArrayView extends _TypedListView implements Float64List { | |
| 2728 // Constructor. | |
| 2729 _Float64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2730 : super(buffer, _offsetInBytes, | |
| 2731 _defaultIfNull(_length, | |
| 2732 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2733 Float64List.BYTES_PER_ELEMENT))) { | |
| 2734 _rangeCheck(buffer.lengthInBytes, | |
| 2735 offsetInBytes, | |
| 2736 length * Float64List.BYTES_PER_ELEMENT); | |
| 2737 } | |
| 2738 | |
| 2739 | |
| 2740 // Method(s) implementing List interface. | |
| 2741 | |
| 2742 double operator[](int index) { | |
| 2743 if (index < 0 || index >= length) { | |
| 2744 _throwRangeError(index, length); | |
| 2745 } | |
| 2746 return _typeddata._getFloat64(offsetInBytes + | |
| 2747 (index * Float64List.BYTES_PER_ELEMENT)); | |
| 2748 } | |
| 2749 | |
| 2750 void operator[]=(int index, double value) { | |
| 2751 if (index < 0 || index >= length) { | |
| 2752 _throwRangeError(index, length); | |
| 2753 } | |
| 2754 _typeddata._setFloat64(offsetInBytes + | |
| 2755 (index * Float64List.BYTES_PER_ELEMENT), value); | |
| 2756 } | |
| 2757 | |
| 2758 Iterator<double> get iterator { | |
| 2759 return new _TypedListIterator<double>(this); | |
| 2760 } | |
| 2761 | |
| 2762 | |
| 2763 // Method(s) implementing TypedData interface. | |
| 2764 | |
| 2765 int get elementSizeInBytes { | |
| 2766 return Float64List.BYTES_PER_ELEMENT; | |
| 2767 } | |
| 2768 | |
| 2769 | |
| 2770 // Internal utility methods. | |
| 2771 | |
| 2772 Float64List _createList(int length) { | |
| 2773 return new Float64List(length); | |
| 2774 } | |
| 2775 } | |
| 2776 | |
| 2777 | |
| 2778 class _Float32x4ArrayView extends _TypedListView implements Float32x4List { | |
| 2779 // Constructor. | |
| 2780 _Float32x4ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2781 : super(buffer, _offsetInBytes, | |
| 2782 _defaultIfNull(_length, | |
| 2783 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2784 Float32x4List.BYTES_PER_ELEMENT))) { | |
| 2785 _rangeCheck(buffer.lengthInBytes, | |
| 2786 offsetInBytes, | |
| 2787 length * Float32x4List.BYTES_PER_ELEMENT); | |
| 2788 } | |
| 2789 | |
| 2790 | |
| 2791 // Method(s) implementing List interface. | |
| 2792 | |
| 2793 Float32x4 operator[](int index) { | |
| 2794 if (index < 0 || index >= length) { | |
| 2795 _throwRangeError(index, length); | |
| 2796 } | |
| 2797 return _typeddata._getFloat32x4(offsetInBytes + | |
| 2798 (index * Float32x4List.BYTES_PER_ELEMENT)); | |
| 2799 } | |
| 2800 | |
| 2801 void operator[]=(int index, Float32x4 value) { | |
| 2802 if (index < 0 || index >= length) { | |
| 2803 _throwRangeError(index, length); | |
| 2804 } | |
| 2805 _typeddata._setFloat32x4(offsetInBytes + | |
| 2806 (index * Float32x4List.BYTES_PER_ELEMENT), value); | |
| 2807 } | |
| 2808 | |
| 2809 Iterator<Float32x4> get iterator { | |
| 2810 return new _TypedListIterator<Float32x4>(this); | |
| 2811 } | |
| 2812 | |
| 2813 | |
| 2814 // Method(s) implementing TypedData interface. | |
| 2815 | |
| 2816 int get elementSizeInBytes { | |
| 2817 return Float32x4List.BYTES_PER_ELEMENT; | |
| 2818 } | |
| 2819 | |
| 2820 | |
| 2821 // Internal utility methods. | |
| 2822 | |
| 2823 Float32x4List _createList(int length) { | |
| 2824 return new Float32x4List(length); | |
| 2825 } | |
| 2826 } | |
| 2827 | |
| 2828 | |
| 2829 class _ByteDataView implements ByteData { | |
| 2830 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes) | |
| 2831 : _typeddata = _buffer, // _buffer is guaranteed to be a TypedData here. | |
| 2832 _offset = _offsetInBytes, | |
| 2833 length = _lengthInBytes { | |
| 2834 _rangeCheck(_buffer.lengthInBytes, _offset, length); | |
| 2835 } | |
| 2836 | |
| 2837 | |
| 2838 // Method(s) implementing TypedData interface. | |
| 2839 | |
| 2840 ByteBuffer get buffer { | |
| 2841 return _typeddata.buffer; | |
| 2842 } | |
| 2843 | |
| 2844 int get lengthInBytes { | |
| 2845 return length; | |
| 2846 } | |
| 2847 | |
| 2848 int get offsetInBytes { | |
| 2849 return _offset; | |
| 2850 } | |
| 2851 | |
| 2852 // Method(s) implementing ByteData interface. | |
| 2853 | |
| 2854 int getInt8(int byteOffset) { | |
| 2855 if (byteOffset < 0 || byteOffset >= length) { | |
| 2856 _throwRangeError(byteOffset, length); | |
| 2857 } | |
| 2858 return _typeddata._getInt8(_offset + byteOffset); | |
| 2859 } | |
| 2860 void setInt8(int byteOffset, int value) { | |
| 2861 if (byteOffset < 0 || byteOffset >= length) { | |
| 2862 _throwRangeError(byteOffset, length); | |
| 2863 } | |
| 2864 _typeddata._setInt8(_offset + byteOffset, _toInt8(value)); | |
| 2865 } | |
| 2866 | |
| 2867 int getUint8(int byteOffset) { | |
| 2868 if (byteOffset < 0 || byteOffset >= length) { | |
| 2869 _throwRangeError(byteOffset, length); | |
| 2870 } | |
| 2871 return _typeddata._getUint8(_offset + byteOffset); | |
| 2872 } | |
| 2873 void setUint8(int byteOffset, int value) { | |
| 2874 if (byteOffset < 0 || byteOffset >= length) { | |
| 2875 _throwRangeError(byteOffset, length); | |
| 2876 } | |
| 2877 _typeddata._setUint8(_offset + byteOffset, _toUint8(value)); | |
| 2878 } | |
| 2879 | |
| 2880 int getInt16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2881 if (byteOffset < 0 || byteOffset >= length) { | |
| 2882 _throwRangeError(byteOffset, length); | |
| 2883 } | |
| 2884 var result = _typeddata._getInt16(_offset + byteOffset); | |
| 2885 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2886 return result; | |
| 2887 } | |
| 2888 return _toEndianInt16(result, endian._littleEndian); | |
| 2889 } | |
| 2890 void setInt16(int byteOffset, | |
| 2891 int value, | |
| 2892 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2893 if (byteOffset < 0 || byteOffset >= length) { | |
| 2894 _throwRangeError(byteOffset, length); | |
| 2895 } | |
| 2896 var set_value = _toInt16(value); | |
| 2897 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2898 set_value = _toEndianInt16(set_value, endian._littleEndian); | |
| 2899 } | |
| 2900 _typeddata._setInt16(_offset + byteOffset, set_value); | |
| 2901 } | |
| 2902 | |
| 2903 int getUint16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2904 if (byteOffset < 0 || byteOffset >= length) { | |
| 2905 _throwRangeError(byteOffset, length); | |
| 2906 } | |
| 2907 var result = _typeddata._getUint16(_offset + byteOffset); | |
| 2908 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2909 return result; | |
| 2910 } | |
| 2911 return _toEndianUint16(result, endian._littleEndian); | |
| 2912 } | |
| 2913 void setUint16(int byteOffset, | |
| 2914 int value, | |
| 2915 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2916 if (byteOffset < 0 || byteOffset >= length) { | |
| 2917 _throwRangeError(byteOffset, length); | |
| 2918 } | |
| 2919 var set_value = _toUint16(value); | |
| 2920 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2921 set_value = _toEndianUint16(set_value, endian._littleEndian); | |
| 2922 } | |
| 2923 _typeddata._setUint16(_offset + byteOffset, set_value); | |
| 2924 } | |
| 2925 | |
| 2926 int getInt32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2927 if (byteOffset < 0 || byteOffset >= length) { | |
| 2928 _throwRangeError(byteOffset, length); | |
| 2929 } | |
| 2930 var result = _typeddata._getInt32(_offset + byteOffset); | |
| 2931 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2932 return result; | |
| 2933 } | |
| 2934 return _toEndianInt32(result, endian._littleEndian); | |
| 2935 } | |
| 2936 void setInt32(int byteOffset, | |
| 2937 int value, | |
| 2938 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2939 if (byteOffset < 0 || byteOffset >= length) { | |
| 2940 _throwRangeError(byteOffset, length); | |
| 2941 } | |
| 2942 var set_value = _toInt32(value); | |
| 2943 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2944 set_value = _toEndianInt32(set_value, endian._littleEndian); | |
| 2945 } | |
| 2946 _typeddata._setInt32(_offset + byteOffset, set_value); | |
| 2947 } | |
| 2948 | |
| 2949 int getUint32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2950 if (byteOffset < 0 || byteOffset >= length) { | |
| 2951 _throwRangeError(byteOffset, length); | |
| 2952 } | |
| 2953 var result = _typeddata._getUint32(_offset + byteOffset); | |
| 2954 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2955 return result; | |
| 2956 } | |
| 2957 return _toEndianUint32(result, endian._littleEndian); | |
| 2958 } | |
| 2959 void setUint32(int byteOffset, | |
| 2960 int value, | |
| 2961 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2962 if (byteOffset < 0 || byteOffset >= length) { | |
| 2963 _throwRangeError(byteOffset, length); | |
| 2964 } | |
| 2965 var set_value = _toUint32(value); | |
| 2966 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2967 set_value = _toEndianUint32(set_value, endian._littleEndian); | |
| 2968 } | |
| 2969 _typeddata._setUint32(_offset + byteOffset, set_value); | |
| 2970 } | |
| 2971 | |
| 2972 int getInt64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2973 if (byteOffset < 0 || byteOffset >= length) { | |
| 2974 _throwRangeError(byteOffset, length); | |
| 2975 } | |
| 2976 var result = _typeddata._getInt64(_offset + byteOffset); | |
| 2977 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2978 return result; | |
| 2979 } | |
| 2980 return _toEndianInt64(result, endian._littleEndian); | |
| 2981 } | |
| 2982 void setInt64(int byteOffset, | |
| 2983 int value, | |
| 2984 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2985 if (byteOffset < 0 || byteOffset >= length) { | |
| 2986 _throwRangeError(byteOffset, length); | |
| 2987 } | |
| 2988 var set_value = _toInt64(value); | |
| 2989 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 2990 set_value = _toEndianInt64(set_value, endian._littleEndian); | |
| 2991 } | |
| 2992 _typeddata._setInt64(_offset + byteOffset, set_value); | |
| 2993 } | |
| 2994 | |
| 2995 int getUint64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 2996 if (byteOffset < 0 || byteOffset >= length) { | |
| 2997 _throwRangeError(byteOffset, length); | |
| 2998 } | |
| 2999 var result = _typeddata._getUint64(_offset + byteOffset); | |
| 3000 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3001 return result; | |
| 3002 } | |
| 3003 return _toEndianUint64(result, endian._littleEndian); | |
| 3004 } | |
| 3005 void setUint64(int byteOffset, | |
| 3006 int value, | |
| 3007 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3008 if (byteOffset < 0 || byteOffset >= length) { | |
| 3009 _throwRangeError(byteOffset, length); | |
| 3010 } | |
| 3011 var set_value = _toUint64(value); | |
| 3012 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3013 set_value = _toEndianUint64(set_value, endian._littleEndian); | |
| 3014 } | |
| 3015 _typeddata._setUint64(_offset + byteOffset, set_value); | |
| 3016 } | |
| 3017 | |
| 3018 double getFloat32(int byteOffset, | |
| 3019 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3020 if (byteOffset < 0 || byteOffset >= length) { | |
| 3021 _throwRangeError(byteOffset, length); | |
| 3022 } | |
| 3023 var result = _typeddata._getFloat32(_offset + byteOffset); | |
| 3024 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3025 return result; | |
| 3026 } | |
| 3027 return _toEndianFloat32(result, endian._littleEndian); | |
| 3028 } | |
| 3029 void setFloat32(int byteOffset, | |
| 3030 double value, | |
| 3031 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3032 if (byteOffset < 0 || byteOffset >= length) { | |
| 3033 _throwRangeError(byteOffset, length); | |
| 3034 } | |
| 3035 var set_value = value; | |
| 3036 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3037 set_value = _toEndianFloat32(set_value, endian._littleEndian); | |
| 3038 } | |
| 3039 _typeddata._setFloat32(_offset + byteOffset, set_value); | |
| 3040 } | |
| 3041 | |
| 3042 double getFloat64(int byteOffset, | |
| 3043 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3044 if (byteOffset < 0 || byteOffset >= length) { | |
| 3045 _throwRangeError(byteOffset, length); | |
| 3046 } | |
| 3047 var result = _typeddata._getFloat64(_offset + byteOffset); | |
| 3048 if (identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3049 return result; | |
| 3050 } | |
| 3051 return _toEndianFloat64(result, endian._littleEndian); | |
| 3052 } | |
| 3053 void setFloat64(int byteOffset, | |
| 3054 double value, | |
| 3055 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3056 if (byteOffset < 0 || byteOffset >= length) { | |
| 3057 _throwRangeError(byteOffset, length); | |
| 3058 } | |
| 3059 var set_value = value; | |
| 3060 if (!identical(endian, Endianness.HOST_ENDIAN)) { | |
| 3061 set_value = _toEndianFloat64(set_value, endian._littleEndian); | |
| 3062 } | |
| 3063 _typeddata._setFloat64(_offset + byteOffset, set_value); | |
| 3064 } | |
| 3065 | |
| 3066 Float32x4 getFloat32x4(int byteOffset, | |
| 3067 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3068 if (byteOffset < 0 || byteOffset >= length) { | |
| 3069 _throwRangeError(byteOffset, length); | |
| 3070 } | |
| 3071 // TODO(johnmccutchan) : Need to resolve this for endianity. | |
| 3072 return _typeddata._getFloat32x4(_offset + byteOffset); | |
| 3073 } | |
| 3074 void setFloat32x4(int byteOffset, | |
| 3075 Float32x4 value, | |
| 3076 [Endianness endian = Endianness.BIG_ENDIAN]) { | |
| 3077 if (byteOffset < 0 || byteOffset >= length) { | |
| 3078 _throwRangeError(byteOffset, length); | |
| 3079 } | |
| 3080 // TODO(johnmccutchan) : Need to resolve this for endianity. | |
| 3081 _typeddata._setFloat32x4(_offset + byteOffset, value); | |
| 3082 | |
| 3083 } | |
| 3084 | |
| 3085 | |
| 3086 // Internal utility methods. | |
| 3087 | |
| 3088 static int _toEndianInt16(int host_value, bool little_endian) | |
| 3089 native "ByteData_ToEndianInt16"; | |
| 3090 static int _toEndianUint16(int host_value, bool little_endian) | |
| 3091 native "ByteData_ToEndianUint16"; | |
| 3092 static int _toEndianInt32(int host_value, bool little_endian) | |
| 3093 native "ByteData_ToEndianInt32"; | |
| 3094 static int _toEndianUint32(int host_value, bool little_endian) | |
| 3095 native "ByteData_ToEndianUint32"; | |
| 3096 static int _toEndianInt64(int host_value, bool little_endian) | |
| 3097 native "ByteData_ToEndianInt64"; | |
| 3098 static int _toEndianUint64(int host_value, bool little_endian) | |
| 3099 native "ByteData_ToEndianUint64"; | |
| 3100 static double _toEndianFloat32(double host_value, bool little_endian) | |
| 3101 native "ByteData_ToEndianFloat32"; | |
| 3102 static double _toEndianFloat64(double host_value, bool little_endian) | |
| 3103 native "ByteData_ToEndianFloat64"; | |
| 3104 | |
| 3105 | |
| 3106 final TypedData _typeddata; | |
| 3107 final int _offset; | |
| 3108 final int length; | |
| 3109 } | |
| 3110 | |
| 3111 | |
| 3112 // Top level utility methods. | |
| 3113 int _toInt(int value, int mask) { | |
| 3114 value &= mask; | |
| 3115 if (value > (mask >> 1)) value -= mask + 1; | |
| 3116 return value; | |
| 3117 } | |
| 3118 | |
| 3119 | |
| 3120 int _toInt8(int value) { | |
| 3121 return _toInt(value, 0xFF); | |
| 3122 } | |
| 3123 | |
| 3124 | |
| 3125 int _toUint8(int value) { | |
| 3126 return value & 0xFF; | |
| 3127 } | |
| 3128 | |
| 3129 | |
| 3130 int _toClampedUint8(int value) { | |
| 3131 if (value < 0) return 0; | |
| 3132 if (value > 0xFF) return 0xFF; | |
| 3133 return value; | |
| 3134 } | |
| 3135 | |
| 3136 | |
| 3137 int _toInt16(int value) { | |
| 3138 return _toInt(value, 0xFFFF); | |
| 3139 } | |
| 3140 | |
| 3141 | |
| 3142 int _toUint16(int value) { | |
| 3143 return value & 0xFFFF; | |
| 3144 } | |
| 3145 | |
| 3146 | |
| 3147 int _toInt32(int value) { | |
| 3148 return _toInt(value, 0xFFFFFFFF); | |
| 3149 } | |
| 3150 | |
| 3151 | |
| 3152 int _toUint32(int value) { | |
| 3153 return value & 0xFFFFFFFF; | |
| 3154 } | |
| 3155 | |
| 3156 | |
| 3157 int _toInt64(int value) { | |
| 3158 return _toInt(value, 0xFFFFFFFFFFFFFFFF); | |
| 3159 } | |
| 3160 | |
| 3161 | |
| 3162 int _toUint64(int value) { | |
| 3163 return value & 0xFFFFFFFFFFFFFFFF; | |
| 3164 } | |
| 3165 | |
| 3166 | |
| 3167 void _rangeCheck(int listLength, int start, int length) { | |
| 3168 if (length < 0) { | |
| 3169 throw new RangeError.value(length); | |
| 3170 } | |
| 3171 if (start < 0) { | |
| 3172 throw new RangeError.value(start); | |
| 3173 } | |
| 3174 if (start + length > listLength) { | |
| 3175 throw new RangeError.value(start + length); | |
| 3176 } | |
| 3177 } | |
| 3178 | |
| 3179 | |
| 3180 int _defaultIfNull(object, value) { | |
| 3181 if (object == null) { | |
| 3182 return value; | |
| 3183 } | |
| 3184 return object; | |
| 3185 } | |
| 3186 | |
| 3187 | |
| 3188 void _throwRangeError(int index, int length) { | |
| 3189 String message = "$index must be in the range [0..$length)"; | |
| 3190 throw new RangeError(message); | |
| 3191 } | |
| OLD | NEW |