| 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 } |
| 11 | 11 |
| 12 /* patch */ factory Int8List.transferable(int length) { | |
| 13 return _newTransferable(length); | |
| 14 } | |
| 15 | |
| 16 /* patch */ factory Int8List.fromList(List<int> elements) { | 12 /* patch */ factory Int8List.fromList(List<int> elements) { |
| 17 var result = new _Int8Array(elements.length); | 13 var result = new _Int8Array(elements.length); |
| 18 for (int i = 0; i < elements.length; i++) { | 14 for (int i = 0; i < elements.length; i++) { |
| 19 result[i] = elements[i]; | 15 result[i] = elements[i]; |
| 20 } | 16 } |
| 21 return result; | 17 return result; |
| 22 } | 18 } |
| 23 | 19 |
| 24 /* patch */ factory Int8List.view(ByteBuffer buffer, | 20 /* patch */ factory Int8List.view(ByteBuffer buffer, |
| 25 [int offsetInBytes = 0, int length]) { | 21 [int offsetInBytes = 0, int length]) { |
| 26 return new _Int8ArrayView(buffer, offsetInBytes, length); | 22 return new _Int8ArrayView(buffer, offsetInBytes, length); |
| 27 } | 23 } |
| 28 | |
| 29 static _ExternalInt8Array _newTransferable(int length) { | |
| 30 return new _ExternalInt8Array(length); | |
| 31 } | |
| 32 } | 24 } |
| 33 | 25 |
| 34 | 26 |
| 35 patch class Uint8List { | 27 patch class Uint8List { |
| 36 /* patch */ factory Uint8List(int length) { | 28 /* patch */ factory Uint8List(int length) { |
| 37 return new _Uint8Array(length); | 29 return new _Uint8Array(length); |
| 38 } | 30 } |
| 39 | 31 |
| 40 /* patch */ factory Uint8List.transferable(int length) { | |
| 41 return _newTransferable(length); | |
| 42 } | |
| 43 | |
| 44 /* patch */ factory Uint8List.fromList(List<int> elements) { | 32 /* patch */ factory Uint8List.fromList(List<int> elements) { |
| 45 var result = new _Uint8Array(elements.length); | 33 var result = new _Uint8Array(elements.length); |
| 46 for (int i = 0; i < elements.length; i++) { | 34 for (int i = 0; i < elements.length; i++) { |
| 47 result[i] = elements[i]; | 35 result[i] = elements[i]; |
| 48 } | 36 } |
| 49 return result; | 37 return result; |
| 50 } | 38 } |
| 51 | 39 |
| 52 /* patch */ factory Uint8List.view(ByteBuffer buffer, | 40 /* patch */ factory Uint8List.view(ByteBuffer buffer, |
| 53 [int offsetInBytes = 0, int length]) { | 41 [int offsetInBytes = 0, int length]) { |
| 54 return new _Uint8ArrayView(buffer, offsetInBytes, length); | 42 return new _Uint8ArrayView(buffer, offsetInBytes, length); |
| 55 } | 43 } |
| 56 | |
| 57 static _ExternalUint8Array _newTransferable(int length) { | |
| 58 return new _ExternalUint8Array(length); | |
| 59 } | |
| 60 } | 44 } |
| 61 | 45 |
| 62 | 46 |
| 63 patch class Uint8ClampedList { | 47 patch class Uint8ClampedList { |
| 64 /* patch */ factory Uint8ClampedList(int length) { | 48 /* patch */ factory Uint8ClampedList(int length) { |
| 65 return new _Uint8ClampedArray(length); | 49 return new _Uint8ClampedArray(length); |
| 66 } | 50 } |
| 67 | 51 |
| 68 /* patch */ factory Uint8ClampedList.transferable(int length) { | |
| 69 return _newTransferable(length); | |
| 70 } | |
| 71 | |
| 72 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { | 52 /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { |
| 73 var result = new _Uint8ClampedArray(elements.length); | 53 var result = new _Uint8ClampedArray(elements.length); |
| 74 for (int i = 0; i < elements.length; i++) { | 54 for (int i = 0; i < elements.length; i++) { |
| 75 result[i] = elements[i]; | 55 result[i] = elements[i]; |
| 76 } | 56 } |
| 77 return result; | 57 return result; |
| 78 } | 58 } |
| 79 | 59 |
| 80 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, | 60 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, |
| 81 [int offsetInBytes = 0, | 61 [int offsetInBytes = 0, |
| 82 int length]) { | 62 int length]) { |
| 83 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | 63 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); |
| 84 } | 64 } |
| 85 | |
| 86 static _ExternalUint8ClampedArray _newTransferable(int length) { | |
| 87 return new _ExternalUint8ClampedArray(length); | |
| 88 } | |
| 89 } | 65 } |
| 90 | 66 |
| 91 | 67 |
| 92 patch class Int16List { | 68 patch class Int16List { |
| 93 /* patch */ factory Int16List(int length) { | 69 /* patch */ factory Int16List(int length) { |
| 94 return new _Int16Array(length); | 70 return new _Int16Array(length); |
| 95 } | 71 } |
| 96 | 72 |
| 97 /* patch */ factory Int16List.transferable(int length) { | |
| 98 return _newTransferable(length); | |
| 99 } | |
| 100 | |
| 101 /* patch */ factory Int16List.fromList(List<int> elements) { | 73 /* patch */ factory Int16List.fromList(List<int> elements) { |
| 102 var result = new _Int16Array(elements.length); | 74 var result = new _Int16Array(elements.length); |
| 103 for (int i = 0; i < elements.length; i++) { | 75 for (int i = 0; i < elements.length; i++) { |
| 104 result[i] = elements[i]; | 76 result[i] = elements[i]; |
| 105 } | 77 } |
| 106 return result; | 78 return result; |
| 107 } | 79 } |
| 108 | 80 |
| 109 /* patch */ factory Int16List.view(ByteBuffer buffer, | 81 /* patch */ factory Int16List.view(ByteBuffer buffer, |
| 110 [int offsetInBytes = 0, int length]) { | 82 [int offsetInBytes = 0, int length]) { |
| 111 return new _Int16ArrayView(buffer, offsetInBytes, length); | 83 return new _Int16ArrayView(buffer, offsetInBytes, length); |
| 112 } | 84 } |
| 113 | |
| 114 static _ExternalInt16Array _newTransferable(int length) { | |
| 115 return new _ExternalInt16Array(length); | |
| 116 } | |
| 117 } | 85 } |
| 118 | 86 |
| 119 | 87 |
| 120 patch class Uint16List { | 88 patch class Uint16List { |
| 121 /* patch */ factory Uint16List(int length) { | 89 /* patch */ factory Uint16List(int length) { |
| 122 return new _Uint16Array(length); | 90 return new _Uint16Array(length); |
| 123 } | 91 } |
| 124 | 92 |
| 125 /* patch */ factory Uint16List.transferable(int length) { | |
| 126 return _newTransferable(length); | |
| 127 } | |
| 128 | |
| 129 /* patch */ factory Uint16List.fromList(List<int> elements) { | 93 /* patch */ factory Uint16List.fromList(List<int> elements) { |
| 130 var result = new _Uint16Array(elements.length); | 94 var result = new _Uint16Array(elements.length); |
| 131 for (int i = 0; i < elements.length; i++) { | 95 for (int i = 0; i < elements.length; i++) { |
| 132 result[i] = elements[i]; | 96 result[i] = elements[i]; |
| 133 } | 97 } |
| 134 return result; | 98 return result; |
| 135 } | 99 } |
| 136 | 100 |
| 137 /* patch */ factory Uint16List.view(ByteBuffer buffer, | 101 /* patch */ factory Uint16List.view(ByteBuffer buffer, |
| 138 [int offsetInBytes = 0, int length]) { | 102 [int offsetInBytes = 0, int length]) { |
| 139 return new _Uint16ArrayView(buffer, offsetInBytes, length); | 103 return new _Uint16ArrayView(buffer, offsetInBytes, length); |
| 140 } | 104 } |
| 141 | |
| 142 static _ExternalUint16Array _newTransferable(int length) { | |
| 143 return new _ExternalUint16Array(length); | |
| 144 } | |
| 145 } | 105 } |
| 146 | 106 |
| 147 | 107 |
| 148 patch class Int32List { | 108 patch class Int32List { |
| 149 /* patch */ factory Int32List(int length) { | 109 /* patch */ factory Int32List(int length) { |
| 150 return new _Int32Array(length); | 110 return new _Int32Array(length); |
| 151 } | 111 } |
| 152 | 112 |
| 153 /* patch */ factory Int32List.transferable(int length) { | |
| 154 return _newTransferable(length); | |
| 155 } | |
| 156 | |
| 157 /* patch */ factory Int32List.fromList(List<int> elements) { | 113 /* patch */ factory Int32List.fromList(List<int> elements) { |
| 158 var result = new _Int32Array(elements.length); | 114 var result = new _Int32Array(elements.length); |
| 159 for (int i = 0; i < elements.length; i++) { | 115 for (int i = 0; i < elements.length; i++) { |
| 160 result[i] = elements[i]; | 116 result[i] = elements[i]; |
| 161 } | 117 } |
| 162 return result; | 118 return result; |
| 163 } | 119 } |
| 164 | 120 |
| 165 /* patch */ factory Int32List.view(ByteBuffer buffer, | 121 /* patch */ factory Int32List.view(ByteBuffer buffer, |
| 166 [int offsetInBytes = 0, int length]) { | 122 [int offsetInBytes = 0, int length]) { |
| 167 return new _Int32ArrayView(buffer, offsetInBytes, length); | 123 return new _Int32ArrayView(buffer, offsetInBytes, length); |
| 168 } | 124 } |
| 169 | |
| 170 static _ExternalInt32Array _newTransferable(int length) { | |
| 171 return new _ExternalInt32Array(length); | |
| 172 } | |
| 173 } | 125 } |
| 174 | 126 |
| 175 | 127 |
| 176 patch class Uint32List { | 128 patch class Uint32List { |
| 177 /* patch */ factory Uint32List(int length) { | 129 /* patch */ factory Uint32List(int length) { |
| 178 return new _Uint32Array(length); | 130 return new _Uint32Array(length); |
| 179 } | 131 } |
| 180 | 132 |
| 181 /* patch */ factory Uint32List.transferable(int length) { | |
| 182 return _newTransferable(length); | |
| 183 } | |
| 184 | |
| 185 /* patch */ factory Uint32List.fromList(List<int> elements) { | 133 /* patch */ factory Uint32List.fromList(List<int> elements) { |
| 186 var result = new _Uint32Array(elements.length); | 134 var result = new _Uint32Array(elements.length); |
| 187 for (int i = 0; i < elements.length; i++) { | 135 for (int i = 0; i < elements.length; i++) { |
| 188 result[i] = elements[i]; | 136 result[i] = elements[i]; |
| 189 } | 137 } |
| 190 return result; | 138 return result; |
| 191 } | 139 } |
| 192 | 140 |
| 193 /* patch */ factory Uint32List.view(ByteBuffer buffer, | 141 /* patch */ factory Uint32List.view(ByteBuffer buffer, |
| 194 [int offsetInBytes = 0, int length]) { | 142 [int offsetInBytes = 0, int length]) { |
| 195 return new _Uint32ArrayView(buffer, offsetInBytes, length); | 143 return new _Uint32ArrayView(buffer, offsetInBytes, length); |
| 196 } | 144 } |
| 197 | |
| 198 static _ExternalUint32Array _newTransferable(int length) { | |
| 199 return new _ExternalUint32Array(length); | |
| 200 } | |
| 201 } | 145 } |
| 202 | 146 |
| 203 | 147 |
| 204 patch class Int64List { | 148 patch class Int64List { |
| 205 /* patch */ factory Int64List(int length) { | 149 /* patch */ factory Int64List(int length) { |
| 206 return new _Int64Array(length); | 150 return new _Int64Array(length); |
| 207 } | 151 } |
| 208 | 152 |
| 209 /* patch */ factory Int64List.transferable(int length) { | |
| 210 return _newTransferable(length); | |
| 211 } | |
| 212 | |
| 213 /* patch */ factory Int64List.fromList(List<int> elements) { | 153 /* patch */ factory Int64List.fromList(List<int> elements) { |
| 214 var result = new _Int64Array(elements.length); | 154 var result = new _Int64Array(elements.length); |
| 215 for (int i = 0; i < elements.length; i++) { | 155 for (int i = 0; i < elements.length; i++) { |
| 216 result[i] = elements[i]; | 156 result[i] = elements[i]; |
| 217 } | 157 } |
| 218 return result; | 158 return result; |
| 219 } | 159 } |
| 220 | 160 |
| 221 /* patch */ factory Int64List.view(ByteBuffer buffer, | 161 /* patch */ factory Int64List.view(ByteBuffer buffer, |
| 222 [int offsetInBytes = 0, int length]) { | 162 [int offsetInBytes = 0, int length]) { |
| 223 return new _Int64ArrayView(buffer, offsetInBytes, length); | 163 return new _Int64ArrayView(buffer, offsetInBytes, length); |
| 224 } | 164 } |
| 225 | |
| 226 static _ExternalInt64Array _newTransferable(int length) { | |
| 227 return new _ExternalInt64Array(length); | |
| 228 } | |
| 229 } | 165 } |
| 230 | 166 |
| 231 | 167 |
| 232 patch class Uint64List { | 168 patch class Uint64List { |
| 233 /* patch */ factory Uint64List(int length) { | 169 /* patch */ factory Uint64List(int length) { |
| 234 return new _Uint64Array(length); | 170 return new _Uint64Array(length); |
| 235 } | 171 } |
| 236 | 172 |
| 237 /* patch */ factory Uint64List.transferable(int length) { | |
| 238 return _newTransferable(length); | |
| 239 } | |
| 240 | |
| 241 /* patch */ factory Uint64List.fromList(List<int> elements) { | 173 /* patch */ factory Uint64List.fromList(List<int> elements) { |
| 242 var result = new _Uint64Array(elements.length); | 174 var result = new _Uint64Array(elements.length); |
| 243 for (int i = 0; i < elements.length; i++) { | 175 for (int i = 0; i < elements.length; i++) { |
| 244 result[i] = elements[i]; | 176 result[i] = elements[i]; |
| 245 } | 177 } |
| 246 return result; | 178 return result; |
| 247 } | 179 } |
| 248 | 180 |
| 249 /* patch */ factory Uint64List.view(ByteBuffer buffer, | 181 /* patch */ factory Uint64List.view(ByteBuffer buffer, |
| 250 [int offsetInBytes = 0, int length]) { | 182 [int offsetInBytes = 0, int length]) { |
| 251 return new _Uint64ArrayView(buffer, offsetInBytes, length); | 183 return new _Uint64ArrayView(buffer, offsetInBytes, length); |
| 252 } | 184 } |
| 253 | |
| 254 static _ExternalUint64Array _newTransferable(int length) { | |
| 255 return new _ExternalUint64Array(length); | |
| 256 } | |
| 257 } | 185 } |
| 258 | 186 |
| 259 | 187 |
| 260 patch class Float32List { | 188 patch class Float32List { |
| 261 /* patch */ factory Float32List(int length) { | 189 /* patch */ factory Float32List(int length) { |
| 262 return new _Float32Array(length); | 190 return new _Float32Array(length); |
| 263 } | 191 } |
| 264 | 192 |
| 265 /* patch */ factory Float32List.transferable(int length) { | |
| 266 return _newTransferable(length); | |
| 267 } | |
| 268 | |
| 269 /* patch */ factory Float32List.fromList(List<double> elements) { | 193 /* patch */ factory Float32List.fromList(List<double> elements) { |
| 270 var result = new _Float32Array(elements.length); | 194 var result = new _Float32Array(elements.length); |
| 271 for (int i = 0; i < elements.length; i++) { | 195 for (int i = 0; i < elements.length; i++) { |
| 272 result[i] = elements[i]; | 196 result[i] = elements[i]; |
| 273 } | 197 } |
| 274 return result; | 198 return result; |
| 275 } | 199 } |
| 276 | 200 |
| 277 /* patch */ factory Float32List.view(ByteBuffer buffer, | 201 /* patch */ factory Float32List.view(ByteBuffer buffer, |
| 278 [int offsetInBytes = 0, int length]) { | 202 [int offsetInBytes = 0, int length]) { |
| 279 return new _Float32ArrayView(buffer, offsetInBytes, length); | 203 return new _Float32ArrayView(buffer, offsetInBytes, length); |
| 280 } | 204 } |
| 281 | |
| 282 static _ExternalFloat32Array _newTransferable(int length) { | |
| 283 return new _ExternalFloat32Array(length); | |
| 284 } | |
| 285 } | 205 } |
| 286 | 206 |
| 287 | 207 |
| 288 patch class Float64List { | 208 patch class Float64List { |
| 289 /* patch */ factory Float64List(int length) { | 209 /* patch */ factory Float64List(int length) { |
| 290 return new _Float64Array(length); | 210 return new _Float64Array(length); |
| 291 } | 211 } |
| 292 | 212 |
| 293 /* patch */ factory Float64List.transferable(int length) { | |
| 294 return _newTransferable(length); | |
| 295 } | |
| 296 | |
| 297 /* patch */ factory Float64List.fromList(List<double> elements) { | 213 /* patch */ factory Float64List.fromList(List<double> elements) { |
| 298 var result = new _Float64Array(elements.length); | 214 var result = new _Float64Array(elements.length); |
| 299 for (int i = 0; i < elements.length; i++) { | 215 for (int i = 0; i < elements.length; i++) { |
| 300 result[i] = elements[i]; | 216 result[i] = elements[i]; |
| 301 } | 217 } |
| 302 return result; | 218 return result; |
| 303 } | 219 } |
| 304 | 220 |
| 305 /* patch */ factory Float64List.view(ByteBuffer buffer, | 221 /* patch */ factory Float64List.view(ByteBuffer buffer, |
| 306 [int offsetInBytes = 0, int length]) { | 222 [int offsetInBytes = 0, int length]) { |
| 307 return new _Float64ArrayView(buffer, offsetInBytes, length); | 223 return new _Float64ArrayView(buffer, offsetInBytes, length); |
| 308 } | 224 } |
| 309 | |
| 310 static _ExternalFloat64Array _newTransferable(int length) { | |
| 311 return new _ExternalFloat64Array(length); | |
| 312 } | |
| 313 } | 225 } |
| 314 | 226 |
| 315 patch class Float32x4List { | 227 patch class Float32x4List { |
| 316 /* patch */ factory Float32x4List(int length) { | 228 /* patch */ factory Float32x4List(int length) { |
| 317 return new _Float32x4Array(length); | 229 return new _Float32x4Array(length); |
| 318 } | 230 } |
| 319 | 231 |
| 320 /* patch */ factory Float32x4List.transferable(int length) { | |
| 321 return _newTransferable(length); | |
| 322 } | |
| 323 | |
| 324 /* patch */ factory Float32x4List.view(ByteBuffer buffer, | 232 /* patch */ factory Float32x4List.view(ByteBuffer buffer, |
| 325 [int offsetInBytes = 0, int length]) { | 233 [int offsetInBytes = 0, int length]) { |
| 326 return new _Float32x4ArrayView(buffer, offsetInBytes, length); | 234 return new _Float32x4ArrayView(buffer, offsetInBytes, length); |
| 327 } | 235 } |
| 328 | |
| 329 static _ExternalFloat32x4Array _newTransferable(int length) { | |
| 330 return new _ExternalFloat32x4Array(length); | |
| 331 } | |
| 332 } | 236 } |
| 333 | 237 |
| 334 | 238 |
| 335 patch class Float32x4 { | 239 patch class Float32x4 { |
| 336 /* patch */ factory Float32x4(double x, double y, double z, double w) { | 240 /* patch */ factory Float32x4(double x, double y, double z, double w) { |
| 337 return new _Float32x4(x, y, z, w); | 241 return new _Float32x4(x, y, z, w); |
| 338 } | 242 } |
| 339 /* patch */ factory Float32x4.zero() { | 243 /* patch */ factory Float32x4.zero() { |
| 340 return new _Float32x4.zero(); | 244 return new _Float32x4.zero(); |
| 341 } | 245 } |
| 342 } | 246 } |
| 343 | 247 |
| 344 | 248 |
| 345 patch class Uint32x4 { | 249 patch class Uint32x4 { |
| 346 /* patch */ factory Uint32x4(int x, int y, int z, int w) { | 250 /* patch */ factory Uint32x4(int x, int y, int z, int w) { |
| 347 return new _Uint32x4(x, y, z, w); | 251 return new _Uint32x4(x, y, z, w); |
| 348 } | 252 } |
| 349 /* patch */ factory Uint32x4.bool(bool x, bool y, bool z, bool w) { | 253 /* patch */ factory Uint32x4.bool(bool x, bool y, bool z, bool w) { |
| 350 return new _Uint32x4.bool(x, y, z, w); | 254 return new _Uint32x4.bool(x, y, z, w); |
| 351 } | 255 } |
| 352 } | 256 } |
| 353 | 257 |
| 354 | 258 |
| 355 patch class ByteData { | 259 patch class ByteData { |
| 356 /* patch */ factory ByteData(int length) { | 260 /* patch */ factory ByteData(int length) { |
| 357 var list = new _Uint8Array(length); | 261 var list = new _Uint8Array(length); |
| 358 return new _ByteDataView(list.buffer, 0, length); | 262 return new _ByteDataView(list.buffer, 0, length); |
| 359 } | 263 } |
| 360 | 264 |
| 361 /* patch */ factory ByteData.transferable(int length) { | |
| 362 var list = new _Uint8Array.transferable(length); | |
| 363 return new _ByteDataView(list.buffer, 0, length); | |
| 364 } | |
| 365 | |
| 366 /* patch */ factory ByteData.view(ByteBuffer buffer, | 265 /* patch */ factory ByteData.view(ByteBuffer buffer, |
| 367 [int offsetInBytes = 0, int length]) { | 266 [int offsetInBytes = 0, int length]) { |
| 368 if (length == null) { | 267 if (length == null) { |
| 369 length = buffer.lengthInBytes - offsetInBytes; | 268 length = buffer.lengthInBytes - offsetInBytes; |
| 370 } | 269 } |
| 371 return new _ByteDataView(buffer, offsetInBytes, length); | 270 return new _ByteDataView(buffer, offsetInBytes, length); |
| 372 } | 271 } |
| 373 } | 272 } |
| 374 | 273 |
| 375 | 274 |
| (...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3175 return value; | 3074 return value; |
| 3176 } | 3075 } |
| 3177 return object; | 3076 return object; |
| 3178 } | 3077 } |
| 3179 | 3078 |
| 3180 | 3079 |
| 3181 void _throwRangeError(int index, int length) { | 3080 void _throwRangeError(int index, int length) { |
| 3182 String message = "$index must be in the range [0..$length)"; | 3081 String message = "$index must be in the range [0..$length)"; |
| 3183 throw new RangeError(message); | 3082 throw new RangeError(message); |
| 3184 } | 3083 } |
| OLD | NEW |