diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart index 5d36f91ff8d..417ed7b356a 100644 --- a/sdk/lib/_internal/compiler/implementation/compiler.dart +++ b/sdk/lib/_internal/compiler/implementation/compiler.dart @@ -805,10 +805,10 @@ abstract class Compiler implements DiagnosticListener { findRequiredElement(library, 'MirrorSystem'); mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); - } else if (uri == new Uri(scheme: 'dart', path: '_native_typed_data')) { + } else if (uri == new Uri(scheme: 'dart', path: 'typed_data')) { typedDataLibrary = library; typedDataClass = - findRequiredElement(library, 'NativeTypedData'); + findRequiredElement(library, 'TypedData'); } else if (uri == new Uri(scheme: 'dart', path: '_internal')) { symbolImplementationClass = findRequiredElement(library, 'Symbol'); diff --git a/sdk/lib/_internal/compiler/implementation/elements/elements.dart b/sdk/lib/_internal/compiler/implementation/elements/elements.dart index b714528f03a..5b80da63486 100644 --- a/sdk/lib/_internal/compiler/implementation/elements/elements.dart +++ b/sdk/lib/_internal/compiler/implementation/elements/elements.dart @@ -566,16 +566,12 @@ class Elements { static bool isConstructorOfTypedArraySubclass(Element element, Compiler compiler) { - if (compiler.typedDataLibrary == null) return false; - if (!element.isConstructor()) return false; - FunctionElement constructor = element; - constructor = constructor.redirectionTarget; - ClassElement cls = constructor.getEnclosingClass(); - return cls.getLibrary() == compiler.typedDataLibrary - && cls.isNative() - && compiler.world.isSubtype(compiler.typedDataClass, cls) - && compiler.world.isSubtype(compiler.listClass, cls) - && constructor.name == ''; + if (compiler.typedDataClass == null) return false; + ClassElement cls = element.getEnclosingClass(); + if (cls == null || !element.isConstructor()) return false; + return compiler.world.isSubclass(compiler.typedDataClass, cls) + && cls.getLibrary() == compiler.typedDataLibrary + && element.name == ''; } static bool switchStatementHasContinue(SwitchStatement node, diff --git a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart index 34c9c02211c..b54ae28c096 100644 --- a/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart +++ b/sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart @@ -977,13 +977,11 @@ class SimpleTypeInferrerVisitor elementType, length)); } else if (Elements.isConstructorOfTypedArraySubclass(element, compiler)) { int length = findLength(node); - FunctionElement constructor = element; - constructor = constructor.redirectionTarget; T elementType = inferrer.returnTypeOfElement( - constructor.getEnclosingClass().lookupMember('[]')); + element.getEnclosingClass().lookupMember('[]')); return inferrer.concreteTypes.putIfAbsent( node, () => types.allocateList( - types.nonNullExact(constructor.getEnclosingClass()), node, + types.nonNullExact(element.getEnclosingClass()), node, outermostElement, elementType, length)); } else if (element.isFunction() || element.isConstructor()) { return returnType; diff --git a/sdk/lib/_internal/compiler/implementation/native_handler.dart b/sdk/lib/_internal/compiler/implementation/native_handler.dart index 8118fd29bb2..5a0d890cb14 100644 --- a/sdk/lib/_internal/compiler/implementation/native_handler.dart +++ b/sdk/lib/_internal/compiler/implementation/native_handler.dart @@ -623,7 +623,7 @@ void maybeEnableNative(Compiler compiler, || libraryName == 'dart:indexed_db' || libraryName == 'dart:js' || libraryName == 'dart:svg' - || libraryName == 'dart:_native_typed_data' + || libraryName == 'dart:typed_data' || libraryName == 'dart:web_audio' || libraryName == 'dart:web_gl' || libraryName == 'dart:web_sql') { diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart index 8af9bd0f3c4..8cc70170533 100644 --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart @@ -4041,7 +4041,6 @@ abstract class SsaFromAstMixin TypeMask inferred = TypeMaskFactory.inferredForNode(sourceElement, send, compiler); ClassElement cls = element.getEnclosingClass(); - assert(cls.thisType.element.isNative()); return inferred.containsAll(compiler) ? new TypeMask.nonNullExact(cls.thisType.element) : inferred; diff --git a/sdk/lib/_internal/libraries.dart b/sdk/lib/_internal/libraries.dart index cb6e7b2242d..fd6e338d040 100644 --- a/sdk/lib/_internal/libraries.dart +++ b/sdk/lib/_internal/libraries.dart @@ -106,13 +106,6 @@ const Map LIBRARIES = const { maturity: Maturity.STABLE, dart2jsPath: "typed_data/dart2js/typed_data_dart2js.dart"), - "_native_typed_data": const LibraryInfo( - "typed_data/dart2js/native_typed_data_dart2js.dart", - category: "Internal", - implementation: true, - documented: false, - platforms: DART2JS_PLATFORM), - "svg": const LibraryInfo( "svg/dartium/svg_dartium.dart", category: "Client", @@ -304,3 +297,4 @@ class Maturity { static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified", "The maturity for this library has not been specified."); } + diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index 29b2825fe0c..d228722aec0 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -32,7 +32,6 @@ import 'dart:indexed_db'; import 'dart:isolate'; import "dart:convert"; import 'dart:math'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:svg' as svg; import 'dart:svg' show Matrix; @@ -12839,7 +12838,7 @@ class FileReader extends EventTarget native "FileReader" { @DomName('FileReader.result') @DocsEditable() - @Creates('String|NativeByteBuffer|Null') + @Creates('String|ByteBuffer|Null') final Object result; @DomName('FileReader.abort') @@ -14961,7 +14960,7 @@ class HttpRequest extends HttpRequestEventTarget native "XMLHttpRequest" { @SupportedBrowser(SupportedBrowser.FIREFOX) @SupportedBrowser(SupportedBrowser.IE, '10') @SupportedBrowser(SupportedBrowser.SAFARI) - @Creates('NativeByteBuffer|Blob|Document|=Object|JSExtendableArray|String|num') + @Creates('ByteBuffer|Blob|Document|=Object|JSExtendableArray|String|num') final dynamic _get_response; /** @@ -15418,8 +15417,8 @@ class ImageData extends Interceptor native "ImageData" { @DomName('ImageData.data') @DocsEditable() - @Creates('NativeUint8ClampedList') - @Returns('NativeUint8ClampedList') + @Creates('Uint8ClampedList') + @Returns('Uint8ClampedList') final List data; @DomName('ImageData.height') diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart index 62f36b9b702..a8f6e5696ea 100644 --- a/sdk/lib/html/dartium/html_dartium.dart +++ b/sdk/lib/html/dartium/html_dartium.dart @@ -28964,13 +28964,13 @@ class Url extends NativeFieldWrapperClass2 implements UrlUtils { if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) { return _createObjectURL_1(blob_OR_source_OR_stream); } - if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) { + if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) { return _createObjectURL_2(blob_OR_source_OR_stream); } - if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) { + if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) { return _createObjectURL_3(blob_OR_source_OR_stream); } - if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) { + if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) { return _createObjectURL_4(blob_OR_source_OR_stream); } throw new ArgumentError("Incorrect number or type of arguments"); diff --git a/sdk/lib/html/html_common/conversions.dart b/sdk/lib/html/html_common/conversions.dart index c65c3aba57f..d2d3a45d085 100644 --- a/sdk/lib/html/html_common/conversions.dart +++ b/sdk/lib/html/html_common/conversions.dart @@ -148,9 +148,9 @@ _convertDartToNative_PrepareForStructuredClone(value) { // TODO(sra): Firefox: How to convert _TypedImageData on the other end? if (e is ImageData) return e; - if (e is NativeByteBuffer) return e; + if (e is ByteBuffer) return e; - if (e is NativeTypedData) return e; + if (e is TypedData) return e; if (e is Map) { var slot = findSlot(e); @@ -332,7 +332,7 @@ gl.ContextAttributes convertNativeToDart_ContextAttributes( // On Firefox, the returned ImageData is a plain object. class _TypedImageData implements ImageData { - final NativeUint8ClampedList data; + final Uint8ClampedList data; final int height; final int width; @@ -370,7 +370,7 @@ ImageData convertNativeToDart_ImageData(nativeImageData) { // object. So we create a _TypedImageData. return new _TypedImageData( - JS('NativeUint8ClampedList', '#.data', nativeImageData), + JS('Uint8ClampedList', '#.data', nativeImageData), JS('var', '#.height', nativeImageData), JS('var', '#.width', nativeImageData)); } @@ -399,7 +399,7 @@ bool isImmutableJavaScriptArray(value) => const String _serializedScriptValue = 'num|String|bool|' 'JSExtendableArray|=Object|' - 'Blob|File|NativeByteBuffer|NativeTypedData' + 'Blob|File|ByteBuffer|TypedData' // TODO(sra): Add Date, RegExp. ; const annotation_Creates_SerializedScriptValue = diff --git a/sdk/lib/html/html_common/html_common_dart2js.dart b/sdk/lib/html/html_common/html_common_dart2js.dart index 1cd0cb38f5e..f35a65eb54b 100644 --- a/sdk/lib/html/html_common/html_common_dart2js.dart +++ b/sdk/lib/html/html_common/html_common_dart2js.dart @@ -7,7 +7,7 @@ library html_common; import 'dart:collection'; import 'dart:html'; import 'dart:web_gl' as gl; -import 'dart:_native_typed_data'; +import 'dart:typed_data'; import 'dart:_js_helper' show Creates, Returns; import 'dart:_foreign_helper' show JS; import 'dart:_interceptors' show Interceptor, JSExtendableArray; diff --git a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart index 5ce201bb8c0..a54fde34748 100644 --- a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart +++ b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart @@ -75,7 +75,6 @@ library dart.dom.indexed_db; import 'dart:async'; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, Returns, JSName, Null; import 'dart:_foreign_helper' show JS; diff --git a/sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart b/sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart deleted file mode 100644 index 17a61b65e77..00000000000 --- a/sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart +++ /dev/null @@ -1,970 +0,0 @@ -// Copyright (c) 2013, 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. - -/** - * Specialized integers and floating point numbers, - * with SIMD support and efficient lists. - */ -library dart.typed_data.implementation; - -import 'dart:collection'; -import 'dart:_internal'; -import 'dart:_interceptors' show JSIndexable, JSUInt32, JSUInt31; -import 'dart:_js_helper' - show Creates, JavaScriptIndexingBehavior, JSName, Null, Returns; -import 'dart:_foreign_helper' show JS; -import 'dart:math' as Math; - -import 'dart:typed_data'; - -/** - * Describes endianness to be used when accessing a sequence of bytes. - */ -class Endianness { - const Endianness._(this._littleEndian); - - static const Endianness BIG_ENDIAN = const Endianness._(false); - static const Endianness LITTLE_ENDIAN = const Endianness._(true); - static final Endianness HOST_ENDIAN = - (new ByteData.view(new Int16List.fromList([1]).buffer)).getInt8(0) == 1 - ? LITTLE_ENDIAN - : BIG_ENDIAN; - - final bool _littleEndian; -} - - -class NativeByteBuffer implements ByteBuffer native "ArrayBuffer" { - @JSName('byteLength') - final int lengthInBytes; - - Type get runtimeType => ByteBuffer; -} - -class NativeTypedData implements TypedData native "ArrayBufferView" { - /** - * Returns the byte buffer associated with this object. - */ - @Creates('NativeByteBuffer') - // May be Null for IE's CanvasPixelArray. - @Returns('NativeByteBuffer|Null') - final ByteBuffer buffer; - - /** - * Returns the length of this view, in bytes. - */ - @JSName('byteLength') - final int lengthInBytes; - - /** - * Returns the offset in bytes into the underlying byte buffer of this view. - */ - @JSName('byteOffset') - final int offsetInBytes; - - /** - * Returns the number of bytes in the representation of each element in this - * list. - */ - @JSName('BYTES_PER_ELEMENT') - final int elementSizeInBytes; - - void _invalidIndex(int index, int length) { - if (index < 0 || index >= length) { - throw new RangeError.range(index, 0, length); - } else { - throw new ArgumentError('Invalid list index $index'); - } - } - - void _checkIndex(int index, int length) { - if (JS('bool', '(# >>> 0 != #)', index, index) || index >= length) { - _invalidIndex(index, length); - } - } - - int _checkSublistArguments(int start, int end, int length) { - // For `sublist` the [start] and [end] indices are allowed to be equal to - // [length]. However, [_checkIndex] only allows indices in the range - // 0 .. length - 1. We therefore increment the [length] argument by one - // for the [_checkIndex] checks. - _checkIndex(start, length + 1); - if (end == null) return length; - _checkIndex(end, length + 1); - if (start > end) throw new RangeError.range(start, 0, end); - return end; - } -} - - -// Validates the unnamed constructor length argument. Checking is necessary -// because passing unvalidated values to the native constructors can cause -// conversions or create views. -int _checkLength(length) { - if (length is! int) throw new ArgumentError('Invalid length $length'); - return length; -} - -// Validates `.view` constructor arguments. Checking is necessary because -// passing unvalidated values to the native constructors can cause conversions -// (e.g. String arguments) or create typed data objects that are not actually -// views of the input. -void _checkViewArguments(buffer, offsetInBytes, length) { - if (buffer is! NativeByteBuffer) { - throw new ArgumentError('Invalid view buffer'); - } - if (offsetInBytes is! int) { - throw new ArgumentError('Invalid view offsetInBytes $offsetInBytes'); - } - if (length != null && length is! int) { - throw new ArgumentError('Invalid view length $length'); - } -} - -// Ensures that [list] is a JavaScript Array or a typed array. If necessary, -// returns a copy of the list. -List _ensureNativeList(List list) { - if (list is JSIndexable) return list; - List result = new List(list.length); - for (int i = 0; i < list.length; i++) { - result[i] = list[i]; - } - return result; -} - - -class NativeByteData extends NativeTypedData implements ByteData - native "DataView" { - /** - * Creates a [ByteData] of the specified length (in elements), all of - * whose elements are initially zero. - */ - factory NativeByteData(int length) => _create1(_checkLength(length)); - - /** - * Creates an [ByteData] _view_ of the specified region in the specified - * byte buffer. Changes in the [ByteData] will be visible in the byte - * buffer and vice versa. If the [offsetInBytes] index of the region is not - * specified, it defaults to zero (the first byte in the byte buffer). - * If the length is not specified, it defaults to null, which indicates - * that the view extends to the end of the byte buffer. - * - * Throws [RangeError] if [offsetInBytes] or [length] are negative, or - * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than - * the length of [buffer]. - */ - factory NativeByteData.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => ByteData; - - int get elementSizeInBytes => 1; - - /** - * Returns the floating point number represented by the four bytes at - * the specified [byteOffset] in this object, in IEEE 754 - * single-precision binary floating-point format (binary32). - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getFloat32(byteOffset, endian._littleEndian); - - @JSName('getFloat32') - @Returns('num') - num _getFloat32(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the floating point number represented by the eight bytes at - * the specified [byteOffset] in this object, in IEEE 754 - * double-precision binary floating-point format (binary64). - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getFloat64(byteOffset, endian._littleEndian); - - @JSName('getFloat64') - @Returns('num') - num _getFloat64(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the (possibly negative) integer represented by the two bytes at - * the specified [byteOffset] in this object, in two's complement binary - * form. - * The return value will be between 215 and 215 - 1, - * inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 2` is greater than the length of this object. - */ - int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getInt16(byteOffset, endian._littleEndian); - - @JSName('getInt16') - @Returns('int') - int _getInt16(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the (possibly negative) integer represented by the four bytes at - * the specified [byteOffset] in this object, in two's complement binary - * form. - * The return value will be between 231 and 231 - 1, - * inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getInt32(byteOffset, endian._littleEndian); - - @JSName('getInt32') - @Returns('int') - int _getInt32(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the (possibly negative) integer represented by the eight bytes at - * the specified [byteOffset] in this object, in two's complement binary - * form. - * The return value will be between 263 and 263 - 1, - * inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { - throw new UnsupportedError("Int64 accessor not supported by dart2js."); - } - - /** - * Returns the (possibly negative) integer represented by the byte at the - * specified [byteOffset] in this object, in two's complement binary - * representation. The return value will be between -128 and 127, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * greater than or equal to the length of this object. - */ - int getInt8(int byteOffset) native; - - /** - * Returns the positive integer represented by the two bytes starting - * at the specified [byteOffset] in this object, in unsigned binary - * form. - * The return value will be between 0 and 216 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 2` is greater than the length of this object. - */ - int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getUint16(byteOffset, endian._littleEndian); - - @JSName('getUint16') - @Returns('JSUInt31') - int _getUint16(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the positive integer represented by the four bytes starting - * at the specified [byteOffset] in this object, in unsigned binary - * form. - * The return value will be between 0 and 232 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => - _getUint32(byteOffset, endian._littleEndian); - - @JSName('getUint32') - @Returns('JSUInt32') - int _getUint32(int byteOffset, [bool littleEndian]) native; - - /** - * Returns the positive integer represented by the eight bytes starting - * at the specified [byteOffset] in this object, in unsigned binary - * form. - * The return value will be between 0 and 264 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { - throw new UnsupportedError("Uint64 accessor not supported by dart2js."); - } - - /** - * Returns the positive integer represented by the byte at the specified - * [byteOffset] in this object, in unsigned binary form. The - * return value will be between 0 and 255, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * greater than or equal to the length of this object. - */ - int getUint8(int byteOffset) native; - - /** - * Sets the four bytes starting at the specified [byteOffset] in this - * object to the IEEE 754 single-precision binary floating-point - * (binary32) representation of the specified [value]. - * - * **Note that this method can lose precision.** The input [value] is - * a 64-bit floating point value, which will be converted to 32-bit - * floating point value by IEEE 754 rounding rules before it is stored. - * If [value] cannot be represented exactly as a binary32, it will be - * converted to the nearest binary32 value. If two binary32 values are - * equally close, the one whose least significant bit is zero will be used. - * Note that finite (but large) values can be converted to infinity, and - * small non-zero values can be converted to zero. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - void setFloat32(int byteOffset, num value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setFloat32(byteOffset, value, endian._littleEndian); - - @JSName('setFloat32') - void _setFloat32(int byteOffset, num value, [bool littleEndian]) native; - - /** - * Sets the eight bytes starting at the specified [byteOffset] in this - * object to the IEEE 754 double-precision binary floating-point - * (binary64) representation of the specified [value]. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - void setFloat64(int byteOffset, num value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setFloat64(byteOffset, value, endian._littleEndian); - - @JSName('setFloat64') - void _setFloat64(int byteOffset, num value, [bool littleEndian]) native; - - /** - * Sets the two bytes starting at the specified [byteOffset] in this - * object to the two's complement binary representation of the specified - * [value], which must fit in two bytes. In other words, [value] must lie - * between 215 and 215 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 2` is greater than the length of this object. - */ - void setInt16(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setInt16(byteOffset, value, endian._littleEndian); - - @JSName('setInt16') - void _setInt16(int byteOffset, int value, [bool littleEndian]) native; - - /** - * Sets the four bytes starting at the specified [byteOffset] in this - * object to the two's complement binary representation of the specified - * [value], which must fit in four bytes. In other words, [value] must lie - * between 231 and 231 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - void setInt32(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setInt32(byteOffset, value, endian._littleEndian); - - @JSName('setInt32') - void _setInt32(int byteOffset, int value, [bool littleEndian]) native; - - /** - * Sets the eight bytes starting at the specified [byteOffset] in this - * object to the two's complement binary representation of the specified - * [value], which must fit in eight bytes. In other words, [value] must lie - * between 263 and 263 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - void setInt64(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) { - throw new UnsupportedError("Int64 accessor not supported by dart2js."); - } - - /** - * Sets the byte at the specified [byteOffset] in this object to the - * two's complement binary representation of the specified [value], which - * must fit in a single byte. In other words, [value] must be between - * -128 and 127, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * greater than or equal to the length of this object. - */ - void setInt8(int byteOffset, int value) native; - - /** - * Sets the two bytes starting at the specified [byteOffset] in this object - * to the unsigned binary representation of the specified [value], - * which must fit in two bytes. in other words, [value] must be between - * 0 and 216 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 2` is greater than the length of this object. - */ - void setUint16(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setUint16(byteOffset, value, endian._littleEndian); - - @JSName('setUint16') - void _setUint16(int byteOffset, int value, [bool littleEndian]) native; - - /** - * Sets the four bytes starting at the specified [byteOffset] in this object - * to the unsigned binary representation of the specified [value], - * which must fit in four bytes. in other words, [value] must be between - * 0 and 232 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 4` is greater than the length of this object. - */ - void setUint32(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) => - _setUint32(byteOffset, value, endian._littleEndian); - - @JSName('setUint32') - void _setUint32(int byteOffset, int value, [bool littleEndian]) native; - - /** - * Sets the eight bytes starting at the specified [byteOffset] in this object - * to the unsigned binary representation of the specified [value], - * which must fit in eight bytes. in other words, [value] must be between - * 0 and 264 - 1, inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, or - * `byteOffset + 8` is greater than the length of this object. - */ - void setUint64(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]) { - throw new UnsupportedError("Uint64 accessor not supported by dart2js."); - } - - /** - * Sets the byte at the specified [byteOffset] in this object to the - * unsigned binary representation of the specified [value], which must fit - * in a single byte. in other words, [value] must be between 0 and 255, - * inclusive. - * - * Throws [RangeError] if [byteOffset] is negative, - * or greater than or equal to the length of this object. - */ - void setUint8(int byteOffset, int value) native; - - static NativeByteData _create1(arg) => - JS('NativeByteData', 'new DataView(new ArrayBuffer(#))', arg); - - static NativeByteData _create2(arg1, arg2) => - JS('NativeByteData', 'new DataView(#, #)', arg1, arg2); - - static NativeByteData _create3(arg1, arg2, arg3) => - JS('NativeByteData', 'new DataView(#, #, #)', arg1, arg2, arg3); -} - - -// TODO(sra): Move this type to a public name in a private library so that other -// platform libraries like dart:html and dart:webaudio can tell a native array -// from a list that implements the implicit interface. -abstract class NativeTypedArray extends NativeTypedData - implements JavaScriptIndexingBehavior { - int get length => JS("JSUInt32", '#.length', this); - - bool _setRangeFast(int start, int end, - NativeTypedArray source, int skipCount) { - int targetLength = this.length; - _checkIndex(start, targetLength + 1); - _checkIndex(end, targetLength + 1); - if (start > end) throw new RangeError.range(start, 0, end); - int count = end - start; - - if (skipCount < 0) throw new ArgumentError(skipCount); - - int sourceLength = source.length; - if (sourceLength - skipCount < count) { - throw new StateError("Not enough elements"); - } - - if (skipCount != 0 || sourceLength != count) { - // Create a view of the exact subrange that is copied from the source. - source = JS('', '#.subarray(#, #)', - source, skipCount, skipCount + count); - } - JS('void', '#.set(#, #)', this, source, start); - } -} - -// TODO(sra): Move to private library, like [NativeTypedArray]. -abstract class NativeTypedArrayOfDouble - extends NativeTypedArray - with ListMixin, FixedLengthListMixin - implements List { - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - if (iterable is NativeTypedArrayOfDouble) { - _setRangeFast(start, end, iterable, skipCount); - return; - } - super.setRange(start, end, iterable, skipCount); - } -} - -// TODO(sra): Move to private library, like [NativeTypedArray]. -abstract class NativeTypedArrayOfInt - extends NativeTypedArray - with ListMixin, FixedLengthListMixin - implements List { - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - if (iterable is NativeTypedArrayOfInt) { - _setRangeFast(start, end, iterable, skipCount); - return; - } - super.setRange(start, end, iterable, skipCount); - } -} - - -class NativeFloat32List - extends NativeTypedArrayOfDouble - implements Float32List - native "Float32Array" { - - factory NativeFloat32List(int length) => _create1(_checkLength(length)); - - factory NativeFloat32List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeFloat32List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Float32List; - - num operator[](int index) { - _checkIndex(index, length); - return JS("num", "#[#]", this, index); - } - - void operator[]=(int index, num value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeFloat32List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeFloat32List _create1(arg) => - JS('NativeFloat32List', 'new Float32Array(#)', arg); - - static NativeFloat32List _create2(arg1, arg2) => - JS('NativeFloat32List', 'new Float32Array(#, #)', arg1, arg2); - - static NativeFloat32List _create3(arg1, arg2, arg3) => - JS('NativeFloat32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeFloat64List - extends NativeTypedArrayOfDouble - implements Float64List - native "Float64Array" { - - factory NativeFloat64List(int length) => _create1(_checkLength(length)); - - factory NativeFloat64List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeFloat64List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Float64List; - - num operator[](int index) { - _checkIndex(index, length); - return JS("num", "#[#]", this, index); - } - - void operator[]=(int index, num value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeFloat64List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeFloat64List _create1(arg) => - JS('NativeFloat64List', 'new Float64Array(#)', arg); - - static NativeFloat64List _create2(arg1, arg2) => - JS('NativeFloat64List', 'new Float64Array(#, #)', arg1, arg2); - - static NativeFloat64List _create3(arg1, arg2, arg3) => - JS('NativeFloat64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeInt16List - extends NativeTypedArrayOfInt - implements Int16List - native "Int16Array" { - - factory NativeInt16List(int length) => _create1(_checkLength(length)); - - factory NativeInt16List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeInt16List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Int16List; - - int operator[](int index) { - _checkIndex(index, length); - return JS("int", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeInt16List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeInt16List _create1(arg) => - JS('NativeInt16List', 'new Int16Array(#)', arg); - - static NativeInt16List _create2(arg1, arg2) => - JS('NativeInt16List', 'new Int16Array(#, #)', arg1, arg2); - - static NativeInt16List _create3(arg1, arg2, arg3) => - JS('NativeInt16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeInt32List - extends NativeTypedArrayOfInt - implements Int32List - native "Int32Array" { - - factory NativeInt32List(int length) => _create1(_checkLength(length)); - - factory NativeInt32List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeInt32List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Int32List; - - int operator[](int index) { - _checkIndex(index, length); - return JS("int", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeInt32List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeInt32List _create1(arg) => - JS('NativeInt32List', 'new Int32Array(#)', arg); - - static NativeInt32List _create2(arg1, arg2) => - JS('NativeInt32List', 'new Int32Array(#, #)', arg1, arg2); - - static NativeInt32List _create3(arg1, arg2, arg3) => - JS('NativeInt32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeInt8List - extends NativeTypedArrayOfInt - implements Int8List - native "Int8Array" { - - factory NativeInt8List(int length) => _create1(_checkLength(length)); - - factory NativeInt8List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeInt8List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Int8List; - - int operator[](int index) { - _checkIndex(index, length); - return JS("int", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeInt8List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeInt8List _create1(arg) => - JS('NativeInt8List', 'new Int8Array(#)', arg); - - static NativeInt8List _create2(arg1, arg2) => - JS('NativeInt8List', 'new Int8Array(#, #)', arg1, arg2); - - static Int8List _create3(arg1, arg2, arg3) => - JS('NativeInt8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeUint16List - extends NativeTypedArrayOfInt - implements Uint16List - native "Uint16Array" { - - factory NativeUint16List(int length) => _create1(_checkLength(length)); - - factory NativeUint16List.fromList(List list) => - _create1(_ensureNativeList(list)); - - factory NativeUint16List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Uint16List; - - int operator[](int index) { - _checkIndex(index, length); - return JS("JSUInt31", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeUint16List _create1(arg) => - JS('NativeUint16List', 'new Uint16Array(#)', arg); - - static NativeUint16List _create2(arg1, arg2) => - JS('NativeUint16List', 'new Uint16Array(#, #)', arg1, arg2); - - static NativeUint16List _create3(arg1, arg2, arg3) => - JS('NativeUint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeUint32List - extends NativeTypedArrayOfInt - implements Uint32List - native "Uint32Array" { - - factory NativeUint32List(int length) => _create1(_checkLength(length)); - - factory NativeUint32List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeUint32List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Uint32List; - - int operator[](int index) { - _checkIndex(index, length); - return JS("JSUInt32", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeUint32List _create1(arg) => - JS('NativeUint32List', 'new Uint32Array(#)', arg); - - static NativeUint32List _create2(arg1, arg2) => - JS('NativeUint32List', 'new Uint32Array(#, #)', arg1, arg2); - - static NativeUint32List _create3(arg1, arg2, arg3) => - JS('NativeUint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3); -} - - -class NativeUint8ClampedList - extends NativeTypedArrayOfInt - implements Uint8ClampedList - native "Uint8ClampedArray,CanvasPixelArray" { - - factory NativeUint8ClampedList(int length) => _create1(_checkLength(length)); - - factory NativeUint8ClampedList.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeUint8ClampedList.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Uint8ClampedList; - - int get length => JS("JSUInt32", '#.length', this); - - int operator[](int index) { - _checkIndex(index, length); - return JS("JSUInt31", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeUint8ClampedList', '#.subarray(#, #)', - this, start, end); - return _create1(source); - } - - static NativeUint8ClampedList _create1(arg) => - JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#)', arg); - - static NativeUint8ClampedList _create2(arg1, arg2) => - JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2); - - static NativeUint8ClampedList _create3(arg1, arg2, arg3) => - JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#, #, #)', - arg1, arg2, arg3); -} - - -class NativeUint8List - extends NativeTypedArrayOfInt - implements Uint8List - // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking - // Uint8List as !nonleaf ensures that the native dispatch correctly handles - // the potential for Uint8ClampedArray to 'accidentally' pick up the - // dispatch record for Uint8List. - native "Uint8Array,!nonleaf" { - - factory NativeUint8List(int length) => _create1(_checkLength(length)); - - factory NativeUint8List.fromList(List elements) => - _create1(_ensureNativeList(elements)); - - factory NativeUint8List.view(ByteBuffer buffer, - int offsetInBytes, int length) { - _checkViewArguments(buffer, offsetInBytes, length); - return length == null - ? _create2(buffer, offsetInBytes) - : _create3(buffer, offsetInBytes, length); - } - - Type get runtimeType => Uint8List; - - int get length => JS("JSUInt32", '#.length', this); - - int operator[](int index) { - _checkIndex(index, length); - return JS("JSUInt31", "#[#]", this, index); - } - - void operator[]=(int index, int value) { - _checkIndex(index, length); - JS("void", "#[#] = #", this, index, value); - } - - List sublist(int start, [int end]) { - end = _checkSublistArguments(start, end, length); - var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end); - return _create1(source); - } - - static NativeUint8List _create1(arg) => - JS('NativeUint8List', 'new Uint8Array(#)', arg); - - static NativeUint8List _create2(arg1, arg2) => - JS('NativeUint8List', 'new Uint8Array(#, #)', arg1, arg2); - - static NativeUint8List _create3(arg1, arg2, arg3) => - JS('NativeUint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3); -} diff --git a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart b/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart index 7e0b50b8f12..92716d97732 100644 --- a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart +++ b/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart @@ -8,13 +8,28 @@ */ library dart.typed_data; -import 'dart:collection' show ListMixin; -import 'dart:_internal' show FixedLengthListMixin; -import 'dart:_native_typed_data'; -import 'dart:_foreign_helper' show JS; +import 'dart:collection'; +import 'dart:_internal'; +import 'dart:_interceptors' show JSIndexable, JSUInt32, JSUInt31; +import 'dart:_js_helper' + show Creates, JavaScriptIndexingBehavior, JSName, Null, Returns; +import 'dart:_foreign_helper' show JS, JS_CONST; import 'dart:math' as Math; -export 'dart:_native_typed_data' show Endianness; +/** + * Describes endianness to be used when accessing a sequence of bytes. + */ +class Endianness { + const Endianness(this._littleEndian); + + static const Endianness BIG_ENDIAN = const Endianness(false); + static const Endianness LITTLE_ENDIAN = const Endianness(true); + static final Endianness HOST_ENDIAN = + (new ByteData.view(new Int16List.fromList([1]).buffer)).getInt8(0) == 1 ? + LITTLE_ENDIAN : BIG_ENDIAN; + + final bool _littleEndian; +} /** @@ -22,35 +37,102 @@ export 'dart:_native_typed_data' show Endianness; * Used to process large quantities of binary or numerical data * more efficiently using a typed view. */ -abstract class ByteBuffer { - int get lengthInBytes; +class ByteBuffer native "ArrayBuffer" { + @JSName('byteLength') + final int lengthInBytes; } - /** * A typed view of a sequence of bytes. */ -abstract class TypedData { +class TypedData native "ArrayBufferView" { /** * Returns the byte buffer associated with this object. */ - ByteBuffer get buffer; + @Creates('ByteBuffer') + @Returns('ByteBuffer|Null') + final ByteBuffer buffer; /** * Returns the length of this view, in bytes. */ - int get lengthInBytes; + @JSName('byteLength') + final int lengthInBytes; /** * Returns the offset in bytes into the underlying byte buffer of this view. */ - int get offsetInBytes; + @JSName('byteOffset') + final int offsetInBytes; /** * Returns the number of bytes in the representation of each element in this * list. */ - int get elementSizeInBytes; + @JSName('BYTES_PER_ELEMENT') + final int elementSizeInBytes; + + void _invalidIndex(int index, int length) { + if (index < 0 || index >= length) { + throw new RangeError.range(index, 0, length); + } else { + throw new ArgumentError('Invalid list index $index'); + } + } + + void _checkIndex(int index, int length) { + if (JS('bool', '(# >>> 0 != #)', index, index) || index >= length) { + _invalidIndex(index, length); + } + } + + int _checkSublistArguments(int start, int end, int length) { + // For `sublist` the [start] and [end] indices are allowed to be equal to + // [length]. However, [_checkIndex] only allows indices in the range + // 0 .. length - 1. We therefore increment the [length] argument by one + // for the [_checkIndex] checks. + _checkIndex(start, length + 1); + if (end == null) return length; + _checkIndex(end, length + 1); + if (start > end) throw new RangeError.range(start, 0, end); + return end; + } +} + + +// Validates the unnamed constructor length argument. Checking is necessary +// because passing unvalidated values to the native constructors can cause +// conversions or create views. +int _checkLength(length) { + if (length is! int) throw new ArgumentError('Invalid length $length'); + return length; +} + +// Validates `.view` constructor arguments. Checking is necessary because +// passing unvalidated values to the native constructors can cause conversions +// (e.g. String arguments) or create typed data objects that are not actually +// views of the input. +void _checkViewArguments(buffer, offsetInBytes, length) { + if (buffer is! ByteBuffer) { + throw new ArgumentError('Invalid view buffer'); + } + if (offsetInBytes is! int) { + throw new ArgumentError('Invalid view offsetInBytes $offsetInBytes'); + } + if (length != null && length is! int) { + throw new ArgumentError('Invalid view length $length'); + } +} + +// Ensures that [list] is a JavaScript Array or a typed array. If necessary, +// returns a copy of the list. +List _ensureNativeList(List list) { + if (list is JSIndexable) return list; + List result = new List(list.length); + for (int i = 0; i < list.length; i++) { + result[i] = list[i]; + } + return result; } @@ -73,12 +155,12 @@ abstract class TypedData { * bdata.setFloat32(0, 3.04); * int huh = bdata.getInt32(0); */ -abstract class ByteData extends TypedData { +class ByteData extends TypedData native "DataView" { /** * Creates a [ByteData] of the specified length (in elements), all of * whose elements are initially zero. */ - factory ByteData(int length) => new NativeByteData(length); + factory ByteData(int length) => _create1(_checkLength(length)); /** * Creates an [ByteData] _view_ of the specified region in the specified @@ -93,10 +175,12 @@ abstract class ByteData extends TypedData { * the length of [buffer]. */ factory ByteData.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeByteData.view(buffer, offsetInBytes, length); - - int get elementSizeInBytes => 1; + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } /** * Returns the floating point number represented by the four bytes at @@ -106,7 +190,14 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + num getFloat32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getFloat32(byteOffset, endian._littleEndian); + + int get elementSizeInBytes => 1; + + @JSName('getFloat32') + @Returns('num') + num _getFloat32(int byteOffset, [bool littleEndian]) native; /** * Returns the floating point number represented by the eight bytes at @@ -116,7 +207,12 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + num getFloat64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getFloat64(byteOffset, endian._littleEndian); + + @JSName('getFloat64') + @Returns('num') + num _getFloat64(int byteOffset, [bool littleEndian]) native; /** * Returns the (possibly negative) integer represented by the two bytes at @@ -128,7 +224,12 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 2` is greater than the length of this object. */ - int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getInt16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getInt16(byteOffset, endian._littleEndian); + + @JSName('getInt16') + @Returns('int') + int _getInt16(int byteOffset, [bool littleEndian]) native; /** * Returns the (possibly negative) integer represented by the four bytes at @@ -140,7 +241,12 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getInt32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getInt32(byteOffset, endian._littleEndian); + + @JSName('getInt32') + @Returns('int') + int _getInt32(int byteOffset, [bool littleEndian]) native; /** * Returns the (possibly negative) integer represented by the eight bytes at @@ -152,7 +258,9 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getInt64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { + throw new UnsupportedError("Int64 accessor not supported by dart2js."); + } /** * Returns the (possibly negative) integer represented by the byte at the @@ -162,7 +270,7 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * greater than or equal to the length of this object. */ - int getInt8(int byteOffset) ; + int getInt8(int byteOffset) native; /** * Returns the positive integer represented by the two bytes starting @@ -173,7 +281,12 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 2` is greater than the length of this object. */ - int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getUint16(byteOffset, endian._littleEndian); + + @JSName('getUint16') + @Returns('JSUInt31') + int _getUint16(int byteOffset, [bool littleEndian]) native; /** * Returns the positive integer represented by the four bytes starting @@ -184,7 +297,12 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => + _getUint32(byteOffset, endian._littleEndian); + + @JSName('getUint32') + @Returns('JSUInt32') + int _getUint32(int byteOffset, [bool littleEndian]) native; /** * Returns the positive integer represented by the eight bytes starting @@ -195,7 +313,9 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]); + int getUint64(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) { + throw new UnsupportedError("Uint64 accessor not supported by dart2js."); + } /** * Returns the positive integer represented by the byte at the specified @@ -205,7 +325,7 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * greater than or equal to the length of this object. */ - int getUint8(int byteOffset); + int getUint8(int byteOffset) native; /** * Sets the four bytes starting at the specified [byteOffset] in this @@ -224,8 +344,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - void setFloat32(int byteOffset, num value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setFloat32(int byteOffset, num value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setFloat32(byteOffset, value, endian._littleEndian); + + @JSName('setFloat32') + void _setFloat32(int byteOffset, num value, [bool littleEndian]) native; /** * Sets the eight bytes starting at the specified [byteOffset] in this @@ -235,8 +358,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - void setFloat64(int byteOffset, num value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setFloat64(int byteOffset, num value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setFloat64(byteOffset, value, endian._littleEndian); + + @JSName('setFloat64') + void _setFloat64(int byteOffset, num value, [bool littleEndian]) native; /** * Sets the two bytes starting at the specified [byteOffset] in this @@ -247,8 +373,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 2` is greater than the length of this object. */ - void setInt16(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setInt16(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setInt16(byteOffset, value, endian._littleEndian); + + @JSName('setInt16') + void _setInt16(int byteOffset, int value, [bool littleEndian]) native; /** * Sets the four bytes starting at the specified [byteOffset] in this @@ -259,8 +388,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - void setInt32(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setInt32(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setInt32(byteOffset, value, endian._littleEndian); + + @JSName('setInt32') + void _setInt32(int byteOffset, int value, [bool littleEndian]) native; /** * Sets the eight bytes starting at the specified [byteOffset] in this @@ -271,8 +403,9 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - void setInt64(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setInt64(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) { + throw new UnsupportedError("Int64 accessor not supported by dart2js."); + } /** * Sets the byte at the specified [byteOffset] in this object to the @@ -283,7 +416,7 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * greater than or equal to the length of this object. */ - void setInt8(int byteOffset, int value); + void setInt8(int byteOffset, int value) native; /** * Sets the two bytes starting at the specified [byteOffset] in this object @@ -294,8 +427,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 2` is greater than the length of this object. */ - void setUint16(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setUint16(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setUint16(byteOffset, value, endian._littleEndian); + + @JSName('setUint16') + void _setUint16(int byteOffset, int value, [bool littleEndian]) native; /** * Sets the four bytes starting at the specified [byteOffset] in this object @@ -306,8 +442,11 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 4` is greater than the length of this object. */ - void setUint32(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setUint32(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) => + _setUint32(byteOffset, value, endian._littleEndian); + + @JSName('setUint32') + void _setUint32(int byteOffset, int value, [bool littleEndian]) native; /** * Sets the eight bytes starting at the specified [byteOffset] in this object @@ -318,8 +457,9 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, or * `byteOffset + 8` is greater than the length of this object. */ - void setUint64(int byteOffset, int value, - [Endianness endian=Endianness.BIG_ENDIAN]); + void setUint64(int byteOffset, int value, [Endianness endian=Endianness.BIG_ENDIAN]) { + throw new UnsupportedError("Uint64 accessor not supported by dart2js."); + } /** * Sets the byte at the specified [byteOffset] in this object to the @@ -330,7 +470,80 @@ abstract class ByteData extends TypedData { * Throws [RangeError] if [byteOffset] is negative, * or greater than or equal to the length of this object. */ - void setUint8(int byteOffset, int value); + void setUint8(int byteOffset, int value) native; + + static ByteData _create1(arg) => + JS('ByteData', 'new DataView(new ArrayBuffer(#))', arg); + + static ByteData _create2(arg1, arg2) => + JS('ByteData', 'new DataView(#, #)', arg1, arg2); + + static ByteData _create3(arg1, arg2, arg3) => + JS('ByteData', 'new DataView(#, #, #)', arg1, arg2, arg3); +} + + +// TODO(sra): Move this type to a public name in a private library so that other +// platform libraries like dart:html and dart:webaudio can tell a native array +// from a list that implements the implicit interface. +abstract class _NativeTypedArray extends TypedData + implements JavaScriptIndexingBehavior { + int get length => JS("JSUInt32", '#.length', this); + + bool _setRangeFast(int start, int end, + _NativeTypedArray source, int skipCount) { + int targetLength = this.length; + _checkIndex(start, targetLength + 1); + _checkIndex(end, targetLength + 1); + if (start > end) throw new RangeError.range(start, 0, end); + int count = end - start; + + if (skipCount < 0) throw new ArgumentError(skipCount); + + int sourceLength = source.length; + if (sourceLength - skipCount < count) { + throw new StateError("Not enough elements"); + } + + if (skipCount != 0 || sourceLength != count) { + // Create a view of the exact subrange that is copied from the source. + source = JS('', '#.subarray(#, #)', + source, skipCount, skipCount + count); + } + JS('void', '#.set(#, #)', this, source, start); + } +} + +// TODO(sra): Move to private library, like [_NativeTypedArray]. +abstract class _NativeTypedArrayOfDouble + extends _NativeTypedArray + with ListMixin, FixedLengthListMixin + implements List { + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + if (iterable is _NativeTypedArrayOfDouble) { + _setRangeFast(start, end, iterable, skipCount); + return; + } + super.setRange(start, end, iterable, skipCount); + } +} + +// TODO(sra): Move to private library, like [_NativeTypedArray]. +abstract class _NativeTypedArrayOfInt + extends _NativeTypedArray + with ListMixin, FixedLengthListMixin + implements List { + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + if (iterable is _NativeTypedArrayOfInt) { + _setRangeFast(start, end, iterable, skipCount); + return; + } + super.setRange(start, end, iterable, skipCount); + } } @@ -340,19 +553,19 @@ abstract class ByteData extends TypedData { * implementation can be considerably more space- and time-efficient than * the default [List] implementation. */ -abstract class Float32List implements TypedData, List { +class Float32List extends _NativeTypedArrayOfDouble native "Float32Array" { /** * Creates a [Float32List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Float32List(int length) = NativeFloat32List; + factory Float32List(int length) => _create1(_checkLength(length)); /** * Creates a [Float32List] with the same size as the [elements] list * and copies over the elements. */ - factory Float32List.fromList(List elements) => - new NativeFloat32List.fromList(elements); + factory Float32List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Float32List] _view_ of the specified region in the specified @@ -370,10 +583,39 @@ abstract class Float32List implements TypedData, List { * BYTES_PER_ELEMENT. */ factory Float32List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeFloat32List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 4; + + num operator[](int index) { + _checkIndex(index, length); + return JS("num", "#[#]", this, index); + } + + void operator[]=(int index, num value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Float32List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Float32List _create1(arg) => + JS('Float32List', 'new Float32Array(#)', arg); + + static Float32List _create2(arg1, arg2) => + JS('Float32List', 'new Float32Array(#, #)', arg1, arg2); + + static Float32List _create3(arg1, arg2, arg3) => + JS('Float32List', 'new Float32Array(#, #, #)', arg1, arg2, arg3); } @@ -383,19 +625,19 @@ abstract class Float32List implements TypedData, List { * implementation can be considerably more space- and time-efficient than * the default [List] implementation. */ -abstract class Float64List implements TypedData, List { +class Float64List extends _NativeTypedArrayOfDouble native "Float64Array" { /** * Creates a [Float64List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Float64List(int length) = NativeFloat64List; + factory Float64List(int length) => _create1(_checkLength(length)); /** * Creates a [Float64List] with the same size as the [elements] list * and copies over the elements. */ - factory Float64List.fromList(List elements) => - new NativeFloat64List.fromList(elements); + factory Float64List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Float64List] _view_ of the specified region in the specified @@ -413,10 +655,42 @@ abstract class Float64List implements TypedData, List { * BYTES_PER_ELEMENT. */ factory Float64List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeFloat64List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 8; + + num operator[](int index) { + _checkIndex(index, length); + return JS("num", "#[#]", this, index); + } + + void operator[]=(int index, num value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Float64List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Float64List _create1(arg) { + return JS('Float64List', 'new Float64Array(#)', arg); + } + + static Float64List _create2(arg1, arg2) { + return JS('Float64List', 'new Float64Array(#, #)', arg1, arg2); + } + + static Float64List _create3(arg1, arg2, arg3) { + return JS('Float64List', 'new Float64Array(#, #, #)', arg1, arg2, arg3); + } } @@ -425,19 +699,19 @@ abstract class Float64List implements TypedData, List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Int16List extends TypedData implements List { +class Int16List extends _NativeTypedArrayOfInt native "Int16Array" { /** * Creates an [Int16List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Int16List(int length) = NativeInt16List; + factory Int16List(int length) => _create1(_checkLength(length)); /** * Creates a [Int16List] with the same size as the [elements] list * and copies over the elements. */ - factory Int16List.fromList(List elements) => - new NativeInt16List.fromList(elements); + factory Int16List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates an [Int16List] _view_ of the specified region in the specified @@ -455,10 +729,39 @@ abstract class Int16List extends TypedData implements List { * BYTES_PER_ELEMENT. */ factory Int16List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeInt16List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 2; + + int operator[](int index) { + _checkIndex(index, length); + return JS("int", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Int16List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Int16List _create1(arg) => + JS('Int16List', 'new Int16Array(#)', arg); + + static Int16List _create2(arg1, arg2) => + JS('Int16List', 'new Int16Array(#, #)', arg1, arg2); + + static Int16List _create3(arg1, arg2, arg3) => + JS('Int16List', 'new Int16Array(#, #, #)', arg1, arg2, arg3); } @@ -467,19 +770,19 @@ abstract class Int16List extends TypedData implements List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Int32List implements TypedData, List { +class Int32List extends _NativeTypedArrayOfInt native "Int32Array" { /** * Creates an [Int32List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Int32List(int length) = NativeInt32List; + factory Int32List(int length) => _create1(_checkLength(length)); /** * Creates a [Int32List] with the same size as the [elements] list * and copies over the elements. */ - factory Int32List.fromList(List elements) => - new NativeInt32List.fromList(elements); + factory Int32List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates an [Int32List] _view_ of the specified region in the specified @@ -497,10 +800,39 @@ abstract class Int32List implements TypedData, List { * BYTES_PER_ELEMENT. */ factory Int32List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeInt32List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 4; + + int operator[](int index) { + _checkIndex(index, length); + return JS("int", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Int32List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Int32List _create1(arg) => + JS('Int32List', 'new Int32Array(#)', arg); + + static Int32List _create2(arg1, arg2) => + JS('Int32List', 'new Int32Array(#, #)', arg1, arg2); + + static Int32List _create3(arg1, arg2, arg3) => + JS('Int32List', 'new Int32Array(#, #, #)', arg1, arg2, arg3); } @@ -509,19 +841,19 @@ abstract class Int32List implements TypedData, List { * For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Int8List implements TypedData, List { +class Int8List extends _NativeTypedArrayOfInt native "Int8Array" { /** * Creates an [Int8List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Int8List(int length) = NativeInt8List; + factory Int8List(int length) => _create1(_checkLength(length)); /** * Creates a [Int8List] with the same size as the [elements] list * and copies over the elements. */ - factory Int8List.fromList(List elements) => - new NativeInt8List.fromList(elements); + factory Int8List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates an [Int8List] _view_ of the specified region in the specified @@ -536,10 +868,39 @@ abstract class Int8List implements TypedData, List { * the length of [buffer]. */ factory Int8List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) - => new NativeInt8List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 1; + + int operator[](int index) { + _checkIndex(index, length); + return JS("int", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Int8List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Int8List _create1(arg) => + JS('Int8List', 'new Int8Array(#)', arg); + + static Int8List _create2(arg1, arg2) => + JS('Int8List', 'new Int8Array(#, #)', arg1, arg2); + + static Int8List _create3(arg1, arg2, arg3) => + JS('Int8List', 'new Int8Array(#, #, #)', arg1, arg2, arg3); } @@ -548,19 +909,19 @@ abstract class Int8List implements TypedData, List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Uint16List implements TypedData, List { +class Uint16List extends _NativeTypedArrayOfInt native "Uint16Array" { /** * Creates a [Uint16List] of the specified length (in elements), all * of whose elements are initially zero. */ - factory Uint16List(int length) = NativeUint16List; + factory Uint16List(int length) => _create1(_checkLength(length)); /** * Creates a [Uint16List] with the same size as the [elements] list * and copies over the elements. */ - factory Uint16List.fromList(List elements) => - new NativeUint16List.fromList(elements); + factory Uint16List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Uint16List] _view_ of the specified region in @@ -578,10 +939,39 @@ abstract class Uint16List implements TypedData, List { * BYTES_PER_ELEMENT. */ factory Uint16List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeUint16List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 2; + + int operator[](int index) { + _checkIndex(index, length); + return JS("JSUInt31", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Uint16List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Uint16List _create1(arg) => + JS('Uint16List', 'new Uint16Array(#)', arg); + + static Uint16List _create2(arg1, arg2) => + JS('Uint16List', 'new Uint16Array(#, #)', arg1, arg2); + + static Uint16List _create3(arg1, arg2, arg3) => + JS('Uint16List', 'new Uint16Array(#, #, #)', arg1, arg2, arg3); } @@ -590,19 +980,19 @@ abstract class Uint16List implements TypedData, List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Uint32List implements TypedData, List { +class Uint32List extends _NativeTypedArrayOfInt native "Uint32Array" { /** * Creates a [Uint32List] of the specified length (in elements), all * of whose elements are initially zero. */ - factory Uint32List(int length) = NativeUint32List; + factory Uint32List(int length) => _create1(_checkLength(length)); /** * Creates a [Uint32List] with the same size as the [elements] list * and copies over the elements. */ - factory Uint32List.fromList(List elements) => - new NativeUint32List.fromList(elements); + factory Uint32List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Uint32List] _view_ of the specified region in @@ -620,10 +1010,39 @@ abstract class Uint32List implements TypedData, List { * BYTES_PER_ELEMENT. */ factory Uint32List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeUint32List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 4; + + int operator[](int index) { + _checkIndex(index, length); + return JS("JSUInt32", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Uint32List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Uint32List _create1(arg) => + JS('Uint32List', 'new Uint32Array(#)', arg); + + static Uint32List _create2(arg1, arg2) => + JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2); + + static Uint32List _create3(arg1, arg2, arg3) => + JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3); } @@ -633,19 +1052,20 @@ abstract class Uint32List implements TypedData, List { * more space- and time-efficient than the default [List] implementation. * Indexed store clamps the value to range 0..0xFF. */ -abstract class Uint8ClampedList implements TypedData, List { +class Uint8ClampedList extends _NativeTypedArrayOfInt + native "Uint8ClampedArray,CanvasPixelArray" { /** * Creates a [Uint8ClampedList] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Uint8ClampedList(int length) = NativeUint8ClampedList; + factory Uint8ClampedList(int length) => _create1(_checkLength(length)); /** * Creates a [Uint8ClampedList] of the same size as the [elements] * list and copies over the values clamping when needed. */ - factory Uint8ClampedList.fromList(List elements) => - new NativeUint8ClampedList.fromList(elements); + factory Uint8ClampedList.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Uint8ClampedList] _view_ of the specified region in the @@ -660,10 +1080,42 @@ abstract class Uint8ClampedList implements TypedData, List { * the length of [buffer]. */ factory Uint8ClampedList.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeUint8ClampedList.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 1; + + int get length => JS("JSUInt32", '#.length', this); + + int operator[](int index) { + _checkIndex(index, length); + return JS("JSUInt31", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Uint8ClampedList', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Uint8ClampedList _create1(arg) => + JS('Uint8ClampedList', 'new Uint8ClampedArray(#)', arg); + + static Uint8ClampedList _create2(arg1, arg2) => + JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2); + + static Uint8ClampedList _create3(arg1, arg2, arg3) => + JS('Uint8ClampedList', 'new Uint8ClampedArray(#, #, #)', + arg1, arg2, arg3); } @@ -672,19 +1124,24 @@ abstract class Uint8ClampedList implements TypedData, List { * For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Uint8List implements TypedData, List { +class Uint8List extends _NativeTypedArrayOfInt + // On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking + // Uint8List as !nonleaf ensures that the native dispatch correctly handles + // the potential for Uint8ClampedArray to 'accidentally' pick up the + // dispatch record for Uint8List. + native "Uint8Array,!nonleaf" { /** * Creates a [Uint8List] of the specified length (in elements), all of * whose elements are initially zero. */ - factory Uint8List(int length) = NativeUint8List; + factory Uint8List(int length) => _create1(_checkLength(length)); /** * Creates a [Uint8List] with the same size as the [elements] list * and copies over the elements. */ - factory Uint8List.fromList(List elements) => - new NativeUint8List.fromList(elements); + factory Uint8List.fromList(List list) => + _create1(_ensureNativeList(list)); /** * Creates a [Uint8List] _view_ of the specified region in the specified @@ -699,10 +1156,41 @@ abstract class Uint8List implements TypedData, List { * the length of [buffer]. */ factory Uint8List.view(ByteBuffer buffer, - [int offsetInBytes = 0, int length]) => - new NativeUint8List.view(buffer, offsetInBytes, length); + [int offsetInBytes = 0, int length]) { + _checkViewArguments(buffer, offsetInBytes, length); + return length == null + ? _create2(buffer, offsetInBytes) + : _create3(buffer, offsetInBytes, length); + } static const int BYTES_PER_ELEMENT = 1; + + int get length => JS("JSUInt32", '#.length', this); + + int operator[](int index) { + _checkIndex(index, length); + return JS("JSUInt31", "#[#]", this, index); + } + + void operator[]=(int index, int value) { + _checkIndex(index, length); + JS("void", "#[#] = #", this, index, value); + } + + List sublist(int start, [int end]) { + end = _checkSublistArguments(start, end, length); + var source = JS('Uint8List', '#.subarray(#, #)', this, start, end); + return _create1(source); + } + + static Uint8List _create1(arg) => + JS('Uint8List', 'new Uint8Array(#)', arg); + + static Uint8List _create2(arg1, arg2) => + JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2); + + static Uint8List _create3(arg1, arg2, arg3) => + JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3); } @@ -711,7 +1199,8 @@ abstract class Uint8List implements TypedData, List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Int64List extends TypedData implements List { +abstract class Int64List extends TypedData + implements JavaScriptIndexingBehavior, List { /** * Creates an [Int64List] of the specified length (in elements), all of * whose elements are initially zero. @@ -756,7 +1245,8 @@ abstract class Int64List extends TypedData implements List { * [TypedData]. For long lists, this implementation can be considerably * more space- and time-efficient than the default [List] implementation. */ -abstract class Uint64List extends TypedData implements List { +abstract class Uint64List extends TypedData + implements JavaScriptIndexingBehavior, List { /** * Creates a [Uint64List] of the specified length (in elements), all * of whose elements are initially zero. @@ -854,10 +1344,10 @@ class Float32x4List : _storage = new Float32List(list.length * 4) { for (int i = 0; i < list.length; i++) { var e = list[i]; - _storage[(i * 4) + 0] = e.x; - _storage[(i * 4) + 1] = e.y; - _storage[(i * 4) + 2] = e.z; - _storage[(i * 4) + 3] = e.w; + _storage[(i*4)+0] = e.x; + _storage[(i*4)+1] = e.y; + _storage[(i*4)+2] = e.z; + _storage[(i*4)+3] = e.w; } } @@ -900,25 +1390,24 @@ class Float32x4List Float32x4 operator[](int index) { _checkIndex(index, length); - double _x = _storage[(index * 4) + 0]; - double _y = _storage[(index * 4) + 1]; - double _z = _storage[(index * 4) + 2]; - double _w = _storage[(index * 4) + 3]; + double _x = _storage[(index*4)+0]; + double _y = _storage[(index*4)+1]; + double _z = _storage[(index*4)+2]; + double _w = _storage[(index*4)+3]; return new Float32x4(_x, _y, _z, _w); } void operator[]=(int index, Float32x4 value) { _checkIndex(index, length); - _storage[(index * 4) + 0] = value._storage[0]; - _storage[(index * 4) + 1] = value._storage[1]; - _storage[(index * 4) + 2] = value._storage[2]; - _storage[(index * 4) + 3] = value._storage[3]; + _storage[(index*4)+0] = value._storage[0]; + _storage[(index*4)+1] = value._storage[1]; + _storage[(index*4)+2] = value._storage[2]; + _storage[(index*4)+3] = value._storage[3]; } List sublist(int start, [int end]) { end = _checkSublistArguments(start, end, length); - return new Float32x4List._externalStorage( - _storage.sublist(start * 4, end * 4)); + return new Float32x4List._externalStorage(_storage.sublist(start*4, end*4)); } } @@ -973,7 +1462,7 @@ class Int32x4List * Creates a [Int32x4List] of the specified length (in elements), * all of whose elements are initially zero. */ - Int32x4List(int length) : _storage = new Uint32List(length * 4); + Int32x4List(int length) : _storage = new Uint32List(length*4); Int32x4List._externalStorage(Uint32List storage) : _storage = storage; @@ -981,10 +1470,10 @@ class Int32x4List : _storage = new Uint32List(list.length * 4) { for (int i = 0; i < list.length; i++) { var e = list[i]; - _storage[(i * 4) + 0] = e.x; - _storage[(i * 4) + 1] = e.y; - _storage[(i * 4) + 2] = e.z; - _storage[(i * 4) + 3] = e.w; + _storage[(i*4)+0] = e.x; + _storage[(i*4)+1] = e.y; + _storage[(i*4)+2] = e.z; + _storage[(i*4)+3] = e.w; } } @@ -1027,19 +1516,19 @@ class Int32x4List Int32x4 operator[](int index) { _checkIndex(index, length); - int _x = _storage[(index * 4) + 0]; - int _y = _storage[(index * 4) + 1]; - int _z = _storage[(index * 4) + 2]; - int _w = _storage[(index * 4) + 3]; + int _x = _storage[(index*4)+0]; + int _y = _storage[(index*4)+1]; + int _z = _storage[(index*4)+2]; + int _w = _storage[(index*4)+3]; return new Int32x4(_x, _y, _z, _w); } void operator[]=(int index, Int32x4 value) { _checkIndex(index, length); - _storage[(index * 4) + 0] = value._storage[0]; - _storage[(index * 4) + 1] = value._storage[1]; - _storage[(index * 4) + 2] = value._storage[2]; - _storage[(index * 4) + 3] = value._storage[3]; + _storage[(index*4)+0] = value._storage[0]; + _storage[(index*4)+1] = value._storage[1]; + _storage[(index*4)+2] = value._storage[2]; + _storage[(index*4)+3] = value._storage[3]; } List sublist(int start, [int end]) { diff --git a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart index 69077f07147..b3e88e920e1 100644 --- a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart +++ b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart @@ -8,7 +8,6 @@ import 'dart:collection'; import 'dart:_internal' hide deprecated; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, JSName, Returns, convertDartClosureToJS; import 'dart:_foreign_helper' show JS; diff --git a/sdk/lib/web_gl/dart2js/web_gl_dart2js.dart b/sdk/lib/web_gl/dart2js/web_gl_dart2js.dart index 185ac73a3d4..d0d67a3a3c6 100644 --- a/sdk/lib/web_gl/dart2js/web_gl_dart2js.dart +++ b/sdk/lib/web_gl/dart2js/web_gl_dart2js.dart @@ -7,7 +7,6 @@ import 'dart:collection'; import 'dart:_internal' hide deprecated; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, JSName, Null, Returns, convertDartClosureToJS; import 'dart:_foreign_helper' show JS; @@ -2505,8 +2504,8 @@ class RenderingContext extends CanvasRenderingContext native "WebGLRenderingCont @DomName('WebGLRenderingContext.getParameter') @DocsEditable() - @Creates('Null|num|String|bool|JSExtendableArray|NativeFloat32List|NativeInt32List|NativeUint32List|Framebuffer|Renderbuffer|Texture') - @Returns('Null|num|String|bool|JSExtendableArray|NativeFloat32List|NativeInt32List|NativeUint32List|Framebuffer|Renderbuffer|Texture') + @Creates('Null|num|String|bool|JSExtendableArray|Float32List|Int32List|Uint32List|Framebuffer|Renderbuffer|Texture') + @Returns('Null|num|String|bool|JSExtendableArray|Float32List|Int32List|Uint32List|Framebuffer|Renderbuffer|Texture') Object getParameter(int pname) native; @DomName('WebGLRenderingContext.getProgramInfoLog') @@ -2555,8 +2554,8 @@ class RenderingContext extends CanvasRenderingContext native "WebGLRenderingCont @DomName('WebGLRenderingContext.getUniform') @DocsEditable() - @Creates('Null|num|String|bool|JSExtendableArray|NativeFloat32List|NativeInt32List|NativeUint32List') - @Returns('Null|num|String|bool|JSExtendableArray|NativeFloat32List|NativeInt32List|NativeUint32List') + @Creates('Null|num|String|bool|JSExtendableArray|Float32List|Int32List|Uint32List') + @Returns('Null|num|String|bool|JSExtendableArray|Float32List|Int32List|Uint32List') Object getUniform(Program program, UniformLocation location) native; @DomName('WebGLRenderingContext.getUniformLocation') @@ -2565,8 +2564,8 @@ class RenderingContext extends CanvasRenderingContext native "WebGLRenderingCont @DomName('WebGLRenderingContext.getVertexAttrib') @DocsEditable() - @Creates('Null|num|bool|NativeFloat32List|Buffer') - @Returns('Null|num|bool|NativeFloat32List|Buffer') + @Creates('Null|num|bool|Float32List|Buffer') + @Returns('Null|num|bool|Float32List|Buffer') Object getVertexAttrib(int index, int pname) native; @DomName('WebGLRenderingContext.getVertexAttribOffset') diff --git a/tests/co19/co19-dart2dart.status b/tests/co19/co19-dart2dart.status index 05608e22fc1..5240facccc0 100644 --- a/tests/co19/co19-dart2dart.status +++ b/tests/co19/co19-dart2dart.status @@ -73,22 +73,6 @@ LibTest/typed_data/Float32x4/greaterThanOrEqual_A01_t01: Skip # co19 issue 656 LibTest/typed_data/Float32x4/lessThan_A01_t01: Skip # co19 issue 656 LibTest/typed_data/Float32x4/lessThanOrEqual_A01_t01: Skip # co19 issue 656 -LibTest/typed_data/ByteData/getInt16_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getInt32_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getInt64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setInt16_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setInt32_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setInt64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getUint16_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getUint32_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getUint64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setUint16_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setUint32_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setUint64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getFloat64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setFloat64_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/getFloat32_A01_t01: Fail # issue 16159 -LibTest/typed_data/ByteData/setFloat32_A01_t01: Fail # issue 16159 [ $compiler == dart2dart && $system == windows ] LibTest/core/double/operator_remainder_A01_t04: Fail # Result is NaN diff --git a/tools/dom/scripts/dartmetadata.py b/tools/dom/scripts/dartmetadata.py index 67d9b5735f4..26ef5694ea7 100644 --- a/tools/dom/scripts/dartmetadata.py +++ b/tools/dom/scripts/dartmetadata.py @@ -109,7 +109,7 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', { "@Creates('Null')", # JS date object. ], - 'FileReader.result': ["@Creates('String|NativeByteBuffer|Null')"], + 'FileReader.result': ["@Creates('String|ByteBuffer|Null')"], 'FocusEvent.relatedTarget': [ "@Creates('Null')", @@ -208,8 +208,8 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', { ], 'ImageData.data': [ - "@Creates('NativeUint8ClampedList')", - "@Returns('NativeUint8ClampedList')", + "@Creates('Uint8ClampedList')", + "@Returns('Uint8ClampedList')", ], 'MediaStream.getAudioTracks': [ @@ -300,26 +300,24 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', { ], 'WebGLRenderingContext.getUniform': [ - "@Creates('Null|num|String|bool|JSExtendableArray|" - "NativeFloat32List|NativeInt32List|NativeUint32List')", - "@Returns('Null|num|String|bool|JSExtendableArray|" - "NativeFloat32List|NativeInt32List|NativeUint32List')", + "@Creates('Null|num|String|bool|JSExtendableArray|Float32List|Int32List" + "|Uint32List')", + "@Returns('Null|num|String|bool|JSExtendableArray|Float32List|Int32List" + "|Uint32List')", ], 'WebGLRenderingContext.getVertexAttrib': [ - "@Creates('Null|num|bool|NativeFloat32List|Buffer')", - "@Returns('Null|num|bool|NativeFloat32List|Buffer')", + "@Creates('Null|num|bool|Float32List|Buffer')", + "@Returns('Null|num|bool|Float32List|Buffer')", ], 'WebGLRenderingContext.getParameter': [ # Taken from http://www.khronos.org/registry/webgl/specs/latest/ # Section 5.14.3 Setting and getting state - "@Creates('Null|num|String|bool|JSExtendableArray|" - "NativeFloat32List|NativeInt32List|NativeUint32List|" - "Framebuffer|Renderbuffer|Texture')", - "@Returns('Null|num|String|bool|JSExtendableArray|" - "NativeFloat32List|NativeInt32List|NativeUint32List|" - "Framebuffer|Renderbuffer|Texture')", + "@Creates('Null|num|String|bool|JSExtendableArray|Float32List|Int32List" + "|Uint32List|Framebuffer|Renderbuffer|Texture')", + "@Returns('Null|num|String|bool|JSExtendableArray|Float32List|Int32List" + "|Uint32List|Framebuffer|Renderbuffer|Texture')", ], 'WebGLRenderingContext.getContextAttributes': [ @@ -327,8 +325,8 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', { ], 'XMLHttpRequest.response': [ - "@Creates('NativeByteBuffer|Blob|Document|=Object|JSExtendableArray" - "|String|num')", + "@Creates('ByteBuffer|Blob|Document|=Object|JSExtendableArray|String" + "|num')", ], }, dart2jsOnly=True) diff --git a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate index 74e01164773..0062f83e73c 100644 --- a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate +++ b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate @@ -40,7 +40,6 @@ import 'dart:indexed_db'; import 'dart:isolate'; import "dart:convert"; import 'dart:math'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; // Not actually used, but imported since dart:html can generate these objects. import 'dart:svg' as svg; diff --git a/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate b/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate index 4b90d8b3258..2ef0587e3b3 100644 --- a/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate +++ b/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate @@ -83,7 +83,6 @@ library dart.dom.indexed_db; import 'dart:async'; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, Returns, JSName, Null; import 'dart:_foreign_helper' show JS; diff --git a/tools/dom/templates/html/dart2js/web_audio_dart2js.darttemplate b/tools/dom/templates/html/dart2js/web_audio_dart2js.darttemplate index 3cc089756ed..0c00c7698fe 100644 --- a/tools/dom/templates/html/dart2js/web_audio_dart2js.darttemplate +++ b/tools/dom/templates/html/dart2js/web_audio_dart2js.darttemplate @@ -12,7 +12,6 @@ import 'dart:collection'; import 'dart:_internal' hide deprecated; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, JSName, Returns, convertDartClosureToJS; import 'dart:_foreign_helper' show JS; diff --git a/tools/dom/templates/html/dart2js/web_gl_dart2js.darttemplate b/tools/dom/templates/html/dart2js/web_gl_dart2js.darttemplate index 804f0bc380e..75007827589 100644 --- a/tools/dom/templates/html/dart2js/web_gl_dart2js.darttemplate +++ b/tools/dom/templates/html/dart2js/web_gl_dart2js.darttemplate @@ -11,7 +11,6 @@ import 'dart:collection'; import 'dart:_internal' hide deprecated; import 'dart:html'; import 'dart:html_common'; -import 'dart:_native_typed_data'; import 'dart:typed_data'; import 'dart:_js_helper' show Creates, JSName, Null, Returns, convertDartClosureToJS; import 'dart:_foreign_helper' show JS;