Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: third_party/pkg/js/lib/src/wrapping/js/array_to_list_adapter.dart

Issue 331833003: Revert "Add "last" setter to List." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/list_test.dart ('k') | tools/dom/src/ImmutableListMixin.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of js.wrapping; 5 part of js.wrapping;
6 6
7 /// Adapter to handle a js array as a dart [List]. 7 /// Adapter to handle a js array as a dart [List].
8 /// You can provide a translator to automatically wrap contained Proxy to some 8 /// You can provide a translator to automatically wrap contained Proxy to some
9 /// TypedProxy or something else. 9 /// TypedProxy or something else.
10 class JsArrayToListAdapter<E> extends TypedProxy /*with ListMixin<E>*/ 10 class JsArrayToListAdapter<E> extends TypedProxy /*with ListMixin<E>*/
(...skipping 16 matching lines...) Expand all
27 27
28 /// Create a new adapter from a proxy of a Js list. 28 /// Create a new adapter from a proxy of a Js list.
29 JsArrayToListAdapter.fromProxy(Proxy proxy, [Translator<E> translator]) 29 JsArrayToListAdapter.fromProxy(Proxy proxy, [Translator<E> translator])
30 : this._translator = translator, 30 : this._translator = translator,
31 super.fromProxy(proxy); 31 super.fromProxy(proxy);
32 32
33 // Iterable 33 // Iterable
34 @override Iterator<E> get iterator => new _JsIterator<E>(this); 34 @override Iterator<E> get iterator => new _JsIterator<E>(this);
35 @override int get length => $unsafe.length; 35 @override int get length => $unsafe.length;
36 36
37 // List 37 // Collection
38 @override void set last(E value) {
39 if (length == 0) throw new StateError("No element");
40 this[length - 1] = value;
41 }
42 @override void add(E value) { $unsafe.push(_toJs(value)); } 38 @override void add(E value) { $unsafe.push(_toJs(value)); }
43 @override void clear() { this.length = 0; } 39 @override void clear() { this.length = 0; }
44 @override bool remove(Object element) => removeAt(indexOf(element)) != null; 40 @override bool remove(Object element) => removeAt(indexOf(element)) != null;
45 41
42 // List
46 @override E operator [](int index) { 43 @override E operator [](int index) {
47 if (index < 0 || index >= this.length) throw new RangeError.value(index); 44 if (index < 0 || index >= this.length) throw new RangeError.value(index);
48 return _fromJs($unsafe[index]); 45 return _fromJs($unsafe[index]);
49 } 46 }
50 @override void operator []=(int index, E value) { 47 @override void operator []=(int index, E value) {
51 if (index < 0 || index >= this.length) throw new RangeError.value(index); 48 if (index < 0 || index >= this.length) throw new RangeError.value(index);
52 $unsafe[index] = _toJs(value); 49 $unsafe[index] = _toJs(value);
53 } 50 }
54 @override void set length(int length) { $unsafe.length = length; } 51 @override void set length(int length) { $unsafe.length = length; }
55 @override void sort([int compare(E a, E b)]) { 52 @override void sort([int compare(E a, E b)]) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Iterator 549 // Iterator
553 @override bool moveNext() { 550 @override bool moveNext() {
554 if (_currentIndex + 1 < length) { 551 if (_currentIndex + 1 < length) {
555 _currentIndex++; 552 _currentIndex++;
556 return true; 553 return true;
557 } 554 }
558 return false; 555 return false;
559 } 556 }
560 @override E get current => _jsArray[_currentIndex]; 557 @override E get current => _jsArray[_currentIndex];
561 } 558 }
OLDNEW
« no previous file with comments | « tests/corelib/list_test.dart ('k') | tools/dom/src/ImmutableListMixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698