| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // TODO(nweiz): when all implementations we target have the same name for the | 5 // TODO(nweiz): when all implementations we target have the same name for the |
| 6 // coreimpl implementation of List<E>, extend that rather than wrapping. | 6 // coreimpl implementation of List<E>, extend that rather than wrapping. |
| 7 class _ListWrapper<E> implements List<E> { | 7 class _ListWrapper<E> implements List<E> { |
| 8 List _list; | 8 List _list; |
| 9 | 9 |
| 10 _ListWrapper(List this._list); | 10 _ListWrapper(List this._list); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 E get first => _list[0]; | 65 E get first => _list[0]; |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * This class is used to insure the results of list operations are NodeLists | 69 * This class is used to insure the results of list operations are NodeLists |
| 70 * instead of lists. | 70 * instead of lists. |
| 71 */ | 71 */ |
| 72 class _NodeListWrapper extends _ListWrapper<Node> implements NodeList { | 72 class _NodeListWrapper extends _ListWrapper<Node> implements NodeList { |
| 73 _NodeListWrapper(List list) : super(list); | 73 _NodeListWrapper(List list) : super(list); |
| 74 | 74 |
| 75 List<Node> filter(bool f(Node element)) => | 75 NodeList filter(bool f(Node element)) => |
| 76 new _NodeListWrapper(_list.filter(f)); | 76 new _NodeListWrapper(_list.filter(f)); |
| 77 | 77 |
| 78 List<Node> getRange(int start, int rangeLength) => | 78 NodeList getRange(int start, int rangeLength) => |
| 79 new _NodeListWrapper(_list.getRange(start, rangeLength)); | 79 new _NodeListWrapper(_list.getRange(start, rangeLength)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 82 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 83 _NodeImpl _parent; | 83 _NodeImpl _parent; |
| 84 | 84 |
| 85 // -- start List<Node> mixins. | 85 // -- start List<Node> mixins. |
| 86 // Node is the element type. | 86 // Node is the element type. |
| 87 | 87 |
| 88 // From Iterable<Node>: | 88 // From Iterable<Node>: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 void add(_NodeImpl value) { | 99 void add(_NodeImpl value) { |
| 100 _parent.$dom_appendChild(value); | 100 _parent.$dom_appendChild(value); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void addLast(_NodeImpl value) { | 103 void addLast(_NodeImpl value) { |
| 104 _parent.$dom_appendChild(value); | 104 _parent.$dom_appendChild(value); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void addAll(Collection<_NodeImpl> collection) { | 107 void addAll(Collection<_NodeImpl> collection) { |
| 108 for (_NodeImpl node in collection) { | 108 for (_NodeImpl node in collection) { |
| 109 _parent.$dom_appendChild(node); | 109 _parent.$dom_appendChild(node); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 _NodeImpl removeLast() { | 113 _NodeImpl removeLast() { |
| 114 final result = this.last(); | 114 final result = this.last(); |
| 115 if (result != null) { | 115 if (result != null) { |
| 116 _parent.$dom_removeChild(result); | 116 _parent.$dom_removeChild(result); |
| 117 } | 117 } |
| 118 return result; | 118 return result; |
| 119 } | 119 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // FIXME: implement thesee. | 157 // FIXME: implement thesee. |
| 158 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { | 158 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { |
| 159 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); | 159 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); |
| 160 } | 160 } |
| 161 void removeRange(int start, int rangeLength) { | 161 void removeRange(int start, int rangeLength) { |
| 162 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); | 162 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); |
| 163 } | 163 } |
| 164 void insertRange(int start, int rangeLength, [Node initialValue]) { | 164 void insertRange(int start, int rangeLength, [Node initialValue]) { |
| 165 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | 165 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); |
| 166 } | 166 } |
| 167 List<Node> getRange(int start, int rangeLength) => | 167 NodeList getRange(int start, int rangeLength) => |
| 168 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); | 168 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); |
| 169 | 169 |
| 170 // -- end List<Node> mixins. | 170 // -- end List<Node> mixins. |
| 171 | 171 |
| 172 $!MEMBERS | 172 $!MEMBERS |
| 173 } | 173 } |
| OLD | NEW |