Chromium Code Reviews| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 } | 272 } |
| 273 return new _ByteDataView(buffer, offsetInBytes, length); | 273 return new _ByteDataView(buffer, offsetInBytes, length); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 |
| 278 // Based class for _TypedList that provides common methods for implementing | 278 // Based class for _TypedList that provides common methods for implementing |
| 279 // the collection and list interfaces. | 279 // the collection and list interfaces. |
| 280 | 280 |
| 281 abstract class _TypedListBase { | 281 abstract class _TypedListBase { |
| 282 static List _toStringList = new List(); | |
| 283 | |
| 282 // Method(s) implementing the Collection interface. | 284 // Method(s) implementing the Collection interface. |
| 283 bool contains(element) => IterableMixinWorkaround.contains(this, element); | 285 bool contains(element) => IterableMixinWorkaround.contains(this, element); |
| 284 | 286 |
| 285 void forEach(void f(num element)) { | 287 void forEach(void f(num element)) { |
| 286 var len = this.length; | 288 var len = this.length; |
| 287 for (var i = 0; i < len; i++) { | 289 for (var i = 0; i < len; i++) { |
| 288 f(this[i]); | 290 f(this[i]); |
| 289 } | 291 } |
| 290 } | 292 } |
| 291 | 293 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 IterableMixinWorkaround.setAllList(this, index, iterable); | 499 IterableMixinWorkaround.setAllList(this, index, iterable); |
| 498 } | 500 } |
| 499 | 501 |
| 500 void fillRange(int start, int end, [num fillValue]) { | 502 void fillRange(int start, int end, [num fillValue]) { |
| 501 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue); | 503 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue); |
| 502 } | 504 } |
| 503 | 505 |
| 504 | 506 |
| 505 // Method(s) implementing Object interface. | 507 // Method(s) implementing Object interface. |
| 506 | 508 |
| 507 String toString() { | 509 String toString() { |
|
floitsch
2013/07/08 12:00:50
change to IterableMixinWorkaround.toStringList(thi
zarah
2013/07/08 14:35:15
Done.
| |
| 508 return ToString.iterableToString(this); | 510 for(int i = 0; i < _toStringList.length; i++) { |
| 511 if(identical(_toStringList[i], this)) | |
| 512 return '[...]'; | |
| 513 } | |
| 514 _toStringList.add(this); | |
| 515 String result = IterableMixinWorkaround.toStringList(this); | |
| 516 _toStringList.remove(this); | |
| 517 return result; | |
| 509 } | 518 } |
| 510 | 519 |
| 511 | |
| 512 // Internal utility methods. | 520 // Internal utility methods. |
| 513 | 521 |
| 514 bool _setRange(int start, int length, Iterable from, int startFrom) | 522 bool _setRange(int start, int length, Iterable from, int startFrom) |
| 515 native "TypedData_setRange"; | 523 native "TypedData_setRange"; |
| 516 } | 524 } |
| 517 | 525 |
| 518 | 526 |
| 519 abstract class _TypedList extends _TypedListBase implements ByteBuffer { | 527 abstract class _TypedList extends _TypedListBase implements ByteBuffer { |
| 520 // Default method implementing parts of the TypedData interface. | 528 // Default method implementing parts of the TypedData interface. |
| 521 int get offsetInBytes { | 529 int get offsetInBytes { |
| (...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3106 return value; | 3114 return value; |
| 3107 } | 3115 } |
| 3108 return object; | 3116 return object; |
| 3109 } | 3117 } |
| 3110 | 3118 |
| 3111 | 3119 |
| 3112 void _throwRangeError(int index, int length) { | 3120 void _throwRangeError(int index, int length) { |
| 3113 String message = "$index must be in the range [0..$length)"; | 3121 String message = "$index must be in the range [0..$length)"; |
| 3114 throw new RangeError(message); | 3122 throw new RangeError(message); |
| 3115 } | 3123 } |
| OLD | NEW |