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

Unified Diff: runtime/lib/typeddata.dart

Issue 12730013: - Use dart:typedata types in the Dart API calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
Index: runtime/lib/typeddata.dart
===================================================================
--- runtime/lib/typeddata.dart (revision 19764)
+++ runtime/lib/typeddata.dart (working copy)
@@ -436,7 +436,7 @@
List getRange(int start, int length) {
_rangeCheck(this.length, start, length);
- List result = _new(length);
+ List result = _createList(length);
result.setRange(0, length, this, start);
return result;
}
@@ -559,6 +559,10 @@
// Internal utility methods.
+ _Int8Array _createList(int length) {
+ return _new(length);
+ }
+
static _Int8Array _new(int length) native "TypedData_Int8Array_new";
}
@@ -610,8 +614,13 @@
return Uint8List.BYTES_PER_ELEMENT;
}
+
// Internal utility methods.
+ _Uint8Array _createList(int length) {
+ return _new(length);
+ }
+
Ivan Posva 2013/03/12 09:32:02 Missing line.
siva 2013/03/12 10:31:46 It seems to have a blank line. On 2013/03/12 09:3
static _Uint8Array _new(int length) native "TypedData_Uint8Array_new";
}
@@ -667,6 +676,10 @@
// Internal utility methods.
+ _Uint8ClampedArray _createList(int length) {
+ return _new(length);
+ }
+
Ivan Posva 2013/03/12 09:32:02 ditto here and more below.
siva 2013/03/12 10:31:46 Seems to have it. The pattern in the file was one
static _Uint8ClampedArray _new(int length)
native "TypedData_Uint8ClampedArray_new";
}
@@ -725,6 +738,10 @@
// Internal utility methods.
+ _Int16Array _createList(int length) {
+ return _new(length);
+ }
+
static _Int16Array _new(int length) native "TypedData_Int16Array_new";
}
@@ -782,6 +799,10 @@
// Internal utility methods.
+ _Uint16Array _createList(int length) {
+ return _new(length);
+ }
+
static _Uint16Array _new(int length) native "TypedData_Uint16Array_new";
}
@@ -839,6 +860,10 @@
// Internal utility methods.
+ _Int32Array _createList(int length) {
+ return _new(length);
+ }
+
static _Int32Array _new(int length) native "TypedData_Int32Array_new";
}
@@ -896,6 +921,10 @@
// Internal utility methods.
+ _Uint32Array _createList(int length) {
+ return _new(length);
+ }
+
static _Uint32Array _new(int length) native "TypedData_Uint32Array_new";
}
@@ -953,6 +982,10 @@
// Internal utility methods.
+ _Int64Array _createList(int length) {
+ return _new(length);
+ }
+
static _Int64Array _new(int length) native "TypedData_Int64Array_new";
}
@@ -1010,6 +1043,10 @@
// Internal utility methods.
+ _Uint64Array _createList(int length) {
+ return _new(length);
+ }
+
static _Uint64Array _new(int length) native "TypedData_Uint64Array_new";
}
@@ -1067,6 +1104,10 @@
// Internal utility methods.
+ _Float32Array _createList(int length) {
+ return _new(length);
+ }
+
static _Float32Array _new(int length) native "TypedData_Float32Array_new";
}
@@ -1124,6 +1165,10 @@
// Internal utility methods.
+ _Float64Array _createList(int length) {
+ return _new(length);
+ }
+
static _Float64Array _new(int length) native "TypedData_Float64Array_new";
}
@@ -1171,6 +1216,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
Mads Ager (google) 2013/03/12 08:18:03 List<int> -> Int8List? Similarly for the ones bel
siva 2013/03/12 10:31:46 Good point. Changed all the return values. On 201
+ return new Int8List(length);
+ }
+
static _ExternalInt8Array _new(int length) native
"ExternalTypedData_Int8Array_new";
}
@@ -1210,7 +1259,6 @@
return new _TypedListIterator<int>(this);
}
-
Ivan Posva 2013/03/12 09:32:02 ?
siva 2013/03/12 10:31:46 Done.
// Method(s) implementing the TypedData interface.
int get elementSizeInBytes {
@@ -1220,6 +1268,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Uint8List(length);
+ }
+
static _ExternalUint8Array _new(int length) native
"ExternalTypedData_Uint8Array_new";
}
@@ -1269,6 +1321,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Uint8ClampedList(length);
+ }
+
static _ExternalUint8ClampedArray _new(int length) native
"ExternalTypedData_Uint8ClampedArray_new";
}
@@ -1318,6 +1374,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Int16List(length);
+ }
+
static _ExternalInt16Array _new(int length) native
"ExternalTypedData_Int16Array_new";
}
@@ -1367,6 +1427,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Uint16List(length);
+ }
+
static _ExternalUint16Array _new(int length) native
"ExternalTypedData_Uint16Array_new";
}
@@ -1416,6 +1480,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Int32List(length);
+ }
+
static _ExternalInt32Array _new(int length) native
"ExternalTypedData_Int32Array_new";
}
@@ -1465,6 +1533,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Uint32List(length);
+ }
+
static _ExternalUint32Array _new(int length) native
"ExternalTypedData_Uint32Array_new";
}
@@ -1514,6 +1586,10 @@
// Internal utility methods.
+ List<int> _createList(int length) {
+ return new Int64List(length);
+ }
+
static _ExternalInt64Array _new(int length) native
"ExternalTypedData_Int64Array_new";
}
@@ -1556,6 +1632,10 @@
// Method(s) implementing the TypedData interface.
+ List<int> _createList(int length) {
+ return new Uint64List(length);
+ }
+
int get elementSizeInBytes {
return Uint64List.BYTES_PER_ELEMENT;
}
@@ -1612,6 +1692,10 @@
// Internal utility methods.
+ List<double> _createList(int length) {
+ return new Float32List(length);
+ }
+
static _ExternalFloat32Array _new(int length) native
"ExternalTypedData_Float32Array_new";
}
@@ -1661,6 +1745,10 @@
// Internal utility methods.
+ List<double> _createList(int length) {
+ return new Float64List(length);
+ }
+
static _ExternalFloat64Array _new(int length) native
"ExternalTypedData_Float64Array_new";
}
@@ -1695,7 +1783,8 @@
class _TypedListView extends _TypedListBase implements TypedData {
_TypedListView(ByteBuffer _buffer, int _offset, int _length)
- : _typeddata = _buffer, // This assignment is type safe.
+ : super(),
Anton Muhin 2013/03/12 08:31:46 nit: as per style guide, shouldn't super ctor invo
siva 2013/03/12 10:31:46 Removed the explicit invoke of the default ctor, I
+ _typeddata = _buffer, // This assignment is type safe.
offsetInBytes = _offset,
length = _length {
}
@@ -1725,8 +1814,8 @@
((buffer.lengthInBytes - _offsetInBytes) ~/
Int8List.BYTES_PER_ELEMENT))) {
_rangeCheck(buffer.lengthInBytes,
- offsetInBytes,
- length * Int8List.BYTES_PER_ELEMENT);
+ _offsetInBytes,
+ _length * Int8List.BYTES_PER_ELEMENT);
}
@@ -1771,8 +1860,8 @@
((buffer.lengthInBytes - _offsetInBytes) ~/
Uint8List.BYTES_PER_ELEMENT))) {
_rangeCheck(buffer.lengthInBytes,
- offsetInBytes,
- length * Uint8List.BYTES_PER_ELEMENT);
+ _offsetInBytes,
+ _length * Uint8List.BYTES_PER_ELEMENT);
}
@@ -2397,4 +2486,5 @@
if (object == null) {
return value;
}
+ return object;
}

Powered by Google App Engine
This is Rietveld 408576698