| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // patch classes for Int8List ..... Float64List and ByteData implementations. | 5 // patch classes for Int8List ..... Float64List and ByteData implementations. |
| 6 | 6 |
| 7 patch class Int8List { | 7 patch class Int8List { |
| 8 /* patch */ factory Int8List(int length) { | 8 /* patch */ factory Int8List(int length) { |
| 9 return new _Int8Array(length); | 9 return new _Int8Array(length); |
| 10 } | 10 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 318 } |
| 319 | 319 |
| 320 int elementAt(int index) { | 320 int elementAt(int index) { |
| 321 return this[index]; | 321 return this[index]; |
| 322 } | 322 } |
| 323 | 323 |
| 324 bool get isEmpty { | 324 bool get isEmpty { |
| 325 return this.length == 0; | 325 return this.length == 0; |
| 326 } | 326 } |
| 327 | 327 |
| 328 |
| 328 // Method(s) implementing the List interface. | 329 // Method(s) implementing the List interface. |
| 329 | 330 |
| 330 set length(newLength) { | 331 set length(newLength) { |
| 331 throw new UnsupportedError( | 332 throw new UnsupportedError( |
| 332 "Cannot resize a non-extendable array"); | 333 "Cannot resize a non-extendable array"); |
| 333 } | 334 } |
| 334 | 335 |
| 335 void add(value) { | 336 void add(value) { |
| 336 throw new UnsupportedError( | 337 throw new UnsupportedError( |
| 337 "Cannot add to a non-extendable array"); | 338 "Cannot add to a non-extendable array"); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 436 } |
| 436 | 437 |
| 437 List getRange(int start, int length) { | 438 List getRange(int start, int length) { |
| 438 _rangeCheck(this.length, start, length); | 439 _rangeCheck(this.length, start, length); |
| 439 List result = _createList(length); | 440 List result = _createList(length); |
| 440 result.setRange(0, length, this, start); | 441 result.setRange(0, length, this, start); |
| 441 return result; | 442 return result; |
| 442 } | 443 } |
| 443 | 444 |
| 444 void setRange(int start, int length, List from, [int startFrom = 0]) { | 445 void setRange(int start, int length, List from, [int startFrom = 0]) { |
| 445 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | 446 if (!_setRange(start, length, from, startFrom)) { |
| 447 IterableMixinWorkaround.setRangeList(this, start, |
| 448 length, from, startFrom); |
| 449 } |
| 446 } | 450 } |
| 447 | 451 |
| 452 |
| 448 // Method(s) implementing Object interface. | 453 // Method(s) implementing Object interface. |
| 449 | 454 |
| 450 String toString() { | 455 String toString() { |
| 451 return Collections.collectionToString(this); | 456 return Collections.collectionToString(this); |
| 452 } | 457 } |
| 458 |
| 459 |
| 460 // Internal utility methods. |
| 461 |
| 462 bool _setRange(int start, int length, List from, startFrom) |
| 463 native "TypedData_setRange"; |
| 453 } | 464 } |
| 454 | 465 |
| 455 | 466 |
| 456 abstract class _TypedList extends _TypedListBase implements ByteBuffer { | 467 abstract class _TypedList extends _TypedListBase implements ByteBuffer { |
| 457 // Default method implementing parts of the TypedData interface. | 468 // Default method implementing parts of the TypedData interface. |
| 458 int get offsetInBytes { | 469 int get offsetInBytes { |
| 459 return 0; | 470 return 0; |
| 460 } | 471 } |
| 461 | 472 |
| 462 int get lengthInBytes { | 473 int get lengthInBytes { |
| (...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 } | 2622 } |
| 2612 } | 2623 } |
| 2613 | 2624 |
| 2614 | 2625 |
| 2615 int _defaultIfNull(object, value) { | 2626 int _defaultIfNull(object, value) { |
| 2616 if (object == null) { | 2627 if (object == null) { |
| 2617 return value; | 2628 return value; |
| 2618 } | 2629 } |
| 2619 return object; | 2630 return object; |
| 2620 } | 2631 } |
| OLD | NEW |