| 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 import "dart:_internal"; | 7 import "dart:_internal"; |
| 8 import 'dart:math' show Random; | 8 import 'dart:math' show Random; |
| 9 | 9 |
| 10 patch class Int8List { | 10 patch class Int8List { |
| 11 /* patch */ factory Int8List(int length) { | 11 /* patch */ factory Int8List(int length) { |
| 12 return new _Int8Array(length); | 12 return new _Int8Array(length); |
| 13 } | 13 } |
| 14 | 14 |
| 15 /* patch */ factory Int8List.fromList(List<int> elements) { | 15 /* patch */ factory Int8List.fromList(List<int> elements) { |
| 16 var result = new _Int8Array(elements.length); | 16 return new _Int8Array(elements.length) |
| 17 for (int i = 0; i < elements.length; i++) { | 17 ..setRange(0, elements.length, elements); |
| 18 result[i] = elements[i]; | |
| 19 } | |
| 20 return result; | |
| 21 } | 18 } |
| 22 | 19 |
| 23 /* patch */ factory Int8List.view(ByteBuffer buffer, | 20 /* patch */ factory Int8List.view(ByteBuffer buffer, |
| 24 [int offsetInBytes = 0, int length]) { | 21 [int offsetInBytes = 0, int length]) { |
| 25 return new _Int8ArrayView(buffer, offsetInBytes, length); | 22 return new _Int8ArrayView(buffer, offsetInBytes, length); |
| 26 } | 23 } |
| 27 } | 24 } |
| 28 | 25 |
| 29 | 26 |
| 30 patch class Uint8List { | 27 patch class Uint8List { |
| 31 /* patch */ factory Uint8List(int length) { | 28 /* patch */ factory Uint8List(int length) { |
| 32 return new _Uint8Array(length); | 29 return new _Uint8Array(length); |
| 33 } | 30 } |
| 34 | 31 |
| 35 /* patch */ factory Uint8List.fromList(List<int> elements) { | 32 /* patch */ factory Uint8List.fromList(List<int> elements) { |
| 36 var result = new _Uint8Array(elements.length); | 33 return new _Uint8Array(elements.length) |
| 37 for (int i = 0; i < elements.length; i++) { | 34 ..setRange(0, elements.length, elements); |
| 38 result[i] = elements[i]; | |
| 39 } | |
| 40 return result; | |
| 41 } | 35 } |
| 42 | 36 |
| 43 /* patch */ factory Uint8List.view(ByteBuffer buffer, | 37 /* patch */ factory Uint8List.view(ByteBuffer buffer, |
| 44 [int offsetInBytes = 0, int length]) { | 38 [int offsetInBytes = 0, int length]) { |
| 45 return new _Uint8ArrayView(buffer, offsetInBytes, length); | 39 return new _Uint8ArrayView(buffer, offsetInBytes, length); |
| 46 } | 40 } |
| 47 } | 41 } |
| 48 | 42 |
| 49 | 43 |
| 50 patch class Uint8ClampedList { | 44 patch class Uint8ClampedList { |
| 51 /* patch */ factory Uint8ClampedList(int length) { | 45 /* patch */ factory Uint8ClampedList(int length) { |
| 52 return new _Uint8ClampedArray(length); | 46 return new _Uint8ClampedArray(length); |
| 53 } | 47 } |
| 54 | 48 |
| 55 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { | 49 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { |
| 56 var result = new _Uint8ClampedArray(elements.length); | 50 return new _Uint8ClampedArray(elements.length) |
| 57 for (int i = 0; i < elements.length; i++) { | 51 ..setRange(0, elements.length, elements); |
| 58 result[i] = elements[i]; | |
| 59 } | |
| 60 return result; | |
| 61 } | 52 } |
| 62 | 53 |
| 63 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, | 54 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, |
| 64 [int offsetInBytes = 0, | 55 [int offsetInBytes = 0, |
| 65 int length]) { | 56 int length]) { |
| 66 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | 57 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); |
| 67 } | 58 } |
| 68 | 59 |
| 69 bool _isClamped() { return true; } | 60 bool _isClamped() { return true; } |
| 70 } | 61 } |
| 71 | 62 |
| 72 | 63 |
| 73 patch class Int16List { | 64 patch class Int16List { |
| 74 /* patch */ factory Int16List(int length) { | 65 /* patch */ factory Int16List(int length) { |
| 75 return new _Int16Array(length); | 66 return new _Int16Array(length); |
| 76 } | 67 } |
| 77 | 68 |
| 78 /* patch */ factory Int16List.fromList(List<int> elements) { | 69 /* patch */ factory Int16List.fromList(List<int> elements) { |
| 79 var result = new _Int16Array(elements.length); | 70 return new _Int16Array(elements.length) |
| 80 for (int i = 0; i < elements.length; i++) { | 71 ..setRange(0, elements.length, elements); |
| 81 result[i] = elements[i]; | |
| 82 } | |
| 83 return result; | |
| 84 } | 72 } |
| 85 | 73 |
| 86 /* patch */ factory Int16List.view(ByteBuffer buffer, | 74 /* patch */ factory Int16List.view(ByteBuffer buffer, |
| 87 [int offsetInBytes = 0, int length]) { | 75 [int offsetInBytes = 0, int length]) { |
| 88 return new _Int16ArrayView(buffer, offsetInBytes, length); | 76 return new _Int16ArrayView(buffer, offsetInBytes, length); |
| 89 } | 77 } |
| 90 } | 78 } |
| 91 | 79 |
| 92 | 80 |
| 93 patch class Uint16List { | 81 patch class Uint16List { |
| 94 /* patch */ factory Uint16List(int length) { | 82 /* patch */ factory Uint16List(int length) { |
| 95 return new _Uint16Array(length); | 83 return new _Uint16Array(length); |
| 96 } | 84 } |
| 97 | 85 |
| 98 /* patch */ factory Uint16List.fromList(List<int> elements) { | 86 /* patch */ factory Uint16List.fromList(List<int> elements) { |
| 99 var result = new _Uint16Array(elements.length); | 87 return new _Uint16Array(elements.length) |
| 100 for (int i = 0; i < elements.length; i++) { | 88 ..setRange(0, elements.length, elements); |
| 101 result[i] = elements[i]; | |
| 102 } | |
| 103 return result; | |
| 104 } | 89 } |
| 105 | 90 |
| 106 /* patch */ factory Uint16List.view(ByteBuffer buffer, | 91 /* patch */ factory Uint16List.view(ByteBuffer buffer, |
| 107 [int offsetInBytes = 0, int length]) { | 92 [int offsetInBytes = 0, int length]) { |
| 108 return new _Uint16ArrayView(buffer, offsetInBytes, length); | 93 return new _Uint16ArrayView(buffer, offsetInBytes, length); |
| 109 } | 94 } |
| 110 } | 95 } |
| 111 | 96 |
| 112 | 97 |
| 113 patch class Int32List { | 98 patch class Int32List { |
| 114 /* patch */ factory Int32List(int length) { | 99 /* patch */ factory Int32List(int length) { |
| 115 return new _Int32Array(length); | 100 return new _Int32Array(length); |
| 116 } | 101 } |
| 117 | 102 |
| 118 /* patch */ factory Int32List.fromList(List<int> elements) { | 103 /* patch */ factory Int32List.fromList(List<int> elements) { |
| 119 var result = new _Int32Array(elements.length); | 104 return new _Int32Array(elements.length) |
| 120 for (int i = 0; i < elements.length; i++) { | 105 ..setRange(0, elements.length, elements); |
| 121 result[i] = elements[i]; | |
| 122 } | |
| 123 return result; | |
| 124 } | 106 } |
| 125 | 107 |
| 126 /* patch */ factory Int32List.view(ByteBuffer buffer, | 108 /* patch */ factory Int32List.view(ByteBuffer buffer, |
| 127 [int offsetInBytes = 0, int length]) { | 109 [int offsetInBytes = 0, int length]) { |
| 128 return new _Int32ArrayView(buffer, offsetInBytes, length); | 110 return new _Int32ArrayView(buffer, offsetInBytes, length); |
| 129 } | 111 } |
| 130 } | 112 } |
| 131 | 113 |
| 132 | 114 |
| 133 patch class Uint32List { | 115 patch class Uint32List { |
| 134 /* patch */ factory Uint32List(int length) { | 116 /* patch */ factory Uint32List(int length) { |
| 135 return new _Uint32Array(length); | 117 return new _Uint32Array(length); |
| 136 } | 118 } |
| 137 | 119 |
| 138 /* patch */ factory Uint32List.fromList(List<int> elements) { | 120 /* patch */ factory Uint32List.fromList(List<int> elements) { |
| 139 var result = new _Uint32Array(elements.length); | 121 return new _Uint32Array(elements.length) |
| 140 for (int i = 0; i < elements.length; i++) { | 122 ..setRange(0, elements.length, elements); |
| 141 result[i] = elements[i]; | |
| 142 } | |
| 143 return result; | |
| 144 } | 123 } |
| 145 | 124 |
| 146 /* patch */ factory Uint32List.view(ByteBuffer buffer, | 125 /* patch */ factory Uint32List.view(ByteBuffer buffer, |
| 147 [int offsetInBytes = 0, int length]) { | 126 [int offsetInBytes = 0, int length]) { |
| 148 return new _Uint32ArrayView(buffer, offsetInBytes, length); | 127 return new _Uint32ArrayView(buffer, offsetInBytes, length); |
| 149 } | 128 } |
| 150 } | 129 } |
| 151 | 130 |
| 152 | 131 |
| 153 patch class Int64List { | 132 patch class Int64List { |
| 154 /* patch */ factory Int64List(int length) { | 133 /* patch */ factory Int64List(int length) { |
| 155 return new _Int64Array(length); | 134 return new _Int64Array(length); |
| 156 } | 135 } |
| 157 | 136 |
| 158 /* patch */ factory Int64List.fromList(List<int> elements) { | 137 /* patch */ factory Int64List.fromList(List<int> elements) { |
| 159 var result = new _Int64Array(elements.length); | 138 return new _Int64Array(elements.length) |
| 160 for (int i = 0; i < elements.length; i++) { | 139 ..setRange(0, elements.length, elements); |
| 161 result[i] = elements[i]; | |
| 162 } | |
| 163 return result; | |
| 164 } | 140 } |
| 165 | 141 |
| 166 /* patch */ factory Int64List.view(ByteBuffer buffer, | 142 /* patch */ factory Int64List.view(ByteBuffer buffer, |
| 167 [int offsetInBytes = 0, int length]) { | 143 [int offsetInBytes = 0, int length]) { |
| 168 return new _Int64ArrayView(buffer, offsetInBytes, length); | 144 return new _Int64ArrayView(buffer, offsetInBytes, length); |
| 169 } | 145 } |
| 170 } | 146 } |
| 171 | 147 |
| 172 | 148 |
| 173 patch class Uint64List { | 149 patch class Uint64List { |
| 174 /* patch */ factory Uint64List(int length) { | 150 /* patch */ factory Uint64List(int length) { |
| 175 return new _Uint64Array(length); | 151 return new _Uint64Array(length); |
| 176 } | 152 } |
| 177 | 153 |
| 178 /* patch */ factory Uint64List.fromList(List<int> elements) { | 154 /* patch */ factory Uint64List.fromList(List<int> elements) { |
| 179 var result = new _Uint64Array(elements.length); | 155 return new _Uint64Array(elements.length) |
| 180 for (int i = 0; i < elements.length; i++) { | 156 ..setRange(0, elements.length, elements); |
| 181 result[i] = elements[i]; | |
| 182 } | |
| 183 return result; | |
| 184 } | 157 } |
| 185 | 158 |
| 186 /* patch */ factory Uint64List.view(ByteBuffer buffer, | 159 /* patch */ factory Uint64List.view(ByteBuffer buffer, |
| 187 [int offsetInBytes = 0, int length]) { | 160 [int offsetInBytes = 0, int length]) { |
| 188 return new _Uint64ArrayView(buffer, offsetInBytes, length); | 161 return new _Uint64ArrayView(buffer, offsetInBytes, length); |
| 189 } | 162 } |
| 190 } | 163 } |
| 191 | 164 |
| 192 | 165 |
| 193 patch class Float32List { | 166 patch class Float32List { |
| 194 /* patch */ factory Float32List(int length) { | 167 /* patch */ factory Float32List(int length) { |
| 195 return new _Float32Array(length); | 168 return new _Float32Array(length); |
| 196 } | 169 } |
| 197 | 170 |
| 198 /* patch */ factory Float32List.fromList(List<double> elements) { | 171 /* patch */ factory Float32List.fromList(List<double> elements) { |
| 199 var result = new _Float32Array(elements.length); | 172 return new _Float32Array(elements.length) |
| 200 for (int i = 0; i < elements.length; i++) { | 173 ..setRange(0, elements.length, elements); |
| 201 result[i] = elements[i]; | |
| 202 } | |
| 203 return result; | |
| 204 } | 174 } |
| 205 | 175 |
| 206 /* patch */ factory Float32List.view(ByteBuffer buffer, | 176 /* patch */ factory Float32List.view(ByteBuffer buffer, |
| 207 [int offsetInBytes = 0, int length]) { | 177 [int offsetInBytes = 0, int length]) { |
| 208 return new _Float32ArrayView(buffer, offsetInBytes, length); | 178 return new _Float32ArrayView(buffer, offsetInBytes, length); |
| 209 } | 179 } |
| 210 } | 180 } |
| 211 | 181 |
| 212 | 182 |
| 213 patch class Float64List { | 183 patch class Float64List { |
| 214 /* patch */ factory Float64List(int length) { | 184 /* patch */ factory Float64List(int length) { |
| 215 return new _Float64Array(length); | 185 return new _Float64Array(length); |
| 216 } | 186 } |
| 217 | 187 |
| 218 /* patch */ factory Float64List.fromList(List<double> elements) { | 188 /* patch */ factory Float64List.fromList(List<double> elements) { |
| 219 var result = new _Float64Array(elements.length); | 189 return new _Float64Array(elements.length) |
| 220 for (int i = 0; i < elements.length; i++) { | 190 ..setRange(0, elements.length, elements); |
| 221 result[i] = elements[i]; | |
| 222 } | |
| 223 return result; | |
| 224 } | 191 } |
| 225 | 192 |
| 226 /* patch */ factory Float64List.view(ByteBuffer buffer, | 193 /* patch */ factory Float64List.view(ByteBuffer buffer, |
| 227 [int offsetInBytes = 0, int length]) { | 194 [int offsetInBytes = 0, int length]) { |
| 228 return new _Float64ArrayView(buffer, offsetInBytes, length); | 195 return new _Float64ArrayView(buffer, offsetInBytes, length); |
| 229 } | 196 } |
| 230 } | 197 } |
| 231 | 198 |
| 232 patch class Float32x4List { | 199 patch class Float32x4List { |
| 233 /* patch */ factory Float32x4List(int length) { | 200 /* patch */ factory Float32x4List(int length) { |
| 234 return new _Float32x4Array(length); | 201 return new _Float32x4Array(length); |
| 235 } | 202 } |
| 236 | 203 |
| 237 /* patch */ factory Float32x4List.fromList(List<Float32x4> elements) { | 204 /* patch */ factory Float32x4List.fromList(List<Float32x4> elements) { |
| 238 var result = new _Float32x4Array(elements.length); | 205 return new _Float32x4Array(elements.length) |
| 239 for (int i = 0; i < elements.length; i++) { | 206 ..setRange(0, elements.length, elements); |
| 240 result[i] = elements[i]; | |
| 241 } | |
| 242 return result; | |
| 243 } | 207 } |
| 244 | 208 |
| 245 /* patch */ factory Float32x4List.view(ByteBuffer buffer, | 209 /* patch */ factory Float32x4List.view(ByteBuffer buffer, |
| 246 [int offsetInBytes = 0, int length]) { | 210 [int offsetInBytes = 0, int length]) { |
| 247 return new _Float32x4ArrayView(buffer, offsetInBytes, length); | 211 return new _Float32x4ArrayView(buffer, offsetInBytes, length); |
| 248 } | 212 } |
| 249 } | 213 } |
| 250 | 214 |
| 251 | 215 |
| 252 patch class Int32x4List { | 216 patch class Int32x4List { |
| 253 /* patch */ factory Int32x4List(int length) { | 217 /* patch */ factory Int32x4List(int length) { |
| 254 return new _Int32x4Array(length); | 218 return new _Int32x4Array(length); |
| 255 } | 219 } |
| 256 | 220 |
| 257 /* patch */ factory Int32x4List.fromList(List<Int32x4> elements) { | 221 /* patch */ factory Int32x4List.fromList(List<Int32x4> elements) { |
| 258 var result = new _Int32x4Array(elements.length); | 222 return new _Int32x4Array(elements.length) |
| 259 for (int i = 0; i < elements.length; i++) { | 223 ..setRange(0, elements.length, elements); |
| 260 result[i] = elements[i]; | |
| 261 } | |
| 262 return result; | |
| 263 } | 224 } |
| 264 | 225 |
| 265 /* patch */ factory Int32x4List.view(ByteBuffer buffer, | 226 /* patch */ factory Int32x4List.view(ByteBuffer buffer, |
| 266 [int offsetInBytes = 0, int length]) { | 227 [int offsetInBytes = 0, int length]) { |
| 267 return new _Int32x4ArrayView(buffer, offsetInBytes, length); | 228 return new _Int32x4ArrayView(buffer, offsetInBytes, length); |
| 268 } | 229 } |
| 269 } | 230 } |
| 270 | 231 |
| 271 | 232 |
| 272 patch class Float32x4 { | 233 patch class Float32x4 { |
| (...skipping 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3403 return value; | 3364 return value; |
| 3404 } | 3365 } |
| 3405 return object; | 3366 return object; |
| 3406 } | 3367 } |
| 3407 | 3368 |
| 3408 | 3369 |
| 3409 void _throwRangeError(int index, int length) { | 3370 void _throwRangeError(int index, int length) { |
| 3410 String message = "$index must be in the range [0..$length)"; | 3371 String message = "$index must be in the range [0..$length)"; |
| 3411 throw new RangeError(message); | 3372 throw new RangeError(message); |
| 3412 } | 3373 } |
| OLD | NEW |