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

Unified Diff: runtime/lib/typeddata.dart

Issue 13834008: Add fromList constructor to typeddata typed lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test for mixing int and double lists. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/typeddata/typeddata.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/typeddata.dart
diff --git a/runtime/lib/typeddata.dart b/runtime/lib/typeddata.dart
index 8419031cc7ab96235ef462c2744fc988d1207c57..9d12fb9d6365d73d89e80141a750d71abf047871 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) {
+ var result = new _Int8Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ 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];
+ 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);
« no previous file with comments | « no previous file | sdk/lib/typeddata/typeddata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698