Chromium Code Reviews| Index: runtime/lib/typeddata.dart |
| diff --git a/runtime/lib/typeddata.dart b/runtime/lib/typeddata.dart |
| index 35eed4ff9839a58c95d1d0f287b479d7b7aea210..4b9dd54a464877273499e8524fbd59294a3e0bbd 100644 |
| --- a/runtime/lib/typeddata.dart |
| +++ b/runtime/lib/typeddata.dart |
| @@ -13,6 +13,12 @@ patch class Int8List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Int8List.fromList(List<int> elements) { |
|
Anton Muhin
2013/04/10 13:32:19
might be too esoteric, but why not
=> new _Int8Ar
Mads Ager (google)
2013/04/10 13:34:23
Yeah, I had a variation on that one but didn't lik
|
| + var result = new _Int8Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
|
Ivan Posva
2013/04/12 16:21:35
Curly braces.
Mads Ager (google)
2013/04/15 06:00:07
Done.
|
| + return result; |
| + } |
| + |
| /* patch */ factory Int8List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Int8ArrayView(buffer, offsetInBytes, length); |
| @@ -33,6 +39,12 @@ patch class Uint8List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Uint8List.fromList(List<int> elements) { |
| + var result = new _Uint8Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
|
Ivan Posva
2013/04/12 16:21:35
Ditto here and below.
Mads Ager (google)
2013/04/15 06:00:07
Done.
|
| + return result; |
| + } |
| + |
| /* patch */ factory Uint8List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Uint8ArrayView(buffer, offsetInBytes, length); |
| @@ -53,6 +65,12 @@ patch class Uint8ClampedList { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Uint8ClampedList.fromList(List<int> elements) { |
| + var result = new _Uint8ClampedArray(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, |
| int length]) { |
| @@ -74,6 +92,12 @@ patch class Int16List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Int16List.fromList(List<int> elements) { |
| + var result = new _Int16Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Int16List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Int16ArrayView(buffer, offsetInBytes, length); |
| @@ -94,6 +118,12 @@ patch class Uint16List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Uint16List.fromList(List<int> elements) { |
| + var result = new _Uint16Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Uint16List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Uint16ArrayView(buffer, offsetInBytes, length); |
| @@ -114,6 +144,12 @@ patch class Int32List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Int32List.fromList(List<int> elements) { |
| + var result = new _Int32Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Int32List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Int32ArrayView(buffer, offsetInBytes, length); |
| @@ -134,6 +170,12 @@ patch class Uint32List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Uint32List.fromList(List<int> elements) { |
| + var result = new _Uint32Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Uint32List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Uint32ArrayView(buffer, offsetInBytes, length); |
| @@ -154,6 +196,12 @@ patch class Int64List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Int64List.fromList(List<int> elements) { |
| + var result = new _Int64Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Int64List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Int64ArrayView(buffer, offsetInBytes, length); |
| @@ -174,6 +222,12 @@ patch class Uint64List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Uint64List.fromList(List<int> elements) { |
| + var result = new _Uint64Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Uint64List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Uint64ArrayView(buffer, offsetInBytes, length); |
| @@ -194,6 +248,12 @@ patch class Float32List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Float32List.fromList(List<double> elements) { |
| + var result = new _Float32Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Float32List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Float32ArrayView(buffer, offsetInBytes, length); |
| @@ -214,6 +274,12 @@ patch class Float64List { |
| return _newTransferable(length); |
| } |
| + /* patch */ factory Float64List.fromList(List<double> elements) { |
| + var result = new _Float64Array(elements.length); |
| + for (int i = 0; i < elements.length; i++) result[i] = elements[i]; |
| + return result; |
| + } |
| + |
| /* patch */ factory Float64List.view(ByteBuffer buffer, |
| [int offsetInBytes = 0, int length]) { |
| return new _Float64ArrayView(buffer, offsetInBytes, length); |