Revert "Make VM TypedList not implement ByteBuffer."

Html transferable test fails to send buffer as buffer.

Review URL: https://codereview.chromium.org//137783019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31875 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
lrn@google.com 2014-01-16 11:48:07 +00:00
parent acc80fb8a2
commit 9357caa547
11 changed files with 87 additions and 227 deletions

View file

@ -298,7 +298,7 @@ patch class Int32x4 {
patch class ByteData { patch class ByteData {
/* patch */ factory ByteData(int length) { /* patch */ factory ByteData(int length) {
var list = new _Uint8Array(length); var list = new _Uint8Array(length);
return new _ByteDataView(list, 0, length); return new _ByteDataView(list.buffer, 0, length);
} }
/* patch */ factory ByteData.view(ByteBuffer buffer, /* patch */ factory ByteData.view(ByteBuffer buffer,
@ -306,13 +306,8 @@ patch class ByteData {
if (length == null) { if (length == null) {
length = buffer.lengthInBytes - offsetInBytes; length = buffer.lengthInBytes - offsetInBytes;
} }
_ByteBuffer internalBuffer = buffer; return new _ByteDataView(buffer, offsetInBytes, length);
return new _ByteDataView(internalBuffer._typedData, offsetInBytes, length);
} }
// Called directly from C code.
factory ByteData._view(TypedData typedData, int offsetInBytes, int length)
=> new _ByteDataView(typedData, offsetInBytes, length);
} }
@ -559,14 +554,11 @@ abstract class _TypedListBase {
if (needsClamping) { if (needsClamping) {
Lists.copy(from, skipCount, this, start, count); Lists.copy(from, skipCount, this, start, count);
return; return;
} } else if (this.buffer._setRange(
_ByteBuffer buffer = this.buffer; start * elementSizeInBytes + this.offsetInBytes,
_ByteBuffer fromBuffer = from.buffer; count * elementSizeInBytes,
if (buffer._typedData._setRange( from.buffer,
start * elementSizeInBytes + this.offsetInBytes, skipCount * elementSizeInBytes + from.offsetInBytes)) {
count * elementSizeInBytes,
fromBuffer._typedData,
skipCount * elementSizeInBytes + from.offsetInBytes)) {
return; return;
} }
} else if (from.buffer == this.buffer) { } else if (from.buffer == this.buffer) {
@ -615,7 +607,7 @@ abstract class _TypedListBase {
} }
abstract class _TypedList extends _TypedListBase { abstract class _TypedList extends _TypedListBase implements ByteBuffer {
// Default method implementing parts of the TypedData interface. // Default method implementing parts of the TypedData interface.
int get offsetInBytes { int get offsetInBytes {
return 0; return 0;
@ -625,7 +617,9 @@ abstract class _TypedList extends _TypedListBase {
return length * elementSizeInBytes; return length * elementSizeInBytes;
} }
ByteBuffer get buffer => new _ByteBuffer(this); ByteBuffer get buffer {
return this;
}
// Methods implementing the collection interface. // Methods implementing the collection interface.
@ -2340,14 +2334,11 @@ class _TypedListIterator<E> implements Iterator<E> {
class _TypedListView extends _TypedListBase implements TypedData { class _TypedListView extends _TypedListBase implements TypedData {
final TypedData _typedData;
final int offsetInBytes;
final int length;
_TypedListView(ByteBuffer _buffer, int _offset, int _length) _TypedListView(ByteBuffer _buffer, int _offset, int _length)
: _typedData = (_buffer as _ByteBuffer)._typedData, : _typedData = _buffer, // This assignment is type safe.
offsetInBytes = _offset, offsetInBytes = _offset,
length = _length; length = _length {
}
// Method(s) implementing the TypedData interface. // Method(s) implementing the TypedData interface.
@ -2358,6 +2349,10 @@ class _TypedListView extends _TypedListBase implements TypedData {
ByteBuffer get buffer { ByteBuffer get buffer {
return _typedData.buffer; return _typedData.buffer;
} }
final TypedData _typedData;
final int offsetInBytes;
final int length;
} }
@ -3038,17 +3033,14 @@ class _Int32x4ArrayView extends _TypedListView implements Int32x4List {
class _ByteDataView implements ByteData { class _ByteDataView implements ByteData {
final TypedData _typedData; _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes)
final int _offset; : _typedData = _buffer, // _buffer is guaranteed to be a TypedData here.
final int length;
_ByteDataView(TypedData typedData, int _offsetInBytes, int _lengthInBytes)
: _typedData = typedData,
_offset = _offsetInBytes, _offset = _offsetInBytes,
length = _lengthInBytes { length = _lengthInBytes {
_rangeCheck(typedData.lengthInBytes, _offset, length); _rangeCheck(_buffer.lengthInBytes, _offset, length);
} }
// Method(s) implementing TypedData interface. // Method(s) implementing TypedData interface.
ByteBuffer get buffer { ByteBuffer get buffer {
@ -3319,6 +3311,11 @@ class _ByteDataView implements ByteData {
native "ByteData_ToEndianFloat32"; native "ByteData_ToEndianFloat32";
static double _toEndianFloat64(double host_value, bool little_endian) static double _toEndianFloat64(double host_value, bool little_endian)
native "ByteData_ToEndianFloat64"; native "ByteData_ToEndianFloat64";
final TypedData _typedData;
final int _offset;
final int length;
} }
@ -3410,18 +3407,3 @@ void _throwRangeError(int index, int length) {
String message = "$index must be in the range [0..$length)"; String message = "$index must be in the range [0..$length)";
throw new RangeError(message); throw new RangeError(message);
} }
/**
* Internal implementation of [ByteBuffer].
*/
class _ByteBuffer implements ByteBuffer {
final _TypedList _typedData;
_ByteBuffer(this._typedData);
int get lengthInBytes => _typedData.lengthInBytes;
int get hashCode => _typedData.hashCode;
bool operator==(Object other) =>
other is _ByteBuffer && identical(_typedData, other._typedData);
}

View file

@ -2628,7 +2628,7 @@ static Dart_Handle NewExternalByteData(
return ext_data; return ext_data;
} }
Object& result = Object::Handle(isolate); Object& result = Object::Handle(isolate);
result = GetByteDataConstructor(isolate, Symbols::ByteDataDot_view(), 3); result = GetByteDataConstructor(isolate, Symbols::ByteDataDotview(), 3);
ASSERT(!result.IsNull()); ASSERT(!result.IsNull());
ASSERT(result.IsFunction()); ASSERT(result.IsFunction());
const Function& factory = Function::Cast(result); const Function& factory = Function::Cast(result);

View file

@ -235,26 +235,26 @@ TEST_CASE(Service_Classes) {
Service::HandleIsolateMessage(isolate, service_msg); Service::HandleIsolateMessage(isolate, service_msg);
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Class\",\"id\":\"classes\\/1010\",\"name\":\"A\"," "{\"type\":\"Class\",\"id\":\"classes\\/1009\",\"name\":\"A\","
"\"user_name\":\"A\",\"implemented\":false,\"abstract\":false," "\"user_name\":\"A\",\"implemented\":false,\"abstract\":false,"
"\"patch\":false,\"finalized\":true,\"const\":false,\"super\":" "\"patch\":false,\"finalized\":true,\"const\":false,\"super\":"
"{\"type\":\"@Class\",\"id\":\"classes\\/35\",\"name\":\"Object\"," "{\"type\":\"@Class\",\"id\":\"classes\\/35\",\"name\":\"Object\","
"\"user_name\":\"Object\"},\"library\":{\"type\":\"@Library\",\"id\":" "\"user_name\":\"Object\"},\"library\":{\"type\":\"@Library\",\"id\":"
"\"libraries\\/12\",\"name\":\"\",\"user_name\":\"dart:test-lib\"}," "\"libraries\\/12\",\"name\":\"\",\"user_name\":\"dart:test-lib\"},"
"\"fields\":[{\"type\":\"@Field\",\"id\":\"classes\\/1010\\/fields\\/0\"," "\"fields\":[{\"type\":\"@Field\",\"id\":\"classes\\/1009\\/fields\\/0\","
"\"name\":\"a\",\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\"," "\"name\":\"a\",\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\","
"\"id\":\"classes\\/1010\",\"name\":\"A\",\"user_name\":\"A\"}," "\"id\":\"classes\\/1009\",\"name\":\"A\",\"user_name\":\"A\"},"
"\"declared_type\":{\"type\":\"@Class\",\"id\":\"classes\\/106\"," "\"declared_type\":{\"type\":\"@Class\",\"id\":\"classes\\/106\","
"\"name\":\"dynamic\",\"user_name\":\"dynamic\"},\"static\":false," "\"name\":\"dynamic\",\"user_name\":\"dynamic\"},\"static\":false,"
"\"final\":false,\"const\":false}],\"functions\":[" "\"final\":false,\"const\":false}],\"functions\":["
"{\"type\":\"@Function\",\"id\":\"classes\\/1010\\/functions\\/0\"," "{\"type\":\"@Function\",\"id\":\"classes\\/1009\\/functions\\/0\","
"\"name\":\"get:a\",\"user_name\":\"A.a\"},{\"type\":\"@Function\"," "\"name\":\"get:a\",\"user_name\":\"A.a\"},{\"type\":\"@Function\","
"\"id\":\"classes\\/1010\\/functions\\/1\",\"name\":\"set:a\"," "\"id\":\"classes\\/1009\\/functions\\/1\",\"name\":\"set:a\","
"\"user_name\":\"A.a=\"},{\"type\":\"@Function\",\"id\":" "\"user_name\":\"A.a=\"},{\"type\":\"@Function\",\"id\":"
"\"classes\\/1010\\/functions\\/2\",\"name\":\"b\",\"user_name\":\"A.b\"}" "\"classes\\/1009\\/functions\\/2\",\"name\":\"b\",\"user_name\":\"A.b\"}"
",{\"type\":\"@Function\",\"id\":\"classes\\/1010\\/functions\\/3\"," ",{\"type\":\"@Function\",\"id\":\"classes\\/1009\\/functions\\/3\","
"\"name\":\"c\",\"user_name\":\"A.c\"},{\"type\":\"@Function\",\"id\":" "\"name\":\"c\",\"user_name\":\"A.c\"},{\"type\":\"@Function\",\"id\":"
"\"classes\\/1010\\/functions\\/4\",\"name\":\"A.\",\"user_name\":" "\"classes\\/1009\\/functions\\/4\",\"name\":\"A.\",\"user_name\":"
"\"A.A\"}]}", "\"A.A\"}]}",
handler.msg()); handler.msg());
@ -264,7 +264,7 @@ TEST_CASE(Service_Classes) {
Service::HandleIsolateMessage(isolate, service_msg); Service::HandleIsolateMessage(isolate, service_msg);
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Function\",\"id\":\"classes\\/1010\\/functions\\/0\",\"name\":" "{\"type\":\"Function\",\"id\":\"classes\\/1009\\/functions\\/0\",\"name\":"
"\"get:a\",\"user_name\":\"A.a\",\"is_static\":false,\"is_const\":false," "\"get:a\",\"user_name\":\"A.a\",\"is_static\":false,\"is_const\":false,"
"\"is_optimizable\":true,\"is_inlinable\":false,\"kind\":" "\"is_optimizable\":true,\"is_inlinable\":false,\"kind\":"
"\"kImplicitGetter\",\"unoptimized_code\":{\"type\":\"null\"}," "\"kImplicitGetter\",\"unoptimized_code\":{\"type\":\"null\"},"
@ -277,9 +277,9 @@ TEST_CASE(Service_Classes) {
Service::HandleIsolateMessage(isolate, service_msg); Service::HandleIsolateMessage(isolate, service_msg);
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Field\",\"id\":\"classes\\/1010\\/fields\\/0\",\"name\":\"a\"," "{\"type\":\"Field\",\"id\":\"classes\\/1009\\/fields\\/0\",\"name\":\"a\","
"\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\",\"id\":" "\"user_name\":\"a\",\"owner\":{\"type\":\"@Class\",\"id\":"
"\"classes\\/1010\",\"name\":\"A\",\"user_name\":\"A\"},\"declared_type\":" "\"classes\\/1009\",\"name\":\"A\",\"user_name\":\"A\"},\"declared_type\":"
"{\"type\":\"@Class\",\"id\":\"classes\\/106\",\"name\":\"dynamic\"," "{\"type\":\"@Class\",\"id\":\"classes\\/106\",\"name\":\"dynamic\","
"\"user_name\":\"dynamic\"},\"static\":false,\"final\":false,\"const\":" "\"user_name\":\"dynamic\"},\"static\":false,\"final\":false,\"const\":"
"false,\"guard_nullable\":true,\"guard_class\":{\"type\":\"@Class\"," "false,\"guard_nullable\":true,\"guard_class\":{\"type\":\"@Class\","
@ -293,7 +293,7 @@ TEST_CASE(Service_Classes) {
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":" "{\"type\":\"Error\",\"text\":\"Invalid sub collection huh\",\"message\":"
"{\"arguments\":[\"classes\",\"1010\",\"huh\",\"0\"],\"option_keys\":[]," "{\"arguments\":[\"classes\",\"1009\",\"huh\",\"0\"],\"option_keys\":[],"
"\"option_values\":[]}}", handler.msg()); "\"option_values\":[]}}", handler.msg());
// Invalid field request. // Invalid field request.
@ -303,7 +303,7 @@ TEST_CASE(Service_Classes) {
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Error\",\"text\":\"Field 9 not found\"," "{\"type\":\"Error\",\"text\":\"Field 9 not found\","
"\"message\":{\"arguments\":[\"classes\",\"1010\",\"fields\",\"9\"]," "\"message\":{\"arguments\":[\"classes\",\"1009\",\"fields\",\"9\"],"
"\"option_keys\":[],\"option_values\":[]}}", handler.msg()); "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
// Invalid function request. // Invalid function request.
@ -313,7 +313,7 @@ TEST_CASE(Service_Classes) {
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Error\",\"text\":\"Function 9 not found\"," "{\"type\":\"Error\",\"text\":\"Function 9 not found\","
"\"message\":{\"arguments\":[\"classes\",\"1010\",\"functions\",\"9\"]," "\"message\":{\"arguments\":[\"classes\",\"1009\",\"functions\",\"9\"],"
"\"option_keys\":[],\"option_values\":[]}}", handler.msg()); "\"option_keys\":[],\"option_values\":[]}}", handler.msg());
@ -324,7 +324,7 @@ TEST_CASE(Service_Classes) {
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":"
"{\"arguments\":[\"classes\",\"1010\",\"fields\",\"9\",\"x\"]," "{\"arguments\":[\"classes\",\"1009\",\"fields\",\"9\",\"x\"],"
"\"option_keys\":[],\"option_values\":[]}}", "\"option_keys\":[],\"option_values\":[]}}",
handler.msg()); handler.msg());
@ -335,7 +335,7 @@ TEST_CASE(Service_Classes) {
handler.HandleNextMessage(); handler.HandleNextMessage();
EXPECT_STREQ( EXPECT_STREQ(
"{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":" "{\"type\":\"Error\",\"text\":\"Command too long\",\"message\":"
"{\"arguments\":[\"classes\",\"1010\",\"functions\",\"9\",\"x\"]," "{\"arguments\":[\"classes\",\"1009\",\"functions\",\"9\",\"x\"],"
"\"option_keys\":[],\"option_values\":[]}}", "\"option_keys\":[],\"option_values\":[]}}",
handler.msg()); handler.msg());
} }

View file

@ -2403,44 +2403,44 @@ UNIT_TEST_CASE(DartGeneratedListMessagesWithTypedData) {
"getTypedDataViewList() {\n" "getTypedDataViewList() {\n"
" var list = new List(30);\n" " var list = new List(30);\n"
" var index = 0;\n" " var index = 0;\n"
" list[index++] = new Int8List.view(new Int8List(256).buffer);\n" " list[index++] = new Int8List.view(new Int8List(256));\n"
" list[index++] = new Uint8List.view(new Uint8List(256).buffer);\n" " list[index++] = new Uint8List.view(new Uint8List(256));\n"
" list[index++] = new Int16List.view(new Int16List(256).buffer);\n" " list[index++] = new Int16List.view(new Int16List(256));\n"
" list[index++] = new Uint16List.view(new Uint16List(256).buffer);\n" " list[index++] = new Uint16List.view(new Uint16List(256));\n"
" list[index++] = new Int32List.view(new Int32List(256).buffer);\n" " list[index++] = new Int32List.view(new Int32List(256));\n"
" list[index++] = new Uint32List.view(new Uint32List(256).buffer);\n" " list[index++] = new Uint32List.view(new Uint32List(256));\n"
" list[index++] = new Int64List.view(new Int64List(256).buffer);\n" " list[index++] = new Int64List.view(new Int64List(256));\n"
" list[index++] = new Uint64List.view(new Uint64List(256).buffer);\n" " list[index++] = new Uint64List.view(new Uint64List(256));\n"
" list[index++] = new Float32List.view(new Float32List(256).buffer);\n" " list[index++] = new Float32List.view(new Float32List(256));\n"
" list[index++] = new Float64List.view(new Float64List(256).buffer);\n" " list[index++] = new Float64List.view(new Float64List(256));\n"
" list[index++] = new Int8List.view(new Int16List(256).buffer);\n" " list[index++] = new Int8List.view(new Int16List(256));\n"
" list[index++] = new Uint8List.view(new Uint16List(256).buffer);\n" " list[index++] = new Uint8List.view(new Uint16List(256));\n"
" list[index++] = new Int8List.view(new Int32List(256).buffer);\n" " list[index++] = new Int8List.view(new Int32List(256));\n"
" list[index++] = new Uint8List.view(new Uint32List(256).buffer);\n" " list[index++] = new Uint8List.view(new Uint32List(256));\n"
" list[index++] = new Int8List.view(new Int64List(256).buffer);\n" " list[index++] = new Int8List.view(new Int64List(256));\n"
" list[index++] = new Uint8List.view(new Uint64List(256).buffer);\n" " list[index++] = new Uint8List.view(new Uint64List(256));\n"
" list[index++] = new Int8List.view(new Float32List(256).buffer);\n" " list[index++] = new Int8List.view(new Float32List(256));\n"
" list[index++] = new Uint8List.view(new Float32List(256).buffer);\n" " list[index++] = new Uint8List.view(new Float32List(256));\n"
" list[index++] = new Int8List.view(new Float64List(256).buffer);\n" " list[index++] = new Int8List.view(new Float64List(256));\n"
" list[index++] = new Uint8List.view(new Float64List(256).buffer);\n" " list[index++] = new Uint8List.view(new Float64List(256));\n"
" list[index++] = new Int16List.view(new Int8List(256).buffer);\n" " list[index++] = new Int16List.view(new Int8List(256));\n"
" list[index++] = new Uint16List.view(new Uint8List(256).buffer);\n" " list[index++] = new Uint16List.view(new Uint8List(256));\n"
" list[index++] = new Int16List.view(new Int32List(256).buffer);\n" " list[index++] = new Int16List.view(new Int32List(256));\n"
" list[index++] = new Uint16List.view(new Uint32List(256).buffer);\n" " list[index++] = new Uint16List.view(new Uint32List(256));\n"
" list[index++] = new Int16List.view(new Int64List(256).buffer);\n" " list[index++] = new Int16List.view(new Int64List(256));\n"
" list[index++] = new Uint16List.view(new Uint64List(256).buffer);\n" " list[index++] = new Uint16List.view(new Uint64List(256));\n"
" list[index++] = new Int16List.view(new Float32List(256).buffer);\n" " list[index++] = new Int16List.view(new Float32List(256));\n"
" list[index++] = new Uint16List.view(new Float32List(256).buffer);\n" " list[index++] = new Uint16List.view(new Float32List(256));\n"
" list[index++] = new Int16List.view(new Float64List(256).buffer);\n" " list[index++] = new Int16List.view(new Float64List(256));\n"
" list[index++] = new Uint16List.view(new Float64List(256).buffer);\n" " list[index++] = new Uint16List.view(new Float64List(256));\n"
" return list;\n" " return list;\n"
"}\n" "}\n"
"getMultipleTypedDataViewList() {\n" "getMultipleTypedDataViewList() {\n"
" var list = new List(10);\n" " var list = new List(10);\n"
" var index = 0;\n" " var index = 0;\n"
" var data = new Uint8List(256).buffer;\n" " var data = new Uint8List(256);\n"
" list[index++] = new Int8List.view(data);\n" " list[index++] = new Int8List.view(data);\n"
" list[index++] = new Uint8List.view(data);\n" " list[index++] = new Uint8List.view(data);\n"
" list[index++] = new Int16List.view(data);\n" " list[index++] = new Int16List.view(data);\n"

View file

@ -218,7 +218,7 @@ class ObjectPointerVisitor;
V(_ExternalFloat64Array, "_ExternalFloat64Array") \ V(_ExternalFloat64Array, "_ExternalFloat64Array") \
V(ByteData, "ByteData") \ V(ByteData, "ByteData") \
V(ByteDataDot, "ByteData.") \ V(ByteDataDot, "ByteData.") \
V(ByteDataDot_view, "ByteData._view") \ V(ByteDataDotview, "ByteData.view") \
V(_ByteDataView, "_ByteDataView") \ V(_ByteDataView, "_ByteDataView") \
V(_WeakProperty, "_WeakProperty") \ V(_WeakProperty, "_WeakProperty") \
V(_MirrorReference, "_MirrorReference") \ V(_MirrorReference, "_MirrorReference") \

View file

@ -12,10 +12,6 @@ import 'dart:math' show Random;
* A sequence of bytes underlying a typed data object. * A sequence of bytes underlying a typed data object.
* Used to process large quantities of binary or numerical data * Used to process large quantities of binary or numerical data
* more efficiently using a typed view. * more efficiently using a typed view.
*
* The `ByteBuffer` instances created by this library are the only ones
* that will work with the `view` constructors.
* Creating a class implementing `ByteBuffer` will not make it usable.
*/ */
abstract class ByteBuffer { abstract class ByteBuffer {
/** /**
@ -23,15 +19,6 @@ abstract class ByteBuffer {
*/ */
int get lengthInBytes; int get lengthInBytes;
int get hashCode;
/**
* Is [other] a `ByteBuffer` holding the same memory as this.
*
* A `ByteBuffer` is only equal to another `ByteBuffer` that
* represents the same underlying memory.
*/
bool operator==(Object other);
} }
@ -57,10 +44,6 @@ abstract class TypedData {
/** /**
* Returns the byte buffer associated with this object. * Returns the byte buffer associated with this object.
*
* The returned object represents the underlying memory.
* It may be the same object returned each time, or a new object representing
* the same memory.
*/ */
ByteBuffer get buffer; ByteBuffer get buffer;
} }
@ -71,6 +54,8 @@ abstract class TypedData {
* sequence of bytes. * sequence of bytes.
*/ */
class Endianness { class Endianness {
const Endianness._(this._littleEndian);
static const Endianness BIG_ENDIAN = const Endianness._(false); static const Endianness BIG_ENDIAN = const Endianness._(false);
static const Endianness LITTLE_ENDIAN = const Endianness._(true); static const Endianness LITTLE_ENDIAN = const Endianness._(true);
static final Endianness HOST_ENDIAN = static final Endianness HOST_ENDIAN =
@ -78,8 +63,6 @@ class Endianness {
LITTLE_ENDIAN : BIG_ENDIAN; LITTLE_ENDIAN : BIG_ENDIAN;
final bool _littleEndian; final bool _littleEndian;
const Endianness._(this._littleEndian);
} }

View file

@ -31,21 +31,6 @@ LibTest/collection/HashSet/HashSet_class_A01_t01: RuntimeError, OK # co19 issue
LibTest/collection/LinkedHashSet/LinkedHashSet_class_A01_t01: RuntimeError, OK # co19 issue 663 LibTest/collection/LinkedHashSet/LinkedHashSet_class_A01_t01: RuntimeError, OK # co19 issue 663
LibTest/core/Set/IterableBase_A01_t01: RuntimeError, OK # co19 issue 663 LibTest/core/Set/IterableBase_A01_t01: RuntimeError, OK # co19 issue 663
LibTest/typed_data/ByteData/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Float32List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Float32x4List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Float64List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Int16List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Int32List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Int64List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Int8List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Uint16List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Uint32List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Uint64List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Uint8ClampedList/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
LibTest/typed_data/Uint8List/buffer_A01_t01: RuntimeError, PASS # co19 issue 669
[ $runtime == vm || $runtime == dartium || $compiler == dart2js ] [ $runtime == vm || $runtime == dartium || $compiler == dart2js ]
LibTest/math/acos_A01_t01: PASS, FAIL, OK # co19 issue 44 LibTest/math/acos_A01_t01: PASS, FAIL, OK # co19 issue 44
LibTest/math/asin_A01_t01: PASS, FAIL, OK # co19 issue 44 LibTest/math/asin_A01_t01: PASS, FAIL, OK # co19 issue 44

View file

@ -192,7 +192,6 @@ convert/json_util_test: Fail # Issue 16109
[ $compiler == dart2js ] [ $compiler == dart2js ]
typed_data/typed_data_hierarchy_int64_test: RuntimeError # Issue 10275 typed_data/typed_data_hierarchy_int64_test: RuntimeError # Issue 10275
typed_data/int32x4_bigint_test: RuntimeError # Issue 1533 typed_data/int32x4_bigint_test: RuntimeError # Issue 1533
typed_data/typed_list_buffer_test/01: RuntimeError # Issue 10275
[ $runtime == opera ] [ $runtime == opera ]
async/multiple_timer_test: Pass, Fail # Probably issue 14734 async/multiple_timer_test: Pass, Fail # Probably issue 14734

View file

@ -1,83 +0,0 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
import 'dart:typed_data';
// Test that the sublist of a typed_data list is of the same type.
class TypedDataConstructor {
final String name;
final Function create;
final Function view;
TypedDataConstructor(this.name, this.create, this.view);
}
List constructors = [
new TypedDataConstructor("ByteData",
(int n) => new ByteData(n),
(ByteBuffer b) => new ByteData.view(b)),
new TypedDataConstructor("Int8",
(int n) => new Int8List(n),
(ByteBuffer b) => new Int8List.view(b)),
new TypedDataConstructor("Uint8",
(int n) => new Uint8List(n),
(ByteBuffer b) => new Uint8List.view(b)),
new TypedDataConstructor("Uint8Clamped",
(int n) => new Uint8ClampedList(n),
(ByteBuffer b) => new Uint8ClampedList.view(b)),
new TypedDataConstructor("Int16",
(int n) => new Int16List(n),
(ByteBuffer b) => new Int16List.view(b)),
new TypedDataConstructor("Uint16",
(int n) => new Uint16List(n),
(ByteBuffer b) => new Uint16List.view(b)),
new TypedDataConstructor("Int32",
(int n) => new Int32List(n),
(ByteBuffer b) => new Int32List.view(b)),
new TypedDataConstructor("Uint32",
(int n) => new Uint32List(n),
(ByteBuffer b) => new Uint32List.view(b)),
// Int64 and Uint64 are not supported on dart2js compiled code.
new TypedDataConstructor("Int64", /// 01: ok
(int n) => new Int64List(n), /// 01: continued
(ByteBuffer b) => new Int64List.view(b)), /// 01: continued
new TypedDataConstructor("Uint64", /// 01: continued
(int n) => new Uint64List(n), /// 01: continued
(ByteBuffer b) => new Uint64List.view(b)), /// 01: continued
new TypedDataConstructor("Float32",
(int n) => new Float32List(n),
(ByteBuffer b) => new Float32List.view(b)),
new TypedDataConstructor("Float64",
(int n) => new Float64List(n),
(ByteBuffer b) => new Float64List.view(b)),
new TypedDataConstructor("Int32x4",
(int n) => new Int32x4List(n),
(ByteBuffer b) => new Int32x4List.view(b)),
new TypedDataConstructor("Float32x4",
(int n) => new Float32x4List(n),
(ByteBuffer b) => new Float32x4List.view(b))
];
void main() {
for (var c in constructors) {
String name = c.name;
var typedData = c.create(64);
Expect.isTrue(typedData is! ByteBuffer);
ByteBuffer buffer = typedData.buffer;
Expect.isTrue(buffer is! List && buffer is! ByteData);
Expect.equals(buffer, typedData.buffer, name);
for (var v in constructors) {
String testDesc = "${v.name} view, $name buffer";
var view = v.view(typedData.buffer);
Expect.equals(buffer, view.buffer, testDesc);
Expect.isTrue(view is List || view is ByteData, testDesc);
Expect.isTrue(view.buffer is ByteBuffer, testDesc);
Expect.isTrue(view is! ByteBuffer, testDesc);
Expect.isTrue(view.buffer is! List && view.buffer is! ByteData, testDesc);
}
}
}

View file

@ -143,8 +143,7 @@ void testWriteInt16ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Int16List.view(typed_data_content));
new Int16List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });
@ -188,8 +187,7 @@ void testWriteUint16ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Uint16List.view(typed_data_content));
new Uint16List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });
@ -233,8 +231,7 @@ void testWriteInt32ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Int32List.view(typed_data_content));
new Int32List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });
@ -278,8 +275,7 @@ void testWriteUint32ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Uint32List.view(typed_data_content));
new Uint32List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });
@ -323,8 +319,7 @@ void testWriteInt64ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Int64List.view(typed_data_content));
new Int64List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });
@ -368,8 +363,7 @@ void testWriteUint64ListAndView() {
for (int i = 0; i < content.length; i++) { for (int i = 0; i < content.length; i++) {
typed_data_content[i] = content[i]; typed_data_content[i] = content[i];
} }
Expect.listEquals(expected, Expect.listEquals(expected, new Uint64List.view(typed_data_content));
new Uint64List.view(typed_data_content.buffer));
temp.deleteSync(recursive: true); temp.deleteSync(recursive: true);
asyncEnd(); asyncEnd();
}); });

View file

@ -169,7 +169,7 @@ void testIndexOutOfRangeHelper(typed_data, value) {
Expect.throws(() { Expect.throws(() {
var size = typed_data.elementSizeInBytes; var size = typed_data.elementSizeInBytes;
var i = (typed_data.length - 1) * size + 1; var i = (typed_data.length - 1) * size + 1;
typed_data[new C(i)] = value; typed_data[new C(i)] = value;
}); });
@ -296,7 +296,7 @@ void testSetAtIndex(TypedData list,
} }
testViewCreation() { testViewCreation() {
var bytes = new Uint8List(1024).buffer; var bytes = new Uint8List(1024);
var view = new ByteData.view(bytes, 24); var view = new ByteData.view(bytes, 24);
Expect.equals(1000, view.lengthInBytes); Expect.equals(1000, view.lengthInBytes);
view = new Uint8List.view(bytes, 24); view = new Uint8List.view(bytes, 24);