From 5ba4a6953cc78b1c1469655e29db0b6e0e7e92ff Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 19 Dec 2013 11:57:56 +0000 Subject: [PATCH 001/113] Create associated packages for the dart:collection and dart:async libs. R=sgjesse@google.com Review URL: https://codereview.chromium.org//113883002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/typed_data@31260 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/typed_data/README.md | 15 + pkgs/typed_data/lib/typed_buffers.dart | 235 +++++++++++ pkgs/typed_data/lib/typed_data.dart | 10 + pkgs/typed_data/pubspec.yaml | 9 + pkgs/typed_data/test/typed_buffers_test.dart | 421 +++++++++++++++++++ 5 files changed, 690 insertions(+) create mode 100644 pkgs/typed_data/README.md create mode 100644 pkgs/typed_data/lib/typed_buffers.dart create mode 100644 pkgs/typed_data/lib/typed_data.dart create mode 100644 pkgs/typed_data/pubspec.yaml create mode 100644 pkgs/typed_data/test/typed_buffers_test.dart diff --git a/pkgs/typed_data/README.md b/pkgs/typed_data/README.md new file mode 100644 index 00000000..e1e7db53 --- /dev/null +++ b/pkgs/typed_data/README.md @@ -0,0 +1,15 @@ +Helper libraries for working with typed data lists. + +The `typed_data` package contains utility functions and classes that makes working with typed data lists easier. + +## Using + +The `typed_data` package can be imported as + + import 'package:typed_data/typed_data.dart'; + +## Typed buffers: Growable typed data lists + +Typed buffers are contains growable lists backed by typed arrays. +These are similar to the growable lists returned by `new List()`, +but stores typed data like a typed data list. \ No newline at end of file diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart new file mode 100644 index 00000000..b8803388 --- /dev/null +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -0,0 +1,235 @@ +// 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. + +/** + * Growable typed-data lists. + * + * These lists works just as a typed-data list, except that they are growable. + * They use an underlying buffer, and when that buffer becomes too small, it + * is replaced by a new buffer. + * + * That means that using the [TypedDataView.buffer] getter is not guaranteed + * to return the same result each time it is used, and that the buffer may + * be larger than what the list is using. + */ +library dart.pkg.typed_data.typed_buffers; + +import "dart:collection" show ListBase; +import "dart:typed_data"; + +abstract class _TypedDataBuffer extends ListBase { + static const int INITIAL_LENGTH = 8; + + /// This is a Uint8List for Uint8Buffer. It's both a List and a TypedData, + /// which we don't have a type for here. + var _buffer; + /// The length of the list being built. + int _length; + + _TypedDataBuffer(List buffer) + : this._buffer = buffer, this._length = buffer.length; + + int get length => _length; + E operator[](int index) { + if (index >= length) throw new RangeError.range(index, 0, length - 1); + return _buffer[index]; + } + + void operator[]=(int index, E value) { + if (index >= length) throw new RangeError.range(index, 0, length - 1); + _buffer[index] = value; + } + + void set length(int newLength) { + if (newLength < _length) { + E defaultValue = _defaultValue; + for (int i = newLength; i < _length; i++) { + _buffer[i] = defaultValue; + } + } else if (newLength > _buffer.length) { + List newBuffer; + if (_buffer.length == 0) { + newBuffer = _createBuffer(newLength); + } else { + newBuffer = _createBiggerBuffer(newLength); + } + newBuffer.setRange(0, _length, _buffer); + _buffer = newBuffer; + } + _length = newLength; + } + + void _add(E value) { + if (_length == _buffer.length) _grow(); + _buffer[_length++] = value; + } + + // We override the default implementation of `add` and `addAll` because + // they grow by setting the length in increments of one. We want to grow + // by doubling capacity in most cases. + void add(E value) { _add(value); } + + void addAll(Iterable values) { + for (E value in values) _add(value); + } + + void insert(int index, E element) { + if (index < 0 || index > _length) { + throw new RangeError.range(index, 0, _length); + } + if (_length < _buffer.length) { + _buffer.setRange(index + 1, _length + 1, _buffer, index); + _buffer[index] = element; + _length++; + return; + } + List newBuffer = _createBiggerBuffer(null); + newBuffer.setRange(0, index, _buffer); + newBuffer.setRange(index + 1, _length + 1, _buffer, index); + newBuffer[index] = element; + _length++; + _buffer = newBuffer; + } + + /** + * Create a bigger buffer. + * + * This method determines how much bigger a bigger buffer should + * be. If [requiredLength] is not null, it will be at least that + * size. It will always have at least have double the capacity of + * the current buffer. + */ + List _createBiggerBuffer(int requiredLength) { + int newLength = _buffer.length * 2; + if (requiredLength != null && newLength < requiredLength) { + newLength = requiredLength; + } else if (newLength < INITIAL_LENGTH) { + newLength = INITIAL_LENGTH; + } + return _createBuffer(newLength); + } + + void _grow() { + _buffer = _createBiggerBuffer(null)..setRange(0, _length, _buffer); + } + + void setRange(int start, int end, Iterable source, [int skipCount = 0]) { + if (end > _length) throw new RangeError.range(end, 0, _length); + if (source is _TypedDataBuffer) { + _buffer.setRange(start, end, source._buffer, skipCount); + } else { + _buffer.setRange(start, end, source, skipCount); + } + } + + // TypedData. + + int get elementSizeInBytes => _buffer.elementSizeInBytes; + + int get lengthInBytes => _length * _buffer.elementSizeInBytes; + + int get offsetInBytes => _buffer.offsetInBytes; + + /** + * Returns the underlying [ByteBuffer]. + * + * The returned buffer may be replaced by operations that change the [length] + * of this list. + * + * The buffer may be larger than [lengthInBytes] bytes, but never smaller. + */ + ByteBuffer get buffer => _buffer.buffer; + + // Specialization for the specific type. + + // Return zero for integers, 0.0 for floats, etc. + // Used to fill buffer when changing length. + E get _defaultValue; + + // Create a new typed list to use as buffer. + List _createBuffer(int size); +} + +abstract class _IntBuffer extends _TypedDataBuffer { + _IntBuffer(buffer): super(buffer); + int get _defaultValue => 0; +} + +abstract class _FloatBuffer extends _TypedDataBuffer { + _FloatBuffer(buffer): super(buffer); + double get _defaultValue => 0.0; +} + +class Uint8Buffer extends _IntBuffer { + Uint8Buffer([int initialLength = 0]) : super(new Uint8List(initialLength)); + Uint8List _createBuffer(int size) => new Uint8List(size); +} + +class Int8Buffer extends _IntBuffer { + Int8Buffer([int initialLength = 0]) : super(new Int8List(initialLength)); + Int8List _createBuffer(int size) => new Int8List(size); +} + +class Uint8ClampedBuffer extends _IntBuffer { + Uint8ClampedBuffer([int initialLength = 0]) + : super(new Uint8ClampedList(initialLength)); + Uint8ClampedList _createBuffer(int size) => new Uint8ClampedList(size); +} + +class Uint16Buffer extends _IntBuffer { + Uint16Buffer([int initialLength = 0]) : super(new Uint16List(initialLength)); + Uint16List _createBuffer(int size) => new Uint16List(size); +} + +class Int16Buffer extends _IntBuffer { + Int16Buffer([int initialLength = 0]) : super(new Int16List(initialLength)); + Int16List _createBuffer(int size) => new Int16List(size); +} + +class Uint32Buffer extends _IntBuffer { + Uint32Buffer([int initialLength = 0]) : super(new Uint32List(initialLength)); + Uint32List _createBuffer(int size) => new Uint32List(size); +} + +class Int32Buffer extends _IntBuffer { + Int32Buffer([int initialLength = 0]) : super(new Int32List(initialLength)); + Int32List _createBuffer(int size) => new Int32List(size); +} + +class Uint64Buffer extends _IntBuffer { + Uint64Buffer([int initialLength = 0]) : super(new Uint64List(initialLength)); + Uint64List _createBuffer(int size) => new Uint64List(size); +} + +class Int64Buffer extends _IntBuffer { + Int64Buffer([int initialLength = 0]) : super(new Int64List(initialLength)); + Int64List _createBuffer(int size) => new Int64List(size); +} + +class Float32Buffer extends _FloatBuffer { + Float32Buffer([int initialLength = 0]) + : super(new Float32List(initialLength)); + Float32List _createBuffer(int size) => new Float32List(size); +} + +class Float64Buffer extends _FloatBuffer { + Float64Buffer([int initialLength = 0]) + : super(new Float64List(initialLength)); + Float64List _createBuffer(int size) => new Float64List(size); +} + +class Int32x4Buffer extends _TypedDataBuffer { + static Int32x4 _zero = new Int32x4(0, 0, 0, 0); + Int32x4Buffer([int initialLength = 0]) + : super(new Int32x4List(initialLength)); + Int32x4 get _defaultValue => _zero; + Int32x4List _createBuffer(int size) => new Int32x4List(size); +} + +class Float32x4Buffer extends _TypedDataBuffer { + Float32x4Buffer([int initialLength = 0]) + : super(new Float32x4List(initialLength)); + Float32x4 get _defaultValue => new Float32x4.zero(); + Float32x4List _createBuffer(int size) => new Float32x4List(size); +} diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart new file mode 100644 index 00000000..b6619abd --- /dev/null +++ b/pkgs/typed_data/lib/typed_data.dart @@ -0,0 +1,10 @@ +// 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. + +/** + * Utilities and functionality related to the "dart:typed_data" library. + */ +library dart.pkg.typed_data; + +export "package:typed_data/typed_buffers.dart"; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml new file mode 100644 index 00000000..8e2432ad --- /dev/null +++ b/pkgs/typed_data/pubspec.yaml @@ -0,0 +1,9 @@ +name: typed_data +version: 0.9.0 +author: '"Dart Team "' +description: Utility functions and classes related to the 'dart:typed_data' library. +homepage: http://www.dartlang.org +dev_dependencies: + unittest: ">=0.9.0 <0.10.0" +environment: + sdk: ">=1.0.0 <2.0.0" diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart new file mode 100644 index 00000000..1cb37b00 --- /dev/null +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -0,0 +1,421 @@ +// 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. + +// Tests typed-data buffer classes. + +import "package:typed_data/typed_buffers.dart"; +import "package:unittest/unittest.dart"; +import "dart:typed_data"; + +main() { + testUint(8, (l) => new Uint8Buffer(l)); + testInt(8, (l) => new Int8Buffer(l)); + test("Uint8ClampedBuffer", () { + testIntBuffer(8, 0, 255, (l) => new Uint8ClampedBuffer(l), clampUint8); + }); + testUint(16, (l) => new Uint16Buffer(l)); + testInt(16, (l) => new Int16Buffer(l)); + testUint(32, (l) => new Uint32Buffer(l)); /// 01: ok + testInt(32, (l) => new Int32Buffer(l)); + testUint(64, (l) => new Uint64Buffer(l)); /// 01: continued + testInt(64, (l) => new Int64Buffer(l)); /// 01: continued + + testInt32x4Buffer(intSamples); + + List roundedFloatSamples = floatSamples.map(roundToFloat).toList(); + testFloatBuffer(32, roundedFloatSamples, + () => new Float32Buffer(), + roundToFloat); + testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); + + testFloat32x4Buffer(roundedFloatSamples); +} + +double roundToFloat(double value) { + return (new Float32List(1)..[0] = value)[0]; +} + +typedef int Rounder(int value); + +Rounder roundUint(bits) { + int halfbits = (1 << (bits ~/ 2)) - 1; + int mask = halfbits | (halfbits << (bits ~/ 2)); + return (int x) => x & mask; +} + +Rounder roundInt(bits) { + int highBit = 1 << (bits - 1); + int mask = highBit - 1; + return (int x) => (x & mask) - (x & highBit); +} + +int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; + +void testUint(int bits, var buffer) { + int min = 0; + Function round = roundUint(bits); + int max = round(-1); + test("Uint${bits}Buffer", () { + testIntBuffer(bits, min, max, buffer, round); + }); +} + +void testInt(int bits, var buffer) { + int min = -(1 << (bits - 1)); + int max = -(min + 1); + test("Int${bits}Buffer", () { + testIntBuffer(bits, min, max, buffer, roundInt(bits)); + }); +} + +const List intSamples = const [ + 0x10000000000000001, + 0x10000000000000000, // 2^64 + 0x0ffffffffffffffff, + 0xaaaaaaaaaaaaaaaa, + 0x8000000000000001, + 0x8000000000000000, // 2^63 + 0x7fffffffffffffff, + 0x5555555555555555, + 0x100000001, + 0x100000000, // 2^32 + 0x0ffffffff, + 0xaaaaaaaa, + 0x80000001, + 0x80000000, // 2^31 + 0x7fffffff, + 0x55555555, + 0x10001, + 0x10000, // 2^16 + 0x0ffff, + 0xaaaa, + 0x8001, + 0x8000, // 2^15 + 0x7fff, + 0x5555, + 0x101, + 0x100, // 2^8 + 0x0ff, + 0xaa, + 0x81, + 0x80, // 2^7 + 0x7f, + 0x55, + 0x02, + 0x01, + 0x00 +]; + +// Takes bit-size, min value, max value, function to create a buffer, and +// the rounding that is applied when storing values outside the valid range +// into the buffer. +void testIntBuffer(int bits, int min, int max, + create(int length), + int round(int)) { + assert(round(min) == min); + assert(round(max) == max); + // All int buffers default to the value 0. + var buffer = create(0); + List list = buffer; // Check the type. + expect(buffer.length, equals(0)); + var bytes = bits ~/ 8; + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(0)); + expect(buffer.offsetInBytes, equals(0)); + + buffer.add(min); + expect(buffer.length, equals(1)); + expect(buffer[0], equals(min)); + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(bytes)); + expect(buffer.offsetInBytes, equals(0)); + + buffer.length = 0; + expect(buffer.length, equals(0)); + + List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); + for (int value in samples) { + int length = buffer.length; + buffer.add(value); + expect(buffer.length, equals(length + 1)); + expect(buffer[length], equals(round(value))); + } + buffer.addAll(samples); // Add all the values at once. + for (int i = 0; i < samples.length; i++) { + expect(buffer[samples.length + i], equals(buffer[i])); + } + + // Remove range works and changes length. + buffer.removeRange(samples.length, buffer.length); + expect(buffer.length, equals(samples.length)); + + // Both values are in `samples`, but equality is performed without rounding. + expect(buffer.contains(min - 1), isFalse); + expect(buffer.contains(max + 1), isFalse); + expect(buffer.contains(round(min - 1)), isTrue); + expect(buffer.contains(round(max + 1)), isTrue); + + // Accessing the underlying buffer works. + buffer.length = 2; + buffer[0] = min; + buffer[1] = max; + var byteBuffer = new Uint8List.view(buffer.buffer); + int byteSize = buffer.elementSizeInBytes; + for (int i = 0; i < byteSize; i++) { + int tmp = byteBuffer[i]; + byteBuffer[i] = byteBuffer[byteSize + i]; + byteBuffer[byteSize + i] = tmp; + } + expect(buffer[0], equals(max)); + expect(buffer[1], equals(min)); +} + +const List doubleSamples = const [ + 0.0, + 5e-324, // Minimal denormal value. + 2.225073858507201e-308, // Maximal denormal value. + 2.2250738585072014e-308, // Minimal normal value. + 0.9999999999999999, // Maximum value < 1. + 1.0, + 1.0000000000000002, // Minimum value > 1. + 4294967295.0, // 2^32 -1. + 4294967296.0, // 2^32. + 4503599627370495.5, // Maximal fractional value. + 9007199254740992.0, // Maximal exact value (adding one gets lost). + 1.7976931348623157e+308, // Maximal value. + 1.0/0.0, // Infinity. + 0.0/0.0, // NaN. + 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards + 4503599627370497.0, // minus infinity will not be the same as rounding + 9007199254740991.0 // to nearest with 0.5 rounding up). +]; + +const List floatSamples = const [ + 0.0, + 1.4e-45, // Minimal denormal value. + 1.1754942E-38, // Maximal denormal value. + 1.17549435E-38, // Minimal normal value. + 0.99999994, // Maximal value < 1. + 1.0, + 1.0000001, // Minimal value > 1. + 8388607.5, // Maximal fractional value. + 16777216.0, // Maximal exact value. + 3.4028235e+38, // Maximal value. + 1.0/0.0, // Infinity. + 0.0/0.0, // NaN. + 0.99999994, // Round traps 1-3. + 8388609.0, + 16777215.0 +]; + +void doubleEqual(x, y) { + if (y.isNaN) { + expect(x.isNaN, isTrue); + } else { + if (x != y) { + } + expect(x, equals(y)); + } +} + +testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { + test("Float${bitSize}Buffer", () { + var buffer = create(); + List list = buffer; // Test type. + int byteSize = bitSize ~/ 8; + + expect(buffer.length, equals(0)); + buffer.add(0.0); + expect(buffer.length, equals(1)); + expect(buffer.removeLast(), equals(0.0)); + expect(buffer.length, equals(0)); + + for (double value in samples) { + buffer.add(value); + doubleEqual(buffer[buffer.length - 1], round(value)); + } + expect(buffer.length, equals(samples.length)); + + buffer.addAll(samples); + expect(buffer.length, equals(samples.length * 2)); + for (int i = 0; i < samples.length; i++) { + doubleEqual(buffer[i], buffer[samples.length + i]); + } + + buffer.removeRange(samples.length, buffer.length); + expect(buffer.length, equals(samples.length)); + + buffer.insertAll(0, samples); + expect(buffer.length, equals(samples.length * 2)); + for (int i = 0; i < samples.length; i++) { + doubleEqual(buffer[i], buffer[samples.length + i]); + } + + buffer.length = samples.length; + expect(buffer.length, equals(samples.length)); + + // TypedData. + expect(buffer.elementSizeInBytes, equals(byteSize)); + expect(buffer.lengthInBytes, equals(byteSize * buffer.length)); + expect(buffer.offsetInBytes, equals(0)); + + // Accessing the buffer works. + // Accessing the underlying buffer works. + buffer.length = 2; + buffer[0] = samples[0]; + buffer[1] = samples[1]; + var bytes = new Uint8List.view(buffer.buffer); + for (int i = 0; i < byteSize; i++) { + int tmp = bytes[i]; + bytes[i] = bytes[byteSize + i]; + bytes[byteSize + i] = tmp; + } + doubleEqual(buffer[0], round(samples[1])); + doubleEqual(buffer[1], round(samples[0])); + }); +} + +testFloat32x4Buffer(List floatSamples) { + List float4Samples = []; + for (int i = 0; i < floatSamples.length - 3; i++) { + float4Samples.add(new Float32x4(floatSamples[i], + floatSamples[i + 1], + floatSamples[i + 2], + floatSamples[i + 3])); + } + + void floatEquals(x, y) { + if (y.isNaN) { + expect(x.isNaN, isTrue); + } else { + expect(x, equals(y)); + } + } + + void x4Equals(Float32x4 x, Float32x4 y) { + floatEquals(x.x, y.x); + floatEquals(x.y, y.y); + floatEquals(x.z, y.z); + floatEquals(x.w, y.w); + } + + test("Float32x4Buffer", () { + var buffer = new Float32x4Buffer(5); + List list = buffer; + + expect(buffer.length, equals(5)); + expect(buffer.elementSizeInBytes, equals(128 ~/ 8)); + expect(buffer.lengthInBytes, equals(5 * 128 ~/ 8)); + expect(buffer.offsetInBytes, equals(0)); + + x4Equals(buffer[0], new Float32x4.zero()); + buffer.length = 0; + expect(buffer.length, equals(0)); + + for (var sample in float4Samples) { + buffer.add(sample); + x4Equals(buffer[buffer.length - 1], sample); + } + expect(buffer.length, equals(float4Samples.length)); + + buffer.addAll(float4Samples); + expect(buffer.length, equals(float4Samples.length * 2)); + for (int i = 0; i < float4Samples.length; i++) { + x4Equals(buffer[i], buffer[float4Samples.length + i]); + } + + buffer.removeRange(4, 4 + float4Samples.length); + for (int i = 0; i < float4Samples.length; i++) { + x4Equals(buffer[i], float4Samples[i]); + } + + // Test underlying buffer. + buffer.length = 1; + buffer[0] = float4Samples[0]; // Does not contain NaN. + + Float32List floats = new Float32List.view(buffer.buffer); + expect(floats[0], equals(buffer[0].x)); + expect(floats[1], equals(buffer[0].y)); + expect(floats[2], equals(buffer[0].z)); + expect(floats[3], equals(buffer[0].w)); + }); +} + +void testInt32x4Buffer(intSamples) { + test("Int32x4Buffer", () { + Function round = roundInt(32); + int bits = 128; + int bytes = 128 ~/ 8; + Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); + + var buffer = new Int32x4Buffer(0); + List list = buffer; // It's a List. + expect(buffer.length, equals(0)); + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(0)); + expect(buffer.offsetInBytes, equals(0)); + + Int32x4 sample = new Int32x4(-0x80000000, -1, 0, 0x7fffffff); + buffer.add(sample); + expect(buffer.length, equals(1)); + expect(buffer[0], equals32x4(sample)); + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(bytes)); + expect(buffer.offsetInBytes, equals(0)); + + buffer.length = 0; + expect(buffer.length, equals(0)); + + var samples = intSamples + .where((value) => value == round(value)) // Issue 15130 + .map((value) => new Int32x4(value, -value, ~value, ~-value)) + .toList(); + for (Int32x4 value in samples) { + int length = buffer.length; + buffer.add(value); + expect(buffer.length, equals(length + 1)); + expect(buffer[length], equals32x4(value)); + } + + buffer.addAll(samples); // Add all the values at once. + for (int i = 0; i < samples.length; i++) { + expect(buffer[samples.length + i], equals32x4(buffer[i])); + } + + // Remove range works and changes length. + buffer.removeRange(samples.length, buffer.length); + expect(buffer.length, equals(samples.length)); + + // Accessing the underlying buffer works. + buffer.length = 2; + buffer[0] = new Int32x4(-80000000, 0x7fffffff, 0, -1); + var byteBuffer = new Uint8List.view(buffer.buffer); + int halfBytes = bytes ~/ 2; + for (int i = 0; i < halfBytes; i++) { + int tmp = byteBuffer[i]; + byteBuffer[i] = byteBuffer[halfBytes + i]; + byteBuffer[halfBytes + i] = tmp; + } + var result = new Int32x4(0, -1, -80000000, 0x7fffffff); + expect(buffer[0], equals32x4(result)); + }); +} + +class MatchesInt32x4 extends Matcher { + Int32x4 result; + MatchesInt32x4(this.result); + bool matches(item, Map matchState) { + if (item is! Int32x4) return false; + Int32x4 value = item; + return result.x == value.x && result.y == value.y && + result.z == value.z && result.w == value.w; + } + + Description describe(Description description) => + description.add('Int32x4.=='); +} From 1223cb18497d91fd1230061f8ff3f98f13686ff5 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 19 Dec 2013 12:12:44 +0000 Subject: [PATCH 002/113] Remove suprplus quoting from pubspec author fields. R=sgjesse@google.com Review URL: https://codereview.chromium.org//119093005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/typed_data@31261 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/typed_data/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8e2432ad..af2e72a5 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,6 +1,6 @@ name: typed_data version: 0.9.0 -author: '"Dart Team "' +author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: http://www.dartlang.org dev_dependencies: From a7840679cf41b4ea1cb053935cddc05ebbfab589 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 19 Dec 2013 12:36:15 +0000 Subject: [PATCH 003/113] Adding license files to packages. R=sgjesse@google.com Review URL: https://codereview.chromium.org//119203002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/typed_data@31264 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/typed_data/LICENSE | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkgs/typed_data/LICENSE diff --git a/pkgs/typed_data/LICENSE b/pkgs/typed_data/LICENSE new file mode 100644 index 00000000..ee999303 --- /dev/null +++ b/pkgs/typed_data/LICENSE @@ -0,0 +1,26 @@ +Copyright 2013, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 89de11a87c05c37e77dbc0b69bb17827cddba239 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 26 Aug 2014 08:44:11 +0000 Subject: [PATCH 004/113] Update package:typed_data to 1.0.0 R=sgjesse@google.com Review URL: https://codereview.chromium.org//499373004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/typed_data@39539 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/typed_data/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index af2e72a5..5688a242 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,9 @@ name: typed_data -version: 0.9.0 +version: 1.0.0 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: http://www.dartlang.org dev_dependencies: unittest: ">=0.9.0 <0.10.0" environment: - sdk: ">=1.0.0 <2.0.0" + sdk: ">=1.5.0 <2.0.0" From be5d5436c96e228e1161d8ba1bd6eda2f8a2d3bf Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 11 Nov 2014 07:55:47 +0000 Subject: [PATCH 005/113] Add some ArgumentError and RangeError constructors that capture more information. Switch some uses of RangeError.range to RangeError.index. Fix bug in Queue where elementAt allowed `length` as input. R=sgjesse@google.com Review URL: https://codereview.chromium.org//711003002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/typed_data@41653 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/typed_data/lib/typed_buffers.dart | 4 ++-- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index b8803388..50ed2414 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -32,12 +32,12 @@ abstract class _TypedDataBuffer extends ListBase { int get length => _length; E operator[](int index) { - if (index >= length) throw new RangeError.range(index, 0, length - 1); + if (index >= length) throw new RangeError.index(index, this); return _buffer[index]; } void operator[]=(int index, E value) { - if (index >= length) throw new RangeError.range(index, 0, length - 1); + if (index >= length) throw new RangeError.index(index, this); _buffer[index] = value; } diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 5688a242..b4c39456 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.0.0 +version: 1.0.1-dev author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: http://www.dartlang.org From 4f0445a617041e0f3a2bab1b5501b1c6b41838be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Gjesse?= Date: Tue, 24 Feb 2015 13:41:00 +0100 Subject: [PATCH 006/113] Update project to match OSS template R=ricow@google.com BUG= Review URL: https://codereview.chromium.org//954703004 --- pkgs/typed_data/.gitignore | 8 +++++++ pkgs/typed_data/.status | 4 ++++ pkgs/typed_data/AUTHORS | 6 ++++++ pkgs/typed_data/CHANGELOG.md | 5 +++++ pkgs/typed_data/CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++ pkgs/typed_data/LICENSE | 2 +- pkgs/typed_data/README.md | 10 +++++++-- pkgs/typed_data/codereview.settings | 3 +++ pkgs/typed_data/pubspec.yaml | 2 +- 9 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 pkgs/typed_data/.gitignore create mode 100644 pkgs/typed_data/.status create mode 100644 pkgs/typed_data/AUTHORS create mode 100644 pkgs/typed_data/CHANGELOG.md create mode 100644 pkgs/typed_data/CONTRIBUTING.md create mode 100644 pkgs/typed_data/codereview.settings diff --git a/pkgs/typed_data/.gitignore b/pkgs/typed_data/.gitignore new file mode 100644 index 00000000..89f7747c --- /dev/null +++ b/pkgs/typed_data/.gitignore @@ -0,0 +1,8 @@ +.buildlog +.DS_Store +.idea +.pub/ +.settings/ +build/ +packages +pubspec.lock diff --git a/pkgs/typed_data/.status b/pkgs/typed_data/.status new file mode 100644 index 00000000..364ca4b4 --- /dev/null +++ b/pkgs/typed_data/.status @@ -0,0 +1,4 @@ +# Copyright (c) 2015, 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. + diff --git a/pkgs/typed_data/AUTHORS b/pkgs/typed_data/AUTHORS new file mode 100644 index 00000000..e8063a8c --- /dev/null +++ b/pkgs/typed_data/AUTHORS @@ -0,0 +1,6 @@ +# Below is a list of people and organizations that have contributed +# to the project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md new file mode 100644 index 00000000..a123d27a --- /dev/null +++ b/pkgs/typed_data/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.0.0 + +- ChangeLog starts here diff --git a/pkgs/typed_data/CONTRIBUTING.md b/pkgs/typed_data/CONTRIBUTING.md new file mode 100644 index 00000000..6f5e0ea6 --- /dev/null +++ b/pkgs/typed_data/CONTRIBUTING.md @@ -0,0 +1,33 @@ +Want to contribute? Great! First, read this page (including the small print at +the end). + +### Before you contribute +Before we can use your code, you must sign the +[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) +(CLA), which you can do online. The CLA is necessary mainly because you own the +copyright to your changes, even after your contribution becomes part of our +codebase, so we need your permission to use and distribute your code. We also +need to be sure of various other things—for instance that you'll tell us if you +know that your code infringes on other people's patents. You don't have to sign +the CLA until after you've submitted your code for review and a member has +approved it, but you must do it before we can put your code into our codebase. + +Before you start working on a larger contribution, you should get in touch with +us first through the issue tracker with your idea so that we can help out and +possibly guide you. Coordinating up front makes it much easier to avoid +frustration later on. + +### Code reviews +All submissions, including submissions by project members, require review. + +### File headers +All files in the project must start with the following header. + + // Copyright (c) 2015, 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. + +### The small print +Contributions made by corporations are covered by a different agreement than the +one above, the +[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). diff --git a/pkgs/typed_data/LICENSE b/pkgs/typed_data/LICENSE index ee999303..de31e1a0 100644 --- a/pkgs/typed_data/LICENSE +++ b/pkgs/typed_data/LICENSE @@ -1,4 +1,4 @@ -Copyright 2013, the Dart project authors. All rights reserved. +Copyright 2015, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/pkgs/typed_data/README.md b/pkgs/typed_data/README.md index e1e7db53..c7a4772c 100644 --- a/pkgs/typed_data/README.md +++ b/pkgs/typed_data/README.md @@ -1,4 +1,4 @@ -Helper libraries for working with typed data lists. +# Helper libraries for working with typed data lists. The `typed_data` package contains utility functions and classes that makes working with typed data lists easier. @@ -12,4 +12,10 @@ The `typed_data` package can be imported as Typed buffers are contains growable lists backed by typed arrays. These are similar to the growable lists returned by `new List()`, -but stores typed data like a typed data list. \ No newline at end of file +but stores typed data like a typed data list. + +## Features and bugs + +Please file feature requests and bugs at the [issue tracker][tracker]. + +[tracker]: https://github.com/dart-lang/typed_data/issues diff --git a/pkgs/typed_data/codereview.settings b/pkgs/typed_data/codereview.settings new file mode 100644 index 00000000..26c267c4 --- /dev/null +++ b/pkgs/typed_data/codereview.settings @@ -0,0 +1,3 @@ +CODE_REVIEW_SERVER: http://codereview.chromium.org/ +VIEW_VC: https://github.com/dart-lang/typed_data/commit/ +CC_LIST: reviews@dartlang.org diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index b4c39456..c804a6a5 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -2,7 +2,7 @@ name: typed_data version: 1.0.1-dev author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. -homepage: http://www.dartlang.org +homepage: https://github.com/dart-lang/typed_data dev_dependencies: unittest: ">=0.9.0 <0.10.0" environment: From 2bf5f4417f1c3f180be88bd5eb84ceab0e9a2be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Gjesse?= Date: Tue, 24 Feb 2015 15:27:26 +0100 Subject: [PATCH 007/113] Update .status for package typed_data R=ricow@google.com BUG= Review URL: https://codereview.chromium.org//951913004 --- pkgs/typed_data/.status | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/typed_data/.status b/pkgs/typed_data/.status index 364ca4b4..ebc5f813 100644 --- a/pkgs/typed_data/.status +++ b/pkgs/typed_data/.status @@ -2,3 +2,11 @@ # 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. +# Skip non-test files ending with "_test". +packages/*: Skip +*/packages/*: Skip +*/*/packages/*: Skip +*/*/*/packages/*: Skip +*/*/*/*packages/*: Skip +*/*/*/*/*packages/*: Skip + From e8dda84a8056e462f9f9674c80fd17a09f02be07 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 13 Oct 2015 12:51:45 -0700 Subject: [PATCH 008/113] Use the new test runner. R=lrn@google.com Review URL: https://codereview.chromium.org//1385333007 . --- pkgs/typed_data/.gitignore | 1 + pkgs/typed_data/.status | 12 ----------- pkgs/typed_data/.test_config | 3 +++ pkgs/typed_data/pubspec.yaml | 4 ++-- pkgs/typed_data/test/typed_buffers_test.dart | 21 ++++++++++++-------- 5 files changed, 19 insertions(+), 22 deletions(-) delete mode 100644 pkgs/typed_data/.status create mode 100644 pkgs/typed_data/.test_config diff --git a/pkgs/typed_data/.gitignore b/pkgs/typed_data/.gitignore index 89f7747c..25a1df33 100644 --- a/pkgs/typed_data/.gitignore +++ b/pkgs/typed_data/.gitignore @@ -5,4 +5,5 @@ .settings/ build/ packages +.packages pubspec.lock diff --git a/pkgs/typed_data/.status b/pkgs/typed_data/.status deleted file mode 100644 index ebc5f813..00000000 --- a/pkgs/typed_data/.status +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2015, 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. - -# Skip non-test files ending with "_test". -packages/*: Skip -*/packages/*: Skip -*/*/packages/*: Skip -*/*/*/packages/*: Skip -*/*/*/*packages/*: Skip -*/*/*/*/*packages/*: Skip - diff --git a/pkgs/typed_data/.test_config b/pkgs/typed_data/.test_config new file mode 100644 index 00000000..25355634 --- /dev/null +++ b/pkgs/typed_data/.test_config @@ -0,0 +1,3 @@ +{ + "test_package": true +} diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index c804a6a5..c54a8601 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -4,6 +4,6 @@ author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data dev_dependencies: - unittest: ">=0.9.0 <0.10.0" + test: "^0.12.0" environment: - sdk: ">=1.5.0 <2.0.0" + sdk: ">=1.8.0 <2.0.0" diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 1cb37b00..b5f907cd 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -4,10 +4,11 @@ // Tests typed-data buffer classes. -import "package:typed_data/typed_buffers.dart"; -import "package:unittest/unittest.dart"; import "dart:typed_data"; +import "package:test/test.dart"; +import "package:typed_data/typed_buffers.dart"; + main() { testUint(8, (l) => new Uint8Buffer(l)); testInt(8, (l) => new Int8Buffer(l)); @@ -18,8 +19,12 @@ main() { testInt(16, (l) => new Int16Buffer(l)); testUint(32, (l) => new Uint32Buffer(l)); /// 01: ok testInt(32, (l) => new Int32Buffer(l)); - testUint(64, (l) => new Uint64Buffer(l)); /// 01: continued - testInt(64, (l) => new Int64Buffer(l)); /// 01: continued + testUint(64, (l) => new Uint64Buffer(l), /// 01: continued + // JS doesn't support 64-bit ints, so only test this on the VM. + testOn: "dart-vm"); + testInt(64, (l) => new Int64Buffer(l), /// 01: continued + // JS doesn't support 64-bit ints, so only test this on the VM. + testOn: "dart-vm"); testInt32x4Buffer(intSamples); @@ -52,21 +57,21 @@ Rounder roundInt(bits) { int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; -void testUint(int bits, var buffer) { +void testUint(int bits, var buffer, {String testOn}) { int min = 0; Function round = roundUint(bits); int max = round(-1); test("Uint${bits}Buffer", () { testIntBuffer(bits, min, max, buffer, round); - }); + }, testOn: testOn); } -void testInt(int bits, var buffer) { +void testInt(int bits, var buffer, {String testOn}) { int min = -(1 << (bits - 1)); int max = -(min + 1); test("Int${bits}Buffer", () { testIntBuffer(bits, min, max, buffer, roundInt(bits)); - }); + }, testOn: testOn); } const List intSamples = const [ From c5711c365c64f1d84aa06139db1c62b9c498e4bd Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 27 Oct 2015 14:27:51 -0700 Subject: [PATCH 009/113] Add _TypedDataBuffer.addRange. This is useful for concatenating ranges of existing lists, as comes up occasionally when implementing converters. Also make _TypedDataBuffer.addAll more efficient for lists. R=lrn@google.com Review URL: https://codereview.chromium.org//1404443005 . --- pkgs/typed_data/CHANGELOG.md | 11 +- pkgs/typed_data/lib/typed_buffers.dart | 128 +++++++++++++++++-- pkgs/typed_data/pubspec.yaml | 2 +- pkgs/typed_data/test/typed_buffers_test.dart | 102 +++++++++++++++ 4 files changed, 231 insertions(+), 12 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index a123d27a..36fa6b17 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,5 +1,12 @@ -# Changelog +## 1.1.0 + +* Add `start` and `end` parameters to the `addAll()` and `insertAll()` methods + for the typed data buffer classes. These allow efficient concatenation of + slices of existing typed data. + +* Make `addAll()` for typed data buffer classes more efficient for lists, + especially typed data lists. ## 1.0.0 -- ChangeLog starts here +* ChangeLog starts here diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 50ed2414..ebf5766f 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -65,13 +65,108 @@ abstract class _TypedDataBuffer extends ListBase { _buffer[_length++] = value; } - // We override the default implementation of `add` and `addAll` because - // they grow by setting the length in increments of one. We want to grow - // by doubling capacity in most cases. + // We override the default implementation of `add` because it grows the list + // by setting the length in increments of one. We want to grow by doubling + // capacity in most cases. void add(E value) { _add(value); } - void addAll(Iterable values) { - for (E value in values) _add(value); + /// Appends all objects of [values] to the end of this buffer. + /// + /// This adds values from [start] (inclusive) to [end] (exclusive) in + /// [values]. If [end] is omitted, it defaults to adding all elements of + /// [values] after [start]. + /// + /// The [start] value must be non-negative. The [values] iterable must have at + /// least [start] elements, and if [end] is specified, it must be greater than + /// or equal to [start] and [values] must have at least [end] elements. + void addAll(Iterable values, [int start = 0, int end]) { + RangeError.checkNotNegative(start, "start"); + if (end != null && start > end) { + throw new RangeError.range(end, start, null, "end"); + } + + _addAll(values, start, end); + } + + /// Inserts all objects of [values] at position [index] in this list. + /// + /// This adds values from [start] (inclusive) to [end] (exclusive) in + /// [values]. If [end] is omitted, it defaults to adding all elements of + /// [values] after [start]. + /// + /// The [start] value must be non-negative. The [values] iterable must have at + /// least [start] elements, and if [end] is specified, it must be greater than + /// or equal to [start] and [values] must have at least [end] elements. + void insertAll(int index, Iterable values, [int start = 0, int end]) { + RangeError.checkValidIndex(index, this, "index", _length + 1); + RangeError.checkNotNegative(start, "start"); + if (end != null && start > end) { + throw new RangeError.range(end, start, null, "end"); + } + + // If we're adding to the end of the list anyway, use [_addAll]. This lets + // us avoid converting [values] into a list even if [end] is null, since we + // can add values iteratively to the end of the list. We can't do so in the + // center because copying the trailing elements every time is non-linear. + if (index == _length) { + _addAll(values, start, end); + return; + } + + // If we don't know how much room to make for [values], convert it to a list + // so we can tell. + if (end == null) { + if (values is! List) values = values.toList(growable: false); + end = values.length; + } + + _insertKnownLength(index, values, start, end); + } + + /// Does the same thing as [addAll]. + /// + /// This allows [addAll] and [insertAll] to share implementation without a + /// subclass unexpectedly overriding both when it intended to only override + /// [addAll]. + void _addAll(Iterable values, [int start = 0, int end]) { + if (values is List) end ??= values.length; + + // If we know the length of the segment to add, do so with [addRange]. This + // way we know how much to grow the buffer in advance, and it may be even + // more efficient for typed data input. + if (end != null) { + _insertKnownLength(_length, values, start, end); + return; + } + + // Otherwise, just add values one at a time. + var i = 0; + for (var value in values) { + if (i >= start) add(value); + i++; + } + if (i < start) throw new StateError("Too few elements"); + } + + /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. + void _insertKnownLength(int index, Iterable values, int start, int end) { + if (values is List) { + end ??= values.length; + if (start > values.length || end > values.length) { + throw new StateError("Too few elements"); + } + } else { + assert(end != null); + } + + var valuesLength = end - start; + var newLength = _length + valuesLength; + _ensureCapacity(newLength); + + _buffer.setRange( + index + valuesLength, _length + valuesLength, _buffer, index); + _buffer.setRange(index, index + valuesLength, values, start); + _length = newLength; } void insert(int index, E element) { @@ -92,18 +187,28 @@ abstract class _TypedDataBuffer extends ListBase { _buffer = newBuffer; } + /// Ensures that [_buffer] is at least [requiredCapacity] long, + /// + /// Grows the buffer if necessary, preserving existing data. + void _ensureCapacity(int requiredCapacity) { + if (requiredCapacity <= _buffer.length) return; + var newBuffer = _createBiggerBuffer(requiredCapacity); + newBuffer.setRange(0, _length, _buffer); + _buffer = newBuffer; + } + /** * Create a bigger buffer. * * This method determines how much bigger a bigger buffer should - * be. If [requiredLength] is not null, it will be at least that + * be. If [requiredCapacity] is not null, it will be at least that * size. It will always have at least have double the capacity of * the current buffer. */ - List _createBiggerBuffer(int requiredLength) { + List _createBiggerBuffer(int requiredCapacity) { int newLength = _buffer.length * 2; - if (requiredLength != null && newLength < requiredLength) { - newLength = requiredLength; + if (requiredCapacity != null && newLength < requiredCapacity) { + newLength = requiredCapacity; } else if (newLength < INITIAL_LENGTH) { newLength = INITIAL_LENGTH; } @@ -116,6 +221,11 @@ abstract class _TypedDataBuffer extends ListBase { void setRange(int start, int end, Iterable source, [int skipCount = 0]) { if (end > _length) throw new RangeError.range(end, 0, _length); + _setRange(start, end, source, skipCount); + } + + /// Like [setRange], but with no bounds checking. + void _setRange(int start, int end, Iterable source, int skipCount) { if (source is _TypedDataBuffer) { _buffer.setRange(start, end, source._buffer, skipCount); } else { diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index c54a8601..4ca6cb20 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.0.1-dev +version: 1.1.0 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index b5f907cd..0c99a404 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -35,6 +35,108 @@ main() { testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); testFloat32x4Buffer(roundedFloatSamples); + + group("addAll", () { + for (var type in ['a list', 'an iterable']) { + group("with $type", () { + var source; + var buffer; + setUp(() { + source = [1, 2, 3, 4, 5]; + if (type == 'an iterable') source = source.reversed.toList().reversed; + buffer = new Uint8Buffer(); + }); + + test("adds values to the buffer", () { + buffer.addAll(source, 1, 4); + expect(buffer, equals([2, 3, 4])); + + buffer.addAll(source, 4); + expect(buffer, equals([2, 3, 4, 5])); + + buffer.addAll(source, 0, 1); + expect(buffer, equals([2, 3, 4, 5, 1])); + }); + + test("does nothing for empty slices", () { + buffer.addAll([6, 7, 8, 9, 10]); + + buffer.addAll(source, 0, 0); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.addAll(source, 3, 3); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.addAll(source, 5); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.addAll(source, 5, 5); + expect(buffer, equals([6, 7, 8, 9, 10])); + }); + + test("throws errors for invalid start and end", () { + expect(() => buffer.addAll(source, -1), throwsRangeError); + expect(() => buffer.addAll(source, -1, 2), throwsRangeError); + expect(() => buffer.addAll(source, 10), throwsStateError); + expect(() => buffer.addAll(source, 10, 11), throwsStateError); + expect(() => buffer.addAll(source, 3, 2), throwsRangeError); + expect(() => buffer.addAll(source, 3, 10), throwsStateError); + expect(() => buffer.addAll(source, 3, -1), throwsRangeError); + }); + }); + } + }); + + group("insertAll", () { + for (var type in ['a list', 'an iterable']) { + group("with $type", () { + var source; + var buffer; + setUp(() { + source = [1, 2, 3, 4, 5]; + if (type == 'an iterable') source = source.reversed.toList().reversed; + buffer = new Uint8Buffer()..addAll([6, 7, 8, 9, 10]); + }); + + test("inserts values into the buffer", () { + buffer.insertAll(0, source, 1, 4); + expect(buffer, equals([2, 3, 4, 6, 7, 8, 9, 10])); + + buffer.insertAll(3, source, 4); + expect(buffer, equals([2, 3, 4, 5, 6, 7, 8, 9, 10])); + + buffer.insertAll(5, source, 0, 1); + expect(buffer, equals([2, 3, 4, 5, 6, 1, 7, 8, 9, 10])); + }); + + test("does nothing for empty slices", () { + buffer.insertAll(1, source, 0, 0); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.insertAll(2, source, 3, 3); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.insertAll(3, source, 5); + expect(buffer, equals([6, 7, 8, 9, 10])); + + buffer.insertAll(4, source, 5, 5); + expect(buffer, equals([6, 7, 8, 9, 10])); + }); + + test("throws errors for invalid start and end", () { + expect(() => buffer.insertAll(-1, source), throwsRangeError); + expect(() => buffer.insertAll(6, source), throwsRangeError); + expect(() => buffer.insertAll(1, source, -1), throwsRangeError); + expect(() => buffer.insertAll(2, source, -1, 2), throwsRangeError); + expect(() => buffer.insertAll(3, source, 10), throwsStateError); + expect(() => buffer.insertAll(4, source, 10, 11), throwsStateError); + expect(() => buffer.insertAll(5, source, 3, 2), throwsRangeError); + expect(() => buffer.insertAll(1, source, 3, 10), throwsStateError); + expect(() => buffer.insertAll(2, source, 3, -1), throwsRangeError); + }); + }); + } + }); } double roundToFloat(double value) { From 2801f944f361684967996fa4c256cf7791138437 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Thu, 29 Oct 2015 10:25:05 +0100 Subject: [PATCH 010/113] Optimizie the insertion of an iterable. Avoids creating a list on the side, at the cost of an extra copying inside the typed-data buffer to move the data into place. R=floitsch@google.com, nweiz@google.com Review URL: https://codereview.chromium.org//1408253004 . --- pkgs/typed_data/CHANGELOG.md | 2 + pkgs/typed_data/lib/typed_buffers.dart | 58 ++++++++++++++++++++++---- pkgs/typed_data/pubspec.yaml | 2 +- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 36fa6b17..6be0b2d6 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.1.1 +* Optimize `insertAll` with an `Iterable` argument and no end-point. ## 1.1.0 * Add `start` and `end` parameters to the `addAll()` and `insertAll()` methods diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index ebf5766f..c8cc75d8 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -100,10 +100,14 @@ abstract class _TypedDataBuffer extends ListBase { void insertAll(int index, Iterable values, [int start = 0, int end]) { RangeError.checkValidIndex(index, this, "index", _length + 1); RangeError.checkNotNegative(start, "start"); - if (end != null && start > end) { - throw new RangeError.range(end, start, null, "end"); + if (end != null) { + if (start > end) { + throw new RangeError.range(end, start, null, "end"); + } + if (start == end) return; } + // If we're adding to the end of the list anyway, use [_addAll]. This lets // us avoid converting [values] into a list even if [end] is null, since we // can add values iteratively to the end of the list. We can't do so in the @@ -113,14 +117,54 @@ abstract class _TypedDataBuffer extends ListBase { return; } - // If we don't know how much room to make for [values], convert it to a list - // so we can tell. - if (end == null) { - if (values is! List) values = values.toList(growable: false); + if (end == null && values is List) { end = values.length; } + if (end != null) { + _insertKnownLength(index, values, start, end); + return; + } - _insertKnownLength(index, values, start, end); + // Add elements at end, growing as appropriate, then put them back at + // position [index] using flip-by-double-reverse. + if (end != null) values = values.take(end); + int writeIndex = _length; + int skipCount = start; + for (var value in values) { + if (skipCount > 0) { + skipCount--; + continue; + } + if (writeIndex == _buffer.length) { + _grow(); + } + _buffer[writeIndex++] = value; + } + if (skipCount > 0) { + throw new StateError("Too few elements"); + } + if (end != null && writeIndex < end) { + throw new RangeError.range(end, start, writeIndex, "end"); + } + // Swap [index.._length) and [_length..writeIndex) by double-reversing. + _reverse(_buffer, index, _length); + _reverse(_buffer, _length, writeIndex); + _reverse(_buffer, index, writeIndex); + _length = writeIndex; + return; + } + + // Reverses the range [start..end) of buffer. + static void _reverse(List buffer, int start, int end) { + end--; // Point to last element, not after last element. + while (start < end) { + var first = buffer[start]; + var last = buffer[end]; + buffer[end] = first; + buffer[start] = last; + start++; + end--; + } } /// Does the same thing as [addAll]. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 4ca6cb20..552b36e6 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.0 +version: 1.1.1 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data From 670c2df96cd8b1911eb95979031bf6c9751fb532 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 2 Nov 2015 16:49:31 -0800 Subject: [PATCH 011/113] Update the doc comment format. R=lrn@google.com Review URL: https://codereview.chromium.org//1420353003 . --- pkgs/typed_data/lib/typed_buffers.dart | 48 +++++++++++--------------- pkgs/typed_data/lib/typed_data.dart | 4 +-- pkgs/typed_data/pubspec.yaml | 2 +- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index c8cc75d8..c3c0f38a 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -2,17 +2,15 @@ // 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. -/** - * Growable typed-data lists. - * - * These lists works just as a typed-data list, except that they are growable. - * They use an underlying buffer, and when that buffer becomes too small, it - * is replaced by a new buffer. - * - * That means that using the [TypedDataView.buffer] getter is not guaranteed - * to return the same result each time it is used, and that the buffer may - * be larger than what the list is using. - */ +/// Growable typed-data lists. +/// +/// These lists works just as a typed-data list, except that they are growable. +/// They use an underlying buffer, and when that buffer becomes too small, it +/// is replaced by a new buffer. +/// +/// That means that using the [TypedDataView.buffer] getter is not guaranteed +/// to return the same result each time it is used, and that the buffer may +/// be larger than what the list is using. library dart.pkg.typed_data.typed_buffers; import "dart:collection" show ListBase; @@ -241,14 +239,12 @@ abstract class _TypedDataBuffer extends ListBase { _buffer = newBuffer; } - /** - * Create a bigger buffer. - * - * This method determines how much bigger a bigger buffer should - * be. If [requiredCapacity] is not null, it will be at least that - * size. It will always have at least have double the capacity of - * the current buffer. - */ + /// Create a bigger buffer. + /// + /// This method determines how much bigger a bigger buffer should + /// be. If [requiredCapacity] is not null, it will be at least that + /// size. It will always have at least have double the capacity of + /// the current buffer. List _createBiggerBuffer(int requiredCapacity) { int newLength = _buffer.length * 2; if (requiredCapacity != null && newLength < requiredCapacity) { @@ -285,14 +281,12 @@ abstract class _TypedDataBuffer extends ListBase { int get offsetInBytes => _buffer.offsetInBytes; - /** - * Returns the underlying [ByteBuffer]. - * - * The returned buffer may be replaced by operations that change the [length] - * of this list. - * - * The buffer may be larger than [lengthInBytes] bytes, but never smaller. - */ + /// Returns the underlying [ByteBuffer]. + /// + /// The returned buffer may be replaced by operations that change the [length] + /// of this list. + /// + /// The buffer may be larger than [lengthInBytes] bytes, but never smaller. ByteBuffer get buffer => _buffer.buffer; // Specialization for the specific type. diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index b6619abd..d56b8bfa 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -2,9 +2,7 @@ // 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. -/** - * Utilities and functionality related to the "dart:typed_data" library. - */ +/// Utilities and functionality related to the "dart:typed_data" library. library dart.pkg.typed_data; export "package:typed_data/typed_buffers.dart"; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 552b36e6..8927a76f 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.1 +version: 1.1.2-dev author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data From 0ac4b1f78e9daca701cbcaf81b5e75b1fc2d42b3 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 24 Feb 2016 10:45:09 -0800 Subject: [PATCH 012/113] Fix TypedDataBuffer.insertAll() with an Iterable. Closes dart-lang/typed_data#1. R=lrn@google.com Review URL: https://codereview.chromium.org//1728943003 . --- pkgs/typed_data/CHANGELOG.md | 7 +++++++ pkgs/typed_data/lib/typed_buffers.dart | 18 +++++++++++------- pkgs/typed_data/pubspec.yaml | 2 +- pkgs/typed_data/test/typed_buffers_test.dart | 7 +++++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 6be0b2d6..edfc03d6 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,5 +1,12 @@ +## 1.1.2 + +* Fix a bug where `TypedDataBuffer.insertAll` could fail to insert some elements + of an `Iterable`. + ## 1.1.1 + * Optimize `insertAll` with an `Iterable` argument and no end-point. + ## 1.1.0 * Add `start` and `end` parameters to the `addAll()` and `insertAll()` methods diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index c3c0f38a..2d1ca132 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -59,7 +59,7 @@ abstract class _TypedDataBuffer extends ListBase { } void _add(E value) { - if (_length == _buffer.length) _grow(); + if (_length == _buffer.length) _grow(_length); _buffer[_length++] = value; } @@ -125,25 +125,26 @@ abstract class _TypedDataBuffer extends ListBase { // Add elements at end, growing as appropriate, then put them back at // position [index] using flip-by-double-reverse. - if (end != null) values = values.take(end); - int writeIndex = _length; - int skipCount = start; + var writeIndex = _length; + var skipCount = start; for (var value in values) { if (skipCount > 0) { skipCount--; continue; } if (writeIndex == _buffer.length) { - _grow(); + _grow(writeIndex); } _buffer[writeIndex++] = value; } + if (skipCount > 0) { throw new StateError("Too few elements"); } if (end != null && writeIndex < end) { throw new RangeError.range(end, start, writeIndex, "end"); } + // Swap [index.._length) and [_length..writeIndex) by double-reversing. _reverse(_buffer, index, _length); _reverse(_buffer, _length, writeIndex); @@ -255,8 +256,11 @@ abstract class _TypedDataBuffer extends ListBase { return _createBuffer(newLength); } - void _grow() { - _buffer = _createBiggerBuffer(null)..setRange(0, _length, _buffer); + /// Grows the buffer. + /// + /// This copies the first [length] elements into the new buffer. + void _grow(int length) { + _buffer = _createBiggerBuffer(null)..setRange(0, length, _buffer); } void setRange(int start, int end, Iterable source, [int skipCount = 0]) { diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8927a76f..a58a7e72 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.2-dev +version: 1.1.2 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 0c99a404..9e97592a 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -109,6 +109,13 @@ main() { expect(buffer, equals([2, 3, 4, 5, 6, 1, 7, 8, 9, 10])); }); + // Regression test for #1. + test("inserts values into the buffer after removeRange()", () { + buffer.removeRange(1, 4); + buffer.insertAll(1, source); + expect(buffer, equals([6, 1, 2, 3, 4, 5, 10])); + }); + test("does nothing for empty slices", () { buffer.insertAll(1, source, 0, 0); expect(buffer, equals([6, 7, 8, 9, 10])); From 25e25ae615271e0bb5b2bd701dfef5fe1e48f26b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 9 May 2016 11:29:28 -0700 Subject: [PATCH 013/113] Fix all strong-mode warnings. R=floitsch@google.com Review URL: https://codereview.chromium.org//1949753005 . --- pkgs/typed_data/CHANGELOG.md | 4 +++ pkgs/typed_data/lib/typed_buffers.dart | 31 +++++++++++------- pkgs/typed_data/pubspec.yaml | 2 +- pkgs/typed_data/test/typed_buffers_test.dart | 33 ++++++++++---------- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index edfc03d6..ac7eb0b7 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.3 + +* Fix all strong-mode warnings. + ## 1.1.2 * Fix a bug where `TypedDataBuffer.insertAll` could fail to insert some elements diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 2d1ca132..ac178b51 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -19,14 +19,21 @@ import "dart:typed_data"; abstract class _TypedDataBuffer extends ListBase { static const int INITIAL_LENGTH = 8; - /// This is a Uint8List for Uint8Buffer. It's both a List and a TypedData, - /// which we don't have a type for here. - var _buffer; + /// The underlying data buffer. + /// + /// This is always both a List and a TypedData, which we don't have a type + /// for here. For example, for a `Uint8Buffer`, this is a `Uint8List`. + List _buffer; + + /// Returns a view of [_buffer] as a [TypedData]. + TypedData get _typedBuffer => _buffer as TypedData; + /// The length of the list being built. int _length; _TypedDataBuffer(List buffer) - : this._buffer = buffer, this._length = buffer.length; + : this._buffer = buffer, + this._length = buffer.length; int get length => _length; E operator[](int index) { @@ -154,7 +161,7 @@ abstract class _TypedDataBuffer extends ListBase { } // Reverses the range [start..end) of buffer. - static void _reverse(List buffer, int start, int end) { + static void _reverse(List buffer, int start, int end) { end--; // Point to last element, not after last element. while (start < end) { var first = buffer[start]; @@ -279,11 +286,11 @@ abstract class _TypedDataBuffer extends ListBase { // TypedData. - int get elementSizeInBytes => _buffer.elementSizeInBytes; + int get elementSizeInBytes => _typedBuffer.elementSizeInBytes; - int get lengthInBytes => _length * _buffer.elementSizeInBytes; + int get lengthInBytes => _length * _typedBuffer.elementSizeInBytes; - int get offsetInBytes => _buffer.offsetInBytes; + int get offsetInBytes => _typedBuffer.offsetInBytes; /// Returns the underlying [ByteBuffer]. /// @@ -291,7 +298,7 @@ abstract class _TypedDataBuffer extends ListBase { /// of this list. /// /// The buffer may be larger than [lengthInBytes] bytes, but never smaller. - ByteBuffer get buffer => _buffer.buffer; + ByteBuffer get buffer => _typedBuffer.buffer; // Specialization for the specific type. @@ -304,12 +311,14 @@ abstract class _TypedDataBuffer extends ListBase { } abstract class _IntBuffer extends _TypedDataBuffer { - _IntBuffer(buffer): super(buffer); + _IntBuffer(List buffer): super(buffer); + int get _defaultValue => 0; } abstract class _FloatBuffer extends _TypedDataBuffer { - _FloatBuffer(buffer): super(buffer); + _FloatBuffer(List buffer): super(buffer); + double get _defaultValue => 0.0; } diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index a58a7e72..89d680fd 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.2 +version: 1.1.3 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 9e97592a..67668163 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -152,13 +152,13 @@ double roundToFloat(double value) { typedef int Rounder(int value); -Rounder roundUint(bits) { +Rounder uintRounder(bits) { int halfbits = (1 << (bits ~/ 2)) - 1; int mask = halfbits | (halfbits << (bits ~/ 2)); return (int x) => x & mask; } -Rounder roundInt(bits) { +Rounder intRounder(bits) { int highBit = 1 << (bits - 1); int mask = highBit - 1; return (int x) => (x & mask) - (x & highBit); @@ -166,20 +166,20 @@ Rounder roundInt(bits) { int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; -void testUint(int bits, var buffer, {String testOn}) { +void testUint(int bits, buffer(int length), {String testOn}) { int min = 0; - Function round = roundUint(bits); - int max = round(-1); + var rounder = uintRounder(bits); + int max = rounder(-1); test("Uint${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, round); + testIntBuffer(bits, min, max, buffer, rounder); }, testOn: testOn); } -void testInt(int bits, var buffer, {String testOn}) { +void testInt(int bits, buffer(int length), {String testOn}) { int min = -(1 << (bits - 1)); int max = -(min + 1); test("Int${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, roundInt(bits)); + testIntBuffer(bits, min, max, buffer, intRounder(bits)); }, testOn: testOn); } @@ -231,7 +231,7 @@ void testIntBuffer(int bits, int min, int max, assert(round(max) == max); // All int buffers default to the value 0. var buffer = create(0); - List list = buffer; // Check the type. + expect(buffer, new isInstanceOf>()); expect(buffer.length, equals(0)); var bytes = bits ~/ 8; @@ -338,7 +338,7 @@ void doubleEqual(x, y) { testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { test("Float${bitSize}Buffer", () { var buffer = create(); - List list = buffer; // Test type. + expect(buffer, new isInstanceOf>()); int byteSize = bitSize ~/ 8; expect(buffer.length, equals(0)); @@ -393,7 +393,7 @@ testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { } testFloat32x4Buffer(List floatSamples) { - List float4Samples = []; + var float4Samples = []; for (int i = 0; i < floatSamples.length - 3; i++) { float4Samples.add(new Float32x4(floatSamples[i], floatSamples[i + 1], @@ -418,7 +418,7 @@ testFloat32x4Buffer(List floatSamples) { test("Float32x4Buffer", () { var buffer = new Float32x4Buffer(5); - List list = buffer; + expect(buffer, new isInstanceOf>()); expect(buffer.length, equals(5)); expect(buffer.elementSizeInBytes, equals(128 ~/ 8)); @@ -458,15 +458,14 @@ testFloat32x4Buffer(List floatSamples) { }); } -void testInt32x4Buffer(intSamples) { +void testInt32x4Buffer(List intSamples) { test("Int32x4Buffer", () { - Function round = roundInt(32); - int bits = 128; + Function rounder = intRounder(32); int bytes = 128 ~/ 8; Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); var buffer = new Int32x4Buffer(0); - List list = buffer; // It's a List. + expect(buffer, new isInstanceOf>()); expect(buffer.length, equals(0)); expect(buffer.elementSizeInBytes, equals(bytes)); @@ -486,7 +485,7 @@ void testInt32x4Buffer(intSamples) { expect(buffer.length, equals(0)); var samples = intSamples - .where((value) => value == round(value)) // Issue 15130 + .where((value) => value == rounder(value)) // Issue 15130 .map((value) => new Int32x4(value, -value, ~value, ~-value)) .toList(); for (Int32x4 value in samples) { From 98a2cf731a67dcd9497bd88253f079b89606cf82 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 2 Aug 2017 14:05:11 -0700 Subject: [PATCH 014/113] expand the sdk constraint; rev version --- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/analysis_options.yaml | 2 ++ pkgs/typed_data/lib/typed_buffers.dart | 2 +- pkgs/typed_data/lib/typed_data.dart | 2 +- pkgs/typed_data/pubspec.yaml | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 pkgs/typed_data/analysis_options.yaml diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index ac7eb0b7..8d40dc4b 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.4 + +* Expand the SDK version constraint to include `<2.0.0-dev.infinity`. + ## 1.1.3 * Fix all strong-mode warnings. diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml new file mode 100644 index 00000000..a10d4c5a --- /dev/null +++ b/pkgs/typed_data/analysis_options.yaml @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index ac178b51..85a1414e 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -11,7 +11,7 @@ /// That means that using the [TypedDataView.buffer] getter is not guaranteed /// to return the same result each time it is used, and that the buffer may /// be larger than what the list is using. -library dart.pkg.typed_data.typed_buffers; +library typed_buffers; import "dart:collection" show ListBase; import "dart:typed_data"; diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index d56b8bfa..5ae0142a 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -3,6 +3,6 @@ // BSD-style license that can be found in the LICENSE file. /// Utilities and functionality related to the "dart:typed_data" library. -library dart.pkg.typed_data; +library typed_data; export "package:typed_data/typed_buffers.dart"; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 89d680fd..59b3cc00 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,9 @@ name: typed_data -version: 1.1.3 +version: 1.1.4 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data dev_dependencies: test: "^0.12.0" environment: - sdk: ">=1.8.0 <2.0.0" + sdk: ">=1.8.0 <2.0.0-dev.infinity" From 235e391073eff915d943ce82caf98b55a94233ce Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 2 Aug 2017 14:35:31 -0700 Subject: [PATCH 015/113] prefix with typed_data. --- pkgs/typed_data/lib/typed_buffers.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 85a1414e..09514807 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -11,7 +11,7 @@ /// That means that using the [TypedDataView.buffer] getter is not guaranteed /// to return the same result each time it is used, and that the buffer may /// be larger than what the list is using. -library typed_buffers; +library typed_data.typed_buffers; import "dart:collection" show ListBase; import "dart:typed_data"; From 40ecbb5604aca6a9f1ecd06bb7196c1bfc98527f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Sep 2017 18:13:15 -0700 Subject: [PATCH 016/113] fix SDK constraint --- pkgs/typed_data/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 59b3cc00..cff6afdc 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,9 @@ name: typed_data -version: 1.1.4 +version: 1.1.5-dev author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data dev_dependencies: test: "^0.12.0" environment: - sdk: ">=1.8.0 <2.0.0-dev.infinity" + sdk: ">=1.8.0 <2.0.0" From ed7c9e5d8881bce1f916b660d92f388a88a6f813 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Sep 2017 17:28:41 -0700 Subject: [PATCH 017/113] enable travis-ci --- pkgs/typed_data/.travis.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pkgs/typed_data/.travis.yml diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml new file mode 100644 index 00000000..aa7342bf --- /dev/null +++ b/pkgs/typed_data/.travis.yml @@ -0,0 +1,17 @@ +language: dart +dart: + - dev + - stable + +dart_task: + - test: -p vm,firefox + - dartfmt + - analyzer + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache From c655f7c02354746dcf46ff641bd74b4c79f69bca Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Sep 2017 17:29:51 -0700 Subject: [PATCH 018/113] dartfmt --- pkgs/typed_data/lib/typed_buffers.dart | 15 +-- pkgs/typed_data/test/typed_buffers_test.dart | 111 +++++++++---------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 09514807..23f2cbb7 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -36,12 +36,12 @@ abstract class _TypedDataBuffer extends ListBase { this._length = buffer.length; int get length => _length; - E operator[](int index) { + E operator [](int index) { if (index >= length) throw new RangeError.index(index, this); return _buffer[index]; } - void operator[]=(int index, E value) { + void operator []=(int index, E value) { if (index >= length) throw new RangeError.index(index, this); _buffer[index] = value; } @@ -73,7 +73,9 @@ abstract class _TypedDataBuffer extends ListBase { // We override the default implementation of `add` because it grows the list // by setting the length in increments of one. We want to grow by doubling // capacity in most cases. - void add(E value) { _add(value); } + void add(E value) { + _add(value); + } /// Appends all objects of [values] to the end of this buffer. /// @@ -112,7 +114,6 @@ abstract class _TypedDataBuffer extends ListBase { if (start == end) return; } - // If we're adding to the end of the list anyway, use [_addAll]. This lets // us avoid converting [values] into a list even if [end] is null, since we // can add values iteratively to the end of the list. We can't do so in the @@ -162,7 +163,7 @@ abstract class _TypedDataBuffer extends ListBase { // Reverses the range [start..end) of buffer. static void _reverse(List buffer, int start, int end) { - end--; // Point to last element, not after last element. + end--; // Point to last element, not after last element. while (start < end) { var first = buffer[start]; var last = buffer[end]; @@ -311,13 +312,13 @@ abstract class _TypedDataBuffer extends ListBase { } abstract class _IntBuffer extends _TypedDataBuffer { - _IntBuffer(List buffer): super(buffer); + _IntBuffer(List buffer) : super(buffer); int get _defaultValue => 0; } abstract class _FloatBuffer extends _TypedDataBuffer { - _FloatBuffer(List buffer): super(buffer); + _FloatBuffer(List buffer) : super(buffer); double get _defaultValue => 0.0; } diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 67668163..749961be 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -17,21 +17,22 @@ main() { }); testUint(16, (l) => new Uint16Buffer(l)); testInt(16, (l) => new Int16Buffer(l)); - testUint(32, (l) => new Uint32Buffer(l)); /// 01: ok + testUint(32, (l) => new Uint32Buffer(l)); + testInt(32, (l) => new Int32Buffer(l)); - testUint(64, (l) => new Uint64Buffer(l), /// 01: continued + + testUint(64, (l) => new Uint64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); - testInt(64, (l) => new Int64Buffer(l), /// 01: continued + testInt(64, (l) => new Int64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); testInt32x4Buffer(intSamples); List roundedFloatSamples = floatSamples.map(roundToFloat).toList(); - testFloatBuffer(32, roundedFloatSamples, - () => new Float32Buffer(), - roundToFloat); + testFloatBuffer( + 32, roundedFloatSamples, () => new Float32Buffer(), roundToFloat); testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); testFloat32x4Buffer(roundedFloatSamples); @@ -185,35 +186,35 @@ void testInt(int bits, buffer(int length), {String testOn}) { const List intSamples = const [ 0x10000000000000001, - 0x10000000000000000, // 2^64 + 0x10000000000000000, // 2^64 0x0ffffffffffffffff, 0xaaaaaaaaaaaaaaaa, 0x8000000000000001, - 0x8000000000000000, // 2^63 + 0x8000000000000000, // 2^63 0x7fffffffffffffff, 0x5555555555555555, 0x100000001, - 0x100000000, // 2^32 + 0x100000000, // 2^32 0x0ffffffff, 0xaaaaaaaa, 0x80000001, - 0x80000000, // 2^31 + 0x80000000, // 2^31 0x7fffffff, 0x55555555, 0x10001, - 0x10000, // 2^16 + 0x10000, // 2^16 0x0ffff, 0xaaaa, 0x8001, - 0x8000, // 2^15 + 0x8000, // 2^15 0x7fff, 0x5555, 0x101, - 0x100, // 2^8 + 0x100, // 2^8 0x0ff, 0xaa, 0x81, - 0x80, // 2^7 + 0x80, // 2^7 0x7f, 0x55, 0x02, @@ -224,9 +225,8 @@ const List intSamples = const [ // Takes bit-size, min value, max value, function to create a buffer, and // the rounding that is applied when storing values outside the valid range // into the buffer. -void testIntBuffer(int bits, int min, int max, - create(int length), - int round(int)) { +void testIntBuffer( + int bits, int min, int max, create(int length), int round(int)) { assert(round(min) == min); assert(round(max) == max); // All int buffers default to the value 0. @@ -257,7 +257,7 @@ void testIntBuffer(int bits, int min, int max, expect(buffer.length, equals(length + 1)); expect(buffer[length], equals(round(value))); } - buffer.addAll(samples); // Add all the values at once. + buffer.addAll(samples); // Add all the values at once. for (int i = 0; i < samples.length; i++) { expect(buffer[samples.length + i], equals(buffer[i])); } @@ -289,38 +289,38 @@ void testIntBuffer(int bits, int min, int max, const List doubleSamples = const [ 0.0, - 5e-324, // Minimal denormal value. - 2.225073858507201e-308, // Maximal denormal value. - 2.2250738585072014e-308, // Minimal normal value. - 0.9999999999999999, // Maximum value < 1. + 5e-324, // Minimal denormal value. + 2.225073858507201e-308, // Maximal denormal value. + 2.2250738585072014e-308, // Minimal normal value. + 0.9999999999999999, // Maximum value < 1. 1.0, - 1.0000000000000002, // Minimum value > 1. - 4294967295.0, // 2^32 -1. - 4294967296.0, // 2^32. - 4503599627370495.5, // Maximal fractional value. - 9007199254740992.0, // Maximal exact value (adding one gets lost). - 1.7976931348623157e+308, // Maximal value. - 1.0/0.0, // Infinity. - 0.0/0.0, // NaN. - 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards - 4503599627370497.0, // minus infinity will not be the same as rounding - 9007199254740991.0 // to nearest with 0.5 rounding up). + 1.0000000000000002, // Minimum value > 1. + 4294967295.0, // 2^32 -1. + 4294967296.0, // 2^32. + 4503599627370495.5, // Maximal fractional value. + 9007199254740992.0, // Maximal exact value (adding one gets lost). + 1.7976931348623157e+308, // Maximal value. + 1.0 / 0.0, // Infinity. + 0.0 / 0.0, // NaN. + 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards + 4503599627370497.0, // minus infinity will not be the same as rounding + 9007199254740991.0 // to nearest with 0.5 rounding up). ]; const List floatSamples = const [ 0.0, - 1.4e-45, // Minimal denormal value. - 1.1754942E-38, // Maximal denormal value. - 1.17549435E-38, // Minimal normal value. - 0.99999994, // Maximal value < 1. + 1.4e-45, // Minimal denormal value. + 1.1754942E-38, // Maximal denormal value. + 1.17549435E-38, // Minimal normal value. + 0.99999994, // Maximal value < 1. 1.0, - 1.0000001, // Minimal value > 1. - 8388607.5, // Maximal fractional value. - 16777216.0, // Maximal exact value. - 3.4028235e+38, // Maximal value. - 1.0/0.0, // Infinity. - 0.0/0.0, // NaN. - 0.99999994, // Round traps 1-3. + 1.0000001, // Minimal value > 1. + 8388607.5, // Maximal fractional value. + 16777216.0, // Maximal exact value. + 3.4028235e+38, // Maximal value. + 1.0 / 0.0, // Infinity. + 0.0 / 0.0, // NaN. + 0.99999994, // Round traps 1-3. 8388609.0, 16777215.0 ]; @@ -329,8 +329,7 @@ void doubleEqual(x, y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { - if (x != y) { - } + if (x != y) {} expect(x, equals(y)); } } @@ -395,10 +394,8 @@ testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { testFloat32x4Buffer(List floatSamples) { var float4Samples = []; for (int i = 0; i < floatSamples.length - 3; i++) { - float4Samples.add(new Float32x4(floatSamples[i], - floatSamples[i + 1], - floatSamples[i + 2], - floatSamples[i + 3])); + float4Samples.add(new Float32x4(floatSamples[i], floatSamples[i + 1], + floatSamples[i + 2], floatSamples[i + 3])); } void floatEquals(x, y) { @@ -448,7 +445,7 @@ testFloat32x4Buffer(List floatSamples) { // Test underlying buffer. buffer.length = 1; - buffer[0] = float4Samples[0]; // Does not contain NaN. + buffer[0] = float4Samples[0]; // Does not contain NaN. Float32List floats = new Float32List.view(buffer.buffer); expect(floats[0], equals(buffer[0].x)); @@ -485,8 +482,8 @@ void testInt32x4Buffer(List intSamples) { expect(buffer.length, equals(0)); var samples = intSamples - .where((value) => value == rounder(value)) // Issue 15130 - .map((value) => new Int32x4(value, -value, ~value, ~-value)) + .where((value) => value == rounder(value)) // Issue 15130 + .map((value) => new Int32x4(value, -value, ~value, ~ -value)) .toList(); for (Int32x4 value in samples) { int length = buffer.length; @@ -495,7 +492,7 @@ void testInt32x4Buffer(List intSamples) { expect(buffer[length], equals32x4(value)); } - buffer.addAll(samples); // Add all the values at once. + buffer.addAll(samples); // Add all the values at once. for (int i = 0; i < samples.length; i++) { expect(buffer[samples.length + i], equals32x4(buffer[i])); } @@ -525,8 +522,10 @@ class MatchesInt32x4 extends Matcher { bool matches(item, Map matchState) { if (item is! Int32x4) return false; Int32x4 value = item; - return result.x == value.x && result.y == value.y && - result.z == value.z && result.w == value.w; + return result.x == value.x && + result.y == value.y && + result.z == value.z && + result.w == value.w; } Description describe(Description description) => From 6d87e2ca2ee6cbcf25fe6d3a1f0251e5b175285b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Sep 2017 18:12:50 -0700 Subject: [PATCH 019/113] fix fuzzy-arrow hints --- pkgs/typed_data/test/typed_buffers_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 749961be..02d03a54 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -226,7 +226,7 @@ const List intSamples = const [ // the rounding that is applied when storing values outside the valid range // into the buffer. void testIntBuffer( - int bits, int min, int max, create(int length), int round(int)) { + int bits, int min, int max, create(int length), int round(int val)) { assert(round(min) == min); assert(round(max) == max); // All int buffers default to the value 0. @@ -307,7 +307,7 @@ const List doubleSamples = const [ 9007199254740991.0 // to nearest with 0.5 rounding up). ]; -const List floatSamples = const [ +const floatSamples = const [ 0.0, 1.4e-45, // Minimal denormal value. 1.1754942E-38, // Maximal denormal value. From c7c1fcb5a99cffc5a94aa45219dcf947dd1bc678 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 29 Sep 2017 10:19:14 -0700 Subject: [PATCH 020/113] Remove SDK 15130 work-around --- pkgs/typed_data/test/typed_buffers_test.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 02d03a54..a9cd28c3 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -457,7 +457,6 @@ testFloat32x4Buffer(List floatSamples) { void testInt32x4Buffer(List intSamples) { test("Int32x4Buffer", () { - Function rounder = intRounder(32); int bytes = 128 ~/ 8; Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); @@ -482,7 +481,6 @@ void testInt32x4Buffer(List intSamples) { expect(buffer.length, equals(0)); var samples = intSamples - .where((value) => value == rounder(value)) // Issue 15130 .map((value) => new Int32x4(value, -value, ~value, ~ -value)) .toList(); for (Int32x4 value in samples) { From ed2b6b67b545de99ed18725f189e65cf00dcba31 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 29 Sep 2017 10:26:35 -0700 Subject: [PATCH 021/113] remove empty if block --- pkgs/typed_data/test/typed_buffers_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index a9cd28c3..47ad57e8 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -329,7 +329,6 @@ void doubleEqual(x, y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { - if (x != y) {} expect(x, equals(y)); } } From 6a8b73f6c480b36c80acf88eeecf71457c454223 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Sep 2017 18:55:31 -0700 Subject: [PATCH 022/113] Prepare for release --- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 8d40dc4b..5f929149 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.5 + +* Undo unnessesary SDK version constraint tweak. + ## 1.1.4 * Expand the SDK version constraint to include `<2.0.0-dev.infinity`. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index cff6afdc..78bc786f 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.5-dev +version: 1.1.5 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data From 74bd42a160378eb1f9b7ec8057eb711692d7db4c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 19 Oct 2017 11:55:21 -0700 Subject: [PATCH 023/113] Fix analyzer task (dart-lang/typed_data#7) --- pkgs/typed_data/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index aa7342bf..1fae12e8 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -6,7 +6,7 @@ dart: dart_task: - test: -p vm,firefox - dartfmt - - analyzer + - dartanalyzer # Only building master means that we don't run two builds for each pull request. branches: From 6636285226f6c39a6323b35408454a405994d0f8 Mon Sep 17 00:00:00 2001 From: Keerti Parthasarathy Date: Wed, 17 Jan 2018 08:56:14 -0800 Subject: [PATCH 024/113] Fix test for Dart 2.0 ints (dart-lang/typed_data#9) * Fix test for Dart 2.0 ints * Update pubspec.yaml * Update typed_buffers_test.dart * Update typed_buffers_test.dart * Add 2^63 back to test data * Update CHANGELOG.md * Update typed_buffers_test.dart * Fix tests * run tests only on dev * Update pubspec --- pkgs/typed_data/.travis.yml | 1 - pkgs/typed_data/CHANGELOG.md | 4 + pkgs/typed_data/pubspec.yaml | 4 +- pkgs/typed_data/test/typed_buffers_test.dart | 399 ++++++++++--------- 4 files changed, 209 insertions(+), 199 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 1fae12e8..ab911a8e 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,7 +1,6 @@ language: dart dart: - dev - - stable dart_task: - test: -p vm,firefox diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 5f929149..1855d95f 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.6 + +* Update tests to work with Dart 2.0 64 bit ints. + ## 1.1.5 * Undo unnessesary SDK version constraint tweak. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 78bc786f..98579db4 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,9 @@ name: typed_data -version: 1.1.5 +version: 1.1.6 author: Dart Team description: Utility functions and classes related to the 'dart:typed_data' library. homepage: https://github.com/dart-lang/typed_data dev_dependencies: test: "^0.12.0" environment: - sdk: ">=1.8.0 <2.0.0" + sdk: ">=2.0.0-dev.16.0 <2.0.0" diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 47ad57e8..35aab014 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -147,46 +147,45 @@ main() { }); } -double roundToFloat(double value) { - return (new Float32List(1)..[0] = value)[0]; -} - -typedef int Rounder(int value); - -Rounder uintRounder(bits) { - int halfbits = (1 << (bits ~/ 2)) - 1; - int mask = halfbits | (halfbits << (bits ~/ 2)); - return (int x) => x & mask; -} - -Rounder intRounder(bits) { - int highBit = 1 << (bits - 1); - int mask = highBit - 1; - return (int x) => (x & mask) - (x & highBit); -} - -int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; - -void testUint(int bits, buffer(int length), {String testOn}) { - int min = 0; - var rounder = uintRounder(bits); - int max = rounder(-1); - test("Uint${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, rounder); - }, testOn: testOn); -} +const List doubleSamples = const [ + 0.0, + 5e-324, // Minimal denormal value. + 2.225073858507201e-308, // Maximal denormal value. + 2.2250738585072014e-308, // Minimal normal value. + 0.9999999999999999, // Maximum value < 1. + 1.0, + 1.0000000000000002, // Minimum value > 1. + 4294967295.0, // 2^32 -1. + 4294967296.0, // 2^32. + 4503599627370495.5, // Maximal fractional value. + 9007199254740992.0, // Maximal exact value (adding one gets lost). + 1.7976931348623157e+308, // Maximal value. + 1.0 / 0.0, // Infinity. + 0.0 / 0.0, // NaN. + 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards + 4503599627370497.0, // minus infinity will not be the same as rounding + 9007199254740991.0 // to nearest with 0.5 rounding up). +]; -void testInt(int bits, buffer(int length), {String testOn}) { - int min = -(1 << (bits - 1)); - int max = -(min + 1); - test("Int${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, intRounder(bits)); - }, testOn: testOn); -} +const floatSamples = const [ + 0.0, + 1.4e-45, // Minimal denormal value. + 1.1754942E-38, // Maximal denormal value. + 1.17549435E-38, // Minimal normal value. + 0.99999994, // Maximal value < 1. + 1.0, + 1.0000001, // Minimal value > 1. + 8388607.5, // Maximal fractional value. + 16777216.0, // Maximal exact value. + 3.4028235e+38, // Maximal value. + 1.0 / 0.0, // Infinity. + 0.0 / 0.0, // NaN. + 0.99999994, // Round traps 1-3. + 8388609.0, + 16777215.0 +]; const List intSamples = const [ - 0x10000000000000001, - 0x10000000000000000, // 2^64 0x0ffffffffffffffff, 0xaaaaaaaaaaaaaaaa, 0x8000000000000001, @@ -222,108 +221,7 @@ const List intSamples = const [ 0x00 ]; -// Takes bit-size, min value, max value, function to create a buffer, and -// the rounding that is applied when storing values outside the valid range -// into the buffer. -void testIntBuffer( - int bits, int min, int max, create(int length), int round(int val)) { - assert(round(min) == min); - assert(round(max) == max); - // All int buffers default to the value 0. - var buffer = create(0); - expect(buffer, new isInstanceOf>()); - expect(buffer.length, equals(0)); - var bytes = bits ~/ 8; - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(0)); - expect(buffer.offsetInBytes, equals(0)); - - buffer.add(min); - expect(buffer.length, equals(1)); - expect(buffer[0], equals(min)); - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(bytes)); - expect(buffer.offsetInBytes, equals(0)); - - buffer.length = 0; - expect(buffer.length, equals(0)); - - List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); - for (int value in samples) { - int length = buffer.length; - buffer.add(value); - expect(buffer.length, equals(length + 1)); - expect(buffer[length], equals(round(value))); - } - buffer.addAll(samples); // Add all the values at once. - for (int i = 0; i < samples.length; i++) { - expect(buffer[samples.length + i], equals(buffer[i])); - } - - // Remove range works and changes length. - buffer.removeRange(samples.length, buffer.length); - expect(buffer.length, equals(samples.length)); - - // Both values are in `samples`, but equality is performed without rounding. - expect(buffer.contains(min - 1), isFalse); - expect(buffer.contains(max + 1), isFalse); - expect(buffer.contains(round(min - 1)), isTrue); - expect(buffer.contains(round(max + 1)), isTrue); - - // Accessing the underlying buffer works. - buffer.length = 2; - buffer[0] = min; - buffer[1] = max; - var byteBuffer = new Uint8List.view(buffer.buffer); - int byteSize = buffer.elementSizeInBytes; - for (int i = 0; i < byteSize; i++) { - int tmp = byteBuffer[i]; - byteBuffer[i] = byteBuffer[byteSize + i]; - byteBuffer[byteSize + i] = tmp; - } - expect(buffer[0], equals(max)); - expect(buffer[1], equals(min)); -} - -const List doubleSamples = const [ - 0.0, - 5e-324, // Minimal denormal value. - 2.225073858507201e-308, // Maximal denormal value. - 2.2250738585072014e-308, // Minimal normal value. - 0.9999999999999999, // Maximum value < 1. - 1.0, - 1.0000000000000002, // Minimum value > 1. - 4294967295.0, // 2^32 -1. - 4294967296.0, // 2^32. - 4503599627370495.5, // Maximal fractional value. - 9007199254740992.0, // Maximal exact value (adding one gets lost). - 1.7976931348623157e+308, // Maximal value. - 1.0 / 0.0, // Infinity. - 0.0 / 0.0, // NaN. - 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards - 4503599627370497.0, // minus infinity will not be the same as rounding - 9007199254740991.0 // to nearest with 0.5 rounding up). -]; - -const floatSamples = const [ - 0.0, - 1.4e-45, // Minimal denormal value. - 1.1754942E-38, // Maximal denormal value. - 1.17549435E-38, // Minimal normal value. - 0.99999994, // Maximal value < 1. - 1.0, - 1.0000001, // Minimal value > 1. - 8388607.5, // Maximal fractional value. - 16777216.0, // Maximal exact value. - 3.4028235e+38, // Maximal value. - 1.0 / 0.0, // Infinity. - 0.0 / 0.0, // NaN. - 0.99999994, // Round traps 1-3. - 8388609.0, - 16777215.0 -]; +int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; void doubleEqual(x, y) { if (y.isNaN) { @@ -333,61 +231,14 @@ void doubleEqual(x, y) { } } -testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { - test("Float${bitSize}Buffer", () { - var buffer = create(); - expect(buffer, new isInstanceOf>()); - int byteSize = bitSize ~/ 8; - - expect(buffer.length, equals(0)); - buffer.add(0.0); - expect(buffer.length, equals(1)); - expect(buffer.removeLast(), equals(0.0)); - expect(buffer.length, equals(0)); - - for (double value in samples) { - buffer.add(value); - doubleEqual(buffer[buffer.length - 1], round(value)); - } - expect(buffer.length, equals(samples.length)); - - buffer.addAll(samples); - expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { - doubleEqual(buffer[i], buffer[samples.length + i]); - } - - buffer.removeRange(samples.length, buffer.length); - expect(buffer.length, equals(samples.length)); - - buffer.insertAll(0, samples); - expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { - doubleEqual(buffer[i], buffer[samples.length + i]); - } - - buffer.length = samples.length; - expect(buffer.length, equals(samples.length)); - - // TypedData. - expect(buffer.elementSizeInBytes, equals(byteSize)); - expect(buffer.lengthInBytes, equals(byteSize * buffer.length)); - expect(buffer.offsetInBytes, equals(0)); +Rounder intRounder(bits) { + int highBit = 1 << (bits - 1); + int mask = highBit - 1; + return (int x) => (x & mask) - (x & highBit); +} - // Accessing the buffer works. - // Accessing the underlying buffer works. - buffer.length = 2; - buffer[0] = samples[0]; - buffer[1] = samples[1]; - var bytes = new Uint8List.view(buffer.buffer); - for (int i = 0; i < byteSize; i++) { - int tmp = bytes[i]; - bytes[i] = bytes[byteSize + i]; - bytes[byteSize + i] = tmp; - } - doubleEqual(buffer[0], round(samples[1])); - doubleEqual(buffer[1], round(samples[0])); - }); +double roundToFloat(double value) { + return (new Float32List(1)..[0] = value)[0]; } testFloat32x4Buffer(List floatSamples) { @@ -454,6 +305,74 @@ testFloat32x4Buffer(List floatSamples) { }); } +// Takes bit-size, min value, max value, function to create a buffer, and +// the rounding that is applied when storing values outside the valid range +// into the buffer. +testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { + test("Float${bitSize}Buffer", () { + var buffer = create(); + expect(buffer, new isInstanceOf>()); + int byteSize = bitSize ~/ 8; + + expect(buffer.length, equals(0)); + buffer.add(0.0); + expect(buffer.length, equals(1)); + expect(buffer.removeLast(), equals(0.0)); + expect(buffer.length, equals(0)); + + for (double value in samples) { + buffer.add(value); + doubleEqual(buffer[buffer.length - 1], round(value)); + } + expect(buffer.length, equals(samples.length)); + + buffer.addAll(samples); + expect(buffer.length, equals(samples.length * 2)); + for (int i = 0; i < samples.length; i++) { + doubleEqual(buffer[i], buffer[samples.length + i]); + } + + buffer.removeRange(samples.length, buffer.length); + expect(buffer.length, equals(samples.length)); + + buffer.insertAll(0, samples); + expect(buffer.length, equals(samples.length * 2)); + for (int i = 0; i < samples.length; i++) { + doubleEqual(buffer[i], buffer[samples.length + i]); + } + + buffer.length = samples.length; + expect(buffer.length, equals(samples.length)); + + // TypedData. + expect(buffer.elementSizeInBytes, equals(byteSize)); + expect(buffer.lengthInBytes, equals(byteSize * buffer.length)); + expect(buffer.offsetInBytes, equals(0)); + + // Accessing the buffer works. + // Accessing the underlying buffer works. + buffer.length = 2; + buffer[0] = samples[0]; + buffer[1] = samples[1]; + var bytes = new Uint8List.view(buffer.buffer); + for (int i = 0; i < byteSize; i++) { + int tmp = bytes[i]; + bytes[i] = bytes[byteSize + i]; + bytes[byteSize + i] = tmp; + } + doubleEqual(buffer[0], round(samples[1])); + doubleEqual(buffer[1], round(samples[0])); + }); +} + +void testInt(int bits, buffer(int length), {String testOn}) { + int min = -(1 << (bits - 1)); + int max = -(min + 1); + test("Int${bits}Buffer", () { + testIntBuffer(bits, min, max, buffer, intRounder(bits)); + }, testOn: testOn); +} + void testInt32x4Buffer(List intSamples) { test("Int32x4Buffer", () { int bytes = 128 ~/ 8; @@ -513,9 +432,100 @@ void testInt32x4Buffer(List intSamples) { }); } +void testIntBuffer( + int bits, int min, int max, create(int length), int round(int val)) { + assert(round(min) == min); + assert(round(max) == max); + // All int buffers default to the value 0. + var buffer = create(0); + expect(buffer, new isInstanceOf>()); + expect(buffer.length, equals(0)); + var bytes = bits ~/ 8; + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(0)); + expect(buffer.offsetInBytes, equals(0)); + + buffer.add(min); + expect(buffer.length, equals(1)); + expect(buffer[0], equals(min)); + + expect(buffer.elementSizeInBytes, equals(bytes)); + expect(buffer.lengthInBytes, equals(bytes)); + expect(buffer.offsetInBytes, equals(0)); + + buffer.length = 0; + expect(buffer.length, equals(0)); + + List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); + for (int value in samples) { + int length = buffer.length; + buffer.add(value); + expect(buffer.length, equals(length + 1)); + expect(buffer[length], equals(round(value))); + } + buffer.addAll(samples); // Add all the values at once. + for (int i = 0; i < samples.length; i++) { + expect(buffer[samples.length + i], equals(buffer[i])); + } + + // Remove range works and changes length. + buffer.removeRange(samples.length, buffer.length); + expect(buffer.length, equals(samples.length)); + + // Both values are in `samples`, but equality is performed without rounding. + // For signed 64 bit ints, min and max wrap around, min-1=max and max+1=min + if (bits == 64) { + // TODO(keertip): fix tests for Uint64 / Int64 as now Uints are represented + // as signed ints. + expect(buffer.contains(min - 1), isTrue); + expect(buffer.contains(max + 1), isTrue); + } else { + // Both values are in `samples`, but equality is performed without rounding. + expect(buffer.contains(min - 1), isFalse); + expect(buffer.contains(max + 1), isFalse); + } + expect(buffer.contains(round(min - 1)), isTrue); + expect(buffer.contains(round(max + 1)), isTrue); + + // Accessing the underlying buffer works. + buffer.length = 2; + buffer[0] = min; + buffer[1] = max; + var byteBuffer = new Uint8List.view(buffer.buffer); + int byteSize = buffer.elementSizeInBytes; + for (int i = 0; i < byteSize; i++) { + int tmp = byteBuffer[i]; + byteBuffer[i] = byteBuffer[byteSize + i]; + byteBuffer[byteSize + i] = tmp; + } + expect(buffer[0], equals(max)); + expect(buffer[1], equals(min)); +} + +void testUint(int bits, buffer(int length), {String testOn}) { + int min = 0; + var rounder = uintRounder(bits); + int max = rounder(-1); + test("Uint${bits}Buffer", () { + testIntBuffer(bits, min, max, buffer, rounder); + }, testOn: testOn); +} + +Rounder uintRounder(bits) { + int halfbits = (1 << (bits ~/ 2)) - 1; + int mask = halfbits | (halfbits << (bits ~/ 2)); + return (int x) => x & mask; +} + +typedef int Rounder(int value); + class MatchesInt32x4 extends Matcher { Int32x4 result; MatchesInt32x4(this.result); + Description describe(Description description) => + description.add('Int32x4.=='); + bool matches(item, Map matchState) { if (item is! Int32x4) return false; Int32x4 value = item; @@ -524,7 +534,4 @@ class MatchesInt32x4 extends Matcher { result.z == value.z && result.w == value.w; } - - Description describe(Description description) => - description.add('Int32x4.=='); } From bfa0de27c3a042c9d260fd2201ccf0a93797f7a4 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 2 May 2018 15:05:42 -0700 Subject: [PATCH 025/113] Fix runtime Dart 2 test errors (dart-lang/typed_data#13) --- pkgs/typed_data/test/typed_buffers_test.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 35aab014..53aa666c 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -30,7 +30,7 @@ main() { testInt32x4Buffer(intSamples); - List roundedFloatSamples = floatSamples.map(roundToFloat).toList(); + var roundedFloatSamples = floatSamples.map(roundToFloat).toList(); testFloatBuffer( 32, roundedFloatSamples, () => new Float32Buffer(), roundToFloat); testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); @@ -147,7 +147,7 @@ main() { }); } -const List doubleSamples = const [ +const doubleSamples = const [ 0.0, 5e-324, // Minimal denormal value. 2.225073858507201e-308, // Maximal denormal value. @@ -308,7 +308,8 @@ testFloat32x4Buffer(List floatSamples) { // Takes bit-size, min value, max value, function to create a buffer, and // the rounding that is applied when storing values outside the valid range // into the buffer. -testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { +void testFloatBuffer( + int bitSize, List samples, create(), double round(double v)) { test("Float${bitSize}Buffer", () { var buffer = create(); expect(buffer, new isInstanceOf>()); From 79fb95b4afc7944639b94589cab1cd38b1c590f6 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Tue, 17 Jul 2018 17:47:59 -0400 Subject: [PATCH 026/113] chore: set max SDK version to <3.0.0 (dart-lang/typed_data#17) * Skip tests known to be failing Due to dart-lang/typed_data#16. This will get the build green again. --- pkgs/typed_data/.travis.yml | 4 +++- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/README.md | 6 ++++-- pkgs/typed_data/analysis_options.yaml | 2 -- pkgs/typed_data/pubspec.yaml | 13 ++++++++----- pkgs/typed_data/test/typed_buffers_test.dart | 8 ++++---- 6 files changed, 23 insertions(+), 14 deletions(-) delete mode 100644 pkgs/typed_data/analysis_options.yaml diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index ab911a8e..01a70209 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -3,7 +3,9 @@ dart: - dev dart_task: - - test: -p vm,firefox + - test: -p vm + # TODO: reinstate once https://github.com/dart-lang/typed_data/issues/16 is fixed + # - test: -p firefox - dartfmt - dartanalyzer diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 1855d95f..3259e41b 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.7 + +* Set max SDK version to `<3.0.0`, and adjust other dependencies. + ## 1.1.6 * Update tests to work with Dart 2.0 64 bit ints. diff --git a/pkgs/typed_data/README.md b/pkgs/typed_data/README.md index c7a4772c..9ec19ba4 100644 --- a/pkgs/typed_data/README.md +++ b/pkgs/typed_data/README.md @@ -6,12 +6,14 @@ The `typed_data` package contains utility functions and classes that makes worki The `typed_data` package can be imported as - import 'package:typed_data/typed_data.dart'; +```dart +import 'package:typed_data/typed_data.dart'; +``` ## Typed buffers: Growable typed data lists Typed buffers are contains growable lists backed by typed arrays. -These are similar to the growable lists returned by `new List()`, +These are similar to the growable lists returned by `List()`, but stores typed data like a typed data list. ## Features and bugs diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml deleted file mode 100644 index a10d4c5a..00000000 --- a/pkgs/typed_data/analysis_options.yaml +++ /dev/null @@ -1,2 +0,0 @@ -analyzer: - strong-mode: true diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 98579db4..41f826b0 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,12 @@ name: typed_data -version: 1.1.6 -author: Dart Team +version: 1.1.7 + description: Utility functions and classes related to the 'dart:typed_data' library. +author: Dart Team homepage: https://github.com/dart-lang/typed_data -dev_dependencies: - test: "^0.12.0" + environment: - sdk: ">=2.0.0-dev.16.0 <2.0.0" + sdk: '>=2.0.0-dev.16.0 <3.0.0' + +dev_dependencies: + test: '>=0.12.42 <2.0.0' diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 53aa666c..90270fe0 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -265,7 +265,7 @@ testFloat32x4Buffer(List floatSamples) { test("Float32x4Buffer", () { var buffer = new Float32x4Buffer(5); - expect(buffer, new isInstanceOf>()); + expect(buffer, new TypeMatcher>()); expect(buffer.length, equals(5)); expect(buffer.elementSizeInBytes, equals(128 ~/ 8)); @@ -312,7 +312,7 @@ void testFloatBuffer( int bitSize, List samples, create(), double round(double v)) { test("Float${bitSize}Buffer", () { var buffer = create(); - expect(buffer, new isInstanceOf>()); + expect(buffer, new TypeMatcher>()); int byteSize = bitSize ~/ 8; expect(buffer.length, equals(0)); @@ -380,7 +380,7 @@ void testInt32x4Buffer(List intSamples) { Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); var buffer = new Int32x4Buffer(0); - expect(buffer, new isInstanceOf>()); + expect(buffer, new TypeMatcher>()); expect(buffer.length, equals(0)); expect(buffer.elementSizeInBytes, equals(bytes)); @@ -439,7 +439,7 @@ void testIntBuffer( assert(round(max) == max); // All int buffers default to the value 0. var buffer = create(0); - expect(buffer, new isInstanceOf>()); + expect(buffer, new TypeMatcher>()); expect(buffer.length, equals(0)); var bytes = bits ~/ 8; From 74c557454db6c6b3d1171fec79ed51045a219637 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 18 Jul 2018 09:38:28 -0700 Subject: [PATCH 027/113] test: fix dart2js tests Fixes https://github.com/dart-lang/typed_data/issues/16 --- pkgs/typed_data/.travis.yml | 3 +- pkgs/typed_data/test/typed_buffers_test.dart | 108 +++++++++--------- .../test/typed_buffers_vm_test.dart | 19 +++ 3 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 pkgs/typed_data/test/typed_buffers_vm_test.dart diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 01a70209..912d41ab 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -4,8 +4,7 @@ dart: dart_task: - test: -p vm - # TODO: reinstate once https://github.com/dart-lang/typed_data/issues/16 is fixed - # - test: -p firefox + - test: -p firefox - dartfmt - dartanalyzer diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 90270fe0..5c27b5b9 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -2,29 +2,65 @@ // 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. -// Tests typed-data buffer classes. +@TestOn('!vm') import "dart:typed_data"; import "package:test/test.dart"; import "package:typed_data/typed_buffers.dart"; -main() { - testUint(8, (l) => new Uint8Buffer(l)); - testInt(8, (l) => new Int8Buffer(l)); +const List browserSafeIntSamples = const [ + 0x8000000000000000, // 2^63 + 0x100000001, + 0x100000000, // 2^32 + 0x0ffffffff, + 0xaaaaaaaa, + 0x80000001, + 0x80000000, // 2^31 + 0x7fffffff, + 0x55555555, + 0x10001, + 0x10000, // 2^16 + 0x0ffff, + 0xaaaa, + 0x8001, + 0x8000, // 2^15 + 0x7fff, + 0x5555, + 0x101, + 0x100, // 2^8 + 0x0ff, + 0xaa, + 0x81, + 0x80, // 2^7 + 0x7f, + 0x55, + 0x02, + 0x01, + 0x00 +]; + +void main() { + initTests(browserSafeIntSamples); +} + +void initTests(List intSamples) { + testUint(intSamples, 8, (l) => new Uint8Buffer(l)); + testInt(intSamples, 8, (l) => new Int8Buffer(l)); test("Uint8ClampedBuffer", () { - testIntBuffer(8, 0, 255, (l) => new Uint8ClampedBuffer(l), clampUint8); + testIntBuffer( + intSamples, 8, 0, 255, (l) => new Uint8ClampedBuffer(l), clampUint8); }); - testUint(16, (l) => new Uint16Buffer(l)); - testInt(16, (l) => new Int16Buffer(l)); - testUint(32, (l) => new Uint32Buffer(l)); + testUint(intSamples, 16, (l) => new Uint16Buffer(l)); + testInt(intSamples, 16, (l) => new Int16Buffer(l)); + testUint(intSamples, 32, (l) => new Uint32Buffer(l)); - testInt(32, (l) => new Int32Buffer(l)); + testInt(intSamples, 32, (l) => new Int32Buffer(l)); - testUint(64, (l) => new Uint64Buffer(l), + testUint(intSamples, 64, (l) => new Uint64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); - testInt(64, (l) => new Int64Buffer(l), + testInt(intSamples, 64, (l) => new Int64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); @@ -185,42 +221,6 @@ const floatSamples = const [ 16777215.0 ]; -const List intSamples = const [ - 0x0ffffffffffffffff, - 0xaaaaaaaaaaaaaaaa, - 0x8000000000000001, - 0x8000000000000000, // 2^63 - 0x7fffffffffffffff, - 0x5555555555555555, - 0x100000001, - 0x100000000, // 2^32 - 0x0ffffffff, - 0xaaaaaaaa, - 0x80000001, - 0x80000000, // 2^31 - 0x7fffffff, - 0x55555555, - 0x10001, - 0x10000, // 2^16 - 0x0ffff, - 0xaaaa, - 0x8001, - 0x8000, // 2^15 - 0x7fff, - 0x5555, - 0x101, - 0x100, // 2^8 - 0x0ff, - 0xaa, - 0x81, - 0x80, // 2^7 - 0x7f, - 0x55, - 0x02, - 0x01, - 0x00 -]; - int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; void doubleEqual(x, y) { @@ -366,11 +366,12 @@ void testFloatBuffer( }); } -void testInt(int bits, buffer(int length), {String testOn}) { +void testInt(List intSamples, int bits, buffer(int length), + {String testOn}) { int min = -(1 << (bits - 1)); int max = -(min + 1); test("Int${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, intRounder(bits)); + testIntBuffer(intSamples, bits, min, max, buffer, intRounder(bits)); }, testOn: testOn); } @@ -433,8 +434,8 @@ void testInt32x4Buffer(List intSamples) { }); } -void testIntBuffer( - int bits, int min, int max, create(int length), int round(int val)) { +void testIntBuffer(List intSamples, int bits, int min, int max, + create(int length), int round(int val)) { assert(round(min) == min); assert(round(max) == max); // All int buffers default to the value 0. @@ -504,12 +505,13 @@ void testIntBuffer( expect(buffer[1], equals(min)); } -void testUint(int bits, buffer(int length), {String testOn}) { +void testUint(List intSamples, int bits, buffer(int length), + {String testOn}) { int min = 0; var rounder = uintRounder(bits); int max = rounder(-1); test("Uint${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, rounder); + testIntBuffer(intSamples, bits, min, max, buffer, rounder); }, testOn: testOn); } diff --git a/pkgs/typed_data/test/typed_buffers_vm_test.dart b/pkgs/typed_data/test/typed_buffers_vm_test.dart new file mode 100644 index 00000000..ad3100c6 --- /dev/null +++ b/pkgs/typed_data/test/typed_buffers_vm_test.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2018, 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. + +@TestOn('vm') +import 'package:test/test.dart'; + +import 'typed_buffers_test.dart'; + +void main() { + var browserUnsafe = [ + 0x0ffffffffffffffff, + 0xaaaaaaaaaaaaaaaa, + 0x8000000000000001, + 0x7fffffffffffffff, + 0x5555555555555555, + ]; + initTests([]..addAll(browserSafeIntSamples)..addAll(browserUnsafe)); +} From 13ba1936f6d5e4032aeca929f98e632c30e4e17b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 18 Jul 2018 09:53:56 -0700 Subject: [PATCH 028/113] Drop version to 1.1.6 before publish ...it was never released --- pkgs/typed_data/CHANGELOG.md | 6 +----- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 3259e41b..bd426fec 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,10 +1,6 @@ -## 1.1.7 - -* Set max SDK version to `<3.0.0`, and adjust other dependencies. - ## 1.1.6 -* Update tests to work with Dart 2.0 64 bit ints. +* Set max SDK version to `<3.0.0`, and adjust other dependencies. ## 1.1.5 diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 41f826b0..0e885a35 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.7 +version: 1.1.6 description: Utility functions and classes related to the 'dart:typed_data' library. author: Dart Team From b518e0ffc5662188cf45cb358ecc35b0616a8fa6 Mon Sep 17 00:00:00 2001 From: BC Ko Date: Mon, 18 Mar 2019 09:32:51 -0700 Subject: [PATCH 029/113] Update .gitignore to new `dart_tool` pub cache (dart-lang/typed_data#14) dart-lang/sdkdart-lang/typed_data#32030 --- pkgs/typed_data/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/typed_data/.gitignore b/pkgs/typed_data/.gitignore index 25a1df33..efbbce15 100644 --- a/pkgs/typed_data/.gitignore +++ b/pkgs/typed_data/.gitignore @@ -1,6 +1,7 @@ .buildlog .DS_Store .idea +.dart_tool/ .pub/ .settings/ build/ From 256fa26f528f5dec94f1e40fd6c59c9f06d217b1 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 29 Apr 2019 17:00:55 -0700 Subject: [PATCH 030/113] Enable and fix a number of lints, test on oldest supported Dart SDK (dart-lang/typed_data#20) --- pkgs/typed_data/.travis.yml | 10 +- pkgs/typed_data/analysis_options.yaml | 57 ++++++++++ pkgs/typed_data/codereview.settings | 3 - pkgs/typed_data/lib/typed_buffers.dart | 112 +++++++++++-------- pkgs/typed_data/pubspec.yaml | 8 +- pkgs/typed_data/test/typed_buffers_test.dart | 88 ++++++++------- 6 files changed, 178 insertions(+), 100 deletions(-) create mode 100644 pkgs/typed_data/analysis_options.yaml delete mode 100644 pkgs/typed_data/codereview.settings diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 912d41ab..43a3f15b 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,12 +1,18 @@ language: dart dart: + - 2.0.0 - dev dart_task: - test: -p vm - test: -p firefox - - dartfmt - - dartanalyzer + - dartanalyzer: --fatal-infos --fatal-warnings . + +matrix: + include: + # Only validate formatting using the dev release + - dart: dev + dart_task: dartfmt # Only building master means that we don't run two builds for each pull request. branches: diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml new file mode 100644 index 00000000..026330a8 --- /dev/null +++ b/pkgs/typed_data/analysis_options.yaml @@ -0,0 +1,57 @@ +include: package:pedantic/analysis_options.yaml +linter: + rules: + #- annotate_overrides + - avoid_function_literals_in_foreach_calls + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports + - avoid_returning_null + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_types + - cancel_subscriptions + - comment_references + - constant_identifier_names + - control_flow_in_finally + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + - invariant_booleans + - iterable_contains_unrelated_type + - library_names + - library_prefixes + - list_remove_unrelated_type + - no_adjacent_strings_in_list + - non_constant_identifier_names + #- omit_local_variable_types + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_final_fields + - prefer_generic_function_type_aliases + - prefer_initializing_formals + - prefer_interpolation_to_compose_strings + #- prefer_single_quotes + - prefer_typing_uninitialized_variables + - slash_for_doc_comments + - test_types_in_equals + - throw_in_finally + - type_init_formals + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_statements + - unnecessary_this diff --git a/pkgs/typed_data/codereview.settings b/pkgs/typed_data/codereview.settings deleted file mode 100644 index 26c267c4..00000000 --- a/pkgs/typed_data/codereview.settings +++ /dev/null @@ -1,3 +0,0 @@ -CODE_REVIEW_SERVER: http://codereview.chromium.org/ -VIEW_VC: https://github.com/dart-lang/typed_data/commit/ -CC_LIST: reviews@dartlang.org diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 23f2cbb7..f2e407db 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -8,7 +8,7 @@ /// They use an underlying buffer, and when that buffer becomes too small, it /// is replaced by a new buffer. /// -/// That means that using the [TypedDataView.buffer] getter is not guaranteed +/// That means that using the `buffer` getter is not guaranteed /// to return the same result each time it is used, and that the buffer may /// be larger than what the list is using. library typed_data.typed_buffers; @@ -17,7 +17,7 @@ import "dart:collection" show ListBase; import "dart:typed_data"; abstract class _TypedDataBuffer extends ListBase { - static const int INITIAL_LENGTH = 8; + static const int _initialLength = 8; /// The underlying data buffer. /// @@ -32,21 +32,22 @@ abstract class _TypedDataBuffer extends ListBase { int _length; _TypedDataBuffer(List buffer) - : this._buffer = buffer, - this._length = buffer.length; + : _buffer = buffer, + _length = buffer.length; int get length => _length; + E operator [](int index) { - if (index >= length) throw new RangeError.index(index, this); + if (index >= length) throw RangeError.index(index, this); return _buffer[index]; } void operator []=(int index, E value) { - if (index >= length) throw new RangeError.index(index, this); + if (index >= length) throw RangeError.index(index, this); _buffer[index] = value; } - void set length(int newLength) { + set length(int newLength) { if (newLength < _length) { E defaultValue = _defaultValue; for (int i = newLength; i < _length; i++) { @@ -54,7 +55,7 @@ abstract class _TypedDataBuffer extends ListBase { } } else if (newLength > _buffer.length) { List newBuffer; - if (_buffer.length == 0) { + if (_buffer.isEmpty) { newBuffer = _createBuffer(newLength); } else { newBuffer = _createBiggerBuffer(newLength); @@ -89,7 +90,7 @@ abstract class _TypedDataBuffer extends ListBase { void addAll(Iterable values, [int start = 0, int end]) { RangeError.checkNotNegative(start, "start"); if (end != null && start > end) { - throw new RangeError.range(end, start, null, "end"); + throw RangeError.range(end, start, null, "end"); } _addAll(values, start, end); @@ -109,7 +110,7 @@ abstract class _TypedDataBuffer extends ListBase { RangeError.checkNotNegative(start, "start"); if (end != null) { if (start > end) { - throw new RangeError.range(end, start, null, "end"); + throw RangeError.range(end, start, null, "end"); } if (start == end) return; } @@ -147,10 +148,10 @@ abstract class _TypedDataBuffer extends ListBase { } if (skipCount > 0) { - throw new StateError("Too few elements"); + throw StateError("Too few elements"); } if (end != null && writeIndex < end) { - throw new RangeError.range(end, start, writeIndex, "end"); + throw RangeError.range(end, start, writeIndex, "end"); } // Swap [index.._length) and [_length..writeIndex) by double-reversing. @@ -196,7 +197,7 @@ abstract class _TypedDataBuffer extends ListBase { if (i >= start) add(value); i++; } - if (i < start) throw new StateError("Too few elements"); + if (i < start) throw StateError("Too few elements"); } /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. @@ -204,7 +205,7 @@ abstract class _TypedDataBuffer extends ListBase { if (values is List) { end ??= values.length; if (start > values.length || end > values.length) { - throw new StateError("Too few elements"); + throw StateError("Too few elements"); } } else { assert(end != null); @@ -222,7 +223,7 @@ abstract class _TypedDataBuffer extends ListBase { void insert(int index, E element) { if (index < 0 || index > _length) { - throw new RangeError.range(index, 0, _length); + throw RangeError.range(index, 0, _length); } if (_length < _buffer.length) { _buffer.setRange(index + 1, _length + 1, _buffer, index); @@ -258,8 +259,8 @@ abstract class _TypedDataBuffer extends ListBase { int newLength = _buffer.length * 2; if (requiredCapacity != null && newLength < requiredCapacity) { newLength = requiredCapacity; - } else if (newLength < INITIAL_LENGTH) { - newLength = INITIAL_LENGTH; + } else if (newLength < _initialLength) { + newLength = _initialLength; } return _createBuffer(newLength); } @@ -272,7 +273,7 @@ abstract class _TypedDataBuffer extends ListBase { } void setRange(int start, int end, Iterable source, [int skipCount = 0]) { - if (end > _length) throw new RangeError.range(end, 0, _length); + if (end > _length) throw RangeError.range(end, 0, _length); _setRange(start, end, source, skipCount); } @@ -324,74 +325,87 @@ abstract class _FloatBuffer extends _TypedDataBuffer { } class Uint8Buffer extends _IntBuffer { - Uint8Buffer([int initialLength = 0]) : super(new Uint8List(initialLength)); - Uint8List _createBuffer(int size) => new Uint8List(size); + Uint8Buffer([int initialLength = 0]) : super(Uint8List(initialLength)); + + Uint8List _createBuffer(int size) => Uint8List(size); } class Int8Buffer extends _IntBuffer { - Int8Buffer([int initialLength = 0]) : super(new Int8List(initialLength)); - Int8List _createBuffer(int size) => new Int8List(size); + Int8Buffer([int initialLength = 0]) : super(Int8List(initialLength)); + + Int8List _createBuffer(int size) => Int8List(size); } class Uint8ClampedBuffer extends _IntBuffer { Uint8ClampedBuffer([int initialLength = 0]) - : super(new Uint8ClampedList(initialLength)); - Uint8ClampedList _createBuffer(int size) => new Uint8ClampedList(size); + : super(Uint8ClampedList(initialLength)); + + Uint8ClampedList _createBuffer(int size) => Uint8ClampedList(size); } class Uint16Buffer extends _IntBuffer { - Uint16Buffer([int initialLength = 0]) : super(new Uint16List(initialLength)); - Uint16List _createBuffer(int size) => new Uint16List(size); + Uint16Buffer([int initialLength = 0]) : super(Uint16List(initialLength)); + + Uint16List _createBuffer(int size) => Uint16List(size); } class Int16Buffer extends _IntBuffer { - Int16Buffer([int initialLength = 0]) : super(new Int16List(initialLength)); - Int16List _createBuffer(int size) => new Int16List(size); + Int16Buffer([int initialLength = 0]) : super(Int16List(initialLength)); + + Int16List _createBuffer(int size) => Int16List(size); } class Uint32Buffer extends _IntBuffer { - Uint32Buffer([int initialLength = 0]) : super(new Uint32List(initialLength)); - Uint32List _createBuffer(int size) => new Uint32List(size); + Uint32Buffer([int initialLength = 0]) : super(Uint32List(initialLength)); + + Uint32List _createBuffer(int size) => Uint32List(size); } class Int32Buffer extends _IntBuffer { - Int32Buffer([int initialLength = 0]) : super(new Int32List(initialLength)); - Int32List _createBuffer(int size) => new Int32List(size); + Int32Buffer([int initialLength = 0]) : super(Int32List(initialLength)); + + Int32List _createBuffer(int size) => Int32List(size); } class Uint64Buffer extends _IntBuffer { - Uint64Buffer([int initialLength = 0]) : super(new Uint64List(initialLength)); - Uint64List _createBuffer(int size) => new Uint64List(size); + Uint64Buffer([int initialLength = 0]) : super(Uint64List(initialLength)); + + Uint64List _createBuffer(int size) => Uint64List(size); } class Int64Buffer extends _IntBuffer { - Int64Buffer([int initialLength = 0]) : super(new Int64List(initialLength)); - Int64List _createBuffer(int size) => new Int64List(size); + Int64Buffer([int initialLength = 0]) : super(Int64List(initialLength)); + + Int64List _createBuffer(int size) => Int64List(size); } class Float32Buffer extends _FloatBuffer { - Float32Buffer([int initialLength = 0]) - : super(new Float32List(initialLength)); - Float32List _createBuffer(int size) => new Float32List(size); + Float32Buffer([int initialLength = 0]) : super(Float32List(initialLength)); + + Float32List _createBuffer(int size) => Float32List(size); } class Float64Buffer extends _FloatBuffer { - Float64Buffer([int initialLength = 0]) - : super(new Float64List(initialLength)); - Float64List _createBuffer(int size) => new Float64List(size); + Float64Buffer([int initialLength = 0]) : super(Float64List(initialLength)); + + Float64List _createBuffer(int size) => Float64List(size); } class Int32x4Buffer extends _TypedDataBuffer { - static Int32x4 _zero = new Int32x4(0, 0, 0, 0); - Int32x4Buffer([int initialLength = 0]) - : super(new Int32x4List(initialLength)); + static final Int32x4 _zero = Int32x4(0, 0, 0, 0); + + Int32x4Buffer([int initialLength = 0]) : super(Int32x4List(initialLength)); + Int32x4 get _defaultValue => _zero; - Int32x4List _createBuffer(int size) => new Int32x4List(size); + + Int32x4List _createBuffer(int size) => Int32x4List(size); } class Float32x4Buffer extends _TypedDataBuffer { Float32x4Buffer([int initialLength = 0]) - : super(new Float32x4List(initialLength)); - Float32x4 get _defaultValue => new Float32x4.zero(); - Float32x4List _createBuffer(int size) => new Float32x4List(size); + : super(Float32x4List(initialLength)); + + Float32x4 get _defaultValue => Float32x4.zero(); + + Float32x4List _createBuffer(int size) => Float32x4List(size); } diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 0e885a35..58ca4700 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,12 +1,14 @@ name: typed_data version: 1.1.6 -description: Utility functions and classes related to the 'dart:typed_data' library. +description: >- + Utility functions and classes related to the dart:typed_data library. author: Dart Team homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.0.0-dev.16.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dev_dependencies: - test: '>=0.12.42 <2.0.0' + pedantic: ^1.0.0 + test: ^1.0.0 diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 5c27b5b9..1aad64c7 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -3,13 +3,12 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('!vm') - import "dart:typed_data"; import "package:test/test.dart"; import "package:typed_data/typed_buffers.dart"; -const List browserSafeIntSamples = const [ +const List browserSafeIntSamples = [ 0x8000000000000000, // 2^63 0x100000001, 0x100000000, // 2^32 @@ -45,43 +44,43 @@ void main() { } void initTests(List intSamples) { - testUint(intSamples, 8, (l) => new Uint8Buffer(l)); - testInt(intSamples, 8, (l) => new Int8Buffer(l)); + testUint(intSamples, 8, (l) => Uint8Buffer(l)); + testInt(intSamples, 8, (l) => Int8Buffer(l)); test("Uint8ClampedBuffer", () { testIntBuffer( - intSamples, 8, 0, 255, (l) => new Uint8ClampedBuffer(l), clampUint8); + intSamples, 8, 0, 255, (l) => Uint8ClampedBuffer(l), clampUint8); }); - testUint(intSamples, 16, (l) => new Uint16Buffer(l)); - testInt(intSamples, 16, (l) => new Int16Buffer(l)); - testUint(intSamples, 32, (l) => new Uint32Buffer(l)); + testUint(intSamples, 16, (l) => Uint16Buffer(l)); + testInt(intSamples, 16, (l) => Int16Buffer(l)); + testUint(intSamples, 32, (l) => Uint32Buffer(l)); - testInt(intSamples, 32, (l) => new Int32Buffer(l)); + testInt(intSamples, 32, (l) => Int32Buffer(l)); - testUint(intSamples, 64, (l) => new Uint64Buffer(l), + testUint(intSamples, 64, (l) => Uint64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); - testInt(intSamples, 64, (l) => new Int64Buffer(l), + testInt(intSamples, 64, (l) => Int64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. testOn: "dart-vm"); testInt32x4Buffer(intSamples); var roundedFloatSamples = floatSamples.map(roundToFloat).toList(); - testFloatBuffer( - 32, roundedFloatSamples, () => new Float32Buffer(), roundToFloat); - testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); + testFloatBuffer(32, roundedFloatSamples, () => Float32Buffer(), roundToFloat); + testFloatBuffer(64, doubleSamples, () => Float64Buffer(), (x) => x); testFloat32x4Buffer(roundedFloatSamples); group("addAll", () { for (var type in ['a list', 'an iterable']) { group("with $type", () { - var source; - var buffer; + Iterable source; + Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; - if (type == 'an iterable') source = source.reversed.toList().reversed; - buffer = new Uint8Buffer(); + if (type == 'an iterable') + source = (source as List).reversed.toList().reversed; + buffer = Uint8Buffer(); }); test("adds values to the buffer", () { @@ -127,12 +126,13 @@ void initTests(List intSamples) { group("insertAll", () { for (var type in ['a list', 'an iterable']) { group("with $type", () { - var source; - var buffer; + Iterable source; + Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; - if (type == 'an iterable') source = source.reversed.toList().reversed; - buffer = new Uint8Buffer()..addAll([6, 7, 8, 9, 10]); + if (type == 'an iterable') + source = (source as List).reversed.toList().reversed; + buffer = Uint8Buffer()..addAll([6, 7, 8, 9, 10]); }); test("inserts values into the buffer", () { @@ -183,7 +183,7 @@ void initTests(List intSamples) { }); } -const doubleSamples = const [ +const doubleSamples = [ 0.0, 5e-324, // Minimal denormal value. 2.225073858507201e-308, // Maximal denormal value. @@ -203,7 +203,7 @@ const doubleSamples = const [ 9007199254740991.0 // to nearest with 0.5 rounding up). ]; -const floatSamples = const [ +const floatSamples = [ 0.0, 1.4e-45, // Minimal denormal value. 1.1754942E-38, // Maximal denormal value. @@ -238,13 +238,13 @@ Rounder intRounder(bits) { } double roundToFloat(double value) { - return (new Float32List(1)..[0] = value)[0]; + return (Float32List(1)..[0] = value)[0]; } testFloat32x4Buffer(List floatSamples) { var float4Samples = []; for (int i = 0; i < floatSamples.length - 3; i++) { - float4Samples.add(new Float32x4(floatSamples[i], floatSamples[i + 1], + float4Samples.add(Float32x4(floatSamples[i], floatSamples[i + 1], floatSamples[i + 2], floatSamples[i + 3])); } @@ -264,15 +264,15 @@ testFloat32x4Buffer(List floatSamples) { } test("Float32x4Buffer", () { - var buffer = new Float32x4Buffer(5); - expect(buffer, new TypeMatcher>()); + var buffer = Float32x4Buffer(5); + expect(buffer, const TypeMatcher>()); expect(buffer.length, equals(5)); expect(buffer.elementSizeInBytes, equals(128 ~/ 8)); expect(buffer.lengthInBytes, equals(5 * 128 ~/ 8)); expect(buffer.offsetInBytes, equals(0)); - x4Equals(buffer[0], new Float32x4.zero()); + x4Equals(buffer[0], Float32x4.zero()); buffer.length = 0; expect(buffer.length, equals(0)); @@ -297,7 +297,7 @@ testFloat32x4Buffer(List floatSamples) { buffer.length = 1; buffer[0] = float4Samples[0]; // Does not contain NaN. - Float32List floats = new Float32List.view(buffer.buffer); + Float32List floats = Float32List.view(buffer.buffer); expect(floats[0], equals(buffer[0].x)); expect(floats[1], equals(buffer[0].y)); expect(floats[2], equals(buffer[0].z)); @@ -312,7 +312,7 @@ void testFloatBuffer( int bitSize, List samples, create(), double round(double v)) { test("Float${bitSize}Buffer", () { var buffer = create(); - expect(buffer, new TypeMatcher>()); + expect(buffer, const TypeMatcher>()); int byteSize = bitSize ~/ 8; expect(buffer.length, equals(0)); @@ -355,7 +355,7 @@ void testFloatBuffer( buffer.length = 2; buffer[0] = samples[0]; buffer[1] = samples[1]; - var bytes = new Uint8List.view(buffer.buffer); + var bytes = Uint8List.view(buffer.buffer); for (int i = 0; i < byteSize; i++) { int tmp = bytes[i]; bytes[i] = bytes[byteSize + i]; @@ -378,17 +378,17 @@ void testInt(List intSamples, int bits, buffer(int length), void testInt32x4Buffer(List intSamples) { test("Int32x4Buffer", () { int bytes = 128 ~/ 8; - Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); + Matcher equals32x4(Int32x4 expected) => MatchesInt32x4(expected); - var buffer = new Int32x4Buffer(0); - expect(buffer, new TypeMatcher>()); + var buffer = Int32x4Buffer(0); + expect(buffer, const TypeMatcher>()); expect(buffer.length, equals(0)); expect(buffer.elementSizeInBytes, equals(bytes)); expect(buffer.lengthInBytes, equals(0)); expect(buffer.offsetInBytes, equals(0)); - Int32x4 sample = new Int32x4(-0x80000000, -1, 0, 0x7fffffff); + Int32x4 sample = Int32x4(-0x80000000, -1, 0, 0x7fffffff); buffer.add(sample); expect(buffer.length, equals(1)); expect(buffer[0], equals32x4(sample)); @@ -401,7 +401,7 @@ void testInt32x4Buffer(List intSamples) { expect(buffer.length, equals(0)); var samples = intSamples - .map((value) => new Int32x4(value, -value, ~value, ~ -value)) + .map((value) => Int32x4(value, -value, ~value, ~ -value)) .toList(); for (Int32x4 value in samples) { int length = buffer.length; @@ -421,15 +421,15 @@ void testInt32x4Buffer(List intSamples) { // Accessing the underlying buffer works. buffer.length = 2; - buffer[0] = new Int32x4(-80000000, 0x7fffffff, 0, -1); - var byteBuffer = new Uint8List.view(buffer.buffer); + buffer[0] = Int32x4(-80000000, 0x7fffffff, 0, -1); + var byteBuffer = Uint8List.view(buffer.buffer); int halfBytes = bytes ~/ 2; for (int i = 0; i < halfBytes; i++) { int tmp = byteBuffer[i]; byteBuffer[i] = byteBuffer[halfBytes + i]; byteBuffer[halfBytes + i] = tmp; } - var result = new Int32x4(0, -1, -80000000, 0x7fffffff); + var result = Int32x4(0, -1, -80000000, 0x7fffffff); expect(buffer[0], equals32x4(result)); }); } @@ -440,7 +440,7 @@ void testIntBuffer(List intSamples, int bits, int min, int max, assert(round(max) == max); // All int buffers default to the value 0. var buffer = create(0); - expect(buffer, new TypeMatcher>()); + expect(buffer, const TypeMatcher>()); expect(buffer.length, equals(0)); var bytes = bits ~/ 8; @@ -494,7 +494,7 @@ void testIntBuffer(List intSamples, int bits, int min, int max, buffer.length = 2; buffer[0] = min; buffer[1] = max; - var byteBuffer = new Uint8List.view(buffer.buffer); + var byteBuffer = Uint8List.view(buffer.buffer); int byteSize = buffer.elementSizeInBytes; for (int i = 0; i < byteSize; i++) { int tmp = byteBuffer[i]; @@ -521,11 +521,13 @@ Rounder uintRounder(bits) { return (int x) => x & mask; } -typedef int Rounder(int value); +typedef Rounder = int Function(int value); class MatchesInt32x4 extends Matcher { Int32x4 result; + MatchesInt32x4(this.result); + Description describe(Description description) => description.add('Int32x4.=='); From 32a90e35482ab678fd2892a5b7f51aa633fc476b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 10 May 2019 08:36:59 -0700 Subject: [PATCH 031/113] fix latest pedantic lints --- pkgs/typed_data/test/typed_buffers_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 1aad64c7..10a148bc 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -78,8 +78,9 @@ void initTests(List intSamples) { Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; - if (type == 'an iterable') + if (type == 'an iterable') { source = (source as List).reversed.toList().reversed; + } buffer = Uint8Buffer(); }); @@ -130,8 +131,9 @@ void initTests(List intSamples) { Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; - if (type == 'an iterable') + if (type == 'an iterable') { source = (source as List).reversed.toList().reversed; + } buffer = Uint8Buffer()..addAll([6, 7, 8, 9, 10]); }); From 9657ac9c2094d2370af32043dd204b6c861a23c1 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 17 Oct 2019 23:42:12 -0700 Subject: [PATCH 032/113] Add typed queue classes These make it easy to, for example, efficiently enqueue incoming chunked binary data for processing. --- pkgs/typed_data/CHANGELOG.md | 6 + pkgs/typed_data/lib/src/typed_queue.dart | 608 +++++++++++++++++++++++ pkgs/typed_data/lib/typed_data.dart | 3 +- pkgs/typed_data/pubspec.yaml | 7 +- pkgs/typed_data/test/queue_test.dart | 306 ++++++++++++ 5 files changed, 927 insertions(+), 3 deletions(-) create mode 100644 pkgs/typed_data/lib/src/typed_queue.dart create mode 100644 pkgs/typed_data/test/queue_test.dart diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index bd426fec..5fdc7284 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.2.0 + +* Add typed queue classes such as `Uint8Queue`. These classes implement both + `Queue` and `List` with a highly-efficient typed-data-backed implementation. + Their `sublist()` methods also return typed data classes. + ## 1.1.6 * Set max SDK version to `<3.0.0`, and adjust other dependencies. diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart new file mode 100644 index 00000000..0e361970 --- /dev/null +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -0,0 +1,608 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:collection"; +import "dart:typed_data"; + +import "package:collection/collection.dart"; + +/// The shared superclass of all the typed queue subclasses. +abstract class _TypedQueue> extends Object + with ListMixin { + /// The underlying data buffer. + /// + /// This is always both a List and a TypedData, which we don't have a type + /// for that. For example, for a `Uint8Buffer`, this is a `Uint8List`. + L _table; + + int _head; + int _tail; + + /// Create an empty queue. + _TypedQueue(this._table) + : _head = 0, + _tail = 0; + + // Iterable interface. + + int get length => (_tail - _head) & (_table.length - 1); + + List toList({bool growable = true}) { + var list = growable ? ([]..length = length) : _createList(length); + _writeToList(list); + return list; + } + + QueueList cast() { + if (this is QueueList) return this as QueueList; + throw UnsupportedError("$this cannot be cast to the desired type."); + } + + QueueList retype() => cast(); + + // Queue interface. + + void addLast(E value) { + _table[_tail] = value; + _tail = (_tail + 1) & (_table.length - 1); + if (_head == _tail) _growAtCapacity(); + } + + void addFirst(E value) { + _head = (_head - 1) & (_table.length - 1); + _table[_head] = value; + if (_head == _tail) _growAtCapacity(); + } + + E removeFirst() { + if (_head == _tail) throw StateError("No element"); + var result = _table[_head]; + _head = (_head + 1) & (_table.length - 1); + return result; + } + + E removeLast() { + if (_head == _tail) throw StateError("No element"); + _tail = (_tail - 1) & (_table.length - 1); + return _table[_tail]; + } + + // List interface. + + void add(E value) => addLast(value); + + set length(int value) { + RangeError.checkNotNegative(value, "length"); + + var delta = value - length; + if (delta >= 0) { + if (_table.length <= value) _growTo(value); + _tail = (_tail + delta) & (_table.length - 1); + } else { + removeRange(value, length); + } + } + + E operator [](int index) { + RangeError.checkValidIndex(index, this); + return _table[(_head + index) & (_table.length - 1)]; + } + + void operator []=(int index, E value) { + RangeError.checkValidIndex(index, this); + _table[(_head + index) & (_table.length - 1)] = value; + } + + void removeRange(int start, int end) { + var length = this.length; + RangeError.checkValidRange(start, end, length); + + // Special-case removing an initial or final range because we can do it very + // efficiently by adjusting `_head` or `_tail`. + if (start == 0) { + _head = (_head + end) & (_table.length - 1); + return; + } + + var elementsAfter = length - end; + if (elementsAfter == 0) { + _tail = (_head + start) & (_table.length - 1); + return; + } + + // Choose whether to copy from the beginning of the end of the queue based + // on which will require fewer copied elements. + var removedElements = end - start; + if (start < elementsAfter) { + setRange(removedElements, end, this); + _head = (_head + removedElements) & (_table.length - 1); + } else { + setRange(start, length - removedElements, this, end); + _tail = (_tail - removedElements) & (_table.length - 1); + } + } + + void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + if (start == end) return; + + var targetStart = (_head + start) & (_table.length - 1); + var targetEnd = (_head + end) & (_table.length - 1); + var targetIsContiguous = targetStart < targetEnd; + if (identical(iterable, this)) { + // If we're copying this queue to itself, we can copy [_table] in directly + // which requires some annoying case analysis but in return bottoms out on + // an extremely efficient `memmove` call. However, we may need to do three + // copies to avoid overwriting data we'll need to use later. + var sourceStart = (_head + skipCount) & (_table.length - 1); + var sourceEnd = (sourceStart + (end - start)) & (_table.length - 1); + if (sourceStart == targetStart) return; + + var sourceIsContiguous = sourceStart < sourceEnd; + if (targetIsContiguous && sourceIsContiguous) { + // If both the source and destination ranges are contiguous, we can + // do a single [setRange]. Hooray! + _table.setRange(targetStart, targetEnd, _table, sourceStart); + } else if (!targetIsContiguous && !sourceIsContiguous) { + // If neither range is contiguous, we need to do three copies. + if (sourceStart > targetStart) { + // [=====| targetEnd targetStart |======] + // [========| sourceEnd sourceStart |===] + + // Copy front to back. + var startGap = sourceStart - targetStart; + var firstEnd = _table.length - startGap; + _table.setRange(targetStart, firstEnd, _table, sourceStart); + _table.setRange(firstEnd, _table.length, _table); + _table.setRange(0, targetEnd, _table, startGap); + } else if (sourceEnd < targetEnd) { + // [=====| targetEnd targetStart |======] + // [==| sourceEnd sourceStart |=========] + + // Copy back to front. + var firstStart = targetEnd - sourceEnd; + _table.setRange(firstStart, targetEnd, _table); + _table.setRange(0, firstStart, _table, _table.length - firstStart); + _table.setRange(targetStart, _table.length, _table, sourceStart); + } + } else if (sourceStart < targetEnd) { + // Copying twice is safe here as long as we copy front to back. + if (sourceIsContiguous) { + // [=====| targetEnd targetStart |======] + // [ |===========| sourceEnd ] + // sourceStart + _table.setRange(targetStart, _table.length, _table, sourceStart); + _table.setRange(0, targetEnd, _table, + sourceStart + (_table.length - targetStart)); + } else { + // targetEnd + // [ targetStart |===========| ] + // [=====| sourceEnd sourceStart |======] + var firstEnd = _table.length - sourceStart; + _table.setRange(targetStart, firstEnd, _table, sourceStart); + _table.setRange(firstEnd, targetEnd, _table); + } + } else { + // Copying twice is safe here as long as we copy back to front. This + // also covers the case where there's no overlap between the source and + // target ranges, in which case the direction doesn't matter. + if (sourceIsContiguous) { + // [=====| targetEnd targetStart |======] + // [ sourceStart |===========| ] + // sourceEnd + _table.setRange(0, targetEnd, _table, + sourceStart + (_table.length - targetStart)); + _table.setRange(targetStart, _table.length, _table, sourceStart); + } else { + // targetStart + // [ |===========| targetEnd ] + // [=====| sourceEnd sourceStart |======] + var firstStart = targetEnd - sourceEnd; + _table.setRange(firstStart, targetEnd, _table); + _table.setRange(targetStart, firstStart, _table, sourceStart); + } + } + } else if (targetIsContiguous) { + // If the range is contiguous within the table, we can set it with a single + // underlying [setRange] call. + _table.setRange(targetStart, targetEnd, iterable, skipCount); + } else if (iterable is List) { + // If the range isn't contiguous and [iterable] is actually a [List] (but + // not this queue), set it with two underlying [setRange] calls. + _table.setRange(targetStart, _table.length, iterable, skipCount); + _table.setRange( + 0, targetEnd, iterable, skipCount + (_table.length - targetStart)); + } else { + // If [iterable] isn't a [List], we don't want to make two different + // [setRange] calls because it could materialize a lazy iterable twice. + // Instead we just fall back to the default iteration-based + // implementation. + super.setRange(start, end, iterable, skipCount); + } + } + + L sublist(int start, [int end]) { + var length = this.length; + RangeError.checkValidRange(start, end, length); + + end ??= length; + var list = _createList(end - start); + _writeToList(list, start, end); + return list; + } + + // Internal helper functions. + + /// Writes the contents of `this` between [start] (which defaults to 0) and + /// [end] (which defaults to [length]) to the beginning of [target]. + /// + /// This is functionally identical to `target.setRange(0, end - start, this, + /// start)`, but it's more efficient when [target] is typed data. + /// + /// Returns the number of elements written to [target]. + int _writeToList(List target, [int start, int end]) { + start ??= 0; + end ??= length; + assert(target.length >= end - start); + + var elementsToWrite = end - start; + var startInTable = (_head + start) & (_table.length - 1); + var endInTable = (_head + end) & (_table.length - 1); + if (startInTable <= endInTable) { + target.setRange(0, elementsToWrite, _table, startInTable); + } else { + var firstPartSize = _table.length - startInTable; + target.setRange(0, firstPartSize, _table, startInTable); + target.setRange(firstPartSize, firstPartSize + endInTable, _table, 0); + } + return elementsToWrite; + } + + /// Assumes the table is currently full to capacity, and grows it to the next + /// power of two. + void _growAtCapacity() { + assert(_head == _tail); + + var newTable = _createList(_table.length * 2); + + // We can't use [_writeToList] here because when `_head == _tail` it thinks + // the queue is empty rather than full. + var partitionPoint = _table.length - _head; + newTable.setRange(0, partitionPoint, _table, _head); + if (partitionPoint != _table.length) { + newTable.setRange(partitionPoint, _table.length, _table); + } + _head = 0; + _tail = _table.length; + _table = newTable; + } + + /// Grows the tableso it's at least large enough size to include that many + /// elements. + void _growTo(int newElementCount) { + assert(newElementCount >= length); + + // Add some extra room to ensure that there's room for more elements after + // expansion. + newElementCount += newElementCount >> 1; + var newTable = _createList(_nextPowerOf2(newElementCount)); + _tail = _writeToList(newTable); + _table = newTable; + _head = 0; + } + + // Specialization for the specific type. + + // Create a new typed list. + L _createList(int size); +} + +abstract class _IntQueue> extends _TypedQueue { + _IntQueue(List queue) : super(queue); +} + +abstract class _FloatQueue> + extends _TypedQueue { + _FloatQueue(List queue) : super(queue); +} + +/// A [QueueList] that efficiently stores 8-bit unsigned integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low eight bits, interpreted +/// as an unsigned 8-bit integer with values in the range 0 to 255. +class Uint8Queue extends _IntQueue implements QueueList { + /// Creates an empty [Uint8Queue] with the given initial internal capacity (in + /// elements). + Uint8Queue([int initialCapacity]) + : super(Uint8List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Uint8Queue] with the same length and contents as [elements]. + factory Uint8Queue.fromList(List elements) => + Uint8Queue(elements.length)..addAll(elements); + + Uint8List _createList(int size) => Uint8List(size); +} + +/// A [QueueList] that efficiently stores 8-bit signed integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low eight bits, interpreted +/// as a signed 8-bit two's complement integer with values in the range -128 to +/// +127. +class Int8Queue extends _IntQueue implements QueueList { + /// Creates an empty [Int8Queue] with the given initial internal capacity (in + /// elements). + Int8Queue([int initialCapacity]) + : super(Int8List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Int8Queue] with the same length and contents as [elements]. + factory Int8Queue.fromList(List elements) => + Int8Queue(elements.length)..addAll(elements); + + Int8List _createList(int size) => Int8List(size); +} + +/// A [QueueList] that efficiently stores 8-bit unsigned integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are clamped to an unsigned eight bit value. That is, +/// all values below zero are stored as zero and all values above 255 are stored +/// as 255. +class Uint8ClampedQueue extends _IntQueue + implements QueueList { + /// Creates an empty [Uint8ClampedQueue] with the given initial internal + /// capacity (in elements). + Uint8ClampedQueue([int initialCapacity]) + : super(Uint8ClampedList(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Uint8ClampedQueue] with the same length and contents as + /// [elements]. + factory Uint8ClampedQueue.fromList(List elements) => + Uint8ClampedQueue(elements.length)..addAll(elements); + + Uint8ClampedList _createList(int size) => Uint8ClampedList(size); +} + +/// A [QueueList] that efficiently stores 16-bit unsigned integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 16 bits, interpreted as +/// an unsigned 16-bit integer with values in the range 0 to 65535. +class Uint16Queue extends _IntQueue implements QueueList { + /// Creates an empty [Uint16Queue] with the given initial internal capacity + /// (in elements). + Uint16Queue([int initialCapacity]) + : super(Uint16List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Uint16Queue] with the same length and contents as [elements]. + factory Uint16Queue.fromList(List elements) => + Uint16Queue(elements.length)..addAll(elements); + + Uint16List _createList(int size) => Uint16List(size); +} + +/// A [QueueList] that efficiently stores 16-bit signed integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 16 bits, interpreted as a +/// signed 16-bit two's complement integer with values in the range -32768 to +/// +32767. +class Int16Queue extends _IntQueue implements QueueList { + /// Creates an empty [Int16Queue] with the given initial internal capacity (in + /// elements). + Int16Queue([int initialCapacity]) + : super(Int16List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Int16Queue] with the same length and contents as [elements]. + factory Int16Queue.fromList(List elements) => + Int16Queue(elements.length)..addAll(elements); + + Int16List _createList(int size) => Int16List(size); +} + +/// A [QueueList] that efficiently stores 32-bit unsigned integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 32 bits, interpreted as +/// an unsigned 32-bit integer with values in the range 0 to 4294967295. +class Uint32Queue extends _IntQueue implements QueueList { + /// Creates an empty [Uint32Queue] with the given initial internal capacity + /// (in elements). + Uint32Queue([int initialCapacity]) + : super(Uint32List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Uint32Queue] with the same length and contents as [elements]. + factory Uint32Queue.fromList(List elements) => + Uint32Queue(elements.length)..addAll(elements); + + Uint32List _createList(int size) => Uint32List(size); +} + +/// A [QueueList] that efficiently stores 32-bit signed integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 32 bits, interpreted as a +/// signed 32-bit two's complement integer with values in the range -2147483648 +/// to 2147483647. +class Int32Queue extends _IntQueue implements QueueList { + /// Creates an empty [Int32Queue] with the given initial internal capacity (in + /// elements). + Int32Queue([int initialCapacity]) + : super(Int32List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Int32Queue] with the same length and contents as [elements]. + factory Int32Queue.fromList(List elements) => + Int32Queue(elements.length)..addAll(elements); + + Int32List _createList(int size) => Int32List(size); +} + +/// A [QueueList] that efficiently stores 64-bit unsigned integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 64 bits, interpreted as +/// an unsigned 64-bit integer with values in the range 0 to +/// 18446744073709551615. +class Uint64Queue extends _IntQueue implements QueueList { + /// Creates an empty [Uint64Queue] with the given initial internal capacity + /// (in elements). + Uint64Queue([int initialCapacity]) + : super(Uint64List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Uint64Queue] with the same length and contents as [elements]. + factory Uint64Queue.fromList(List elements) => + Uint64Queue(elements.length)..addAll(elements); + + Uint64List _createList(int size) => Uint64List(size); +} + +/// A [QueueList] that efficiently stores 64-bit signed integers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Integers stored in this are truncated to their low 64 bits, interpreted as a +/// signed 64-bit two's complement integer with values in the range +/// -9223372036854775808 to +9223372036854775807. +class Int64Queue extends _IntQueue implements QueueList { + /// Creates an empty [Int64Queue] with the given initial internal capacity (in + /// elements). + Int64Queue([int initialCapacity]) + : super(Int64List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Int64Queue] with the same length and contents as [elements]. + factory Int64Queue.fromList(List elements) => + Int64Queue(elements.length)..addAll(elements); + + Int64List _createList(int size) => Int64List(size); +} + +/// A [QueueList] that efficiently stores IEEE 754 single-precision binary +/// floating-point numbers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +/// +/// Doubles stored in this are converted to the nearest single-precision value. +/// Values read are converted to a double value with the same value. +class Float32Queue extends _FloatQueue + implements QueueList { + /// Creates an empty [Float32Queue] with the given initial internal capacity + /// (in elements). + Float32Queue([int initialCapacity]) + : super(Float32List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Float32Queue] with the same length and contents as [elements]. + factory Float32Queue.fromList(List elements) => + Float32Queue(elements.length)..addAll(elements); + + Float32List _createList(int size) => Float32List(size); +} + +/// A [QueueList] that efficiently stores IEEE 754 double-precision binary +/// floating-point numbers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +class Float64Queue extends _FloatQueue + implements QueueList { + /// Creates an empty [Float64Queue] with the given initial internal capacity + /// (in elements). + Float64Queue([int initialCapacity]) + : super(Float64List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Float64Queue] with the same length and contents as [elements]. + factory Float64Queue.fromList(List elements) => + Float64Queue(elements.length)..addAll(elements); + + Float64List _createList(int size) => Float64List(size); +} + +/// A [QueueList] that efficiently stores [Int32x4] numbers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +class Int32x4Queue extends _TypedQueue + implements QueueList { + /// Creates an empty [Int32x4Queue] with the given initial internal capacity + /// (in elements). + Int32x4Queue([int initialCapacity]) + : super(Int32x4List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Int32x4Queue] with the same length and contents as [elements]. + factory Int32x4Queue.fromList(List elements) => + Int32x4Queue(elements.length)..addAll(elements); + + Int32x4List _createList(int size) => Int32x4List(size); +} + +/// A [QueueList] that efficiently stores [Float32x4] numbers. +/// +/// For long queues, this implementation can be considerably more space- and +/// time-efficient than a default [QueueList] implementation. +class Float32x4Queue extends _TypedQueue + implements QueueList { + /// Creates an empty [Float32x4Queue] with the given initial internal capacity (in + /// elements). + Float32x4Queue([int initialCapacity]) + : super(Float32x4List(_chooseRealInitialCapacity(initialCapacity))); + + /// Creates a [Float32x4Queue] with the same length and contents as [elements]. + factory Float32x4Queue.fromList(List elements) => + Float32x4Queue(elements.length)..addAll(elements); + + Float32x4List _createList(int size) => Float32x4List(size); +} + +/// The initial capacity of queues if the user doesn't specify one. +const _defaultInitialCapacity = 16; + +/// Choose the next-highest power of two given a user-specified +/// [initialCapacity] for a queue. +int _chooseRealInitialCapacity(int initialCapacity) { + if (initialCapacity == null || initialCapacity < _defaultInitialCapacity) { + return _defaultInitialCapacity; + } else if (!_isPowerOf2(initialCapacity)) { + return _nextPowerOf2(initialCapacity); + } else { + return initialCapacity; + } +} + +/// Whether [number] is a power of two. +/// +/// Only works for positive numbers. +bool _isPowerOf2(int number) => (number & (number - 1)) == 0; + +/// Rounds [number] up to the nearest power of 2. +/// +/// If [number] is a power of 2 already, it is returned. +/// +/// Only works for positive numbers. +int _nextPowerOf2(int number) { + assert(number > 0); + number = (number << 1) - 1; + for (;;) { + int nextNumber = number & (number - 1); + if (nextNumber == 0) return number; + number = nextNumber; + } +} diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index 5ae0142a..b23fdf06 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -5,4 +5,5 @@ /// Utilities and functionality related to the "dart:typed_data" library. library typed_data; -export "package:typed_data/typed_buffers.dart"; +export "src/typed_queue.dart"; +export "typed_buffers.dart"; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 58ca4700..fecb4efd 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.6 +version: 1.2.0 description: >- Utility functions and classes related to the dart:typed_data library. @@ -7,7 +7,10 @@ author: Dart Team homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.2.2 <3.0.0' + +dependencies: + collection: ^1.1.0 dev_dependencies: pedantic: ^1.0.0 diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart new file mode 100644 index 00000000..cc0c95a8 --- /dev/null +++ b/pkgs/typed_data/test/queue_test.dart @@ -0,0 +1,306 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:test/test.dart"; + +import "package:typed_data/typed_data.dart"; + +/// The initial capacity of queues if the user doesn't specify one. +const capacity = 16; + +void main() { + group("Uint8Queue()", () { + test("creates an empty Uint8Queue", () { + expect(Uint8Queue(), isEmpty); + }); + + test("takes an initial capacity", () { + expect(Uint8Queue(100), isEmpty); + }); + }); + + group("add() adds an element to the end", () { + forEachInternalRepresentation((queue) { + queue.add(16); + expect(queue, equals(oneThrough(capacity))); + }); + }); + + group("addFirst() adds an element to the beginning", () { + forEachInternalRepresentation((queue) { + queue.addFirst(0); + expect(queue, equals([0, ...oneThrough(capacity - 1)])); + }); + }); + + group("removeFirst() removes an element from the beginning", () { + forEachInternalRepresentation((queue) { + expect(queue.removeFirst(), equals(1)); + expect(queue, equals(oneThrough(capacity - 1).skip(1))); + }); + + test("throws a StateError for an empty queue", () { + expect(Uint8Queue().removeFirst, throwsStateError); + }); + }); + + group("removeLast() removes an element from the end", () { + forEachInternalRepresentation((queue) { + expect(queue.removeLast(), equals(15)); + expect(queue, equals(oneThrough(capacity - 2))); + }); + + test("throws a StateError for an empty queue", () { + expect(Uint8Queue().removeLast, throwsStateError); + }); + }); + + group("removeRange()", () { + group("removes a prefix", () { + forEachInternalRepresentation((queue) { + queue.removeRange(0, 5); + expect(queue, equals(oneThrough(capacity - 1).skip(5))); + }); + }); + + group("removes a suffix", () { + forEachInternalRepresentation((queue) { + queue.removeRange(10, 15); + expect(queue, equals(oneThrough(capacity - 6))); + }); + }); + + group("removes from the middle", () { + forEachInternalRepresentation((queue) { + queue.removeRange(5, 10); + expect(queue, equals([1, 2, 3, 4, 5, 11, 12, 13, 14, 15])); + }); + }); + + group("removes everything", () { + forEachInternalRepresentation((queue) { + queue.removeRange(0, 15); + expect(queue, isEmpty); + }); + }); + + test("throws a RangeError for an invalid range", () { + expect(() => Uint8Queue().removeRange(0, 1), throwsRangeError); + }); + }); + + group("setRange()", () { + group("sets a range to the contents of an iterable", () { + forEachInternalRepresentation((queue) { + queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n), 2); + expect(queue, + [1, 2, 3, 4, 5, 103, 104, 105, 106, 107, 11, 12, 13, 14, 15]); + }); + }); + + group("sets a range to the contents of a list", () { + forEachInternalRepresentation((queue) { + queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n).toList(), 2); + expect(queue, + [1, 2, 3, 4, 5, 103, 104, 105, 106, 107, 11, 12, 13, 14, 15]); + }); + }); + + group( + "sets a range to a section of the same queue overlapping at the beginning", + () { + forEachInternalRepresentation((queue) { + queue.setRange(5, 10, queue, 2); + expect(queue, [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15]); + }); + }); + + group("sets a range to a section of the same queue overlapping at the end", + () { + forEachInternalRepresentation((queue) { + queue.setRange(5, 10, queue, 6); + expect(queue, [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15]); + }); + }); + + test("throws a RangeError for an invalid range", () { + expect(() => Uint8Queue().setRange(0, 1, [1]), throwsRangeError); + }); + }); + + group("length returns the length", () { + forEachInternalRepresentation((queue) { + expect(queue.length, equals(15)); + }); + }); + + group("length=", () { + group("empties", () { + forEachInternalRepresentation((queue) { + queue.length = 0; + expect(queue, isEmpty); + }); + }); + + group("shrinks", () { + forEachInternalRepresentation((queue) { + queue.length = 5; + expect(queue, equals([1, 2, 3, 4, 5])); + }); + }); + + group("grows", () { + forEachInternalRepresentation((queue) { + queue.length = 20; + expect( + queue, + equals(oneThrough(capacity - 1) + + List.filled(20 - (capacity - 1), 0))); + }); + }); + + test("throws a RangeError if length is less than 0", () { + expect(() => Uint8Queue().length = -1, throwsRangeError); + }); + }); + + group("[]", () { + group("returns individual entries", () { + forEachInternalRepresentation((queue) { + for (var i = 0; i < capacity - 1; i++) { + expect(queue[i], equals(i + 1)); + } + }); + }); + + test("throws a RangeError if the index is less than 0", () { + var queue = Uint8Queue.fromList([1, 2, 3]); + expect(() => queue[-1], throwsRangeError); + }); + + test( + "throws a RangeError if the index is greater than or equal to the " + "length", () { + var queue = Uint8Queue.fromList([1, 2, 3]); + expect(() => queue[3], throwsRangeError); + }); + }); + + group("[]=", () { + group("sets individual entries", () { + forEachInternalRepresentation((queue) { + for (var i = 0; i < capacity - 1; i++) { + queue[i] = 100 + i; + } + expect(queue, equals(List.generate(capacity - 1, (i) => 100 + i))); + }); + }); + + test("throws a RangeError if the index is less than 0", () { + var queue = Uint8Queue.fromList([1, 2, 3]); + expect(() { + queue[-1] = 0; + }, throwsRangeError); + }); + + test( + "throws a RangeError if the index is greater than or equal to the " + "length", () { + var queue = Uint8Queue.fromList([1, 2, 3]); + expect(() { + queue[3] = 4; + }, throwsRangeError); + }); + }); + + group("throws a modification error for", () { + Uint8Queue queue; + setUp(() { + queue = Uint8Queue.fromList([1, 2, 3]); + }); + + test("add", () { + expect(() => queue.forEach((_) => queue.add(4)), + throwsConcurrentModificationError); + }); + + test("addAll", () { + expect(() => queue.forEach((_) => queue.addAll([4, 5, 6])), + throwsConcurrentModificationError); + }); + + test("addFirst", () { + expect(() => queue.forEach((_) => queue.addFirst(0)), + throwsConcurrentModificationError); + }); + + test("removeFirst", () { + expect(() => queue.forEach((_) => queue.removeFirst()), + throwsConcurrentModificationError); + }); + + test("removeLast", () { + expect(() => queue.forEach((_) => queue.removeLast()), + throwsConcurrentModificationError); + }); + + test("length=", () { + expect(() => queue.forEach((_) => queue.length = 1), + throwsConcurrentModificationError); + }); + }); +} + +/// Runs [callback] in multiple tests, all with queues containing numbers from +/// one through 15 in various different internal states. +void forEachInternalRepresentation(void callback(Uint8Queue queue)) { + // Test with a queue whose internal table has plenty of room. + group("for a queue that's below capacity", () { + // Test with a queue whose elements are in one contiguous block, so `_head < + // _tail`. + test("with contiguous elements", () { + callback(Uint8Queue(capacity * 2)..addAll(oneThrough(capacity - 1))); + }); + + // Test with a queue whose elements are split across the ends of the table, + // so `_head > _tail`. + test("with an internal gap", () { + var queue = Uint8Queue(capacity * 2); + for (var i = capacity ~/ 2; i < capacity; i++) { + queue.add(i); + } + for (var i = capacity ~/ 2 - 1; i > 0; i--) { + queue.addFirst(i); + } + callback(queue); + }); + }); + + // Test with a queue whose internal table will need to expand if one more + // element is added. + group("for a queue that's at capacity", () { + test("with contiguous elements", () { + callback(Uint8Queue()..addAll(oneThrough(capacity - 1))); + }); + + test("with an internal gap", () { + var queue = Uint8Queue(); + for (var i = capacity ~/ 2; i < capacity; i++) { + queue.add(i); + } + for (var i = capacity ~/ 2 - 1; i > 0; i--) { + queue.addFirst(i); + } + callback(queue); + }); + }); +} + +/// Returns a list containing the integers from one through [n]. +List oneThrough(int n) => List.generate(n, (i) => i + 1); + +/// Returns a matcher that expects that a closure throws a +/// [ConcurrentModificationError]. +final throwsConcurrentModificationError = + throwsA(const TypeMatcher()); From ee8d23205c5158dd81020a80cca4182c47cf4882 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 18 Oct 2019 10:23:30 +0100 Subject: [PATCH 033/113] Ignore an unhelpful lint --- pkgs/typed_data/test/queue_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index cc0c95a8..a98c157a 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -2,6 +2,8 @@ // 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. +// ignore_for_file: avoid_function_literals_in_foreach_calls + import "package:test/test.dart"; import "package:typed_data/typed_data.dart"; From ef6e1abeccb95bcaf4b8ac6e7c03127a09b8b9b5 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 18 Oct 2019 10:23:55 +0100 Subject: [PATCH 034/113] Run tests on stable and dev --- pkgs/typed_data/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 43a3f15b..0d83a599 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,6 +1,6 @@ language: dart dart: - - 2.0.0 + - stable - dev dart_task: From 3e70f40e71fa9135353aeecd3e013ee9d4d35823 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 14 Nov 2019 15:52:24 -0800 Subject: [PATCH 035/113] Code review changes --- pkgs/typed_data/lib/src/typed_queue.dart | 61 ++++++++++++++++++++---- pkgs/typed_data/test/queue_test.dart | 8 ++++ 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 0e361970..93b0a42e 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -7,13 +7,14 @@ import "dart:typed_data"; import "package:collection/collection.dart"; +import '../typed_buffers.dart'; + /// The shared superclass of all the typed queue subclasses. -abstract class _TypedQueue> extends Object - with ListMixin { +abstract class _TypedQueue> with ListMixin { /// The underlying data buffer. /// /// This is always both a List and a TypedData, which we don't have a type - /// for that. For example, for a `Uint8Buffer`, this is a `Uint8List`. + /// for that. For example, for a `Uint8Queue`, this is a `Uint8List`. L _table; int _head; @@ -29,7 +30,7 @@ abstract class _TypedQueue> extends Object int get length => (_tail - _head) & (_table.length - 1); List toList({bool growable = true}) { - var list = growable ? ([]..length = length) : _createList(length); + var list = growable ? _createBuffer(length) : _createList(length); _writeToList(list); return list; } @@ -77,15 +78,21 @@ abstract class _TypedQueue> extends Object var delta = value - length; if (delta >= 0) { - if (_table.length <= value) _growTo(value); + var needsToGrow = _table.length <= value; + if (needsToGrow) _growTo(value); _tail = (_tail + delta) & (_table.length - 1); + + // If we didn't copy into a new table, make sure that we overwrite the + // existing data so that users don't accidentally depend on it still + // existing. + if (!needsToGrow) fillRange(value - delta, value, _defaultValue); } else { removeRange(value, length); } } E operator [](int index) { - RangeError.checkValidIndex(index, this); + RangeError.checkValidIndex(index, this, null, this.length); return _table[(_head + index) & (_table.length - 1)]; } @@ -222,11 +229,21 @@ abstract class _TypedQueue> extends Object } } + void fillRange(int start, int end, [E value]) { + var startInTable = (_head + start) & (_table.length - 1); + var endInTable = (_head + end) & (_table.length - 1); + if (startInTable <= endInTable) { + _table.fillRange(startInTable, endInTable, value); + } else { + _table.fillRange(startInTable, _table.length, value); + _table.fillRange(0, endInTable, value); + } + } + L sublist(int start, [int end]) { var length = this.length; - RangeError.checkValidRange(start, end, length); + end = RangeError.checkValidRange(start, end, length); - end ??= length; var list = _createList(end - start); _writeToList(list, start, end); return list; @@ -245,6 +262,7 @@ abstract class _TypedQueue> extends Object start ??= 0; end ??= length; assert(target.length >= end - start); + assert(start <= end); var elementsToWrite = end - start; var startInTable = (_head + start) & (_table.length - 1); @@ -296,15 +314,25 @@ abstract class _TypedQueue> extends Object // Create a new typed list. L _createList(int size); + + // Create a new typed buffer of the given type. + List _createBuffer(int size); + + /// The default value used to fill the queue when changing length. + E get _defaultValue; } abstract class _IntQueue> extends _TypedQueue { _IntQueue(List queue) : super(queue); + + int get _defaultValue => 0; } abstract class _FloatQueue> extends _TypedQueue { _FloatQueue(List queue) : super(queue); + + double get _defaultValue => 0.0; } /// A [QueueList] that efficiently stores 8-bit unsigned integers. @@ -325,6 +353,7 @@ class Uint8Queue extends _IntQueue implements QueueList { Uint8Queue(elements.length)..addAll(elements); Uint8List _createList(int size) => Uint8List(size); + Uint8Buffer _createBuffer(int size) => Uint8Buffer(size); } /// A [QueueList] that efficiently stores 8-bit signed integers. @@ -346,6 +375,7 @@ class Int8Queue extends _IntQueue implements QueueList { Int8Queue(elements.length)..addAll(elements); Int8List _createList(int size) => Int8List(size); + Int8Buffer _createBuffer(int size) => Int8Buffer(size); } /// A [QueueList] that efficiently stores 8-bit unsigned integers. @@ -369,6 +399,7 @@ class Uint8ClampedQueue extends _IntQueue Uint8ClampedQueue(elements.length)..addAll(elements); Uint8ClampedList _createList(int size) => Uint8ClampedList(size); + Uint8ClampedBuffer _createBuffer(int size) => Uint8ClampedBuffer(size); } /// A [QueueList] that efficiently stores 16-bit unsigned integers. @@ -389,6 +420,7 @@ class Uint16Queue extends _IntQueue implements QueueList { Uint16Queue(elements.length)..addAll(elements); Uint16List _createList(int size) => Uint16List(size); + Uint16Buffer _createBuffer(int size) => Uint16Buffer(size); } /// A [QueueList] that efficiently stores 16-bit signed integers. @@ -410,6 +442,7 @@ class Int16Queue extends _IntQueue implements QueueList { Int16Queue(elements.length)..addAll(elements); Int16List _createList(int size) => Int16List(size); + Int16Buffer _createBuffer(int size) => Int16Buffer(size); } /// A [QueueList] that efficiently stores 32-bit unsigned integers. @@ -430,6 +463,7 @@ class Uint32Queue extends _IntQueue implements QueueList { Uint32Queue(elements.length)..addAll(elements); Uint32List _createList(int size) => Uint32List(size); + Uint32Buffer _createBuffer(int size) => Uint32Buffer(size); } /// A [QueueList] that efficiently stores 32-bit signed integers. @@ -451,6 +485,7 @@ class Int32Queue extends _IntQueue implements QueueList { Int32Queue(elements.length)..addAll(elements); Int32List _createList(int size) => Int32List(size); + Int32Buffer _createBuffer(int size) => Int32Buffer(size); } /// A [QueueList] that efficiently stores 64-bit unsigned integers. @@ -472,6 +507,7 @@ class Uint64Queue extends _IntQueue implements QueueList { Uint64Queue(elements.length)..addAll(elements); Uint64List _createList(int size) => Uint64List(size); + Uint64Buffer _createBuffer(int size) => Uint64Buffer(size); } /// A [QueueList] that efficiently stores 64-bit signed integers. @@ -493,6 +529,7 @@ class Int64Queue extends _IntQueue implements QueueList { Int64Queue(elements.length)..addAll(elements); Int64List _createList(int size) => Int64List(size); + Int64Buffer _createBuffer(int size) => Int64Buffer(size); } /// A [QueueList] that efficiently stores IEEE 754 single-precision binary @@ -515,6 +552,7 @@ class Float32Queue extends _FloatQueue Float32Queue(elements.length)..addAll(elements); Float32List _createList(int size) => Float32List(size); + Float32Buffer _createBuffer(int size) => Float32Buffer(size); } /// A [QueueList] that efficiently stores IEEE 754 double-precision binary @@ -534,6 +572,7 @@ class Float64Queue extends _FloatQueue Float64Queue(elements.length)..addAll(elements); Float64List _createList(int size) => Float64List(size); + Float64Buffer _createBuffer(int size) => Float64Buffer(size); } /// A [QueueList] that efficiently stores [Int32x4] numbers. @@ -542,6 +581,8 @@ class Float64Queue extends _FloatQueue /// time-efficient than a default [QueueList] implementation. class Int32x4Queue extends _TypedQueue implements QueueList { + static final Int32x4 _zero = Int32x4(0, 0, 0, 0); + /// Creates an empty [Int32x4Queue] with the given initial internal capacity /// (in elements). Int32x4Queue([int initialCapacity]) @@ -552,6 +593,8 @@ class Int32x4Queue extends _TypedQueue Int32x4Queue(elements.length)..addAll(elements); Int32x4List _createList(int size) => Int32x4List(size); + Int32x4Buffer _createBuffer(int size) => Int32x4Buffer(size); + Int32x4 get _defaultValue => _zero; } /// A [QueueList] that efficiently stores [Float32x4] numbers. @@ -570,6 +613,8 @@ class Float32x4Queue extends _TypedQueue Float32x4Queue(elements.length)..addAll(elements); Float32x4List _createList(int size) => Float32x4List(size); + Float32x4Buffer _createBuffer(int size) => Float32x4Buffer(size); + Float32x4 get _defaultValue => Float32x4.zero(); } /// The initial capacity of queues if the user doesn't specify one. diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index a98c157a..6b6daf94 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -162,6 +162,14 @@ void main() { }); }); + group("zeroes out existing data", () { + forEachInternalRepresentation((queue) { + queue.length = 0; + queue.length = 15; + expect(queue, equals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); + }); + }); + test("throws a RangeError if length is less than 0", () { expect(() => Uint8Queue().length = -1, throwsRangeError); }); From 563c285f181acfbdb71b707dcdf895cdfa87b6c9 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 15 Nov 2019 12:51:03 -0800 Subject: [PATCH 036/113] More fixes --- pkgs/typed_data/lib/src/typed_queue.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 93b0a42e..df91e358 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -40,6 +40,7 @@ abstract class _TypedQueue> with ListMixin { throw UnsupportedError("$this cannot be cast to the desired type."); } + @deprecated QueueList retype() => cast(); // Queue interface. @@ -92,7 +93,7 @@ abstract class _TypedQueue> with ListMixin { } E operator [](int index) { - RangeError.checkValidIndex(index, this, null, this.length); + RangeError.checkValidIndex(index, this, null, length); return _table[(_head + index) & (_table.length - 1)]; } From 28c2603b0cc164d489130faa8acaf7c4421342e4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 7 Dec 2019 10:03:42 -0800 Subject: [PATCH 037/113] Fix new pedantic lints (dart-lang/typed_data#22) --- pkgs/typed_data/.travis.yml | 2 +- pkgs/typed_data/lib/typed_buffers.dart | 56 +++++--- pkgs/typed_data/lib/typed_data.dart | 2 +- pkgs/typed_data/pubspec.yaml | 5 +- pkgs/typed_data/test/typed_buffers_test.dart | 122 +++++++++--------- .../test/typed_buffers_vm_test.dart | 5 +- 6 files changed, 115 insertions(+), 77 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 43a3f15b..e9ef0bf6 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,6 +1,6 @@ language: dart dart: - - 2.0.0 + - 2.3.0 - dev dart_task: diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index f2e407db..17964c28 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -13,8 +13,8 @@ /// be larger than what the list is using. library typed_data.typed_buffers; -import "dart:collection" show ListBase; -import "dart:typed_data"; +import 'dart:collection' show ListBase; +import 'dart:typed_data'; abstract class _TypedDataBuffer extends ListBase { static const int _initialLength = 8; @@ -35,22 +35,26 @@ abstract class _TypedDataBuffer extends ListBase { : _buffer = buffer, _length = buffer.length; + @override int get length => _length; + @override E operator [](int index) { if (index >= length) throw RangeError.index(index, this); return _buffer[index]; } + @override void operator []=(int index, E value) { if (index >= length) throw RangeError.index(index, this); _buffer[index] = value; } + @override set length(int newLength) { if (newLength < _length) { - E defaultValue = _defaultValue; - for (int i = newLength; i < _length; i++) { + var defaultValue = _defaultValue; + for (var i = newLength; i < _length; i++) { _buffer[i] = defaultValue; } } else if (newLength > _buffer.length) { @@ -74,6 +78,7 @@ abstract class _TypedDataBuffer extends ListBase { // We override the default implementation of `add` because it grows the list // by setting the length in increments of one. We want to grow by doubling // capacity in most cases. + @override void add(E value) { _add(value); } @@ -87,10 +92,11 @@ abstract class _TypedDataBuffer extends ListBase { /// The [start] value must be non-negative. The [values] iterable must have at /// least [start] elements, and if [end] is specified, it must be greater than /// or equal to [start] and [values] must have at least [end] elements. + @override void addAll(Iterable values, [int start = 0, int end]) { - RangeError.checkNotNegative(start, "start"); + RangeError.checkNotNegative(start, 'start'); if (end != null && start > end) { - throw RangeError.range(end, start, null, "end"); + throw RangeError.range(end, start, null, 'end'); } _addAll(values, start, end); @@ -105,12 +111,13 @@ abstract class _TypedDataBuffer extends ListBase { /// The [start] value must be non-negative. The [values] iterable must have at /// least [start] elements, and if [end] is specified, it must be greater than /// or equal to [start] and [values] must have at least [end] elements. + @override void insertAll(int index, Iterable values, [int start = 0, int end]) { - RangeError.checkValidIndex(index, this, "index", _length + 1); - RangeError.checkNotNegative(start, "start"); + RangeError.checkValidIndex(index, this, 'index', _length + 1); + RangeError.checkNotNegative(start, 'start'); if (end != null) { if (start > end) { - throw RangeError.range(end, start, null, "end"); + throw RangeError.range(end, start, null, 'end'); } if (start == end) return; } @@ -148,10 +155,10 @@ abstract class _TypedDataBuffer extends ListBase { } if (skipCount > 0) { - throw StateError("Too few elements"); + throw StateError('Too few elements'); } if (end != null && writeIndex < end) { - throw RangeError.range(end, start, writeIndex, "end"); + throw RangeError.range(end, start, writeIndex, 'end'); } // Swap [index.._length) and [_length..writeIndex) by double-reversing. @@ -197,7 +204,7 @@ abstract class _TypedDataBuffer extends ListBase { if (i >= start) add(value); i++; } - if (i < start) throw StateError("Too few elements"); + if (i < start) throw StateError('Too few elements'); } /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. @@ -205,7 +212,7 @@ abstract class _TypedDataBuffer extends ListBase { if (values is List) { end ??= values.length; if (start > values.length || end > values.length) { - throw StateError("Too few elements"); + throw StateError('Too few elements'); } } else { assert(end != null); @@ -221,6 +228,7 @@ abstract class _TypedDataBuffer extends ListBase { _length = newLength; } + @override void insert(int index, E element) { if (index < 0 || index > _length) { throw RangeError.range(index, 0, _length); @@ -231,7 +239,7 @@ abstract class _TypedDataBuffer extends ListBase { _length++; return; } - List newBuffer = _createBiggerBuffer(null); + var newBuffer = _createBiggerBuffer(null); newBuffer.setRange(0, index, _buffer); newBuffer.setRange(index + 1, _length + 1, _buffer, index); newBuffer[index] = element; @@ -256,7 +264,7 @@ abstract class _TypedDataBuffer extends ListBase { /// size. It will always have at least have double the capacity of /// the current buffer. List _createBiggerBuffer(int requiredCapacity) { - int newLength = _buffer.length * 2; + var newLength = _buffer.length * 2; if (requiredCapacity != null && newLength < requiredCapacity) { newLength = requiredCapacity; } else if (newLength < _initialLength) { @@ -272,6 +280,7 @@ abstract class _TypedDataBuffer extends ListBase { _buffer = _createBiggerBuffer(null)..setRange(0, length, _buffer); } + @override void setRange(int start, int end, Iterable source, [int skipCount = 0]) { if (end > _length) throw RangeError.range(end, 0, _length); _setRange(start, end, source, skipCount); @@ -315,24 +324,28 @@ abstract class _TypedDataBuffer extends ListBase { abstract class _IntBuffer extends _TypedDataBuffer { _IntBuffer(List buffer) : super(buffer); + @override int get _defaultValue => 0; } abstract class _FloatBuffer extends _TypedDataBuffer { _FloatBuffer(List buffer) : super(buffer); + @override double get _defaultValue => 0.0; } class Uint8Buffer extends _IntBuffer { Uint8Buffer([int initialLength = 0]) : super(Uint8List(initialLength)); + @override Uint8List _createBuffer(int size) => Uint8List(size); } class Int8Buffer extends _IntBuffer { Int8Buffer([int initialLength = 0]) : super(Int8List(initialLength)); + @override Int8List _createBuffer(int size) => Int8List(size); } @@ -340,54 +353,63 @@ class Uint8ClampedBuffer extends _IntBuffer { Uint8ClampedBuffer([int initialLength = 0]) : super(Uint8ClampedList(initialLength)); + @override Uint8ClampedList _createBuffer(int size) => Uint8ClampedList(size); } class Uint16Buffer extends _IntBuffer { Uint16Buffer([int initialLength = 0]) : super(Uint16List(initialLength)); + @override Uint16List _createBuffer(int size) => Uint16List(size); } class Int16Buffer extends _IntBuffer { Int16Buffer([int initialLength = 0]) : super(Int16List(initialLength)); + @override Int16List _createBuffer(int size) => Int16List(size); } class Uint32Buffer extends _IntBuffer { Uint32Buffer([int initialLength = 0]) : super(Uint32List(initialLength)); + @override Uint32List _createBuffer(int size) => Uint32List(size); } class Int32Buffer extends _IntBuffer { Int32Buffer([int initialLength = 0]) : super(Int32List(initialLength)); + @override Int32List _createBuffer(int size) => Int32List(size); } class Uint64Buffer extends _IntBuffer { Uint64Buffer([int initialLength = 0]) : super(Uint64List(initialLength)); + @override Uint64List _createBuffer(int size) => Uint64List(size); } class Int64Buffer extends _IntBuffer { Int64Buffer([int initialLength = 0]) : super(Int64List(initialLength)); + @override Int64List _createBuffer(int size) => Int64List(size); } class Float32Buffer extends _FloatBuffer { Float32Buffer([int initialLength = 0]) : super(Float32List(initialLength)); + @override Float32List _createBuffer(int size) => Float32List(size); } class Float64Buffer extends _FloatBuffer { Float64Buffer([int initialLength = 0]) : super(Float64List(initialLength)); + @override Float64List _createBuffer(int size) => Float64List(size); } @@ -396,8 +418,10 @@ class Int32x4Buffer extends _TypedDataBuffer { Int32x4Buffer([int initialLength = 0]) : super(Int32x4List(initialLength)); + @override Int32x4 get _defaultValue => _zero; + @override Int32x4List _createBuffer(int size) => Int32x4List(size); } @@ -405,7 +429,9 @@ class Float32x4Buffer extends _TypedDataBuffer { Float32x4Buffer([int initialLength = 0]) : super(Float32x4List(initialLength)); + @override Float32x4 get _defaultValue => Float32x4.zero(); + @override Float32x4List _createBuffer(int size) => Float32x4List(size); } diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index 5ae0142a..d7c73930 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -5,4 +5,4 @@ /// Utilities and functionality related to the "dart:typed_data" library. library typed_data; -export "package:typed_data/typed_buffers.dart"; +export 'package:typed_data/typed_buffers.dart'; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 58ca4700..24b0adc2 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -7,8 +7,11 @@ author: Dart Team homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.3.0 <3.0.0' dev_dependencies: pedantic: ^1.0.0 test: ^1.0.0 + + # Remove when https://github.com/dart-lang/sdk/issues/39702 is fixed + analyzer: <0.39.2 diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 10a148bc..3f682b1f 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -3,10 +3,10 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('!vm') -import "dart:typed_data"; +import 'dart:typed_data'; -import "package:test/test.dart"; -import "package:typed_data/typed_buffers.dart"; +import 'package:test/test.dart'; +import 'package:typed_data/typed_buffers.dart'; const List browserSafeIntSamples = [ 0x8000000000000000, // 2^63 @@ -46,7 +46,7 @@ void main() { void initTests(List intSamples) { testUint(intSamples, 8, (l) => Uint8Buffer(l)); testInt(intSamples, 8, (l) => Int8Buffer(l)); - test("Uint8ClampedBuffer", () { + test('Uint8ClampedBuffer', () { testIntBuffer( intSamples, 8, 0, 255, (l) => Uint8ClampedBuffer(l), clampUint8); }); @@ -58,10 +58,10 @@ void initTests(List intSamples) { testUint(intSamples, 64, (l) => Uint64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. - testOn: "dart-vm"); + testOn: 'dart-vm'); testInt(intSamples, 64, (l) => Int64Buffer(l), // JS doesn't support 64-bit ints, so only test this on the VM. - testOn: "dart-vm"); + testOn: 'dart-vm'); testInt32x4Buffer(intSamples); @@ -71,9 +71,9 @@ void initTests(List intSamples) { testFloat32x4Buffer(roundedFloatSamples); - group("addAll", () { + group('addAll', () { for (var type in ['a list', 'an iterable']) { - group("with $type", () { + group('with $type', () { Iterable source; Uint8Buffer buffer; setUp(() { @@ -84,7 +84,7 @@ void initTests(List intSamples) { buffer = Uint8Buffer(); }); - test("adds values to the buffer", () { + test('adds values to the buffer', () { buffer.addAll(source, 1, 4); expect(buffer, equals([2, 3, 4])); @@ -95,7 +95,7 @@ void initTests(List intSamples) { expect(buffer, equals([2, 3, 4, 5, 1])); }); - test("does nothing for empty slices", () { + test('does nothing for empty slices', () { buffer.addAll([6, 7, 8, 9, 10]); buffer.addAll(source, 0, 0); @@ -111,7 +111,7 @@ void initTests(List intSamples) { expect(buffer, equals([6, 7, 8, 9, 10])); }); - test("throws errors for invalid start and end", () { + test('throws errors for invalid start and end', () { expect(() => buffer.addAll(source, -1), throwsRangeError); expect(() => buffer.addAll(source, -1, 2), throwsRangeError); expect(() => buffer.addAll(source, 10), throwsStateError); @@ -124,9 +124,9 @@ void initTests(List intSamples) { } }); - group("insertAll", () { + group('insertAll', () { for (var type in ['a list', 'an iterable']) { - group("with $type", () { + group('with $type', () { Iterable source; Uint8Buffer buffer; setUp(() { @@ -137,7 +137,7 @@ void initTests(List intSamples) { buffer = Uint8Buffer()..addAll([6, 7, 8, 9, 10]); }); - test("inserts values into the buffer", () { + test('inserts values into the buffer', () { buffer.insertAll(0, source, 1, 4); expect(buffer, equals([2, 3, 4, 6, 7, 8, 9, 10])); @@ -149,13 +149,13 @@ void initTests(List intSamples) { }); // Regression test for #1. - test("inserts values into the buffer after removeRange()", () { + test('inserts values into the buffer after removeRange()', () { buffer.removeRange(1, 4); buffer.insertAll(1, source); expect(buffer, equals([6, 1, 2, 3, 4, 5, 10])); }); - test("does nothing for empty slices", () { + test('does nothing for empty slices', () { buffer.insertAll(1, source, 0, 0); expect(buffer, equals([6, 7, 8, 9, 10])); @@ -169,7 +169,7 @@ void initTests(List intSamples) { expect(buffer, equals([6, 7, 8, 9, 10])); }); - test("throws errors for invalid start and end", () { + test('throws errors for invalid start and end', () { expect(() => buffer.insertAll(-1, source), throwsRangeError); expect(() => buffer.insertAll(6, source), throwsRangeError); expect(() => buffer.insertAll(1, source, -1), throwsRangeError); @@ -234,8 +234,8 @@ void doubleEqual(x, y) { } Rounder intRounder(bits) { - int highBit = 1 << (bits - 1); - int mask = highBit - 1; + var highBit = 1 << (bits - 1); + var mask = highBit - 1; return (int x) => (x & mask) - (x & highBit); } @@ -243,9 +243,9 @@ double roundToFloat(double value) { return (Float32List(1)..[0] = value)[0]; } -testFloat32x4Buffer(List floatSamples) { +void testFloat32x4Buffer(List floatSamples) { var float4Samples = []; - for (int i = 0; i < floatSamples.length - 3; i++) { + for (var i = 0; i < floatSamples.length - 3; i++) { float4Samples.add(Float32x4(floatSamples[i], floatSamples[i + 1], floatSamples[i + 2], floatSamples[i + 3])); } @@ -265,7 +265,7 @@ testFloat32x4Buffer(List floatSamples) { floatEquals(x.w, y.w); } - test("Float32x4Buffer", () { + test('Float32x4Buffer', () { var buffer = Float32x4Buffer(5); expect(buffer, const TypeMatcher>()); @@ -286,12 +286,12 @@ testFloat32x4Buffer(List floatSamples) { buffer.addAll(float4Samples); expect(buffer.length, equals(float4Samples.length * 2)); - for (int i = 0; i < float4Samples.length; i++) { + for (var i = 0; i < float4Samples.length; i++) { x4Equals(buffer[i], buffer[float4Samples.length + i]); } buffer.removeRange(4, 4 + float4Samples.length); - for (int i = 0; i < float4Samples.length; i++) { + for (var i = 0; i < float4Samples.length; i++) { x4Equals(buffer[i], float4Samples[i]); } @@ -299,7 +299,7 @@ testFloat32x4Buffer(List floatSamples) { buffer.length = 1; buffer[0] = float4Samples[0]; // Does not contain NaN. - Float32List floats = Float32List.view(buffer.buffer); + var floats = Float32List.view(buffer.buffer); expect(floats[0], equals(buffer[0].x)); expect(floats[1], equals(buffer[0].y)); expect(floats[2], equals(buffer[0].z)); @@ -311,11 +311,15 @@ testFloat32x4Buffer(List floatSamples) { // the rounding that is applied when storing values outside the valid range // into the buffer. void testFloatBuffer( - int bitSize, List samples, create(), double round(double v)) { - test("Float${bitSize}Buffer", () { + int bitSize, + List samples, + Function() create, + double Function(double v) round, +) { + test('Float${bitSize}Buffer', () { var buffer = create(); expect(buffer, const TypeMatcher>()); - int byteSize = bitSize ~/ 8; + var byteSize = bitSize ~/ 8; expect(buffer.length, equals(0)); buffer.add(0.0); @@ -323,7 +327,7 @@ void testFloatBuffer( expect(buffer.removeLast(), equals(0.0)); expect(buffer.length, equals(0)); - for (double value in samples) { + for (var value in samples) { buffer.add(value); doubleEqual(buffer[buffer.length - 1], round(value)); } @@ -331,7 +335,7 @@ void testFloatBuffer( buffer.addAll(samples); expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { + for (var i = 0; i < samples.length; i++) { doubleEqual(buffer[i], buffer[samples.length + i]); } @@ -340,7 +344,7 @@ void testFloatBuffer( buffer.insertAll(0, samples); expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { + for (var i = 0; i < samples.length; i++) { doubleEqual(buffer[i], buffer[samples.length + i]); } @@ -358,8 +362,8 @@ void testFloatBuffer( buffer[0] = samples[0]; buffer[1] = samples[1]; var bytes = Uint8List.view(buffer.buffer); - for (int i = 0; i < byteSize; i++) { - int tmp = bytes[i]; + for (var i = 0; i < byteSize; i++) { + var tmp = bytes[i]; bytes[i] = bytes[byteSize + i]; bytes[byteSize + i] = tmp; } @@ -368,18 +372,18 @@ void testFloatBuffer( }); } -void testInt(List intSamples, int bits, buffer(int length), +void testInt(List intSamples, int bits, void Function(int length) buffer, {String testOn}) { - int min = -(1 << (bits - 1)); - int max = -(min + 1); - test("Int${bits}Buffer", () { + var min = -(1 << (bits - 1)); + var max = -(min + 1); + test('Int${bits}Buffer', () { testIntBuffer(intSamples, bits, min, max, buffer, intRounder(bits)); }, testOn: testOn); } void testInt32x4Buffer(List intSamples) { - test("Int32x4Buffer", () { - int bytes = 128 ~/ 8; + test('Int32x4Buffer', () { + var bytes = 128 ~/ 8; Matcher equals32x4(Int32x4 expected) => MatchesInt32x4(expected); var buffer = Int32x4Buffer(0); @@ -390,7 +394,7 @@ void testInt32x4Buffer(List intSamples) { expect(buffer.lengthInBytes, equals(0)); expect(buffer.offsetInBytes, equals(0)); - Int32x4 sample = Int32x4(-0x80000000, -1, 0, 0x7fffffff); + var sample = Int32x4(-0x80000000, -1, 0, 0x7fffffff); buffer.add(sample); expect(buffer.length, equals(1)); expect(buffer[0], equals32x4(sample)); @@ -405,15 +409,15 @@ void testInt32x4Buffer(List intSamples) { var samples = intSamples .map((value) => Int32x4(value, -value, ~value, ~ -value)) .toList(); - for (Int32x4 value in samples) { - int length = buffer.length; + for (var value in samples) { + var length = buffer.length; buffer.add(value); expect(buffer.length, equals(length + 1)); expect(buffer[length], equals32x4(value)); } buffer.addAll(samples); // Add all the values at once. - for (int i = 0; i < samples.length; i++) { + for (var i = 0; i < samples.length; i++) { expect(buffer[samples.length + i], equals32x4(buffer[i])); } @@ -425,9 +429,9 @@ void testInt32x4Buffer(List intSamples) { buffer.length = 2; buffer[0] = Int32x4(-80000000, 0x7fffffff, 0, -1); var byteBuffer = Uint8List.view(buffer.buffer); - int halfBytes = bytes ~/ 2; - for (int i = 0; i < halfBytes; i++) { - int tmp = byteBuffer[i]; + var halfBytes = bytes ~/ 2; + for (var i = 0; i < halfBytes; i++) { + var tmp = byteBuffer[i]; byteBuffer[i] = byteBuffer[halfBytes + i]; byteBuffer[halfBytes + i] = tmp; } @@ -437,7 +441,7 @@ void testInt32x4Buffer(List intSamples) { } void testIntBuffer(List intSamples, int bits, int min, int max, - create(int length), int round(int val)) { + Function(int length) create, int Function(int val) round) { assert(round(min) == min); assert(round(max) == max); // All int buffers default to the value 0. @@ -462,14 +466,14 @@ void testIntBuffer(List intSamples, int bits, int min, int max, expect(buffer.length, equals(0)); List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); - for (int value in samples) { + for (var value in samples) { int length = buffer.length; buffer.add(value); expect(buffer.length, equals(length + 1)); expect(buffer[length], equals(round(value))); } buffer.addAll(samples); // Add all the values at once. - for (int i = 0; i < samples.length; i++) { + for (var i = 0; i < samples.length; i++) { expect(buffer[samples.length + i], equals(buffer[i])); } @@ -497,9 +501,9 @@ void testIntBuffer(List intSamples, int bits, int min, int max, buffer[0] = min; buffer[1] = max; var byteBuffer = Uint8List.view(buffer.buffer); - int byteSize = buffer.elementSizeInBytes; - for (int i = 0; i < byteSize; i++) { - int tmp = byteBuffer[i]; + var byteSize = buffer.elementSizeInBytes; + for (var i = 0; i < byteSize; i++) { + var tmp = byteBuffer[i]; byteBuffer[i] = byteBuffer[byteSize + i]; byteBuffer[byteSize + i] = tmp; } @@ -507,19 +511,19 @@ void testIntBuffer(List intSamples, int bits, int min, int max, expect(buffer[1], equals(min)); } -void testUint(List intSamples, int bits, buffer(int length), +void testUint(List intSamples, int bits, void Function(int length) buffer, {String testOn}) { - int min = 0; + var min = 0; var rounder = uintRounder(bits); - int max = rounder(-1); - test("Uint${bits}Buffer", () { + var max = rounder(-1); + test('Uint${bits}Buffer', () { testIntBuffer(intSamples, bits, min, max, buffer, rounder); }, testOn: testOn); } Rounder uintRounder(bits) { - int halfbits = (1 << (bits ~/ 2)) - 1; - int mask = halfbits | (halfbits << (bits ~/ 2)); + var halfbits = (1 << (bits ~/ 2)) - 1; + var mask = halfbits | (halfbits << (bits ~/ 2)); return (int x) => x & mask; } @@ -530,9 +534,11 @@ class MatchesInt32x4 extends Matcher { MatchesInt32x4(this.result); + @override Description describe(Description description) => description.add('Int32x4.=='); + @override bool matches(item, Map matchState) { if (item is! Int32x4) return false; Int32x4 value = item; diff --git a/pkgs/typed_data/test/typed_buffers_vm_test.dart b/pkgs/typed_data/test/typed_buffers_vm_test.dart index ad3100c6..44a66bfc 100644 --- a/pkgs/typed_data/test/typed_buffers_vm_test.dart +++ b/pkgs/typed_data/test/typed_buffers_vm_test.dart @@ -15,5 +15,8 @@ void main() { 0x7fffffffffffffff, 0x5555555555555555, ]; - initTests([]..addAll(browserSafeIntSamples)..addAll(browserUnsafe)); + initTests([ + ...browserSafeIntSamples, + ...browserUnsafe, + ]); } From 21ca39b096315275f76f993455b4bd756b1fd1e2 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 9 Dec 2019 09:58:02 -0800 Subject: [PATCH 038/113] =?UTF-8?q?Revert=20analyzer=20hack=20=E2=80=93?= =?UTF-8?q?=C2=A0fixed=20version=20published=20(dart-lang/typed=5Fdata#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/typed_data/pubspec.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 24b0adc2..94646ae3 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -12,6 +12,3 @@ environment: dev_dependencies: pedantic: ^1.0.0 test: ^1.0.0 - - # Remove when https://github.com/dart-lang/sdk/issues/39702 is fixed - analyzer: <0.39.2 From 07e695a0fd83af68a81654356517779a729cf1ef Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 13 Jan 2020 11:57:24 -0800 Subject: [PATCH 039/113] Update min SDK to 2.4 (dart-lang/typed_data#24) Related to https://github.com/dart-lang/test/issues/1141 --- pkgs/typed_data/.travis.yml | 2 +- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index e9ef0bf6..1c702c8a 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,6 +1,6 @@ language: dart dart: - - 2.3.0 + - 2.4.0 - dev dart_task: diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index bd426fec..f6f0c0d2 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.7-dev + +* Update min Dart SDK to `2.4.0`. + ## 1.1.6 * Set max SDK version to `<3.0.0`, and adjust other dependencies. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 94646ae3..1a4cd2cd 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.1.6 +version: 1.1.7-dev description: >- Utility functions and classes related to the dart:typed_data library. @@ -7,7 +7,7 @@ author: Dart Team homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.3.0 <3.0.0' + sdk: '>=2.4.0 <3.0.0' dev_dependencies: pedantic: ^1.0.0 From b1062e781e56bbb8098abe14e9e0d6e737d49d3c Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 15 Jan 2020 11:46:03 -0800 Subject: [PATCH 040/113] Fix a couple lints --- pkgs/typed_data/lib/src/typed_queue.dart | 2 +- pkgs/typed_data/test/queue_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index df91e358..8d83944d 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -647,7 +647,7 @@ int _nextPowerOf2(int number) { assert(number > 0); number = (number << 1) - 1; for (;;) { - int nextNumber = number & (number - 1); + var nextNumber = number & (number - 1); if (nextNumber == 0) return number; number = nextNumber; } diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index 6b6daf94..82d96f68 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -264,7 +264,7 @@ void main() { /// Runs [callback] in multiple tests, all with queues containing numbers from /// one through 15 in various different internal states. -void forEachInternalRepresentation(void callback(Uint8Queue queue)) { +void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { // Test with a queue whose internal table has plenty of room. group("for a queue that's below capacity", () { // Test with a queue whose elements are in one contiguous block, so `_head < From a3fcc1fa84d73693369a2b7aef2c7cb531b637a2 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 15 Jan 2020 12:29:59 -0800 Subject: [PATCH 041/113] dartfix --- pkgs/typed_data/lib/src/typed_queue.dart | 56 +++++++++++-- pkgs/typed_data/lib/typed_data.dart | 4 +- pkgs/typed_data/test/queue_test.dart | 102 +++++++++++------------ 3 files changed, 102 insertions(+), 60 deletions(-) diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 8d83944d..2ac68907 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -2,10 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import "dart:collection"; -import "dart:typed_data"; +import 'dart:collection'; +import 'dart:typed_data'; -import "package:collection/collection.dart"; +import 'package:collection/collection.dart'; import '../typed_buffers.dart'; @@ -27,17 +27,20 @@ abstract class _TypedQueue> with ListMixin { // Iterable interface. + @override int get length => (_tail - _head) & (_table.length - 1); + @override List toList({bool growable = true}) { var list = growable ? _createBuffer(length) : _createList(length); _writeToList(list); return list; } + @override QueueList cast() { if (this is QueueList) return this as QueueList; - throw UnsupportedError("$this cannot be cast to the desired type."); + throw UnsupportedError('$this cannot be cast to the desired type.'); } @deprecated @@ -58,24 +61,27 @@ abstract class _TypedQueue> with ListMixin { } E removeFirst() { - if (_head == _tail) throw StateError("No element"); + if (_head == _tail) throw StateError('No element'); var result = _table[_head]; _head = (_head + 1) & (_table.length - 1); return result; } + @override E removeLast() { - if (_head == _tail) throw StateError("No element"); + if (_head == _tail) throw StateError('No element'); _tail = (_tail - 1) & (_table.length - 1); return _table[_tail]; } // List interface. + @override void add(E value) => addLast(value); + @override set length(int value) { - RangeError.checkNotNegative(value, "length"); + RangeError.checkNotNegative(value, 'length'); var delta = value - length; if (delta >= 0) { @@ -92,16 +98,19 @@ abstract class _TypedQueue> with ListMixin { } } + @override E operator [](int index) { RangeError.checkValidIndex(index, this, null, length); return _table[(_head + index) & (_table.length - 1)]; } + @override void operator []=(int index, E value) { RangeError.checkValidIndex(index, this); _table[(_head + index) & (_table.length - 1)] = value; } + @override void removeRange(int start, int end) { var length = this.length; RangeError.checkValidRange(start, end, length); @@ -131,6 +140,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { RangeError.checkValidRange(start, end, length); if (start == end) return; @@ -230,6 +240,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override void fillRange(int start, int end, [E value]) { var startInTable = (_head + start) & (_table.length - 1); var endInTable = (_head + end) & (_table.length - 1); @@ -241,6 +252,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override L sublist(int start, [int end]) { var length = this.length; end = RangeError.checkValidRange(start, end, length); @@ -326,6 +338,7 @@ abstract class _TypedQueue> with ListMixin { abstract class _IntQueue> extends _TypedQueue { _IntQueue(List queue) : super(queue); + @override int get _defaultValue => 0; } @@ -333,6 +346,7 @@ abstract class _FloatQueue> extends _TypedQueue { _FloatQueue(List queue) : super(queue); + @override double get _defaultValue => 0.0; } @@ -353,7 +367,9 @@ class Uint8Queue extends _IntQueue implements QueueList { factory Uint8Queue.fromList(List elements) => Uint8Queue(elements.length)..addAll(elements); + @override Uint8List _createList(int size) => Uint8List(size); + @override Uint8Buffer _createBuffer(int size) => Uint8Buffer(size); } @@ -375,7 +391,9 @@ class Int8Queue extends _IntQueue implements QueueList { factory Int8Queue.fromList(List elements) => Int8Queue(elements.length)..addAll(elements); + @override Int8List _createList(int size) => Int8List(size); + @override Int8Buffer _createBuffer(int size) => Int8Buffer(size); } @@ -399,7 +417,9 @@ class Uint8ClampedQueue extends _IntQueue factory Uint8ClampedQueue.fromList(List elements) => Uint8ClampedQueue(elements.length)..addAll(elements); + @override Uint8ClampedList _createList(int size) => Uint8ClampedList(size); + @override Uint8ClampedBuffer _createBuffer(int size) => Uint8ClampedBuffer(size); } @@ -420,7 +440,9 @@ class Uint16Queue extends _IntQueue implements QueueList { factory Uint16Queue.fromList(List elements) => Uint16Queue(elements.length)..addAll(elements); + @override Uint16List _createList(int size) => Uint16List(size); + @override Uint16Buffer _createBuffer(int size) => Uint16Buffer(size); } @@ -442,7 +464,9 @@ class Int16Queue extends _IntQueue implements QueueList { factory Int16Queue.fromList(List elements) => Int16Queue(elements.length)..addAll(elements); + @override Int16List _createList(int size) => Int16List(size); + @override Int16Buffer _createBuffer(int size) => Int16Buffer(size); } @@ -463,7 +487,9 @@ class Uint32Queue extends _IntQueue implements QueueList { factory Uint32Queue.fromList(List elements) => Uint32Queue(elements.length)..addAll(elements); + @override Uint32List _createList(int size) => Uint32List(size); + @override Uint32Buffer _createBuffer(int size) => Uint32Buffer(size); } @@ -485,7 +511,9 @@ class Int32Queue extends _IntQueue implements QueueList { factory Int32Queue.fromList(List elements) => Int32Queue(elements.length)..addAll(elements); + @override Int32List _createList(int size) => Int32List(size); + @override Int32Buffer _createBuffer(int size) => Int32Buffer(size); } @@ -507,7 +535,9 @@ class Uint64Queue extends _IntQueue implements QueueList { factory Uint64Queue.fromList(List elements) => Uint64Queue(elements.length)..addAll(elements); + @override Uint64List _createList(int size) => Uint64List(size); + @override Uint64Buffer _createBuffer(int size) => Uint64Buffer(size); } @@ -529,7 +559,9 @@ class Int64Queue extends _IntQueue implements QueueList { factory Int64Queue.fromList(List elements) => Int64Queue(elements.length)..addAll(elements); + @override Int64List _createList(int size) => Int64List(size); + @override Int64Buffer _createBuffer(int size) => Int64Buffer(size); } @@ -552,7 +584,9 @@ class Float32Queue extends _FloatQueue factory Float32Queue.fromList(List elements) => Float32Queue(elements.length)..addAll(elements); + @override Float32List _createList(int size) => Float32List(size); + @override Float32Buffer _createBuffer(int size) => Float32Buffer(size); } @@ -572,7 +606,9 @@ class Float64Queue extends _FloatQueue factory Float64Queue.fromList(List elements) => Float64Queue(elements.length)..addAll(elements); + @override Float64List _createList(int size) => Float64List(size); + @override Float64Buffer _createBuffer(int size) => Float64Buffer(size); } @@ -593,8 +629,11 @@ class Int32x4Queue extends _TypedQueue factory Int32x4Queue.fromList(List elements) => Int32x4Queue(elements.length)..addAll(elements); + @override Int32x4List _createList(int size) => Int32x4List(size); + @override Int32x4Buffer _createBuffer(int size) => Int32x4Buffer(size); + @override Int32x4 get _defaultValue => _zero; } @@ -613,8 +652,11 @@ class Float32x4Queue extends _TypedQueue factory Float32x4Queue.fromList(List elements) => Float32x4Queue(elements.length)..addAll(elements); + @override Float32x4List _createList(int size) => Float32x4List(size); + @override Float32x4Buffer _createBuffer(int size) => Float32x4Buffer(size); + @override Float32x4 get _defaultValue => Float32x4.zero(); } diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index b23fdf06..1dc9fc8b 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -5,5 +5,5 @@ /// Utilities and functionality related to the "dart:typed_data" library. library typed_data; -export "src/typed_queue.dart"; -export "typed_buffers.dart"; +export 'src/typed_queue.dart'; +export 'typed_buffers.dart'; diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index 82d96f68..14cc2d63 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -4,96 +4,96 @@ // ignore_for_file: avoid_function_literals_in_foreach_calls -import "package:test/test.dart"; +import 'package:test/test.dart'; -import "package:typed_data/typed_data.dart"; +import 'package:typed_data/typed_data.dart'; /// The initial capacity of queues if the user doesn't specify one. const capacity = 16; void main() { - group("Uint8Queue()", () { - test("creates an empty Uint8Queue", () { + group('Uint8Queue()', () { + test('creates an empty Uint8Queue', () { expect(Uint8Queue(), isEmpty); }); - test("takes an initial capacity", () { + test('takes an initial capacity', () { expect(Uint8Queue(100), isEmpty); }); }); - group("add() adds an element to the end", () { + group('add() adds an element to the end', () { forEachInternalRepresentation((queue) { queue.add(16); expect(queue, equals(oneThrough(capacity))); }); }); - group("addFirst() adds an element to the beginning", () { + group('addFirst() adds an element to the beginning', () { forEachInternalRepresentation((queue) { queue.addFirst(0); expect(queue, equals([0, ...oneThrough(capacity - 1)])); }); }); - group("removeFirst() removes an element from the beginning", () { + group('removeFirst() removes an element from the beginning', () { forEachInternalRepresentation((queue) { expect(queue.removeFirst(), equals(1)); expect(queue, equals(oneThrough(capacity - 1).skip(1))); }); - test("throws a StateError for an empty queue", () { + test('throws a StateError for an empty queue', () { expect(Uint8Queue().removeFirst, throwsStateError); }); }); - group("removeLast() removes an element from the end", () { + group('removeLast() removes an element from the end', () { forEachInternalRepresentation((queue) { expect(queue.removeLast(), equals(15)); expect(queue, equals(oneThrough(capacity - 2))); }); - test("throws a StateError for an empty queue", () { + test('throws a StateError for an empty queue', () { expect(Uint8Queue().removeLast, throwsStateError); }); }); - group("removeRange()", () { - group("removes a prefix", () { + group('removeRange()', () { + group('removes a prefix', () { forEachInternalRepresentation((queue) { queue.removeRange(0, 5); expect(queue, equals(oneThrough(capacity - 1).skip(5))); }); }); - group("removes a suffix", () { + group('removes a suffix', () { forEachInternalRepresentation((queue) { queue.removeRange(10, 15); expect(queue, equals(oneThrough(capacity - 6))); }); }); - group("removes from the middle", () { + group('removes from the middle', () { forEachInternalRepresentation((queue) { queue.removeRange(5, 10); expect(queue, equals([1, 2, 3, 4, 5, 11, 12, 13, 14, 15])); }); }); - group("removes everything", () { + group('removes everything', () { forEachInternalRepresentation((queue) { queue.removeRange(0, 15); expect(queue, isEmpty); }); }); - test("throws a RangeError for an invalid range", () { + test('throws a RangeError for an invalid range', () { expect(() => Uint8Queue().removeRange(0, 1), throwsRangeError); }); }); - group("setRange()", () { - group("sets a range to the contents of an iterable", () { + group('setRange()', () { + group('sets a range to the contents of an iterable', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n), 2); expect(queue, @@ -101,7 +101,7 @@ void main() { }); }); - group("sets a range to the contents of a list", () { + group('sets a range to the contents of a list', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n).toList(), 2); expect(queue, @@ -110,7 +110,7 @@ void main() { }); group( - "sets a range to a section of the same queue overlapping at the beginning", + 'sets a range to a section of the same queue overlapping at the beginning', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 2); @@ -118,7 +118,7 @@ void main() { }); }); - group("sets a range to a section of the same queue overlapping at the end", + group('sets a range to a section of the same queue overlapping at the end', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 6); @@ -126,33 +126,33 @@ void main() { }); }); - test("throws a RangeError for an invalid range", () { + test('throws a RangeError for an invalid range', () { expect(() => Uint8Queue().setRange(0, 1, [1]), throwsRangeError); }); }); - group("length returns the length", () { + group('length returns the length', () { forEachInternalRepresentation((queue) { expect(queue.length, equals(15)); }); }); - group("length=", () { - group("empties", () { + group('length=', () { + group('empties', () { forEachInternalRepresentation((queue) { queue.length = 0; expect(queue, isEmpty); }); }); - group("shrinks", () { + group('shrinks', () { forEachInternalRepresentation((queue) { queue.length = 5; expect(queue, equals([1, 2, 3, 4, 5])); }); }); - group("grows", () { + group('grows', () { forEachInternalRepresentation((queue) { queue.length = 20; expect( @@ -162,7 +162,7 @@ void main() { }); }); - group("zeroes out existing data", () { + group('zeroes out existing data', () { forEachInternalRepresentation((queue) { queue.length = 0; queue.length = 15; @@ -170,13 +170,13 @@ void main() { }); }); - test("throws a RangeError if length is less than 0", () { + test('throws a RangeError if length is less than 0', () { expect(() => Uint8Queue().length = -1, throwsRangeError); }); }); - group("[]", () { - group("returns individual entries", () { + group('[]', () { + group('returns individual entries', () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { expect(queue[i], equals(i + 1)); @@ -184,21 +184,21 @@ void main() { }); }); - test("throws a RangeError if the index is less than 0", () { + test('throws a RangeError if the index is less than 0', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[-1], throwsRangeError); }); test( - "throws a RangeError if the index is greater than or equal to the " - "length", () { + 'throws a RangeError if the index is greater than or equal to the ' + 'length', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[3], throwsRangeError); }); }); - group("[]=", () { - group("sets individual entries", () { + group('[]=', () { + group('sets individual entries', () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { queue[i] = 100 + i; @@ -207,7 +207,7 @@ void main() { }); }); - test("throws a RangeError if the index is less than 0", () { + test('throws a RangeError if the index is less than 0', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[-1] = 0; @@ -215,8 +215,8 @@ void main() { }); test( - "throws a RangeError if the index is greater than or equal to the " - "length", () { + 'throws a RangeError if the index is greater than or equal to the ' + 'length', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[3] = 4; @@ -224,38 +224,38 @@ void main() { }); }); - group("throws a modification error for", () { + group('throws a modification error for', () { Uint8Queue queue; setUp(() { queue = Uint8Queue.fromList([1, 2, 3]); }); - test("add", () { + test('add', () { expect(() => queue.forEach((_) => queue.add(4)), throwsConcurrentModificationError); }); - test("addAll", () { + test('addAll', () { expect(() => queue.forEach((_) => queue.addAll([4, 5, 6])), throwsConcurrentModificationError); }); - test("addFirst", () { + test('addFirst', () { expect(() => queue.forEach((_) => queue.addFirst(0)), throwsConcurrentModificationError); }); - test("removeFirst", () { + test('removeFirst', () { expect(() => queue.forEach((_) => queue.removeFirst()), throwsConcurrentModificationError); }); - test("removeLast", () { + test('removeLast', () { expect(() => queue.forEach((_) => queue.removeLast()), throwsConcurrentModificationError); }); - test("length=", () { + test('length=', () { expect(() => queue.forEach((_) => queue.length = 1), throwsConcurrentModificationError); }); @@ -269,13 +269,13 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { group("for a queue that's below capacity", () { // Test with a queue whose elements are in one contiguous block, so `_head < // _tail`. - test("with contiguous elements", () { + test('with contiguous elements', () { callback(Uint8Queue(capacity * 2)..addAll(oneThrough(capacity - 1))); }); // Test with a queue whose elements are split across the ends of the table, // so `_head > _tail`. - test("with an internal gap", () { + test('with an internal gap', () { var queue = Uint8Queue(capacity * 2); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); @@ -290,11 +290,11 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { // Test with a queue whose internal table will need to expand if one more // element is added. group("for a queue that's at capacity", () { - test("with contiguous elements", () { + test('with contiguous elements', () { callback(Uint8Queue()..addAll(oneThrough(capacity - 1))); }); - test("with an internal gap", () { + test('with an internal gap', () { var queue = Uint8Queue(); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); From 8c2aa8f2112895423452a3e5faff4cc6866d96c9 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 16 Jan 2020 13:03:21 -0800 Subject: [PATCH 042/113] Revert "dartfix" This reverts commit a3fcc1fa84d73693369a2b7aef2c7cb531b637a2. --- pkgs/typed_data/lib/src/typed_queue.dart | 56 ++----------- pkgs/typed_data/lib/typed_data.dart | 4 +- pkgs/typed_data/test/queue_test.dart | 102 +++++++++++------------ 3 files changed, 60 insertions(+), 102 deletions(-) diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 2ac68907..8d83944d 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -2,10 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:collection'; -import 'dart:typed_data'; +import "dart:collection"; +import "dart:typed_data"; -import 'package:collection/collection.dart'; +import "package:collection/collection.dart"; import '../typed_buffers.dart'; @@ -27,20 +27,17 @@ abstract class _TypedQueue> with ListMixin { // Iterable interface. - @override int get length => (_tail - _head) & (_table.length - 1); - @override List toList({bool growable = true}) { var list = growable ? _createBuffer(length) : _createList(length); _writeToList(list); return list; } - @override QueueList cast() { if (this is QueueList) return this as QueueList; - throw UnsupportedError('$this cannot be cast to the desired type.'); + throw UnsupportedError("$this cannot be cast to the desired type."); } @deprecated @@ -61,27 +58,24 @@ abstract class _TypedQueue> with ListMixin { } E removeFirst() { - if (_head == _tail) throw StateError('No element'); + if (_head == _tail) throw StateError("No element"); var result = _table[_head]; _head = (_head + 1) & (_table.length - 1); return result; } - @override E removeLast() { - if (_head == _tail) throw StateError('No element'); + if (_head == _tail) throw StateError("No element"); _tail = (_tail - 1) & (_table.length - 1); return _table[_tail]; } // List interface. - @override void add(E value) => addLast(value); - @override set length(int value) { - RangeError.checkNotNegative(value, 'length'); + RangeError.checkNotNegative(value, "length"); var delta = value - length; if (delta >= 0) { @@ -98,19 +92,16 @@ abstract class _TypedQueue> with ListMixin { } } - @override E operator [](int index) { RangeError.checkValidIndex(index, this, null, length); return _table[(_head + index) & (_table.length - 1)]; } - @override void operator []=(int index, E value) { RangeError.checkValidIndex(index, this); _table[(_head + index) & (_table.length - 1)] = value; } - @override void removeRange(int start, int end) { var length = this.length; RangeError.checkValidRange(start, end, length); @@ -140,7 +131,6 @@ abstract class _TypedQueue> with ListMixin { } } - @override void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { RangeError.checkValidRange(start, end, length); if (start == end) return; @@ -240,7 +230,6 @@ abstract class _TypedQueue> with ListMixin { } } - @override void fillRange(int start, int end, [E value]) { var startInTable = (_head + start) & (_table.length - 1); var endInTable = (_head + end) & (_table.length - 1); @@ -252,7 +241,6 @@ abstract class _TypedQueue> with ListMixin { } } - @override L sublist(int start, [int end]) { var length = this.length; end = RangeError.checkValidRange(start, end, length); @@ -338,7 +326,6 @@ abstract class _TypedQueue> with ListMixin { abstract class _IntQueue> extends _TypedQueue { _IntQueue(List queue) : super(queue); - @override int get _defaultValue => 0; } @@ -346,7 +333,6 @@ abstract class _FloatQueue> extends _TypedQueue { _FloatQueue(List queue) : super(queue); - @override double get _defaultValue => 0.0; } @@ -367,9 +353,7 @@ class Uint8Queue extends _IntQueue implements QueueList { factory Uint8Queue.fromList(List elements) => Uint8Queue(elements.length)..addAll(elements); - @override Uint8List _createList(int size) => Uint8List(size); - @override Uint8Buffer _createBuffer(int size) => Uint8Buffer(size); } @@ -391,9 +375,7 @@ class Int8Queue extends _IntQueue implements QueueList { factory Int8Queue.fromList(List elements) => Int8Queue(elements.length)..addAll(elements); - @override Int8List _createList(int size) => Int8List(size); - @override Int8Buffer _createBuffer(int size) => Int8Buffer(size); } @@ -417,9 +399,7 @@ class Uint8ClampedQueue extends _IntQueue factory Uint8ClampedQueue.fromList(List elements) => Uint8ClampedQueue(elements.length)..addAll(elements); - @override Uint8ClampedList _createList(int size) => Uint8ClampedList(size); - @override Uint8ClampedBuffer _createBuffer(int size) => Uint8ClampedBuffer(size); } @@ -440,9 +420,7 @@ class Uint16Queue extends _IntQueue implements QueueList { factory Uint16Queue.fromList(List elements) => Uint16Queue(elements.length)..addAll(elements); - @override Uint16List _createList(int size) => Uint16List(size); - @override Uint16Buffer _createBuffer(int size) => Uint16Buffer(size); } @@ -464,9 +442,7 @@ class Int16Queue extends _IntQueue implements QueueList { factory Int16Queue.fromList(List elements) => Int16Queue(elements.length)..addAll(elements); - @override Int16List _createList(int size) => Int16List(size); - @override Int16Buffer _createBuffer(int size) => Int16Buffer(size); } @@ -487,9 +463,7 @@ class Uint32Queue extends _IntQueue implements QueueList { factory Uint32Queue.fromList(List elements) => Uint32Queue(elements.length)..addAll(elements); - @override Uint32List _createList(int size) => Uint32List(size); - @override Uint32Buffer _createBuffer(int size) => Uint32Buffer(size); } @@ -511,9 +485,7 @@ class Int32Queue extends _IntQueue implements QueueList { factory Int32Queue.fromList(List elements) => Int32Queue(elements.length)..addAll(elements); - @override Int32List _createList(int size) => Int32List(size); - @override Int32Buffer _createBuffer(int size) => Int32Buffer(size); } @@ -535,9 +507,7 @@ class Uint64Queue extends _IntQueue implements QueueList { factory Uint64Queue.fromList(List elements) => Uint64Queue(elements.length)..addAll(elements); - @override Uint64List _createList(int size) => Uint64List(size); - @override Uint64Buffer _createBuffer(int size) => Uint64Buffer(size); } @@ -559,9 +529,7 @@ class Int64Queue extends _IntQueue implements QueueList { factory Int64Queue.fromList(List elements) => Int64Queue(elements.length)..addAll(elements); - @override Int64List _createList(int size) => Int64List(size); - @override Int64Buffer _createBuffer(int size) => Int64Buffer(size); } @@ -584,9 +552,7 @@ class Float32Queue extends _FloatQueue factory Float32Queue.fromList(List elements) => Float32Queue(elements.length)..addAll(elements); - @override Float32List _createList(int size) => Float32List(size); - @override Float32Buffer _createBuffer(int size) => Float32Buffer(size); } @@ -606,9 +572,7 @@ class Float64Queue extends _FloatQueue factory Float64Queue.fromList(List elements) => Float64Queue(elements.length)..addAll(elements); - @override Float64List _createList(int size) => Float64List(size); - @override Float64Buffer _createBuffer(int size) => Float64Buffer(size); } @@ -629,11 +593,8 @@ class Int32x4Queue extends _TypedQueue factory Int32x4Queue.fromList(List elements) => Int32x4Queue(elements.length)..addAll(elements); - @override Int32x4List _createList(int size) => Int32x4List(size); - @override Int32x4Buffer _createBuffer(int size) => Int32x4Buffer(size); - @override Int32x4 get _defaultValue => _zero; } @@ -652,11 +613,8 @@ class Float32x4Queue extends _TypedQueue factory Float32x4Queue.fromList(List elements) => Float32x4Queue(elements.length)..addAll(elements); - @override Float32x4List _createList(int size) => Float32x4List(size); - @override Float32x4Buffer _createBuffer(int size) => Float32x4Buffer(size); - @override Float32x4 get _defaultValue => Float32x4.zero(); } diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index 1dc9fc8b..b23fdf06 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -5,5 +5,5 @@ /// Utilities and functionality related to the "dart:typed_data" library. library typed_data; -export 'src/typed_queue.dart'; -export 'typed_buffers.dart'; +export "src/typed_queue.dart"; +export "typed_buffers.dart"; diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index 14cc2d63..82d96f68 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -4,96 +4,96 @@ // ignore_for_file: avoid_function_literals_in_foreach_calls -import 'package:test/test.dart'; +import "package:test/test.dart"; -import 'package:typed_data/typed_data.dart'; +import "package:typed_data/typed_data.dart"; /// The initial capacity of queues if the user doesn't specify one. const capacity = 16; void main() { - group('Uint8Queue()', () { - test('creates an empty Uint8Queue', () { + group("Uint8Queue()", () { + test("creates an empty Uint8Queue", () { expect(Uint8Queue(), isEmpty); }); - test('takes an initial capacity', () { + test("takes an initial capacity", () { expect(Uint8Queue(100), isEmpty); }); }); - group('add() adds an element to the end', () { + group("add() adds an element to the end", () { forEachInternalRepresentation((queue) { queue.add(16); expect(queue, equals(oneThrough(capacity))); }); }); - group('addFirst() adds an element to the beginning', () { + group("addFirst() adds an element to the beginning", () { forEachInternalRepresentation((queue) { queue.addFirst(0); expect(queue, equals([0, ...oneThrough(capacity - 1)])); }); }); - group('removeFirst() removes an element from the beginning', () { + group("removeFirst() removes an element from the beginning", () { forEachInternalRepresentation((queue) { expect(queue.removeFirst(), equals(1)); expect(queue, equals(oneThrough(capacity - 1).skip(1))); }); - test('throws a StateError for an empty queue', () { + test("throws a StateError for an empty queue", () { expect(Uint8Queue().removeFirst, throwsStateError); }); }); - group('removeLast() removes an element from the end', () { + group("removeLast() removes an element from the end", () { forEachInternalRepresentation((queue) { expect(queue.removeLast(), equals(15)); expect(queue, equals(oneThrough(capacity - 2))); }); - test('throws a StateError for an empty queue', () { + test("throws a StateError for an empty queue", () { expect(Uint8Queue().removeLast, throwsStateError); }); }); - group('removeRange()', () { - group('removes a prefix', () { + group("removeRange()", () { + group("removes a prefix", () { forEachInternalRepresentation((queue) { queue.removeRange(0, 5); expect(queue, equals(oneThrough(capacity - 1).skip(5))); }); }); - group('removes a suffix', () { + group("removes a suffix", () { forEachInternalRepresentation((queue) { queue.removeRange(10, 15); expect(queue, equals(oneThrough(capacity - 6))); }); }); - group('removes from the middle', () { + group("removes from the middle", () { forEachInternalRepresentation((queue) { queue.removeRange(5, 10); expect(queue, equals([1, 2, 3, 4, 5, 11, 12, 13, 14, 15])); }); }); - group('removes everything', () { + group("removes everything", () { forEachInternalRepresentation((queue) { queue.removeRange(0, 15); expect(queue, isEmpty); }); }); - test('throws a RangeError for an invalid range', () { + test("throws a RangeError for an invalid range", () { expect(() => Uint8Queue().removeRange(0, 1), throwsRangeError); }); }); - group('setRange()', () { - group('sets a range to the contents of an iterable', () { + group("setRange()", () { + group("sets a range to the contents of an iterable", () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n), 2); expect(queue, @@ -101,7 +101,7 @@ void main() { }); }); - group('sets a range to the contents of a list', () { + group("sets a range to the contents of a list", () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n).toList(), 2); expect(queue, @@ -110,7 +110,7 @@ void main() { }); group( - 'sets a range to a section of the same queue overlapping at the beginning', + "sets a range to a section of the same queue overlapping at the beginning", () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 2); @@ -118,7 +118,7 @@ void main() { }); }); - group('sets a range to a section of the same queue overlapping at the end', + group("sets a range to a section of the same queue overlapping at the end", () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 6); @@ -126,33 +126,33 @@ void main() { }); }); - test('throws a RangeError for an invalid range', () { + test("throws a RangeError for an invalid range", () { expect(() => Uint8Queue().setRange(0, 1, [1]), throwsRangeError); }); }); - group('length returns the length', () { + group("length returns the length", () { forEachInternalRepresentation((queue) { expect(queue.length, equals(15)); }); }); - group('length=', () { - group('empties', () { + group("length=", () { + group("empties", () { forEachInternalRepresentation((queue) { queue.length = 0; expect(queue, isEmpty); }); }); - group('shrinks', () { + group("shrinks", () { forEachInternalRepresentation((queue) { queue.length = 5; expect(queue, equals([1, 2, 3, 4, 5])); }); }); - group('grows', () { + group("grows", () { forEachInternalRepresentation((queue) { queue.length = 20; expect( @@ -162,7 +162,7 @@ void main() { }); }); - group('zeroes out existing data', () { + group("zeroes out existing data", () { forEachInternalRepresentation((queue) { queue.length = 0; queue.length = 15; @@ -170,13 +170,13 @@ void main() { }); }); - test('throws a RangeError if length is less than 0', () { + test("throws a RangeError if length is less than 0", () { expect(() => Uint8Queue().length = -1, throwsRangeError); }); }); - group('[]', () { - group('returns individual entries', () { + group("[]", () { + group("returns individual entries", () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { expect(queue[i], equals(i + 1)); @@ -184,21 +184,21 @@ void main() { }); }); - test('throws a RangeError if the index is less than 0', () { + test("throws a RangeError if the index is less than 0", () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[-1], throwsRangeError); }); test( - 'throws a RangeError if the index is greater than or equal to the ' - 'length', () { + "throws a RangeError if the index is greater than or equal to the " + "length", () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[3], throwsRangeError); }); }); - group('[]=', () { - group('sets individual entries', () { + group("[]=", () { + group("sets individual entries", () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { queue[i] = 100 + i; @@ -207,7 +207,7 @@ void main() { }); }); - test('throws a RangeError if the index is less than 0', () { + test("throws a RangeError if the index is less than 0", () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[-1] = 0; @@ -215,8 +215,8 @@ void main() { }); test( - 'throws a RangeError if the index is greater than or equal to the ' - 'length', () { + "throws a RangeError if the index is greater than or equal to the " + "length", () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[3] = 4; @@ -224,38 +224,38 @@ void main() { }); }); - group('throws a modification error for', () { + group("throws a modification error for", () { Uint8Queue queue; setUp(() { queue = Uint8Queue.fromList([1, 2, 3]); }); - test('add', () { + test("add", () { expect(() => queue.forEach((_) => queue.add(4)), throwsConcurrentModificationError); }); - test('addAll', () { + test("addAll", () { expect(() => queue.forEach((_) => queue.addAll([4, 5, 6])), throwsConcurrentModificationError); }); - test('addFirst', () { + test("addFirst", () { expect(() => queue.forEach((_) => queue.addFirst(0)), throwsConcurrentModificationError); }); - test('removeFirst', () { + test("removeFirst", () { expect(() => queue.forEach((_) => queue.removeFirst()), throwsConcurrentModificationError); }); - test('removeLast', () { + test("removeLast", () { expect(() => queue.forEach((_) => queue.removeLast()), throwsConcurrentModificationError); }); - test('length=', () { + test("length=", () { expect(() => queue.forEach((_) => queue.length = 1), throwsConcurrentModificationError); }); @@ -269,13 +269,13 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { group("for a queue that's below capacity", () { // Test with a queue whose elements are in one contiguous block, so `_head < // _tail`. - test('with contiguous elements', () { + test("with contiguous elements", () { callback(Uint8Queue(capacity * 2)..addAll(oneThrough(capacity - 1))); }); // Test with a queue whose elements are split across the ends of the table, // so `_head > _tail`. - test('with an internal gap', () { + test("with an internal gap", () { var queue = Uint8Queue(capacity * 2); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); @@ -290,11 +290,11 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { // Test with a queue whose internal table will need to expand if one more // element is added. group("for a queue that's at capacity", () { - test('with contiguous elements', () { + test("with contiguous elements", () { callback(Uint8Queue()..addAll(oneThrough(capacity - 1))); }); - test('with an internal gap', () { + test("with an internal gap", () { var queue = Uint8Queue(); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); From 22d33421aa9b001dacab374eeeb0a4bc6754178c Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 16 Jan 2020 13:02:28 -0800 Subject: [PATCH 043/113] Avoid newer pedantic lints, per request from @lrhn --- pkgs/typed_data/pubspec.yaml | 2 +- pkgs/typed_data/test/typed_buffers_test.dart | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 7f2a21db..8952141b 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -13,5 +13,5 @@ dependencies: collection: ^1.1.0 dev_dependencies: - pedantic: ^1.0.0 + pedantic: '>=1.7.0 <1.8.0' test: ^1.0.0 diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 3f682b1f..33054520 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -534,11 +534,9 @@ class MatchesInt32x4 extends Matcher { MatchesInt32x4(this.result); - @override Description describe(Description description) => description.add('Int32x4.=='); - @override bool matches(item, Map matchState) { if (item is! Int32x4) return false; Int32x4 value = item; From 1540edb16ffab8d403e3cdce443bdc124d8084b7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 26 Feb 2020 16:01:58 -0800 Subject: [PATCH 044/113] Pin pedantic lints while avoiding version lock Also remove lints duplicated in pkg:pedantic --- pkgs/typed_data/analysis_options.yaml | 28 +++++++-------------------- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 026330a8..5d1b7432 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,11 +1,13 @@ -include: package:pedantic/analysis_options.yaml +include: package:pedantic/analysis_options.1.9.0.yaml + +analyzer: + errors: + annotate_overrides: ignore + prefer_single_quotes: ignore + linter: rules: - #- annotate_overrides - avoid_function_literals_in_foreach_calls - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_relative_lib_imports - avoid_returning_null - avoid_unused_constructor_parameters - await_only_futures @@ -15,43 +17,27 @@ linter: - constant_identifier_names - control_flow_in_finally - directives_ordering - - empty_catches - - empty_constructor_bodies - empty_statements - hash_and_equals - implementation_imports - invariant_booleans - iterable_contains_unrelated_type - - library_names - - library_prefixes - list_remove_unrelated_type - no_adjacent_strings_in_list - non_constant_identifier_names - #- omit_local_variable_types - only_throw_errors - overridden_fields - package_api_docs - package_names - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - prefer_const_constructors - - prefer_final_fields - - prefer_generic_function_type_aliases - prefer_initializing_formals - prefer_interpolation_to_compose_strings - #- prefer_single_quotes - prefer_typing_uninitialized_variables - - slash_for_doc_comments - test_types_in_equals - throw_in_finally - - type_init_formals - unnecessary_brace_in_string_interps - - unnecessary_const - unnecessary_getters_setters - unnecessary_lambdas - - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_statements - - unnecessary_this diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8952141b..698314f0 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -13,5 +13,5 @@ dependencies: collection: ^1.1.0 dev_dependencies: - pedantic: '>=1.7.0 <1.8.0' + pedantic: ^1.9.0 test: ^1.0.0 From fb7999e6e1c536b0423756155e8fdf36dc2b4242 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 26 Feb 2020 16:04:25 -0800 Subject: [PATCH 045/113] Remove author field, flag this as unreleased v1.2.0(-dev) --- pkgs/typed_data/CHANGELOG.md | 2 +- pkgs/typed_data/pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 7edf873b..3a84e591 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0 +## 1.2.0-dev * Add typed queue classes such as `Uint8Queue`. These classes implement both `Queue` and `List` with a highly-efficient typed-data-backed implementation. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 698314f0..2b2d379e 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,8 @@ name: typed_data -version: 1.2.0 +version: 1.2.0-dev description: >- Utility functions and classes related to the dart:typed_data library. -author: Dart Team homepage: https://github.com/dart-lang/typed_data environment: From ae3986cdefaa322bf865b8951b1c44e0c5657030 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Tue, 17 Mar 2020 15:55:46 -0700 Subject: [PATCH 046/113] Migrate to NNBD. --- pkgs/typed_data/analysis_options.yaml | 2 + pkgs/typed_data/lib/src/typed_queue.dart | 45 ++++++++++---------- pkgs/typed_data/lib/typed_buffers.dart | 9 ++-- pkgs/typed_data/pubspec.yaml | 10 ++++- pkgs/typed_data/test/queue_test.dart | 2 +- pkgs/typed_data/test/typed_buffers_test.dart | 12 +++--- 6 files changed, 44 insertions(+), 36 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 5d1b7432..f449081d 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -4,6 +4,8 @@ analyzer: errors: annotate_overrides: ignore prefer_single_quotes: ignore + enable-experiment: + - non-nullable linter: rules: diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 8d83944d..24081bad 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -21,8 +21,9 @@ abstract class _TypedQueue> with ListMixin { int _tail; /// Create an empty queue. - _TypedQueue(this._table) - : _head = 0, + _TypedQueue(List table) + : _table = table as L, + _head = 0, _tail = 0; // Iterable interface. @@ -230,7 +231,7 @@ abstract class _TypedQueue> with ListMixin { } } - void fillRange(int start, int end, [E value]) { + void fillRange(int start, int end, [E? value]) { var startInTable = (_head + start) & (_table.length - 1); var endInTable = (_head + end) & (_table.length - 1); if (startInTable <= endInTable) { @@ -241,12 +242,12 @@ abstract class _TypedQueue> with ListMixin { } } - L sublist(int start, [int end]) { + L sublist(int start, [int? end]) { var length = this.length; - end = RangeError.checkValidRange(start, end, length); + var nonNullEnd = RangeError.checkValidRange(start, end, length); - var list = _createList(end - start); - _writeToList(list, start, end); + var list = _createList(nonNullEnd - start); + _writeToList(list, start, nonNullEnd); return list; } @@ -259,7 +260,7 @@ abstract class _TypedQueue> with ListMixin { /// start)`, but it's more efficient when [target] is typed data. /// /// Returns the number of elements written to [target]. - int _writeToList(List target, [int start, int end]) { + int _writeToList(List target, [int? start, int? end]) { start ??= 0; end ??= length; assert(target.length >= end - start); @@ -346,7 +347,7 @@ abstract class _FloatQueue> class Uint8Queue extends _IntQueue implements QueueList { /// Creates an empty [Uint8Queue] with the given initial internal capacity (in /// elements). - Uint8Queue([int initialCapacity]) + Uint8Queue([int? initialCapacity]) : super(Uint8List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Uint8Queue] with the same length and contents as [elements]. @@ -368,7 +369,7 @@ class Uint8Queue extends _IntQueue implements QueueList { class Int8Queue extends _IntQueue implements QueueList { /// Creates an empty [Int8Queue] with the given initial internal capacity (in /// elements). - Int8Queue([int initialCapacity]) + Int8Queue([int? initialCapacity]) : super(Int8List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Int8Queue] with the same length and contents as [elements]. @@ -391,7 +392,7 @@ class Uint8ClampedQueue extends _IntQueue implements QueueList { /// Creates an empty [Uint8ClampedQueue] with the given initial internal /// capacity (in elements). - Uint8ClampedQueue([int initialCapacity]) + Uint8ClampedQueue([int? initialCapacity]) : super(Uint8ClampedList(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Uint8ClampedQueue] with the same length and contents as @@ -413,7 +414,7 @@ class Uint8ClampedQueue extends _IntQueue class Uint16Queue extends _IntQueue implements QueueList { /// Creates an empty [Uint16Queue] with the given initial internal capacity /// (in elements). - Uint16Queue([int initialCapacity]) + Uint16Queue([int? initialCapacity]) : super(Uint16List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Uint16Queue] with the same length and contents as [elements]. @@ -435,7 +436,7 @@ class Uint16Queue extends _IntQueue implements QueueList { class Int16Queue extends _IntQueue implements QueueList { /// Creates an empty [Int16Queue] with the given initial internal capacity (in /// elements). - Int16Queue([int initialCapacity]) + Int16Queue([int? initialCapacity]) : super(Int16List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Int16Queue] with the same length and contents as [elements]. @@ -456,7 +457,7 @@ class Int16Queue extends _IntQueue implements QueueList { class Uint32Queue extends _IntQueue implements QueueList { /// Creates an empty [Uint32Queue] with the given initial internal capacity /// (in elements). - Uint32Queue([int initialCapacity]) + Uint32Queue([int? initialCapacity]) : super(Uint32List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Uint32Queue] with the same length and contents as [elements]. @@ -478,7 +479,7 @@ class Uint32Queue extends _IntQueue implements QueueList { class Int32Queue extends _IntQueue implements QueueList { /// Creates an empty [Int32Queue] with the given initial internal capacity (in /// elements). - Int32Queue([int initialCapacity]) + Int32Queue([int? initialCapacity]) : super(Int32List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Int32Queue] with the same length and contents as [elements]. @@ -500,7 +501,7 @@ class Int32Queue extends _IntQueue implements QueueList { class Uint64Queue extends _IntQueue implements QueueList { /// Creates an empty [Uint64Queue] with the given initial internal capacity /// (in elements). - Uint64Queue([int initialCapacity]) + Uint64Queue([int? initialCapacity]) : super(Uint64List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Uint64Queue] with the same length and contents as [elements]. @@ -522,7 +523,7 @@ class Uint64Queue extends _IntQueue implements QueueList { class Int64Queue extends _IntQueue implements QueueList { /// Creates an empty [Int64Queue] with the given initial internal capacity (in /// elements). - Int64Queue([int initialCapacity]) + Int64Queue([int? initialCapacity]) : super(Int64List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Int64Queue] with the same length and contents as [elements]. @@ -545,7 +546,7 @@ class Float32Queue extends _FloatQueue implements QueueList { /// Creates an empty [Float32Queue] with the given initial internal capacity /// (in elements). - Float32Queue([int initialCapacity]) + Float32Queue([int? initialCapacity]) : super(Float32List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Float32Queue] with the same length and contents as [elements]. @@ -565,7 +566,7 @@ class Float64Queue extends _FloatQueue implements QueueList { /// Creates an empty [Float64Queue] with the given initial internal capacity /// (in elements). - Float64Queue([int initialCapacity]) + Float64Queue([int? initialCapacity]) : super(Float64List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Float64Queue] with the same length and contents as [elements]. @@ -586,7 +587,7 @@ class Int32x4Queue extends _TypedQueue /// Creates an empty [Int32x4Queue] with the given initial internal capacity /// (in elements). - Int32x4Queue([int initialCapacity]) + Int32x4Queue([int? initialCapacity]) : super(Int32x4List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Int32x4Queue] with the same length and contents as [elements]. @@ -606,7 +607,7 @@ class Float32x4Queue extends _TypedQueue implements QueueList { /// Creates an empty [Float32x4Queue] with the given initial internal capacity (in /// elements). - Float32x4Queue([int initialCapacity]) + Float32x4Queue([int? initialCapacity]) : super(Float32x4List(_chooseRealInitialCapacity(initialCapacity))); /// Creates a [Float32x4Queue] with the same length and contents as [elements]. @@ -623,7 +624,7 @@ const _defaultInitialCapacity = 16; /// Choose the next-highest power of two given a user-specified /// [initialCapacity] for a queue. -int _chooseRealInitialCapacity(int initialCapacity) { +int _chooseRealInitialCapacity(int? initialCapacity) { if (initialCapacity == null || initialCapacity < _defaultInitialCapacity) { return _defaultInitialCapacity; } else if (!_isPowerOf2(initialCapacity)) { diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 17964c28..e9bc2429 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -93,7 +93,7 @@ abstract class _TypedDataBuffer extends ListBase { /// least [start] elements, and if [end] is specified, it must be greater than /// or equal to [start] and [values] must have at least [end] elements. @override - void addAll(Iterable values, [int start = 0, int end]) { + void addAll(Iterable values, [int start = 0, int? end]) { RangeError.checkNotNegative(start, 'start'); if (end != null && start > end) { throw RangeError.range(end, start, null, 'end'); @@ -112,7 +112,7 @@ abstract class _TypedDataBuffer extends ListBase { /// least [start] elements, and if [end] is specified, it must be greater than /// or equal to [start] and [values] must have at least [end] elements. @override - void insertAll(int index, Iterable values, [int start = 0, int end]) { + void insertAll(int index, Iterable values, [int start = 0, int? end]) { RangeError.checkValidIndex(index, this, 'index', _length + 1); RangeError.checkNotNegative(start, 'start'); if (end != null) { @@ -187,7 +187,7 @@ abstract class _TypedDataBuffer extends ListBase { /// This allows [addAll] and [insertAll] to share implementation without a /// subclass unexpectedly overriding both when it intended to only override /// [addAll]. - void _addAll(Iterable values, [int start = 0, int end]) { + void _addAll(Iterable values, [int start = 0, int? end]) { if (values is List) end ??= values.length; // If we know the length of the segment to add, do so with [addRange]. This @@ -210,7 +210,6 @@ abstract class _TypedDataBuffer extends ListBase { /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. void _insertKnownLength(int index, Iterable values, int start, int end) { if (values is List) { - end ??= values.length; if (start > values.length || end > values.length) { throw StateError('Too few elements'); } @@ -263,7 +262,7 @@ abstract class _TypedDataBuffer extends ListBase { /// be. If [requiredCapacity] is not null, it will be at least that /// size. It will always have at least have double the capacity of /// the current buffer. - List _createBiggerBuffer(int requiredCapacity) { + List _createBiggerBuffer(int? requiredCapacity) { var newLength = _buffer.length * 2; if (requiredCapacity != null && newLength < requiredCapacity) { newLength = requiredCapacity; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 2b2d379e..5cd4236e 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,12 +1,12 @@ name: typed_data -version: 1.2.0-dev +version: 2.0.0-dev description: >- Utility functions and classes related to the dart:typed_data library. homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.4.0 <3.0.0' + sdk: '>=2.8.0-dev.0 <3.0.0' dependencies: collection: ^1.1.0 @@ -14,3 +14,9 @@ dependencies: dev_dependencies: pedantic: ^1.9.0 test: ^1.0.0 + +#dependency_overrides: +# collection: +# git: +# url: git://github.com/dart-lang/collection.git +# ref: null_safety diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index 82d96f68..ccd93ac8 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -225,7 +225,7 @@ void main() { }); group("throws a modification error for", () { - Uint8Queue queue; + late Uint8Queue queue; setUp(() { queue = Uint8Queue.fromList([1, 2, 3]); }); diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 33054520..fe4a9cfa 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -74,8 +74,8 @@ void initTests(List intSamples) { group('addAll', () { for (var type in ['a list', 'an iterable']) { group('with $type', () { - Iterable source; - Uint8Buffer buffer; + late Iterable source; + late Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; if (type == 'an iterable') { @@ -127,8 +127,8 @@ void initTests(List intSamples) { group('insertAll', () { for (var type in ['a list', 'an iterable']) { group('with $type', () { - Iterable source; - Uint8Buffer buffer; + late Iterable source; + late Uint8Buffer buffer; setUp(() { source = [1, 2, 3, 4, 5]; if (type == 'an iterable') { @@ -373,7 +373,7 @@ void testFloatBuffer( } void testInt(List intSamples, int bits, void Function(int length) buffer, - {String testOn}) { + {String? testOn}) { var min = -(1 << (bits - 1)); var max = -(min + 1); test('Int${bits}Buffer', () { @@ -512,7 +512,7 @@ void testIntBuffer(List intSamples, int bits, int min, int max, } void testUint(List intSamples, int bits, void Function(int length) buffer, - {String testOn}) { + {String? testOn}) { var min = 0; var rounder = uintRounder(bits); var max = rounder(-1); From f5a1d80011613aa9263d9f056647e09245bf6b14 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 20 Mar 2020 12:01:25 -0700 Subject: [PATCH 047/113] Fix a couple of analyzer hints --- pkgs/typed_data/lib/typed_buffers.dart | 2 -- pkgs/typed_data/test/typed_buffers_test.dart | 14 ++++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index e9bc2429..08ce2ff7 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -213,8 +213,6 @@ abstract class _TypedDataBuffer extends ListBase { if (start > values.length || end > values.length) { throw StateError('Too few elements'); } - } else { - assert(end != null); } var valuesLength = end - start; diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index fe4a9cfa..9bec136e 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -537,12 +537,10 @@ class MatchesInt32x4 extends Matcher { Description describe(Description description) => description.add('Int32x4.=='); - bool matches(item, Map matchState) { - if (item is! Int32x4) return false; - Int32x4 value = item; - return result.x == value.x && - result.y == value.y && - result.z == value.z && - result.w == value.w; - } + bool matches(item, Map matchState) => + item is Int32x4 && + result.x == item.x && + result.y == item.y && + result.z == item.z && + result.w == item.w; } From d75a5828e42775191ea764f55b874b9d0593da73 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 20 Mar 2020 12:01:36 -0700 Subject: [PATCH 048/113] change version back to 1.3.0-dev so pub get works --- pkgs/typed_data/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 5cd4236e..8bd1225a 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 2.0.0-dev +version: 1.3.0-dev description: >- Utility functions and classes related to the dart:typed_data library. From 36f82ec0a65151019542d91c9b81d5707e9b7cef Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 20 Mar 2020 14:45:46 -0700 Subject: [PATCH 049/113] Refactor libraries so TypedDataBuffer is public, but hidden (dart-lang/typed_data#27) --- pkgs/typed_data/lib/src/typed_buffer.dart | 426 +++++++++++++++++++ pkgs/typed_data/lib/src/typed_queue.dart | 6 +- pkgs/typed_data/lib/typed_buffers.dart | 423 +----------------- pkgs/typed_data/test/typed_buffers_test.dart | 34 +- 4 files changed, 454 insertions(+), 435 deletions(-) create mode 100644 pkgs/typed_data/lib/src/typed_buffer.dart diff --git a/pkgs/typed_data/lib/src/typed_buffer.dart b/pkgs/typed_data/lib/src/typed_buffer.dart new file mode 100644 index 00000000..f85bd164 --- /dev/null +++ b/pkgs/typed_data/lib/src/typed_buffer.dart @@ -0,0 +1,426 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:collection' show ListBase; +import 'dart:typed_data'; + +abstract class TypedDataBuffer extends ListBase { + static const int _initialLength = 8; + + /// The underlying data buffer. + /// + /// This is always both a List and a TypedData, which we don't have a type + /// for here. For example, for a `Uint8Buffer`, this is a `Uint8List`. + List _buffer; + + /// Returns a view of [_buffer] as a [TypedData]. + TypedData get _typedBuffer => _buffer as TypedData; + + /// The length of the list being built. + int _length; + + TypedDataBuffer(List buffer) + : _buffer = buffer, + _length = buffer.length; + + @override + int get length => _length; + + @override + E operator [](int index) { + if (index >= length) throw RangeError.index(index, this); + return _buffer[index]; + } + + @override + void operator []=(int index, E value) { + if (index >= length) throw RangeError.index(index, this); + _buffer[index] = value; + } + + @override + set length(int newLength) { + if (newLength < _length) { + var defaultValue = _defaultValue; + for (var i = newLength; i < _length; i++) { + _buffer[i] = defaultValue; + } + } else if (newLength > _buffer.length) { + List newBuffer; + if (_buffer.isEmpty) { + newBuffer = _createBuffer(newLength); + } else { + newBuffer = _createBiggerBuffer(newLength); + } + newBuffer.setRange(0, _length, _buffer); + _buffer = newBuffer; + } + _length = newLength; + } + + void _add(E value) { + if (_length == _buffer.length) _grow(_length); + _buffer[_length++] = value; + } + + // We override the default implementation of `add` because it grows the list + // by setting the length in increments of one. We want to grow by doubling + // capacity in most cases. + @override + void add(E value) { + _add(value); + } + + /// Appends all objects of [values] to the end of this buffer. + /// + /// This adds values from [start] (inclusive) to [end] (exclusive) in + /// [values]. If [end] is omitted, it defaults to adding all elements of + /// [values] after [start]. + /// + /// The [start] value must be non-negative. The [values] iterable must have at + /// least [start] elements, and if [end] is specified, it must be greater than + /// or equal to [start] and [values] must have at least [end] elements. + @override + void addAll(Iterable values, [int start = 0, int end]) { + RangeError.checkNotNegative(start, 'start'); + if (end != null && start > end) { + throw RangeError.range(end, start, null, 'end'); + } + + _addAll(values, start, end); + } + + /// Inserts all objects of [values] at position [index] in this list. + /// + /// This adds values from [start] (inclusive) to [end] (exclusive) in + /// [values]. If [end] is omitted, it defaults to adding all elements of + /// [values] after [start]. + /// + /// The [start] value must be non-negative. The [values] iterable must have at + /// least [start] elements, and if [end] is specified, it must be greater than + /// or equal to [start] and [values] must have at least [end] elements. + @override + void insertAll(int index, Iterable values, [int start = 0, int end]) { + RangeError.checkValidIndex(index, this, 'index', _length + 1); + RangeError.checkNotNegative(start, 'start'); + if (end != null) { + if (start > end) { + throw RangeError.range(end, start, null, 'end'); + } + if (start == end) return; + } + + // If we're adding to the end of the list anyway, use [_addAll]. This lets + // us avoid converting [values] into a list even if [end] is null, since we + // can add values iteratively to the end of the list. We can't do so in the + // center because copying the trailing elements every time is non-linear. + if (index == _length) { + _addAll(values, start, end); + return; + } + + if (end == null && values is List) { + end = values.length; + } + if (end != null) { + _insertKnownLength(index, values, start, end); + return; + } + + // Add elements at end, growing as appropriate, then put them back at + // position [index] using flip-by-double-reverse. + var writeIndex = _length; + var skipCount = start; + for (var value in values) { + if (skipCount > 0) { + skipCount--; + continue; + } + if (writeIndex == _buffer.length) { + _grow(writeIndex); + } + _buffer[writeIndex++] = value; + } + + if (skipCount > 0) { + throw StateError('Too few elements'); + } + if (end != null && writeIndex < end) { + throw RangeError.range(end, start, writeIndex, 'end'); + } + + // Swap [index.._length) and [_length..writeIndex) by double-reversing. + _reverse(_buffer, index, _length); + _reverse(_buffer, _length, writeIndex); + _reverse(_buffer, index, writeIndex); + _length = writeIndex; + return; + } + + // Reverses the range [start..end) of buffer. + static void _reverse(List buffer, int start, int end) { + end--; // Point to last element, not after last element. + while (start < end) { + var first = buffer[start]; + var last = buffer[end]; + buffer[end] = first; + buffer[start] = last; + start++; + end--; + } + } + + /// Does the same thing as [addAll]. + /// + /// This allows [addAll] and [insertAll] to share implementation without a + /// subclass unexpectedly overriding both when it intended to only override + /// [addAll]. + void _addAll(Iterable values, [int start = 0, int end]) { + if (values is List) end ??= values.length; + + // If we know the length of the segment to add, do so with [addRange]. This + // way we know how much to grow the buffer in advance, and it may be even + // more efficient for typed data input. + if (end != null) { + _insertKnownLength(_length, values, start, end); + return; + } + + // Otherwise, just add values one at a time. + var i = 0; + for (var value in values) { + if (i >= start) add(value); + i++; + } + if (i < start) throw StateError('Too few elements'); + } + + /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. + void _insertKnownLength(int index, Iterable values, int start, int end) { + if (values is List) { + end ??= values.length; + if (start > values.length || end > values.length) { + throw StateError('Too few elements'); + } + } else { + assert(end != null); + } + + var valuesLength = end - start; + var newLength = _length + valuesLength; + _ensureCapacity(newLength); + + _buffer.setRange( + index + valuesLength, _length + valuesLength, _buffer, index); + _buffer.setRange(index, index + valuesLength, values, start); + _length = newLength; + } + + @override + void insert(int index, E element) { + if (index < 0 || index > _length) { + throw RangeError.range(index, 0, _length); + } + if (_length < _buffer.length) { + _buffer.setRange(index + 1, _length + 1, _buffer, index); + _buffer[index] = element; + _length++; + return; + } + var newBuffer = _createBiggerBuffer(null); + newBuffer.setRange(0, index, _buffer); + newBuffer.setRange(index + 1, _length + 1, _buffer, index); + newBuffer[index] = element; + _length++; + _buffer = newBuffer; + } + + /// Ensures that [_buffer] is at least [requiredCapacity] long, + /// + /// Grows the buffer if necessary, preserving existing data. + void _ensureCapacity(int requiredCapacity) { + if (requiredCapacity <= _buffer.length) return; + var newBuffer = _createBiggerBuffer(requiredCapacity); + newBuffer.setRange(0, _length, _buffer); + _buffer = newBuffer; + } + + /// Create a bigger buffer. + /// + /// This method determines how much bigger a bigger buffer should + /// be. If [requiredCapacity] is not null, it will be at least that + /// size. It will always have at least have double the capacity of + /// the current buffer. + List _createBiggerBuffer(int requiredCapacity) { + var newLength = _buffer.length * 2; + if (requiredCapacity != null && newLength < requiredCapacity) { + newLength = requiredCapacity; + } else if (newLength < _initialLength) { + newLength = _initialLength; + } + return _createBuffer(newLength); + } + + /// Grows the buffer. + /// + /// This copies the first [length] elements into the new buffer. + void _grow(int length) { + _buffer = _createBiggerBuffer(null)..setRange(0, length, _buffer); + } + + @override + void setRange(int start, int end, Iterable source, [int skipCount = 0]) { + if (end > _length) throw RangeError.range(end, 0, _length); + _setRange(start, end, source, skipCount); + } + + /// Like [setRange], but with no bounds checking. + void _setRange(int start, int end, Iterable source, int skipCount) { + if (source is TypedDataBuffer) { + _buffer.setRange(start, end, source._buffer, skipCount); + } else { + _buffer.setRange(start, end, source, skipCount); + } + } + + // TypedData. + + int get elementSizeInBytes => _typedBuffer.elementSizeInBytes; + + int get lengthInBytes => _length * _typedBuffer.elementSizeInBytes; + + int get offsetInBytes => _typedBuffer.offsetInBytes; + + /// Returns the underlying [ByteBuffer]. + /// + /// The returned buffer may be replaced by operations that change the [length] + /// of this list. + /// + /// The buffer may be larger than [lengthInBytes] bytes, but never smaller. + ByteBuffer get buffer => _typedBuffer.buffer; + + // Specialization for the specific type. + + // Return zero for integers, 0.0 for floats, etc. + // Used to fill buffer when changing length. + E get _defaultValue; + + // Create a new typed list to use as buffer. + List _createBuffer(int size); +} + +abstract class _IntBuffer extends TypedDataBuffer { + _IntBuffer(List buffer) : super(buffer); + + @override + int get _defaultValue => 0; +} + +abstract class _FloatBuffer extends TypedDataBuffer { + _FloatBuffer(List buffer) : super(buffer); + + @override + double get _defaultValue => 0.0; +} + +class Uint8Buffer extends _IntBuffer { + Uint8Buffer([int initialLength = 0]) : super(Uint8List(initialLength)); + + @override + Uint8List _createBuffer(int size) => Uint8List(size); +} + +class Int8Buffer extends _IntBuffer { + Int8Buffer([int initialLength = 0]) : super(Int8List(initialLength)); + + @override + Int8List _createBuffer(int size) => Int8List(size); +} + +class Uint8ClampedBuffer extends _IntBuffer { + Uint8ClampedBuffer([int initialLength = 0]) + : super(Uint8ClampedList(initialLength)); + + @override + Uint8ClampedList _createBuffer(int size) => Uint8ClampedList(size); +} + +class Uint16Buffer extends _IntBuffer { + Uint16Buffer([int initialLength = 0]) : super(Uint16List(initialLength)); + + @override + Uint16List _createBuffer(int size) => Uint16List(size); +} + +class Int16Buffer extends _IntBuffer { + Int16Buffer([int initialLength = 0]) : super(Int16List(initialLength)); + + @override + Int16List _createBuffer(int size) => Int16List(size); +} + +class Uint32Buffer extends _IntBuffer { + Uint32Buffer([int initialLength = 0]) : super(Uint32List(initialLength)); + + @override + Uint32List _createBuffer(int size) => Uint32List(size); +} + +class Int32Buffer extends _IntBuffer { + Int32Buffer([int initialLength = 0]) : super(Int32List(initialLength)); + + @override + Int32List _createBuffer(int size) => Int32List(size); +} + +class Uint64Buffer extends _IntBuffer { + Uint64Buffer([int initialLength = 0]) : super(Uint64List(initialLength)); + + @override + Uint64List _createBuffer(int size) => Uint64List(size); +} + +class Int64Buffer extends _IntBuffer { + Int64Buffer([int initialLength = 0]) : super(Int64List(initialLength)); + + @override + Int64List _createBuffer(int size) => Int64List(size); +} + +class Float32Buffer extends _FloatBuffer { + Float32Buffer([int initialLength = 0]) : super(Float32List(initialLength)); + + @override + Float32List _createBuffer(int size) => Float32List(size); +} + +class Float64Buffer extends _FloatBuffer { + Float64Buffer([int initialLength = 0]) : super(Float64List(initialLength)); + + @override + Float64List _createBuffer(int size) => Float64List(size); +} + +class Int32x4Buffer extends TypedDataBuffer { + static final Int32x4 _zero = Int32x4(0, 0, 0, 0); + + Int32x4Buffer([int initialLength = 0]) : super(Int32x4List(initialLength)); + + @override + Int32x4 get _defaultValue => _zero; + + @override + Int32x4List _createBuffer(int size) => Int32x4List(size); +} + +class Float32x4Buffer extends TypedDataBuffer { + Float32x4Buffer([int initialLength = 0]) + : super(Float32x4List(initialLength)); + + @override + Float32x4 get _defaultValue => Float32x4.zero(); + + @override + Float32x4List _createBuffer(int size) => Float32x4List(size); +} diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 8d83944d..13e63d48 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -7,7 +7,7 @@ import "dart:typed_data"; import "package:collection/collection.dart"; -import '../typed_buffers.dart'; +import 'typed_buffer.dart'; /// The shared superclass of all the typed queue subclasses. abstract class _TypedQueue> with ListMixin { @@ -324,14 +324,14 @@ abstract class _TypedQueue> with ListMixin { } abstract class _IntQueue> extends _TypedQueue { - _IntQueue(List queue) : super(queue); + _IntQueue(L queue) : super(queue); int get _defaultValue => 0; } abstract class _FloatQueue> extends _TypedQueue { - _FloatQueue(List queue) : super(queue); + _FloatQueue(L queue) : super(queue); double get _defaultValue => 0.0; } diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index 17964c28..da954347 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -13,425 +13,4 @@ /// be larger than what the list is using. library typed_data.typed_buffers; -import 'dart:collection' show ListBase; -import 'dart:typed_data'; - -abstract class _TypedDataBuffer extends ListBase { - static const int _initialLength = 8; - - /// The underlying data buffer. - /// - /// This is always both a List and a TypedData, which we don't have a type - /// for here. For example, for a `Uint8Buffer`, this is a `Uint8List`. - List _buffer; - - /// Returns a view of [_buffer] as a [TypedData]. - TypedData get _typedBuffer => _buffer as TypedData; - - /// The length of the list being built. - int _length; - - _TypedDataBuffer(List buffer) - : _buffer = buffer, - _length = buffer.length; - - @override - int get length => _length; - - @override - E operator [](int index) { - if (index >= length) throw RangeError.index(index, this); - return _buffer[index]; - } - - @override - void operator []=(int index, E value) { - if (index >= length) throw RangeError.index(index, this); - _buffer[index] = value; - } - - @override - set length(int newLength) { - if (newLength < _length) { - var defaultValue = _defaultValue; - for (var i = newLength; i < _length; i++) { - _buffer[i] = defaultValue; - } - } else if (newLength > _buffer.length) { - List newBuffer; - if (_buffer.isEmpty) { - newBuffer = _createBuffer(newLength); - } else { - newBuffer = _createBiggerBuffer(newLength); - } - newBuffer.setRange(0, _length, _buffer); - _buffer = newBuffer; - } - _length = newLength; - } - - void _add(E value) { - if (_length == _buffer.length) _grow(_length); - _buffer[_length++] = value; - } - - // We override the default implementation of `add` because it grows the list - // by setting the length in increments of one. We want to grow by doubling - // capacity in most cases. - @override - void add(E value) { - _add(value); - } - - /// Appends all objects of [values] to the end of this buffer. - /// - /// This adds values from [start] (inclusive) to [end] (exclusive) in - /// [values]. If [end] is omitted, it defaults to adding all elements of - /// [values] after [start]. - /// - /// The [start] value must be non-negative. The [values] iterable must have at - /// least [start] elements, and if [end] is specified, it must be greater than - /// or equal to [start] and [values] must have at least [end] elements. - @override - void addAll(Iterable values, [int start = 0, int end]) { - RangeError.checkNotNegative(start, 'start'); - if (end != null && start > end) { - throw RangeError.range(end, start, null, 'end'); - } - - _addAll(values, start, end); - } - - /// Inserts all objects of [values] at position [index] in this list. - /// - /// This adds values from [start] (inclusive) to [end] (exclusive) in - /// [values]. If [end] is omitted, it defaults to adding all elements of - /// [values] after [start]. - /// - /// The [start] value must be non-negative. The [values] iterable must have at - /// least [start] elements, and if [end] is specified, it must be greater than - /// or equal to [start] and [values] must have at least [end] elements. - @override - void insertAll(int index, Iterable values, [int start = 0, int end]) { - RangeError.checkValidIndex(index, this, 'index', _length + 1); - RangeError.checkNotNegative(start, 'start'); - if (end != null) { - if (start > end) { - throw RangeError.range(end, start, null, 'end'); - } - if (start == end) return; - } - - // If we're adding to the end of the list anyway, use [_addAll]. This lets - // us avoid converting [values] into a list even if [end] is null, since we - // can add values iteratively to the end of the list. We can't do so in the - // center because copying the trailing elements every time is non-linear. - if (index == _length) { - _addAll(values, start, end); - return; - } - - if (end == null && values is List) { - end = values.length; - } - if (end != null) { - _insertKnownLength(index, values, start, end); - return; - } - - // Add elements at end, growing as appropriate, then put them back at - // position [index] using flip-by-double-reverse. - var writeIndex = _length; - var skipCount = start; - for (var value in values) { - if (skipCount > 0) { - skipCount--; - continue; - } - if (writeIndex == _buffer.length) { - _grow(writeIndex); - } - _buffer[writeIndex++] = value; - } - - if (skipCount > 0) { - throw StateError('Too few elements'); - } - if (end != null && writeIndex < end) { - throw RangeError.range(end, start, writeIndex, 'end'); - } - - // Swap [index.._length) and [_length..writeIndex) by double-reversing. - _reverse(_buffer, index, _length); - _reverse(_buffer, _length, writeIndex); - _reverse(_buffer, index, writeIndex); - _length = writeIndex; - return; - } - - // Reverses the range [start..end) of buffer. - static void _reverse(List buffer, int start, int end) { - end--; // Point to last element, not after last element. - while (start < end) { - var first = buffer[start]; - var last = buffer[end]; - buffer[end] = first; - buffer[start] = last; - start++; - end--; - } - } - - /// Does the same thing as [addAll]. - /// - /// This allows [addAll] and [insertAll] to share implementation without a - /// subclass unexpectedly overriding both when it intended to only override - /// [addAll]. - void _addAll(Iterable values, [int start = 0, int end]) { - if (values is List) end ??= values.length; - - // If we know the length of the segment to add, do so with [addRange]. This - // way we know how much to grow the buffer in advance, and it may be even - // more efficient for typed data input. - if (end != null) { - _insertKnownLength(_length, values, start, end); - return; - } - - // Otherwise, just add values one at a time. - var i = 0; - for (var value in values) { - if (i >= start) add(value); - i++; - } - if (i < start) throw StateError('Too few elements'); - } - - /// Like [insertAll], but with a guaranteed non-`null` [start] and [end]. - void _insertKnownLength(int index, Iterable values, int start, int end) { - if (values is List) { - end ??= values.length; - if (start > values.length || end > values.length) { - throw StateError('Too few elements'); - } - } else { - assert(end != null); - } - - var valuesLength = end - start; - var newLength = _length + valuesLength; - _ensureCapacity(newLength); - - _buffer.setRange( - index + valuesLength, _length + valuesLength, _buffer, index); - _buffer.setRange(index, index + valuesLength, values, start); - _length = newLength; - } - - @override - void insert(int index, E element) { - if (index < 0 || index > _length) { - throw RangeError.range(index, 0, _length); - } - if (_length < _buffer.length) { - _buffer.setRange(index + 1, _length + 1, _buffer, index); - _buffer[index] = element; - _length++; - return; - } - var newBuffer = _createBiggerBuffer(null); - newBuffer.setRange(0, index, _buffer); - newBuffer.setRange(index + 1, _length + 1, _buffer, index); - newBuffer[index] = element; - _length++; - _buffer = newBuffer; - } - - /// Ensures that [_buffer] is at least [requiredCapacity] long, - /// - /// Grows the buffer if necessary, preserving existing data. - void _ensureCapacity(int requiredCapacity) { - if (requiredCapacity <= _buffer.length) return; - var newBuffer = _createBiggerBuffer(requiredCapacity); - newBuffer.setRange(0, _length, _buffer); - _buffer = newBuffer; - } - - /// Create a bigger buffer. - /// - /// This method determines how much bigger a bigger buffer should - /// be. If [requiredCapacity] is not null, it will be at least that - /// size. It will always have at least have double the capacity of - /// the current buffer. - List _createBiggerBuffer(int requiredCapacity) { - var newLength = _buffer.length * 2; - if (requiredCapacity != null && newLength < requiredCapacity) { - newLength = requiredCapacity; - } else if (newLength < _initialLength) { - newLength = _initialLength; - } - return _createBuffer(newLength); - } - - /// Grows the buffer. - /// - /// This copies the first [length] elements into the new buffer. - void _grow(int length) { - _buffer = _createBiggerBuffer(null)..setRange(0, length, _buffer); - } - - @override - void setRange(int start, int end, Iterable source, [int skipCount = 0]) { - if (end > _length) throw RangeError.range(end, 0, _length); - _setRange(start, end, source, skipCount); - } - - /// Like [setRange], but with no bounds checking. - void _setRange(int start, int end, Iterable source, int skipCount) { - if (source is _TypedDataBuffer) { - _buffer.setRange(start, end, source._buffer, skipCount); - } else { - _buffer.setRange(start, end, source, skipCount); - } - } - - // TypedData. - - int get elementSizeInBytes => _typedBuffer.elementSizeInBytes; - - int get lengthInBytes => _length * _typedBuffer.elementSizeInBytes; - - int get offsetInBytes => _typedBuffer.offsetInBytes; - - /// Returns the underlying [ByteBuffer]. - /// - /// The returned buffer may be replaced by operations that change the [length] - /// of this list. - /// - /// The buffer may be larger than [lengthInBytes] bytes, but never smaller. - ByteBuffer get buffer => _typedBuffer.buffer; - - // Specialization for the specific type. - - // Return zero for integers, 0.0 for floats, etc. - // Used to fill buffer when changing length. - E get _defaultValue; - - // Create a new typed list to use as buffer. - List _createBuffer(int size); -} - -abstract class _IntBuffer extends _TypedDataBuffer { - _IntBuffer(List buffer) : super(buffer); - - @override - int get _defaultValue => 0; -} - -abstract class _FloatBuffer extends _TypedDataBuffer { - _FloatBuffer(List buffer) : super(buffer); - - @override - double get _defaultValue => 0.0; -} - -class Uint8Buffer extends _IntBuffer { - Uint8Buffer([int initialLength = 0]) : super(Uint8List(initialLength)); - - @override - Uint8List _createBuffer(int size) => Uint8List(size); -} - -class Int8Buffer extends _IntBuffer { - Int8Buffer([int initialLength = 0]) : super(Int8List(initialLength)); - - @override - Int8List _createBuffer(int size) => Int8List(size); -} - -class Uint8ClampedBuffer extends _IntBuffer { - Uint8ClampedBuffer([int initialLength = 0]) - : super(Uint8ClampedList(initialLength)); - - @override - Uint8ClampedList _createBuffer(int size) => Uint8ClampedList(size); -} - -class Uint16Buffer extends _IntBuffer { - Uint16Buffer([int initialLength = 0]) : super(Uint16List(initialLength)); - - @override - Uint16List _createBuffer(int size) => Uint16List(size); -} - -class Int16Buffer extends _IntBuffer { - Int16Buffer([int initialLength = 0]) : super(Int16List(initialLength)); - - @override - Int16List _createBuffer(int size) => Int16List(size); -} - -class Uint32Buffer extends _IntBuffer { - Uint32Buffer([int initialLength = 0]) : super(Uint32List(initialLength)); - - @override - Uint32List _createBuffer(int size) => Uint32List(size); -} - -class Int32Buffer extends _IntBuffer { - Int32Buffer([int initialLength = 0]) : super(Int32List(initialLength)); - - @override - Int32List _createBuffer(int size) => Int32List(size); -} - -class Uint64Buffer extends _IntBuffer { - Uint64Buffer([int initialLength = 0]) : super(Uint64List(initialLength)); - - @override - Uint64List _createBuffer(int size) => Uint64List(size); -} - -class Int64Buffer extends _IntBuffer { - Int64Buffer([int initialLength = 0]) : super(Int64List(initialLength)); - - @override - Int64List _createBuffer(int size) => Int64List(size); -} - -class Float32Buffer extends _FloatBuffer { - Float32Buffer([int initialLength = 0]) : super(Float32List(initialLength)); - - @override - Float32List _createBuffer(int size) => Float32List(size); -} - -class Float64Buffer extends _FloatBuffer { - Float64Buffer([int initialLength = 0]) : super(Float64List(initialLength)); - - @override - Float64List _createBuffer(int size) => Float64List(size); -} - -class Int32x4Buffer extends _TypedDataBuffer { - static final Int32x4 _zero = Int32x4(0, 0, 0, 0); - - Int32x4Buffer([int initialLength = 0]) : super(Int32x4List(initialLength)); - - @override - Int32x4 get _defaultValue => _zero; - - @override - Int32x4List _createBuffer(int size) => Int32x4List(size); -} - -class Float32x4Buffer extends _TypedDataBuffer { - Float32x4Buffer([int initialLength = 0]) - : super(Float32x4List(initialLength)); - - @override - Float32x4 get _defaultValue => Float32x4.zero(); - - @override - Float32x4List _createBuffer(int size) => Float32x4List(size); -} +export 'src/typed_buffer.dart' hide TypedDataBuffer; diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 33054520..ab36559f 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; import 'package:test/test.dart'; -import 'package:typed_data/typed_buffers.dart'; +import 'package:typed_data/src/typed_buffer.dart'; const List browserSafeIntSamples = [ 0x8000000000000000, // 2^63 @@ -313,7 +313,7 @@ void testFloat32x4Buffer(List floatSamples) { void testFloatBuffer( int bitSize, List samples, - Function() create, + TypedDataBuffer Function() create, double Function(double v) round, ) { test('Float${bitSize}Buffer', () { @@ -372,8 +372,12 @@ void testFloatBuffer( }); } -void testInt(List intSamples, int bits, void Function(int length) buffer, - {String testOn}) { +void testInt( + List intSamples, + int bits, + TypedDataBuffer Function(int length) buffer, { + String testOn, +}) { var min = -(1 << (bits - 1)); var max = -(min + 1); test('Int${bits}Buffer', () { @@ -440,8 +444,14 @@ void testInt32x4Buffer(List intSamples) { }); } -void testIntBuffer(List intSamples, int bits, int min, int max, - Function(int length) create, int Function(int val) round) { +void testIntBuffer( + List intSamples, + int bits, + int min, + int max, + TypedDataBuffer Function(int length) create, + int Function(int val) round, +) { assert(round(min) == min); assert(round(max) == max); // All int buffers default to the value 0. @@ -465,9 +475,9 @@ void testIntBuffer(List intSamples, int bits, int min, int max, buffer.length = 0; expect(buffer.length, equals(0)); - List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); + var samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); for (var value in samples) { - int length = buffer.length; + var length = buffer.length; buffer.add(value); expect(buffer.length, equals(length + 1)); expect(buffer[length], equals(round(value))); @@ -511,8 +521,12 @@ void testIntBuffer(List intSamples, int bits, int min, int max, expect(buffer[1], equals(min)); } -void testUint(List intSamples, int bits, void Function(int length) buffer, - {String testOn}) { +void testUint( + List intSamples, + int bits, + TypedDataBuffer Function(int length) buffer, { + String testOn, +}) { var min = 0; var rounder = uintRounder(bits); var max = rounder(-1); From e6524052efcab0c09f3e896a734aeb4c66bba71c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 20 Mar 2020 16:14:27 -0700 Subject: [PATCH 050/113] Disallow implicit casts in analysis_options (dart-lang/typed_data#28) --- pkgs/typed_data/analysis_options.yaml | 2 ++ pkgs/typed_data/test/typed_buffers_test.dart | 26 +++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 5d1b7432..4a774a7e 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:pedantic/analysis_options.1.9.0.yaml analyzer: + strong-mode: + implicit-casts: false errors: annotate_overrides: ignore prefer_single_quotes: ignore diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index ab36559f..174806b0 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -223,9 +223,9 @@ const floatSamples = [ 16777215.0 ]; -int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; +int clampUint8(int x) => x < 0 ? 0 : x > 255 ? 255 : x; -void doubleEqual(x, y) { +void doubleEqual(x, num y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { @@ -233,7 +233,7 @@ void doubleEqual(x, y) { } } -Rounder intRounder(bits) { +Rounder intRounder(int bits) { var highBit = 1 << (bits - 1); var mask = highBit - 1; return (int x) => (x & mask) - (x & highBit); @@ -243,14 +243,14 @@ double roundToFloat(double value) { return (Float32List(1)..[0] = value)[0]; } -void testFloat32x4Buffer(List floatSamples) { +void testFloat32x4Buffer(List floatSamples) { var float4Samples = []; for (var i = 0; i < floatSamples.length - 3; i++) { float4Samples.add(Float32x4(floatSamples[i], floatSamples[i + 1], floatSamples[i + 2], floatSamples[i + 3])); } - void floatEquals(x, y) { + void floatEquals(x, num y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { @@ -535,7 +535,7 @@ void testUint( }, testOn: testOn); } -Rounder uintRounder(bits) { +Rounder uintRounder(int bits) { var halfbits = (1 << (bits ~/ 2)) - 1; var mask = halfbits | (halfbits << (bits ~/ 2)); return (int x) => x & mask; @@ -551,12 +551,10 @@ class MatchesInt32x4 extends Matcher { Description describe(Description description) => description.add('Int32x4.=='); - bool matches(item, Map matchState) { - if (item is! Int32x4) return false; - Int32x4 value = item; - return result.x == value.x && - result.y == value.y && - result.z == value.z && - result.w == value.w; - } + bool matches(item, Map matchState) => + item is Int32x4 && + result.x == item.x && + result.y == item.y && + result.z == item.z && + result.w == item.w; } From 497508158fe7b0c21504106441eedf9b028ad38f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 May 2020 14:57:31 -0700 Subject: [PATCH 051/113] Update SDK dep and add dependency overrides for null-safe pkg versions --- pkgs/typed_data/pubspec.yaml | 72 +++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8bd1225a..e6440a8a 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -6,7 +6,7 @@ description: >- homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.8.0-dev.0 <3.0.0' + sdk: '>=2.9.0-1 <3.0.0' dependencies: collection: ^1.1.0 @@ -15,8 +15,68 @@ dev_dependencies: pedantic: ^1.9.0 test: ^1.0.0 -#dependency_overrides: -# collection: -# git: -# url: git://github.com/dart-lang/collection.git -# ref: null_safety + +dependency_overrides: + # test: ^1.12.0 + # test_api: ^0.2.14 + # test_core: ^0.3.0 + async: + git: + url: git://github.com/dart-lang/async.git + ref: null_safety + boolean_selector: + git: + url: git://github.com/dart-lang/boolean_selector.git + ref: null_safety + charcode: + git: + url: git://github.com/dart-lang/charcode.git + ref: null_safety + collection: + git: + url: git://github.com/dart-lang/collection.git + ref: null_safety + matcher: + git: + url: git://github.com/dart-lang/matcher.git + ref: null_safety + meta: + git: + url: git://github.com/dart-lang/sdk.git + ref: null_safety-pkgs + path: pkg/meta + path: + git: + url: git://github.com/dart-lang/path.git + ref: null_safety + source_span: + git: + url: git://github.com/dart-lang/source_span.git + ref: null_safety + stack_trace: + git: + url: git://github.com/dart-lang/stack_trace.git + ref: null_safety + string_scanner: + git: + url: git://github.com/dart-lang/string_scanner.git + ref: null_safety + term_glyph: + git: + url: git://github.com/dart-lang/term_glyph.git + ref: null_safety + test_api: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test_api + test_core: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test_core + test: + git: + url: git://github.com/dart-lang/test.git + ref: null_safety + path: pkgs/test From b0e9cd94a303600413a5936479a7060fc0fd6595 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 15 May 2020 16:02:53 -0700 Subject: [PATCH 052/113] Add two more null safe overrides --- pkgs/typed_data/pubspec.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index e6440a8a..8e53b43d 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -49,6 +49,10 @@ dependency_overrides: git: url: git://github.com/dart-lang/path.git ref: null_safety + pedantic: + git: + url: git://github.com/dart-lang/pedantic.git + ref: null_safety source_span: git: url: git://github.com/dart-lang/source_span.git @@ -57,6 +61,10 @@ dependency_overrides: git: url: git://github.com/dart-lang/stack_trace.git ref: null_safety + stream_channel: + git: + url: git://github.com/dart-lang/stream_channel.git + ref: null_safety string_scanner: git: url: git://github.com/dart-lang/string_scanner.git From f9cbdcf49fd5c769fbaeb48573db44dcf4466da8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 18 May 2020 12:27:08 -0700 Subject: [PATCH 053/113] add a few more dependency overrides --- pkgs/typed_data/pubspec.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8e53b43d..02f373b1 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -53,6 +53,10 @@ dependency_overrides: git: url: git://github.com/dart-lang/pedantic.git ref: null_safety + pool: + git: + url: git://github.com/dart-lang/pool.git + ref: null_safety source_span: git: url: git://github.com/dart-lang/source_span.git From f146399af6ba8ae59b2fbb6ee6a6c28e1ab624d7 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Mon, 22 Jun 2020 10:49:42 -0700 Subject: [PATCH 054/113] release 1.2 (dart-lang/typed_data#30) --- pkgs/typed_data/CHANGELOG.md | 2 +- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 3a84e591..7edf873b 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0-dev +## 1.2.0 * Add typed queue classes such as `Uint8Queue`. These classes implement both `Queue` and `List` with a highly-efficient typed-data-backed implementation. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 2b2d379e..564b1a5c 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.2.0-dev +version: 1.2.0 description: >- Utility functions and classes related to the dart:typed_data library. From 5c601d45a95e7646a1e4c5d4f056f597f1e458ac Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 23 Jun 2020 11:36:18 -0700 Subject: [PATCH 055/113] run tests on travis and other prep for merging into master (dart-lang/typed_data#29) * run tests on travis and other prep for merging into master * release 1.2 (dart-lang/typed_data#30) * add web test dep overrides * use latest dev --- pkgs/typed_data/.travis.yml | 43 +++++++++++++++++++++++++++--------- pkgs/typed_data/CHANGELOG.md | 7 ++++-- pkgs/typed_data/pubspec.yaml | 23 +++++++++++++------ 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 0d83a599..7ccf79c3 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,22 +1,43 @@ language: dart dart: - - stable - dev -dart_task: - - test: -p vm - - test: -p firefox - - dartanalyzer: --fatal-infos --fatal-warnings . - -matrix: +jobs: include: - # Only validate formatting using the dev release - - dart: dev - dart_task: dartfmt + - stage: analyze_and_format + name: "Analyze lib/" + dart: dev + os: linux + script: dartanalyzer --fatal-warnings --fatal-infos lib/ + # Dirs outside of `lib` are not supported by allowed_experiments.json + - stage: analyze_and_format + name: "Analyze test/" + dart: dev + os: linux + script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos test/ + - stage: analyze_and_format + name: "Format" + dart: dev + os: linux + script: dartfmt -n --set-exit-if-changed . + - stage: test + name: "Vm Tests" + dart: dev + os: linux + script: pub run --enable-experiment=non-nullable test -p vm + - stage: test + name: "Web Tests" + dart: dev + os: linux + script: pub run --enable-experiment=non-nullable test -p chrome + +stages: + - analyze_and_format + - test # Only building master means that we don't run two builds for each pull request. branches: - only: [master] + only: [master, null_safety] cache: directories: diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 3a84e591..a35d3c16 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,9 +1,12 @@ -## 1.2.0-dev +## 1.3.0-nnbd + +* Migrate to NNBD + +## 1.2.0 * Add typed queue classes such as `Uint8Queue`. These classes implement both `Queue` and `List` with a highly-efficient typed-data-backed implementation. Their `sublist()` methods also return typed data classes. - * Update min Dart SDK to `2.4.0`. ## 1.1.6 diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 02f373b1..7bdb3749 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,25 +1,21 @@ name: typed_data -version: 1.3.0-dev +version: 1.3.0-nnbd description: >- Utility functions and classes related to the dart:typed_data library. homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.9.0-1 <3.0.0' + sdk: '>=2.9.0-18.0 <2.9.0' dependencies: - collection: ^1.1.0 + collection: ^1.15.0-nnbd dev_dependencies: pedantic: ^1.9.0 test: ^1.0.0 - dependency_overrides: - # test: ^1.12.0 - # test_api: ^0.2.14 - # test_core: ^0.3.0 async: git: url: git://github.com/dart-lang/async.git @@ -36,6 +32,11 @@ dependency_overrides: git: url: git://github.com/dart-lang/collection.git ref: null_safety + js: + git: + url: git://github.com/dart-lang/sdk.git + ref: null_safety-pkgs + path: pkg/js matcher: git: url: git://github.com/dart-lang/matcher.git @@ -57,6 +58,14 @@ dependency_overrides: git: url: git://github.com/dart-lang/pool.git ref: null_safety + source_maps: + git: + url: git://github.com/dart-lang/source_maps.git + ref: null_safety + source_map_stack_trace: + git: + url: git://github.com/dart-lang/source_map_stack_trace.git + ref: null_safety source_span: git: url: git://github.com/dart-lang/source_span.git From f7a63f06593ccd84bcb1228d3cf21691f9b91a11 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 8 Jul 2020 11:55:36 -0700 Subject: [PATCH 056/113] restrict the collection dep to not allow stable releases (dart-lang/typed_data#32) --- pkgs/typed_data/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 7bdb3749..53ba24c6 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -9,7 +9,7 @@ environment: sdk: '>=2.9.0-18.0 <2.9.0' dependencies: - collection: ^1.15.0-nnbd + collection: '>=1.15.0-nnbd <1.15.0' dev_dependencies: pedantic: ^1.9.0 From 9089159d9fbff5cee247aa57a829c6464832461f Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 9 Jul 2020 07:51:07 -0700 Subject: [PATCH 057/113] rename version to -nullsafety (dart-lang/typed_data#33) --- pkgs/typed_data/CHANGELOG.md | 2 +- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index a35d3c16..549b1dd6 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.3.0-nnbd +## 1.3.0-nullsafety * Migrate to NNBD diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 53ba24c6..dd4b772c 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.0-nnbd +version: 1.3.0-nullsafety description: >- Utility functions and classes related to the dart:typed_data library. From d046d8155b3f0de7731feaab21ea71afa494211e Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 17 Jul 2020 09:39:31 -0700 Subject: [PATCH 058/113] allow the <=2.9.10 stable sdk and bump version (dart-lang/typed_data#34) --- pkgs/typed_data/CHANGELOG.md | 4 ++ pkgs/typed_data/pubspec.yaml | 71 +++++++++--------------------------- 2 files changed, 21 insertions(+), 54 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 549b1dd6..b8fb9b06 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.1-nullsafety.1 + +* Allow the <=2.9.10 stable sdks. + ## 1.3.0-nullsafety * Migrate to NNBD diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index dd4b772c..4c7e7611 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,15 +1,15 @@ name: typed_data -version: 1.3.0-nullsafety +version: 1.3.0-nullsafety.1 description: >- Utility functions and classes related to the dart:typed_data library. homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.9.0-18.0 <2.9.0' + sdk: '>=2.9.0-18.0 <=2.9.10' dependencies: - collection: '>=1.15.0-nnbd <1.15.0' + collection: '>=1.15.0-nullsafety <1.15.0' dev_dependencies: pedantic: ^1.9.0 @@ -17,87 +17,50 @@ dev_dependencies: dependency_overrides: async: - git: - url: git://github.com/dart-lang/async.git - ref: null_safety + git: git://github.com/dart-lang/async.git boolean_selector: - git: - url: git://github.com/dart-lang/boolean_selector.git - ref: null_safety + git: git://github.com/dart-lang/boolean_selector.git charcode: - git: - url: git://github.com/dart-lang/charcode.git - ref: null_safety - collection: - git: - url: git://github.com/dart-lang/collection.git - ref: null_safety + git: git://github.com/dart-lang/charcode.git js: git: url: git://github.com/dart-lang/sdk.git - ref: null_safety-pkgs path: pkg/js matcher: - git: - url: git://github.com/dart-lang/matcher.git - ref: null_safety + git: git://github.com/dart-lang/matcher.git meta: git: url: git://github.com/dart-lang/sdk.git - ref: null_safety-pkgs path: pkg/meta path: - git: - url: git://github.com/dart-lang/path.git - ref: null_safety + git: git://github.com/dart-lang/path.git pedantic: - git: - url: git://github.com/dart-lang/pedantic.git - ref: null_safety + git: git://github.com/dart-lang/pedantic.git pool: - git: - url: git://github.com/dart-lang/pool.git - ref: null_safety + git: git://github.com/dart-lang/pool.git source_maps: - git: - url: git://github.com/dart-lang/source_maps.git - ref: null_safety + git: git://github.com/dart-lang/source_maps.git source_map_stack_trace: - git: - url: git://github.com/dart-lang/source_map_stack_trace.git - ref: null_safety + git: git://github.com/dart-lang/source_map_stack_trace.git source_span: - git: - url: git://github.com/dart-lang/source_span.git - ref: null_safety + git: git://github.com/dart-lang/source_span.git stack_trace: - git: - url: git://github.com/dart-lang/stack_trace.git - ref: null_safety + git: git://github.com/dart-lang/stack_trace.git stream_channel: - git: - url: git://github.com/dart-lang/stream_channel.git - ref: null_safety + git: git://github.com/dart-lang/stream_channel.git string_scanner: - git: - url: git://github.com/dart-lang/string_scanner.git - ref: null_safety + git: git://github.com/dart-lang/string_scanner.git term_glyph: - git: - url: git://github.com/dart-lang/term_glyph.git - ref: null_safety + git: git://github.com/dart-lang/term_glyph.git test_api: git: url: git://github.com/dart-lang/test.git - ref: null_safety path: pkgs/test_api test_core: git: url: git://github.com/dart-lang/test.git - ref: null_safety path: pkgs/test_core test: git: url: git://github.com/dart-lang/test.git - ref: null_safety path: pkgs/test From 848a60db7e63f16688c05a0bb512812ed498ec47 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 17 Jul 2020 10:07:19 -0700 Subject: [PATCH 059/113] fix changelog typo (dart-lang/typed_data#35) --- pkgs/typed_data/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index b8fb9b06..1bfa9c34 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.3.1-nullsafety.1 +## 1.3.0-nullsafety.1 * Allow the <=2.9.10 stable sdks. From 390f284d4b526a46fca1b39f491bf7421a1b94dc Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 21 Jul 2020 19:39:26 -0700 Subject: [PATCH 060/113] update for the 2.10 dev sdk (dart-lang/typed_data#36) This is in preparation for the actual 2.10 dev sdk release. This package needs to be published and pinned in flutter simultaneously with that release. --- pkgs/typed_data/.travis.yml | 14 +++++++------- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index 7ccf79c3..ca6ce1b3 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,33 +1,33 @@ language: dart dart: - - dev + - preview/raw/2.10.0-0.2-dev jobs: include: - stage: analyze_and_format name: "Analyze lib/" - dart: dev + dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --fatal-warnings --fatal-infos lib/ # Dirs outside of `lib` are not supported by allowed_experiments.json - stage: analyze_and_format name: "Analyze test/" - dart: dev + dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos test/ - stage: analyze_and_format name: "Format" - dart: dev + dart: preview/raw/2.10.0-0.2-dev os: linux script: dartfmt -n --set-exit-if-changed . - stage: test name: "Vm Tests" - dart: dev + dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p vm - stage: test name: "Web Tests" - dart: dev + dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p chrome @@ -37,7 +37,7 @@ stages: # Only building master means that we don't run two builds for each pull request. branches: - only: [master, null_safety] + only: [master] cache: directories: diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 1bfa9c34..b95971e9 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.0-nullsafety.2 + +* Update for the 2.10 dev sdk. + ## 1.3.0-nullsafety.1 * Allow the <=2.9.10 stable sdks. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 4c7e7611..6f209541 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -6,7 +6,8 @@ description: >- homepage: https://github.com/dart-lang/typed_data environment: - sdk: '>=2.9.0-18.0 <=2.9.10' + # This must remain a tight constraint until nnbd is stable + sdk: '>=2.10.0-0 <2.10.0' dependencies: collection: '>=1.15.0-nullsafety <1.15.0' @@ -22,16 +23,20 @@ dependency_overrides: git: git://github.com/dart-lang/boolean_selector.git charcode: git: git://github.com/dart-lang/charcode.git + collection: + git: git://github.com/dart-lang/collection.git js: git: url: git://github.com/dart-lang/sdk.git path: pkg/js + ref: 2-10-pkgs matcher: git: git://github.com/dart-lang/matcher.git meta: git: url: git://github.com/dart-lang/sdk.git path: pkg/meta + ref: 2-10-pkgs path: git: git://github.com/dart-lang/path.git pedantic: From 2a3e3f0554c593c6d69c9fc8844487d073eaf164 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 22 Jul 2020 07:40:30 -0700 Subject: [PATCH 061/113] bump version for release (dart-lang/typed_data#37) --- pkgs/typed_data/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 6f209541..ee0a5f70 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.0-nullsafety.1 +version: 1.3.0-nullsafety.2 description: >- Utility functions and classes related to the dart:typed_data library. From 8a418f56e7f9a96dad2b523f71d97f0ec7f34d6b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 28 Jul 2020 13:55:58 -0700 Subject: [PATCH 062/113] Update travis-ci to test on latest dev (dart-lang/typed_data#38) --- pkgs/typed_data/.travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml index ca6ce1b3..f87ab522 100644 --- a/pkgs/typed_data/.travis.yml +++ b/pkgs/typed_data/.travis.yml @@ -1,33 +1,28 @@ language: dart dart: - - preview/raw/2.10.0-0.2-dev + - dev jobs: include: - stage: analyze_and_format name: "Analyze lib/" - dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --fatal-warnings --fatal-infos lib/ # Dirs outside of `lib` are not supported by allowed_experiments.json - stage: analyze_and_format name: "Analyze test/" - dart: preview/raw/2.10.0-0.2-dev os: linux script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos test/ - stage: analyze_and_format name: "Format" - dart: preview/raw/2.10.0-0.2-dev os: linux script: dartfmt -n --set-exit-if-changed . - stage: test name: "Vm Tests" - dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p vm - stage: test name: "Web Tests" - dart: preview/raw/2.10.0-0.2-dev os: linux script: pub run --enable-experiment=non-nullable test -p chrome From c43744a5527fe084cd6ba7445e1d6090aabdf835 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 28 Jul 2020 20:32:10 -0700 Subject: [PATCH 063/113] Delete .test_config No longer used --- pkgs/typed_data/.test_config | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 pkgs/typed_data/.test_config diff --git a/pkgs/typed_data/.test_config b/pkgs/typed_data/.test_config deleted file mode 100644 index 25355634..00000000 --- a/pkgs/typed_data/.test_config +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test_package": true -} From 2589a1d060397d431c1bc38da05e878d33735784 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 4 Sep 2020 08:59:15 -0700 Subject: [PATCH 064/113] fix formatting --- pkgs/typed_data/test/typed_buffers_test.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index f5aea864..9452ad3c 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -223,7 +223,11 @@ const floatSamples = [ 16777215.0 ]; -int clampUint8(int x) => x < 0 ? 0 : x > 255 ? 255 : x; +int clampUint8(int x) => x < 0 + ? 0 + : x > 255 + ? 255 + : x; void doubleEqual(x, num y) { if (y.isNaN) { From 82779f8f7f4828a517203586a84986e7c9fa0669 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 22 Sep 2020 08:28:57 -0700 Subject: [PATCH 065/113] Prepare for the 2.11 dev SDKs (dart-lang/typed_data#40) Bump the upper bound to allow 2.10 stable and 2.11.0 dev SDK versions. --- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index b95971e9..e03f158b 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.0-nullsafety.3 + +* Allow 2.10 stable and 2.11.0 dev SDK versions. + ## 1.3.0-nullsafety.2 * Update for the 2.10 dev sdk. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index ee0a5f70..a7ce1fe3 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.0-nullsafety.2 +version: 1.3.0-nullsafety.3 description: >- Utility functions and classes related to the dart:typed_data library. @@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/typed_data environment: # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.10.0' + sdk: '>=2.10.0-0 <2.11.0' dependencies: collection: '>=1.15.0-nullsafety <1.15.0' From 5a4afd5d62c3b8f032ca5670d5f73e2ca17d8b26 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 23 Oct 2020 12:39:51 -0700 Subject: [PATCH 066/113] allow the 2.12 prerelease sdks (dart-lang/typed_data#41) --- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index e03f158b..308fd72c 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.0-nullsafety.4 + +* Allow prerelease versions of the `2.12` sdk. + ## 1.3.0-nullsafety.3 * Allow 2.10 stable and 2.11.0 dev SDK versions. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index a7ce1fe3..551ec429 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.0-nullsafety.3 +version: 1.3.0-nullsafety.4 description: >- Utility functions and classes related to the dart:typed_data library. @@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/typed_data environment: # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.11.0' + sdk: '>=2.10.0-0 <2.12.0' dependencies: collection: '>=1.15.0-nullsafety <1.15.0' From 6ca922d997eca1e36eb74017d67186102c252bf8 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 23 Oct 2020 13:00:23 -0700 Subject: [PATCH 067/113] remove git overrides (dart-lang/typed_data#42) --- pkgs/typed_data/pubspec.yaml | 58 ++---------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 551ec429..b5cdf447 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -13,59 +13,5 @@ dependencies: collection: '>=1.15.0-nullsafety <1.15.0' dev_dependencies: - pedantic: ^1.9.0 - test: ^1.0.0 - -dependency_overrides: - async: - git: git://github.com/dart-lang/async.git - boolean_selector: - git: git://github.com/dart-lang/boolean_selector.git - charcode: - git: git://github.com/dart-lang/charcode.git - collection: - git: git://github.com/dart-lang/collection.git - js: - git: - url: git://github.com/dart-lang/sdk.git - path: pkg/js - ref: 2-10-pkgs - matcher: - git: git://github.com/dart-lang/matcher.git - meta: - git: - url: git://github.com/dart-lang/sdk.git - path: pkg/meta - ref: 2-10-pkgs - path: - git: git://github.com/dart-lang/path.git - pedantic: - git: git://github.com/dart-lang/pedantic.git - pool: - git: git://github.com/dart-lang/pool.git - source_maps: - git: git://github.com/dart-lang/source_maps.git - source_map_stack_trace: - git: git://github.com/dart-lang/source_map_stack_trace.git - source_span: - git: git://github.com/dart-lang/source_span.git - stack_trace: - git: git://github.com/dart-lang/stack_trace.git - stream_channel: - git: git://github.com/dart-lang/stream_channel.git - string_scanner: - git: git://github.com/dart-lang/string_scanner.git - term_glyph: - git: git://github.com/dart-lang/term_glyph.git - test_api: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test_api - test_core: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test_core - test: - git: - url: git://github.com/dart-lang/test.git - path: pkgs/test + pedantic: ^1.10.0-nullsafety + test: ^1.16.0-nullsafety From 76dbff898c6a6e3cd2ebcd2e71c6e09e0758c205 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 3 Nov 2020 14:09:52 -0800 Subject: [PATCH 068/113] Bump SDK constraints for pub (dart-lang/typed_data#43) Use a 2.12.0 lower bound since pub does not understand allowed experiments for earlier versions. Use a 3.0.0 upper bound to avoid a warning in pub and to give some flexibility in publishing for stable. --- pkgs/typed_data/CHANGELOG.md | 5 +++++ pkgs/typed_data/pubspec.yaml | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 308fd72c..9aed3a08 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.3.0-nullsafety.5 + +* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release + guidelines. + ## 1.3.0-nullsafety.4 * Allow prerelease versions of the `2.12` sdk. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index b5cdf447..2e8a0fb6 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,13 +1,12 @@ name: typed_data -version: 1.3.0-nullsafety.4 +version: 1.3.0-nullsafety.5 description: >- Utility functions and classes related to the dart:typed_data library. homepage: https://github.com/dart-lang/typed_data environment: - # This must remain a tight constraint until nnbd is stable - sdk: '>=2.10.0-0 <2.12.0' + sdk: ">=2.12.0-0 <3.0.0" dependencies: collection: '>=1.15.0-nullsafety <1.15.0' From b3acec918ae86911bd4ee845387aa117ee7e632b Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Thu, 12 Nov 2020 07:13:57 -0800 Subject: [PATCH 069/113] remove redundant experiment (dart-lang/typed_data#44) --- pkgs/typed_data/analysis_options.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index c03796b6..4a774a7e 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -6,8 +6,6 @@ analyzer: errors: annotate_overrides: ignore prefer_single_quotes: ignore - enable-experiment: - - non-nullable linter: rules: From 78c0b4bae2b40b3032499620e80aaf77d92f4353 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Thu, 14 Jan 2021 17:37:34 +0100 Subject: [PATCH 070/113] Migrate to GitHub Actions (dart-lang/typed_data#45) * Delete .travis.yml --- .../.github/workflows/test-package.yml | 64 +++++++++++++++++++ pkgs/typed_data/.travis.yml | 39 ----------- 2 files changed, 64 insertions(+), 39 deletions(-) create mode 100644 pkgs/typed_data/.github/workflows/test-package.yml delete mode 100644 pkgs/typed_data/.travis.yml diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml new file mode 100644 index 00000000..e55702c2 --- /dev/null +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -0,0 +1,64 @@ +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart dev. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.1 + with: + channel: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Analyze code + run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + + # Run tests on a matrix consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release channel: dev + test: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.1 + with: + channel: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm + if: always() && steps.install.outcome == 'success' + - name: Run Chrome tests + run: dart test --platform chrome + if: always() && steps.install.outcome == 'success' diff --git a/pkgs/typed_data/.travis.yml b/pkgs/typed_data/.travis.yml deleted file mode 100644 index f87ab522..00000000 --- a/pkgs/typed_data/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: dart -dart: - - dev - -jobs: - include: - - stage: analyze_and_format - name: "Analyze lib/" - os: linux - script: dartanalyzer --fatal-warnings --fatal-infos lib/ - # Dirs outside of `lib` are not supported by allowed_experiments.json - - stage: analyze_and_format - name: "Analyze test/" - os: linux - script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos test/ - - stage: analyze_and_format - name: "Format" - os: linux - script: dartfmt -n --set-exit-if-changed . - - stage: test - name: "Vm Tests" - os: linux - script: pub run --enable-experiment=non-nullable test -p vm - - stage: test - name: "Web Tests" - os: linux - script: pub run --enable-experiment=non-nullable test -p chrome - -stages: - - analyze_and_format - - test - -# Only building master means that we don't run two builds for each pull request. -branches: - only: [master] - -cache: - directories: - - $HOME/.pub-cache From 5b9e4eb0b31bf996fcde9415a6d353fbd87835e2 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 2 Feb 2021 11:18:30 -0800 Subject: [PATCH 071/113] Prepare to publish stable null safety (dart-lang/typed_data#46) --- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 9aed3a08..3bc5b717 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.0 + +* Stable release for null safety. + ## 1.3.0-nullsafety.5 * Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 2e8a0fb6..0501c939 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.0-nullsafety.5 +version: 1.3.0 description: >- Utility functions and classes related to the dart:typed_data library. @@ -9,7 +9,7 @@ environment: sdk: ">=2.12.0-0 <3.0.0" dependencies: - collection: '>=1.15.0-nullsafety <1.15.0' + collection: ^1.15.0 dev_dependencies: pedantic: ^1.10.0-nullsafety From 12b30b220a3602c19fa63cd4cb1b4adc24eac7e4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 30 Mar 2021 18:16:04 -0700 Subject: [PATCH 072/113] Latest setup, test on oldest supported SDK (dart-lang/typed_data#47) --- pkgs/typed_data/.github/workflows/test-package.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index e55702c2..cdc25d95 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,9 +23,9 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.1 + - uses: dart-lang/setup-dart@v1.0 with: - channel: ${{ matrix.sdk }} + sdk: ${{ matrix.sdk }} - id: install name: Install dependencies run: dart pub get @@ -47,12 +47,12 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [dev] + sdk: [2.12.0, dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.1 + - uses: dart-lang/setup-dart@v1.0 with: - channel: ${{ matrix.sdk }} + sdk: ${{ matrix.sdk }} - id: install name: Install dependencies run: dart pub get From 7d23e4c4b7bad0b05985df955492882fef94f4d5 Mon Sep 17 00:00:00 2001 From: Franklin Yow <58489007+franklinyow@users.noreply.github.com> Date: Wed, 31 Mar 2021 15:51:55 -0700 Subject: [PATCH 073/113] Update LICENSE (dart-lang/typed_data#48) Changes to comply to internal review --- pkgs/typed_data/LICENSE | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/LICENSE b/pkgs/typed_data/LICENSE index de31e1a0..dbd2843a 100644 --- a/pkgs/typed_data/LICENSE +++ b/pkgs/typed_data/LICENSE @@ -1,4 +1,5 @@ -Copyright 2015, the Dart project authors. All rights reserved. +Copyright 2015, the Dart project authors. + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -9,7 +10,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. From e0762b073ff0a511f048f8bfe1059bbd27631cc9 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 22 Jul 2021 14:24:58 -0700 Subject: [PATCH 074/113] Move from pedantic to lints package (dart-lang/typed_data#49) Fix existing violations of lints: - `annotate_overrides` - `avoid_renaming_method_parameters` - `provide_deprecation_message` --- pkgs/typed_data/CHANGELOG.md | 2 + pkgs/typed_data/analysis_options.yaml | 5 +-- pkgs/typed_data/lib/src/typed_buffer.dart | 8 ++-- pkgs/typed_data/lib/src/typed_queue.dart | 44 +++++++++++++++++++- pkgs/typed_data/pubspec.yaml | 8 ++-- pkgs/typed_data/test/typed_buffers_test.dart | 2 + 6 files changed, 56 insertions(+), 13 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 3bc5b717..9a701d50 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.3.1-dev + ## 1.3.0 * Stable release for null safety. diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 4a774a7e..5fcbac8d 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,11 +1,8 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:lints/recommended.yaml analyzer: strong-mode: implicit-casts: false - errors: - annotate_overrides: ignore - prefer_single_quotes: ignore linter: rules: diff --git a/pkgs/typed_data/lib/src/typed_buffer.dart b/pkgs/typed_data/lib/src/typed_buffer.dart index 37933f98..7d72a046 100644 --- a/pkgs/typed_data/lib/src/typed_buffer.dart +++ b/pkgs/typed_data/lib/src/typed_buffer.dart @@ -68,8 +68,8 @@ abstract class TypedDataBuffer extends ListBase { // by setting the length in increments of one. We want to grow by doubling // capacity in most cases. @override - void add(E value) { - _add(value); + void add(E element) { + _add(element); } /// Appends all objects of [values] to the end of this buffer. @@ -267,9 +267,9 @@ abstract class TypedDataBuffer extends ListBase { } @override - void setRange(int start, int end, Iterable source, [int skipCount = 0]) { + void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { if (end > _length) throw RangeError.range(end, 0, _length); - _setRange(start, end, source, skipCount); + _setRange(start, end, iterable, skipCount); } /// Like [setRange], but with no bounds checking. diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index a7ee91a5..0100fd0f 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -28,20 +28,23 @@ abstract class _TypedQueue> with ListMixin { // Iterable interface. + @override int get length => (_tail - _head) & (_table.length - 1); + @override List toList({bool growable = true}) { var list = growable ? _createBuffer(length) : _createList(length); _writeToList(list); return list; } + @override QueueList cast() { if (this is QueueList) return this as QueueList; throw UnsupportedError("$this cannot be cast to the desired type."); } - @deprecated + @Deprecated('Use `cast` instead') QueueList retype() => cast(); // Queue interface. @@ -65,6 +68,7 @@ abstract class _TypedQueue> with ListMixin { return result; } + @override E removeLast() { if (_head == _tail) throw StateError("No element"); _tail = (_tail - 1) & (_table.length - 1); @@ -73,8 +77,10 @@ abstract class _TypedQueue> with ListMixin { // List interface. + @override void add(E value) => addLast(value); + @override set length(int value) { RangeError.checkNotNegative(value, "length"); @@ -93,16 +99,19 @@ abstract class _TypedQueue> with ListMixin { } } + @override E operator [](int index) { RangeError.checkValidIndex(index, this, null, length); return _table[(_head + index) & (_table.length - 1)]; } + @override void operator []=(int index, E value) { RangeError.checkValidIndex(index, this); _table[(_head + index) & (_table.length - 1)] = value; } + @override void removeRange(int start, int end) { var length = this.length; RangeError.checkValidRange(start, end, length); @@ -132,6 +141,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { RangeError.checkValidRange(start, end, length); if (start == end) return; @@ -231,6 +241,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override void fillRange(int start, int end, [E? value]) { var startInTable = (_head + start) & (_table.length - 1); var endInTable = (_head + end) & (_table.length - 1); @@ -242,6 +253,7 @@ abstract class _TypedQueue> with ListMixin { } } + @override L sublist(int start, [int? end]) { var length = this.length; var nonNullEnd = RangeError.checkValidRange(start, end, length); @@ -327,6 +339,7 @@ abstract class _TypedQueue> with ListMixin { abstract class _IntQueue> extends _TypedQueue { _IntQueue(L queue) : super(queue); + @override int get _defaultValue => 0; } @@ -334,6 +347,7 @@ abstract class _FloatQueue> extends _TypedQueue { _FloatQueue(L queue) : super(queue); + @override double get _defaultValue => 0.0; } @@ -354,7 +368,9 @@ class Uint8Queue extends _IntQueue implements QueueList { factory Uint8Queue.fromList(List elements) => Uint8Queue(elements.length)..addAll(elements); + @override Uint8List _createList(int size) => Uint8List(size); + @override Uint8Buffer _createBuffer(int size) => Uint8Buffer(size); } @@ -376,7 +392,9 @@ class Int8Queue extends _IntQueue implements QueueList { factory Int8Queue.fromList(List elements) => Int8Queue(elements.length)..addAll(elements); + @override Int8List _createList(int size) => Int8List(size); + @override Int8Buffer _createBuffer(int size) => Int8Buffer(size); } @@ -400,7 +418,9 @@ class Uint8ClampedQueue extends _IntQueue factory Uint8ClampedQueue.fromList(List elements) => Uint8ClampedQueue(elements.length)..addAll(elements); + @override Uint8ClampedList _createList(int size) => Uint8ClampedList(size); + @override Uint8ClampedBuffer _createBuffer(int size) => Uint8ClampedBuffer(size); } @@ -421,7 +441,9 @@ class Uint16Queue extends _IntQueue implements QueueList { factory Uint16Queue.fromList(List elements) => Uint16Queue(elements.length)..addAll(elements); + @override Uint16List _createList(int size) => Uint16List(size); + @override Uint16Buffer _createBuffer(int size) => Uint16Buffer(size); } @@ -443,7 +465,9 @@ class Int16Queue extends _IntQueue implements QueueList { factory Int16Queue.fromList(List elements) => Int16Queue(elements.length)..addAll(elements); + @override Int16List _createList(int size) => Int16List(size); + @override Int16Buffer _createBuffer(int size) => Int16Buffer(size); } @@ -464,7 +488,9 @@ class Uint32Queue extends _IntQueue implements QueueList { factory Uint32Queue.fromList(List elements) => Uint32Queue(elements.length)..addAll(elements); + @override Uint32List _createList(int size) => Uint32List(size); + @override Uint32Buffer _createBuffer(int size) => Uint32Buffer(size); } @@ -486,7 +512,9 @@ class Int32Queue extends _IntQueue implements QueueList { factory Int32Queue.fromList(List elements) => Int32Queue(elements.length)..addAll(elements); + @override Int32List _createList(int size) => Int32List(size); + @override Int32Buffer _createBuffer(int size) => Int32Buffer(size); } @@ -508,7 +536,9 @@ class Uint64Queue extends _IntQueue implements QueueList { factory Uint64Queue.fromList(List elements) => Uint64Queue(elements.length)..addAll(elements); + @override Uint64List _createList(int size) => Uint64List(size); + @override Uint64Buffer _createBuffer(int size) => Uint64Buffer(size); } @@ -530,7 +560,9 @@ class Int64Queue extends _IntQueue implements QueueList { factory Int64Queue.fromList(List elements) => Int64Queue(elements.length)..addAll(elements); + @override Int64List _createList(int size) => Int64List(size); + @override Int64Buffer _createBuffer(int size) => Int64Buffer(size); } @@ -553,7 +585,9 @@ class Float32Queue extends _FloatQueue factory Float32Queue.fromList(List elements) => Float32Queue(elements.length)..addAll(elements); + @override Float32List _createList(int size) => Float32List(size); + @override Float32Buffer _createBuffer(int size) => Float32Buffer(size); } @@ -573,7 +607,9 @@ class Float64Queue extends _FloatQueue factory Float64Queue.fromList(List elements) => Float64Queue(elements.length)..addAll(elements); + @override Float64List _createList(int size) => Float64List(size); + @override Float64Buffer _createBuffer(int size) => Float64Buffer(size); } @@ -594,8 +630,11 @@ class Int32x4Queue extends _TypedQueue factory Int32x4Queue.fromList(List elements) => Int32x4Queue(elements.length)..addAll(elements); + @override Int32x4List _createList(int size) => Int32x4List(size); + @override Int32x4Buffer _createBuffer(int size) => Int32x4Buffer(size); + @override Int32x4 get _defaultValue => _zero; } @@ -614,8 +653,11 @@ class Float32x4Queue extends _TypedQueue factory Float32x4Queue.fromList(List elements) => Float32x4Queue(elements.length)..addAll(elements); + @override Float32x4List _createList(int size) => Float32x4List(size); + @override Float32x4Buffer _createBuffer(int size) => Float32x4Buffer(size); + @override Float32x4 get _defaultValue => Float32x4.zero(); } diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 0501c939..9e5942dd 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,16 +1,16 @@ name: typed_data -version: 1.3.0 +version: 1.3.1-dev description: >- Utility functions and classes related to the dart:typed_data library. homepage: https://github.com/dart-lang/typed_data environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: collection: ^1.15.0 dev_dependencies: - pedantic: ^1.10.0-nullsafety - test: ^1.16.0-nullsafety + lints: ^1.0.0 + test: ^1.16.0 diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 9452ad3c..c0a00015 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -552,9 +552,11 @@ class MatchesInt32x4 extends Matcher { MatchesInt32x4(this.result); + @override Description describe(Description description) => description.add('Int32x4.=='); + @override bool matches(item, Map matchState) => item is Int32x4 && result.x == item.x && From 30cb9819f3edbed24efe12517d36132a19b99c23 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 16 Nov 2021 14:51:53 -0800 Subject: [PATCH 075/113] Remove duplicative lints --- pkgs/typed_data/analysis_options.yaml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 5fcbac8d..0a2868d3 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -6,37 +6,19 @@ analyzer: linter: rules: - - avoid_function_literals_in_foreach_calls - avoid_returning_null - avoid_unused_constructor_parameters - - await_only_futures - - camel_case_types - cancel_subscriptions - comment_references - - constant_identifier_names - - control_flow_in_finally - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - invariant_booleans - - iterable_contains_unrelated_type - - list_remove_unrelated_type - no_adjacent_strings_in_list - - non_constant_identifier_names - only_throw_errors - - overridden_fields - package_api_docs - - package_names - - package_prefixed_library_names - prefer_const_constructors - - prefer_initializing_formals - prefer_interpolation_to_compose_strings - - prefer_typing_uninitialized_variables - test_types_in_equals - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - unnecessary_lambdas - unnecessary_null_aware_assignments - unnecessary_statements From 7706f679f9663d9cc1a24464f85f9d1c3ef71870 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 16 Nov 2021 14:54:56 -0800 Subject: [PATCH 076/113] Enable and fix a few more lints --- pkgs/typed_data/analysis_options.yaml | 5 + pkgs/typed_data/lib/src/typed_queue.dart | 14 +-- pkgs/typed_data/lib/typed_data.dart | 4 +- pkgs/typed_data/test/queue_test.dart | 102 +++++++++---------- pkgs/typed_data/test/typed_buffers_test.dart | 4 +- 5 files changed, 67 insertions(+), 62 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 0a2868d3..821eb572 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -6,6 +6,8 @@ analyzer: linter: rules: + - avoid_dynamic_calls + - always_declare_return_types - avoid_returning_null - avoid_unused_constructor_parameters - cancel_subscriptions @@ -13,12 +15,15 @@ linter: - directives_ordering - invariant_booleans - no_adjacent_strings_in_list + - omit_local_variable_types - only_throw_errors - package_api_docs - prefer_const_constructors - prefer_interpolation_to_compose_strings + - prefer_single_quotes - test_types_in_equals - throw_in_finally + - unawaited_futures - unnecessary_lambdas - unnecessary_null_aware_assignments - unnecessary_statements diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index 0100fd0f..bdd33e02 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -2,10 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import "dart:collection"; -import "dart:typed_data"; +import 'dart:collection'; +import 'dart:typed_data'; -import "package:collection/collection.dart"; +import 'package:collection/collection.dart'; import 'typed_buffer.dart'; @@ -41,7 +41,7 @@ abstract class _TypedQueue> with ListMixin { @override QueueList cast() { if (this is QueueList) return this as QueueList; - throw UnsupportedError("$this cannot be cast to the desired type."); + throw UnsupportedError('$this cannot be cast to the desired type.'); } @Deprecated('Use `cast` instead') @@ -62,7 +62,7 @@ abstract class _TypedQueue> with ListMixin { } E removeFirst() { - if (_head == _tail) throw StateError("No element"); + if (_head == _tail) throw StateError('No element'); var result = _table[_head]; _head = (_head + 1) & (_table.length - 1); return result; @@ -70,7 +70,7 @@ abstract class _TypedQueue> with ListMixin { @override E removeLast() { - if (_head == _tail) throw StateError("No element"); + if (_head == _tail) throw StateError('No element'); _tail = (_tail - 1) & (_table.length - 1); return _table[_tail]; } @@ -82,7 +82,7 @@ abstract class _TypedQueue> with ListMixin { @override set length(int value) { - RangeError.checkNotNegative(value, "length"); + RangeError.checkNotNegative(value, 'length'); var delta = value - length; if (delta >= 0) { diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index b23fdf06..1dc9fc8b 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -5,5 +5,5 @@ /// Utilities and functionality related to the "dart:typed_data" library. library typed_data; -export "src/typed_queue.dart"; -export "typed_buffers.dart"; +export 'src/typed_queue.dart'; +export 'typed_buffers.dart'; diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index ccd93ac8..5dcbc74c 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -4,96 +4,96 @@ // ignore_for_file: avoid_function_literals_in_foreach_calls -import "package:test/test.dart"; +import 'package:test/test.dart'; -import "package:typed_data/typed_data.dart"; +import 'package:typed_data/typed_data.dart'; /// The initial capacity of queues if the user doesn't specify one. const capacity = 16; void main() { - group("Uint8Queue()", () { - test("creates an empty Uint8Queue", () { + group('Uint8Queue()', () { + test('creates an empty Uint8Queue', () { expect(Uint8Queue(), isEmpty); }); - test("takes an initial capacity", () { + test('takes an initial capacity', () { expect(Uint8Queue(100), isEmpty); }); }); - group("add() adds an element to the end", () { + group('add() adds an element to the end', () { forEachInternalRepresentation((queue) { queue.add(16); expect(queue, equals(oneThrough(capacity))); }); }); - group("addFirst() adds an element to the beginning", () { + group('addFirst() adds an element to the beginning', () { forEachInternalRepresentation((queue) { queue.addFirst(0); expect(queue, equals([0, ...oneThrough(capacity - 1)])); }); }); - group("removeFirst() removes an element from the beginning", () { + group('removeFirst() removes an element from the beginning', () { forEachInternalRepresentation((queue) { expect(queue.removeFirst(), equals(1)); expect(queue, equals(oneThrough(capacity - 1).skip(1))); }); - test("throws a StateError for an empty queue", () { + test('throws a StateError for an empty queue', () { expect(Uint8Queue().removeFirst, throwsStateError); }); }); - group("removeLast() removes an element from the end", () { + group('removeLast() removes an element from the end', () { forEachInternalRepresentation((queue) { expect(queue.removeLast(), equals(15)); expect(queue, equals(oneThrough(capacity - 2))); }); - test("throws a StateError for an empty queue", () { + test('throws a StateError for an empty queue', () { expect(Uint8Queue().removeLast, throwsStateError); }); }); - group("removeRange()", () { - group("removes a prefix", () { + group('removeRange()', () { + group('removes a prefix', () { forEachInternalRepresentation((queue) { queue.removeRange(0, 5); expect(queue, equals(oneThrough(capacity - 1).skip(5))); }); }); - group("removes a suffix", () { + group('removes a suffix', () { forEachInternalRepresentation((queue) { queue.removeRange(10, 15); expect(queue, equals(oneThrough(capacity - 6))); }); }); - group("removes from the middle", () { + group('removes from the middle', () { forEachInternalRepresentation((queue) { queue.removeRange(5, 10); expect(queue, equals([1, 2, 3, 4, 5, 11, 12, 13, 14, 15])); }); }); - group("removes everything", () { + group('removes everything', () { forEachInternalRepresentation((queue) { queue.removeRange(0, 15); expect(queue, isEmpty); }); }); - test("throws a RangeError for an invalid range", () { + test('throws a RangeError for an invalid range', () { expect(() => Uint8Queue().removeRange(0, 1), throwsRangeError); }); }); - group("setRange()", () { - group("sets a range to the contents of an iterable", () { + group('setRange()', () { + group('sets a range to the contents of an iterable', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n), 2); expect(queue, @@ -101,7 +101,7 @@ void main() { }); }); - group("sets a range to the contents of a list", () { + group('sets a range to the contents of a list', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, oneThrough(10).map((n) => 100 + n).toList(), 2); expect(queue, @@ -110,7 +110,7 @@ void main() { }); group( - "sets a range to a section of the same queue overlapping at the beginning", + 'sets a range to a section of the same queue overlapping at the beginning', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 2); @@ -118,7 +118,7 @@ void main() { }); }); - group("sets a range to a section of the same queue overlapping at the end", + group('sets a range to a section of the same queue overlapping at the end', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 6); @@ -126,33 +126,33 @@ void main() { }); }); - test("throws a RangeError for an invalid range", () { + test('throws a RangeError for an invalid range', () { expect(() => Uint8Queue().setRange(0, 1, [1]), throwsRangeError); }); }); - group("length returns the length", () { + group('length returns the length', () { forEachInternalRepresentation((queue) { expect(queue.length, equals(15)); }); }); - group("length=", () { - group("empties", () { + group('length=', () { + group('empties', () { forEachInternalRepresentation((queue) { queue.length = 0; expect(queue, isEmpty); }); }); - group("shrinks", () { + group('shrinks', () { forEachInternalRepresentation((queue) { queue.length = 5; expect(queue, equals([1, 2, 3, 4, 5])); }); }); - group("grows", () { + group('grows', () { forEachInternalRepresentation((queue) { queue.length = 20; expect( @@ -162,7 +162,7 @@ void main() { }); }); - group("zeroes out existing data", () { + group('zeroes out existing data', () { forEachInternalRepresentation((queue) { queue.length = 0; queue.length = 15; @@ -170,13 +170,13 @@ void main() { }); }); - test("throws a RangeError if length is less than 0", () { + test('throws a RangeError if length is less than 0', () { expect(() => Uint8Queue().length = -1, throwsRangeError); }); }); - group("[]", () { - group("returns individual entries", () { + group('[]', () { + group('returns individual entries', () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { expect(queue[i], equals(i + 1)); @@ -184,21 +184,21 @@ void main() { }); }); - test("throws a RangeError if the index is less than 0", () { + test('throws a RangeError if the index is less than 0', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[-1], throwsRangeError); }); test( - "throws a RangeError if the index is greater than or equal to the " - "length", () { + 'throws a RangeError if the index is greater than or equal to the ' + 'length', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() => queue[3], throwsRangeError); }); }); - group("[]=", () { - group("sets individual entries", () { + group('[]=', () { + group('sets individual entries', () { forEachInternalRepresentation((queue) { for (var i = 0; i < capacity - 1; i++) { queue[i] = 100 + i; @@ -207,7 +207,7 @@ void main() { }); }); - test("throws a RangeError if the index is less than 0", () { + test('throws a RangeError if the index is less than 0', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[-1] = 0; @@ -215,8 +215,8 @@ void main() { }); test( - "throws a RangeError if the index is greater than or equal to the " - "length", () { + 'throws a RangeError if the index is greater than or equal to the ' + 'length', () { var queue = Uint8Queue.fromList([1, 2, 3]); expect(() { queue[3] = 4; @@ -224,38 +224,38 @@ void main() { }); }); - group("throws a modification error for", () { + group('throws a modification error for', () { late Uint8Queue queue; setUp(() { queue = Uint8Queue.fromList([1, 2, 3]); }); - test("add", () { + test('add', () { expect(() => queue.forEach((_) => queue.add(4)), throwsConcurrentModificationError); }); - test("addAll", () { + test('addAll', () { expect(() => queue.forEach((_) => queue.addAll([4, 5, 6])), throwsConcurrentModificationError); }); - test("addFirst", () { + test('addFirst', () { expect(() => queue.forEach((_) => queue.addFirst(0)), throwsConcurrentModificationError); }); - test("removeFirst", () { + test('removeFirst', () { expect(() => queue.forEach((_) => queue.removeFirst()), throwsConcurrentModificationError); }); - test("removeLast", () { + test('removeLast', () { expect(() => queue.forEach((_) => queue.removeLast()), throwsConcurrentModificationError); }); - test("length=", () { + test('length=', () { expect(() => queue.forEach((_) => queue.length = 1), throwsConcurrentModificationError); }); @@ -269,13 +269,13 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { group("for a queue that's below capacity", () { // Test with a queue whose elements are in one contiguous block, so `_head < // _tail`. - test("with contiguous elements", () { + test('with contiguous elements', () { callback(Uint8Queue(capacity * 2)..addAll(oneThrough(capacity - 1))); }); // Test with a queue whose elements are split across the ends of the table, // so `_head > _tail`. - test("with an internal gap", () { + test('with an internal gap', () { var queue = Uint8Queue(capacity * 2); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); @@ -290,11 +290,11 @@ void forEachInternalRepresentation(void Function(Uint8Queue queue) callback) { // Test with a queue whose internal table will need to expand if one more // element is added. group("for a queue that's at capacity", () { - test("with contiguous elements", () { + test('with contiguous elements', () { callback(Uint8Queue()..addAll(oneThrough(capacity - 1))); }); - test("with an internal gap", () { + test('with an internal gap', () { var queue = Uint8Queue(); for (var i = capacity ~/ 2; i < capacity; i++) { queue.add(i); diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index c0a00015..1d6bfbdc 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -229,7 +229,7 @@ int clampUint8(int x) => x < 0 ? 255 : x; -void doubleEqual(x, num y) { +void doubleEqual(num x, num y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { @@ -254,7 +254,7 @@ void testFloat32x4Buffer(List floatSamples) { floatSamples[i + 2], floatSamples[i + 3])); } - void floatEquals(x, num y) { + void floatEquals(num x, num y) { if (y.isNaN) { expect(x.isNaN, isTrue); } else { From 9f19d7d03b46f3e430c5c0f4bf1d47a4324f2f29 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 20 Apr 2022 14:42:23 -0700 Subject: [PATCH 077/113] Switch from homepage to repository in pubspec (dart-lang/typed_data#51) --- pkgs/typed_data/pubspec.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 9e5942dd..125bd060 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,9 +1,8 @@ name: typed_data version: 1.3.1-dev - description: >- Utility functions and classes related to the dart:typed_data library. -homepage: https://github.com/dart-lang/typed_data +repository: https://github.com/dart-lang/typed_data environment: sdk: ">=2.12.0 <3.0.0" From f1ad55cef6c08b48e378805c761d7755e5a0d760 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 12 May 2022 10:16:40 -0700 Subject: [PATCH 078/113] prep for publishing 1.3.1 (dart-lang/typed_data#52) prep for publishing 1.3.1 --- pkgs/typed_data/CHANGELOG.md | 5 ++++- pkgs/typed_data/README.md | 22 ++++++++++------------ pkgs/typed_data/pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 9a701d50..edd3a11d 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,4 +1,7 @@ -## 1.3.1-dev +## 1.3.1 + +* Switch to using `package:lints`. +* Populate the pubspec `repository` field. ## 1.3.0 diff --git a/pkgs/typed_data/README.md b/pkgs/typed_data/README.md index 9ec19ba4..212c48e4 100644 --- a/pkgs/typed_data/README.md +++ b/pkgs/typed_data/README.md @@ -1,23 +1,21 @@ -# Helper libraries for working with typed data lists. +[![Dart CI](https://github.com/dart-lang/typed_data/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/typed_data/actions/workflows/test-package.yml) +[![pub package](https://img.shields.io/pub/v/typed_data.svg)](https://pub.dev/packages/typed_data) +[![package publisher](https://img.shields.io/pub/publisher/typed_data.svg)](https://pub.dev/packages/typed_data/publisher) + +Helper libraries for working with typed data lists. The `typed_data` package contains utility functions and classes that makes working with typed data lists easier. ## Using -The `typed_data` package can be imported as +The `typed_data` package can be imported using: ```dart import 'package:typed_data/typed_data.dart'; ``` -## Typed buffers: Growable typed data lists - -Typed buffers are contains growable lists backed by typed arrays. -These are similar to the growable lists returned by `List()`, -but stores typed data like a typed data list. - -## Features and bugs - -Please file feature requests and bugs at the [issue tracker][tracker]. +## Typed buffers -[tracker]: https://github.com/dart-lang/typed_data/issues +Typed buffers are growable lists backed by typed arrays. These are similar to +the growable lists created by `[]` or `[]`, but store typed data +like a typed data list. diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 125bd060..705ec6dd 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.1-dev +version: 1.3.1 description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/typed_data From 6fe45ca0471a4dc62442932e97df361647b09c2f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 6 Aug 2022 19:05:14 -0700 Subject: [PATCH 079/113] Drop invariant bools lint (dart-lang/typed_data#53) --- pkgs/typed_data/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 821eb572..3394eae0 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -13,7 +13,6 @@ linter: - cancel_subscriptions - comment_references - directives_ordering - - invariant_booleans - no_adjacent_strings_in_list - omit_local_variable_types - only_throw_errors From 53803b41d45ef63d70c02951ea7a0f52f3869613 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 10 Nov 2022 09:38:15 -0800 Subject: [PATCH 080/113] blast_repo fixes (dart-lang/typed_data#55) Dependabot GitHub Action --- pkgs/typed_data/.github/dependabot.yml | 9 +++++++++ pkgs/typed_data/.github/workflows/test-package.yml | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 pkgs/typed_data/.github/dependabot.yml diff --git a/pkgs/typed_data/.github/dependabot.yml b/pkgs/typed_data/.github/dependabot.yml new file mode 100644 index 00000000..1603cdd9 --- /dev/null +++ b/pkgs/typed_data/.github/dependabot.yml @@ -0,0 +1,9 @@ +# Dependabot configuration file. +# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index cdc25d95..68f255c7 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -49,8 +49,8 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install From 95c51af0664001feb38a4620c0851c499e285cb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:30:40 -0800 Subject: [PATCH 081/113] Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/typed_data#57) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 68f255c7..c3560007 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 4186736ae23d98f30b6adfbcae4843e1eeaa1ee8 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 9 Jan 2023 19:24:50 -0800 Subject: [PATCH 082/113] Migrate no-implicit-casts to strict-casts (dart-lang/typed_data#58) --- pkgs/typed_data/analysis_options.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 3394eae0..aba9cd2a 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,8 +1,8 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false + language: + strict-casts: true linter: rules: From e85b2c8a03b5a6053656f4db5ebefed5a0445d93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 21:55:31 -0800 Subject: [PATCH 083/113] Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/typed_data#60) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index c3560007..6e460072 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From fdfcc82ba15a232e24b811623d0a8cea4f9ed820 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:35:54 -0800 Subject: [PATCH 084/113] Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/typed_data#59) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 6e460072..70fb7ec4 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.12.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From f8c33524a3ba3c6603984bf2516fb6f2b1f2ee23 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 12 Feb 2023 17:14:02 -0800 Subject: [PATCH 085/113] fix ci, update analysis options (dart-lang/typed_data#61) --- .../.github/workflows/test-package.yml | 2 +- pkgs/typed_data/CHANGELOG.md | 29 ++++--------------- pkgs/typed_data/analysis_options.yaml | 15 ++-------- pkgs/typed_data/lib/src/typed_buffer.dart | 4 +-- pkgs/typed_data/lib/src/typed_queue.dart | 15 +++++----- pkgs/typed_data/pubspec.yaml | 6 ++-- pkgs/typed_data/test/queue_test.dart | 5 ++-- pkgs/typed_data/test/typed_buffers_test.dart | 25 ++++++++-------- 8 files changed, 35 insertions(+), 66 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 70fb7ec4..5a3d9cfe 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.17.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index edd3a11d..f7c48f08 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.2-dev + +* Require Dart 2.17 + ## 1.3.1 * Switch to using `package:lints`. @@ -6,32 +10,9 @@ ## 1.3.0 * Stable release for null safety. - -## 1.3.0-nullsafety.5 - * Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release guidelines. -## 1.3.0-nullsafety.4 - -* Allow prerelease versions of the `2.12` sdk. - -## 1.3.0-nullsafety.3 - -* Allow 2.10 stable and 2.11.0 dev SDK versions. - -## 1.3.0-nullsafety.2 - -* Update for the 2.10 dev sdk. - -## 1.3.0-nullsafety.1 - -* Allow the <=2.9.10 stable sdks. - -## 1.3.0-nullsafety - -* Migrate to NNBD - ## 1.2.0 * Add typed queue classes such as `Uint8Queue`. These classes implement both @@ -45,7 +26,7 @@ ## 1.1.5 -* Undo unnessesary SDK version constraint tweak. +* Undo unnecessary SDK version constraint tweak. ## 1.1.4 diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index aba9cd2a..13eb823c 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -6,23 +6,12 @@ analyzer: linter: rules: - - avoid_dynamic_calls - - always_declare_return_types - avoid_returning_null - avoid_unused_constructor_parameters - cancel_subscriptions - comment_references - - directives_ordering - no_adjacent_strings_in_list - - omit_local_variable_types - - only_throw_errors - package_api_docs - prefer_const_constructors - - prefer_interpolation_to_compose_strings - - prefer_single_quotes - test_types_in_equals - - throw_in_finally - - unawaited_futures - - unnecessary_lambdas - - unnecessary_null_aware_assignments - - unnecessary_statements + - use_super_parameters diff --git a/pkgs/typed_data/lib/src/typed_buffer.dart b/pkgs/typed_data/lib/src/typed_buffer.dart index 7d72a046..b79e7a6b 100644 --- a/pkgs/typed_data/lib/src/typed_buffer.dart +++ b/pkgs/typed_data/lib/src/typed_buffer.dart @@ -308,14 +308,14 @@ abstract class TypedDataBuffer extends ListBase { } abstract class _IntBuffer extends TypedDataBuffer { - _IntBuffer(List buffer) : super(buffer); + _IntBuffer(super.buffer); @override int get _defaultValue => 0; } abstract class _FloatBuffer extends TypedDataBuffer { - _FloatBuffer(List buffer) : super(buffer); + _FloatBuffer(super.buffer); @override double get _defaultValue => 0.0; diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index bdd33e02..c7929178 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -223,8 +223,8 @@ abstract class _TypedQueue> with ListMixin { } } } else if (targetIsContiguous) { - // If the range is contiguous within the table, we can set it with a single - // underlying [setRange] call. + // If the range is contiguous within the table, we can set it with a + // single underlying [setRange] call. _table.setRange(targetStart, targetEnd, iterable, skipCount); } else if (iterable is List) { // If the range isn't contiguous and [iterable] is actually a [List] (but @@ -337,7 +337,7 @@ abstract class _TypedQueue> with ListMixin { } abstract class _IntQueue> extends _TypedQueue { - _IntQueue(L queue) : super(queue); + _IntQueue(super.queue); @override int get _defaultValue => 0; @@ -345,7 +345,7 @@ abstract class _IntQueue> extends _TypedQueue { abstract class _FloatQueue> extends _TypedQueue { - _FloatQueue(L queue) : super(queue); + _FloatQueue(super.queue); @override double get _defaultValue => 0.0; @@ -644,12 +644,13 @@ class Int32x4Queue extends _TypedQueue /// time-efficient than a default [QueueList] implementation. class Float32x4Queue extends _TypedQueue implements QueueList { - /// Creates an empty [Float32x4Queue] with the given initial internal capacity (in - /// elements). + /// Creates an empty [Float32x4Queue] with the given initial internal capacity + /// (in elements). Float32x4Queue([int? initialCapacity]) : super(Float32x4List(_chooseRealInitialCapacity(initialCapacity))); - /// Creates a [Float32x4Queue] with the same length and contents as [elements]. + /// Creates a [Float32x4Queue] with the same length and contents as + /// [elements]. factory Float32x4Queue.fromList(List elements) => Float32x4Queue(elements.length)..addAll(elements); diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 705ec6dd..72a110ec 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,15 +1,15 @@ name: typed_data -version: 1.3.1 +version: 1.3.2-dev description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/typed_data environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" dependencies: collection: ^1.15.0 dev_dependencies: - lints: ^1.0.0 + dart_flutter_team_lints: ^0.1.0 test: ^1.16.0 diff --git a/pkgs/typed_data/test/queue_test.dart b/pkgs/typed_data/test/queue_test.dart index 5dcbc74c..c0b1368d 100644 --- a/pkgs/typed_data/test/queue_test.dart +++ b/pkgs/typed_data/test/queue_test.dart @@ -5,7 +5,6 @@ // ignore_for_file: avoid_function_literals_in_foreach_calls import 'package:test/test.dart'; - import 'package:typed_data/typed_data.dart'; /// The initial capacity of queues if the user doesn't specify one. @@ -110,8 +109,8 @@ void main() { }); group( - 'sets a range to a section of the same queue overlapping at the beginning', - () { + 'sets a range to a section of the same queue overlapping at the ' + 'beginning', () { forEachInternalRepresentation((queue) { queue.setRange(5, 10, queue, 2); expect(queue, [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15]); diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 1d6bfbdc..409eb5fb 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -44,30 +44,29 @@ void main() { } void initTests(List intSamples) { - testUint(intSamples, 8, (l) => Uint8Buffer(l)); - testInt(intSamples, 8, (l) => Int8Buffer(l)); + testUint(intSamples, 8, Uint8Buffer.new); + testInt(intSamples, 8, Int8Buffer.new); test('Uint8ClampedBuffer', () { - testIntBuffer( - intSamples, 8, 0, 255, (l) => Uint8ClampedBuffer(l), clampUint8); + testIntBuffer(intSamples, 8, 0, 255, Uint8ClampedBuffer.new, clampUint8); }); - testUint(intSamples, 16, (l) => Uint16Buffer(l)); - testInt(intSamples, 16, (l) => Int16Buffer(l)); - testUint(intSamples, 32, (l) => Uint32Buffer(l)); + testUint(intSamples, 16, Uint16Buffer.new); + testInt(intSamples, 16, Int16Buffer.new); + testUint(intSamples, 32, Uint32Buffer.new); - testInt(intSamples, 32, (l) => Int32Buffer(l)); + testInt(intSamples, 32, Int32Buffer.new); - testUint(intSamples, 64, (l) => Uint64Buffer(l), + testUint(intSamples, 64, Uint64Buffer.new, // JS doesn't support 64-bit ints, so only test this on the VM. testOn: 'dart-vm'); - testInt(intSamples, 64, (l) => Int64Buffer(l), + testInt(intSamples, 64, Int64Buffer.new, // JS doesn't support 64-bit ints, so only test this on the VM. testOn: 'dart-vm'); testInt32x4Buffer(intSamples); var roundedFloatSamples = floatSamples.map(roundToFloat).toList(); - testFloatBuffer(32, roundedFloatSamples, () => Float32Buffer(), roundToFloat); - testFloatBuffer(64, doubleSamples, () => Float64Buffer(), (x) => x); + testFloatBuffer(32, roundedFloatSamples, Float32Buffer.new, roundToFloat); + testFloatBuffer(64, doubleSamples, Float64Buffer.new, (x) => x); testFloat32x4Buffer(roundedFloatSamples); @@ -557,7 +556,7 @@ class MatchesInt32x4 extends Matcher { description.add('Int32x4.=='); @override - bool matches(item, Map matchState) => + bool matches(Object? item, Map matchState) => item is Int32x4 && result.x == item.x && result.y == item.y && From d23118b508d57901ef16b2038590d50a727fb9b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Apr 2023 19:52:51 -0700 Subject: [PATCH 086/113] Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/typed_data#63) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 5a3d9cfe..c3372217 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 6e4185cde781dc835219e8d5ff2e5529e40cc85d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Apr 2023 19:55:51 -0700 Subject: [PATCH 087/113] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/typed_data#62) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index c3372217..35a98b0c 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From a3f4dc1f9e9bf0596bdcb1bbd6bb83efde5fa5e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 12:30:04 -0700 Subject: [PATCH 088/113] Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/typed_data#64) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 35a98b0c..4bad718a 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 0d38a4b2db483c94d5bfd64f3edc9497477b6b4a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 9 May 2023 09:47:48 -0700 Subject: [PATCH 089/113] add topics to the pubspec file (dart-lang/typed_data#65) * add topics to the pubspec file * fix a typo --- pkgs/typed_data/CHANGELOG.md | 5 +++-- pkgs/typed_data/pubspec.yaml | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index f7c48f08..192a2800 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,6 +1,7 @@ -## 1.3.2-dev +## 1.3.2 -* Require Dart 2.17 +* Added package topics to the pubspec file. +* Require Dart 2.17. ## 1.3.1 diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 72a110ec..a7d713f1 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,11 +1,14 @@ name: typed_data -version: 1.3.2-dev +version: 1.3.2 description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/typed_data +topics: + - data-structures + environment: - sdk: ">=2.17.0 <3.0.0" + sdk: '>=2.17.0 <4.0.0' dependencies: collection: ^1.15.0 From a44b9cbcd01abb153810cfb1f825f9605530e545 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 22 May 2023 16:23:07 -0700 Subject: [PATCH 090/113] blast_repo fixes (dart-lang/typed_data#66) dependabot --- pkgs/typed_data/.github/dependabot.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/typed_data/.github/dependabot.yml b/pkgs/typed_data/.github/dependabot.yml index 1603cdd9..725f03af 100644 --- a/pkgs/typed_data/.github/dependabot.yml +++ b/pkgs/typed_data/.github/dependabot.yml @@ -3,7 +3,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From 778b8006c33205261b40420af34bdd5a90abfa08 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 7 Jun 2023 20:31:15 -0700 Subject: [PATCH 091/113] Require Dart 3.0, update lints (dart-lang/typed_data#67) --- pkgs/typed_data/.github/workflows/test-package.yml | 2 +- pkgs/typed_data/CHANGELOG.md | 4 ++++ pkgs/typed_data/analysis_options.yaml | 1 + pkgs/typed_data/pubspec.yaml | 6 +++--- pkgs/typed_data/test/typed_buffers_test.dart | 2 ++ pkgs/typed_data/test/typed_buffers_vm_test.dart | 2 ++ 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 4bad718a..6e9fc391 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [3.0.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 192a2800..b067b898 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.3-wip + +* Require Dart 3.0 + ## 1.3.2 * Added package topics to the pubspec file. diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 13eb823c..03546538 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -1,3 +1,4 @@ +# https://dart.dev/guides/language/analysis-options include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index a7d713f1..de8c6d2c 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.2 +version: 1.3.3-wip description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/typed_data @@ -8,11 +8,11 @@ topics: - data-structures environment: - sdk: '>=2.17.0 <4.0.0' + sdk: ^3.0.0 dependencies: collection: ^1.15.0 dev_dependencies: - dart_flutter_team_lints: ^0.1.0 + dart_flutter_team_lints: ^1.0.0 test: ^1.16.0 diff --git a/pkgs/typed_data/test/typed_buffers_test.dart b/pkgs/typed_data/test/typed_buffers_test.dart index 409eb5fb..9d73040f 100644 --- a/pkgs/typed_data/test/typed_buffers_test.dart +++ b/pkgs/typed_data/test/typed_buffers_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('!vm') +library; + import 'dart:typed_data'; import 'package:test/test.dart'; diff --git a/pkgs/typed_data/test/typed_buffers_vm_test.dart b/pkgs/typed_data/test/typed_buffers_vm_test.dart index 44a66bfc..62afcef7 100644 --- a/pkgs/typed_data/test/typed_buffers_vm_test.dart +++ b/pkgs/typed_data/test/typed_buffers_vm_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; + import 'package:test/test.dart'; import 'typed_buffers_test.dart'; From 2d39eb5ae7e5ffa9591d30a511b969587d14c3d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 02:16:17 +0000 Subject: [PATCH 092/113] Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/typed_data#69) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 6e9fc391..7ad5f74e 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 84b0ee5b7fa2003bf3e76456e7aeb32b57f1d580 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:11:32 +0000 Subject: [PATCH 093/113] Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/typed_data#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 7ad5f74e..24d44c9a 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 444c3adc8a1d1b4e78437f0a5e552e6296c579e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 02:59:02 +0000 Subject: [PATCH 094/113] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/typed_data#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/typed_data#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/typed_data#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 24d44c9a..b187c463 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From 4c32e1f658d9523199e4b5f9909a33b7ba478552 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 03:02:34 +0000 Subject: [PATCH 095/113] Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/typed_data#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚠️ **Dependabot is rebasing this PR** ⚠️ Rebasing might not happen immediately, so don't worry if this takes some time. Note: if you make any changes to this PR yourself, they will take precedence over the rebase. --- Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index b187c463..657b236d 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From f85d1d58478f0cac5faa56589baafa73120a36a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:11:51 +0000 Subject: [PATCH 096/113] Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/typed_data#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 657b236d..e41d9a85 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From 7fabdebfd053b5d9910820cfd3154dc7200261f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 04:02:43 +0000 Subject: [PATCH 097/113] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/typed_data#76) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/typed_data#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/typed_data#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index e41d9a85..4cb7d3a7 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From e08f52a1cc2793334ea9862595c61002cdb2abb5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Dec 2023 10:34:10 -0800 Subject: [PATCH 098/113] drop outdated lints (dart-lang/typed_data#78) --- pkgs/typed_data/analysis_options.yaml | 5 ----- pkgs/typed_data/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/typed_data/analysis_options.yaml b/pkgs/typed_data/analysis_options.yaml index 03546538..543787c0 100644 --- a/pkgs/typed_data/analysis_options.yaml +++ b/pkgs/typed_data/analysis_options.yaml @@ -7,12 +7,7 @@ analyzer: linter: rules: - - avoid_returning_null - avoid_unused_constructor_parameters - cancel_subscriptions - - comment_references - no_adjacent_strings_in_list - package_api_docs - - prefer_const_constructors - - test_types_in_equals - - use_super_parameters diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index de8c6d2c..7e8428a8 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -14,5 +14,5 @@ dependencies: collection: ^1.15.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 test: ^1.16.0 From d588dd67e3b6d4cc4ce045b19b1aa6eb9f5ce34f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 02:15:04 +0000 Subject: [PATCH 099/113] Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/typed_data#79) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.0 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/typed_data#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/typed_data#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.0&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 4cb7d3a7..4e4e97d8 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install From c4d60c4076ab5b82707047e58422b41abdcbb5bd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 1 Feb 2024 12:32:34 -0800 Subject: [PATCH 100/113] Test dart2wasm (dart-lang/typed_data#80) --- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 4e4e97d8..fb748d75 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -62,3 +62,7 @@ jobs: - name: Run Chrome tests run: dart test --platform chrome if: always() && steps.install.outcome == 'success' + - name: Run Chrome tests - wasm + run: dart test --platform chrome --compiler dart2wasm + # TODO: drop `dev` filter when dart2wasm is working on stable + if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev' From 093c4d2b177143eb56b2640d7300f85abeba923c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 02:13:05 +0000 Subject: [PATCH 101/113] Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/typed_data#83) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
Release notes

Sourced from actions/checkout's releases.

v4.1.2

We are investigating the following issue with this release and have rolled-back the v4 tag to point to v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.1...v4.1.2

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.1&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index fb748d75..a0903163 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From 63151977a7890c6ed42b7e9d6bfaabd78e649557 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 02:11:08 +0000 Subject: [PATCH 102/113] Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/typed_data#84) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.4.
Release notes

Sourced from actions/checkout's releases.

v4.1.4

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.3...v4.1.4

v4.1.3

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.2...v4.1.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.2&new-version=4.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index a0903163..ee7dc665 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From 8cbbda1c45000a1b4d009702c90fde00eb493ab1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:21:32 +0000 Subject: [PATCH 103/113] Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/typed_data#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.4

  • Rebuild JS code to include changes from v1.6.3

v1.6.3

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.2&new-version=1.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index ee7dc665..0366d585 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install From a444952ccfd210fbb81b625bf3c68bb7653a64be Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 13 May 2024 10:35:58 -0700 Subject: [PATCH 104/113] blast_repo fixes (dart-lang/typed_data#86) dependabot --- pkgs/typed_data/.github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/typed_data/.github/dependabot.yml b/pkgs/typed_data/.github/dependabot.yml index 725f03af..cde02ad6 100644 --- a/pkgs/typed_data/.github/dependabot.yml +++ b/pkgs/typed_data/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: interval: monthly labels: - autosubmit + groups: + github-actions: + patterns: + - "*" From 0358a8a46f61a3ca13c9e8aa19d1c75e43be1e6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 17:39:15 +0000 Subject: [PATCH 105/113] Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group (dart-lang/typed_data#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.4 to 4.1.5
Release notes

Sourced from actions/checkout's releases.

v4.1.5

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.4...v4.1.5

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.4&new-version=4.1.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 0366d585..b488fb1f 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From 2cbdb3fa02129650fadddb2e3d76c8c804263d93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:51:00 +0000 Subject: [PATCH 106/113] Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group (dart-lang/typed_data#88) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.5 to 4.1.6
Release notes

Sourced from actions/checkout's releases.

v4.1.6

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.5...v4.1.6

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.5&new-version=4.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index b488fb1f..46382201 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From fde38158a5e833ebb3bb8b99063c23a0a051ba44 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 20 Jun 2024 10:30:58 -0700 Subject: [PATCH 107/113] blast_repo fixes (dart-lang/typed_data#89) auto-publish, github-actions, no-response --- .../.github/workflows/no-response.yml | 37 +++++++++++++++++++ .../typed_data/.github/workflows/publish.yaml | 17 +++++++++ .../.github/workflows/test-package.yml | 4 +- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 pkgs/typed_data/.github/workflows/no-response.yml create mode 100644 pkgs/typed_data/.github/workflows/publish.yaml diff --git a/pkgs/typed_data/.github/workflows/no-response.yml b/pkgs/typed_data/.github/workflows/no-response.yml new file mode 100644 index 00000000..ab1ac498 --- /dev/null +++ b/pkgs/typed_data/.github/workflows/no-response.yml @@ -0,0 +1,37 @@ +# A workflow to close issues where the author hasn't responded to a request for +# more information; see https://github.com/actions/stale. + +name: No Response + +# Run as a daily cron. +on: + schedule: + # Every day at 8am + - cron: '0 8 * * *' + +# All permissions not specified are set to 'none'. +permissions: + issues: write + pull-requests: write + +jobs: + no-response: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dart-lang' }} + steps: + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e + with: + # Don't automatically mark inactive issues+PRs as stale. + days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! diff --git a/pkgs/typed_data/.github/workflows/publish.yaml b/pkgs/typed_data/.github/workflows/publish.yaml new file mode 100644 index 00000000..27157a04 --- /dev/null +++ b/pkgs/typed_data/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ master ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 46382201..b214faad 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From 7a429ad1e43f504b20aafbd9224af0fa815ddf4d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 21 Jun 2024 16:21:13 -0700 Subject: [PATCH 108/113] update lints, require Dart 3.1 (dart-lang/typed_data#90) --- pkgs/typed_data/.github/workflows/test-package.yml | 2 +- pkgs/typed_data/CHANGELOG.md | 2 +- pkgs/typed_data/lib/typed_buffers.dart | 2 +- pkgs/typed_data/lib/typed_data.dart | 2 +- pkgs/typed_data/pubspec.yaml | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index b214faad..d1fcc34d 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [3.0.0, dev] + sdk: [3.1, dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index b067b898..2b3af0e5 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.3.3-wip -* Require Dart 3.0 +* Require Dart 3.1 ## 1.3.2 diff --git a/pkgs/typed_data/lib/typed_buffers.dart b/pkgs/typed_data/lib/typed_buffers.dart index da954347..05c8993d 100644 --- a/pkgs/typed_data/lib/typed_buffers.dart +++ b/pkgs/typed_data/lib/typed_buffers.dart @@ -11,6 +11,6 @@ /// That means that using the `buffer` getter is not guaranteed /// to return the same result each time it is used, and that the buffer may /// be larger than what the list is using. -library typed_data.typed_buffers; +library; export 'src/typed_buffer.dart' hide TypedDataBuffer; diff --git a/pkgs/typed_data/lib/typed_data.dart b/pkgs/typed_data/lib/typed_data.dart index 1dc9fc8b..cc94c32c 100644 --- a/pkgs/typed_data/lib/typed_data.dart +++ b/pkgs/typed_data/lib/typed_data.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// Utilities and functionality related to the "dart:typed_data" library. -library typed_data; +library; export 'src/typed_queue.dart'; export 'typed_buffers.dart'; diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 7e8428a8..8b595d7f 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -8,11 +8,11 @@ topics: - data-structures environment: - sdk: ^3.0.0 + sdk: ^3.1.0 dependencies: collection: ^1.15.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 - test: ^1.16.0 + dart_flutter_team_lints: ^3.0.0 + test: ^1.16.6 From 4ac0456f49553d663fa3bfc6337760642b3de814 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 02:31:22 +0000 Subject: [PATCH 109/113] Bump dart-lang/setup-dart in the github-actions group (dart-lang/typed_data#91) Bumps the github-actions group with 1 update: [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `dart-lang/setup-dart` from 1.6.4 to 1.6.5
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.5

dart-lang/typed_data#118: dart-lang/setup-dartdart-lang/typed_data#118

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.5

dart-lang/typed_data#118: dart-lang/setup-dartdart-lang/typed_data#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.4&new-version=1.6.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index d1fcc34d..3af713a0 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [3.1, dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install From 808ca6eec2eaade6edd803d5357800a31f67aa37 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 26 Aug 2024 18:02:33 -0700 Subject: [PATCH 110/113] Require Dart 3.5, use TypeDataList in many places (dart-lang/typed_data#92) Tighten types, remove casts, etc --- .../.github/workflows/test-package.yml | 5 ++-- pkgs/typed_data/CHANGELOG.md | 8 +++++-- pkgs/typed_data/lib/src/typed_buffer.dart | 24 +++++++------------ pkgs/typed_data/lib/src/typed_queue.dart | 19 +++++++-------- pkgs/typed_data/pubspec.yaml | 4 ++-- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index 3af713a0..a39c2df0 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [3.1, dev] + sdk: [3.5, dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 @@ -64,5 +64,4 @@ jobs: if: always() && steps.install.outcome == 'success' - name: Run Chrome tests - wasm run: dart test --platform chrome --compiler dart2wasm - # TODO: drop `dev` filter when dart2wasm is working on stable - if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev' + if: always() && steps.install.outcome == 'success' diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index 2b3af0e5..af74b2fb 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,6 +1,10 @@ -## 1.3.3-wip +## 1.4.0-wip -* Require Dart 3.1 +* The type of the `buffer` constructor argument to `TypedDataBuffer` is now + `TypeDataList` (instead of `List`). While this is breaking change + statically there was a runtime cast that makes this change a no-op in + practice. +* Require Dart 3.5 ## 1.3.2 diff --git a/pkgs/typed_data/lib/src/typed_buffer.dart b/pkgs/typed_data/lib/src/typed_buffer.dart index b79e7a6b..dcb2c585 100644 --- a/pkgs/typed_data/lib/src/typed_buffer.dart +++ b/pkgs/typed_data/lib/src/typed_buffer.dart @@ -9,18 +9,12 @@ abstract class TypedDataBuffer extends ListBase { static const int _initialLength = 8; /// The underlying data buffer. - /// - /// This is always both a List and a TypedData, which we don't have a type - /// for here. For example, for a `Uint8Buffer`, this is a `Uint8List`. - List _buffer; - - /// Returns a view of [_buffer] as a [TypedData]. - TypedData get _typedBuffer => _buffer as TypedData; + TypedDataList _buffer; /// The length of the list being built. int _length; - TypedDataBuffer(List buffer) + TypedDataBuffer(TypedDataList buffer) : _buffer = buffer, _length = buffer.length; @@ -47,7 +41,7 @@ abstract class TypedDataBuffer extends ListBase { _buffer[i] = defaultValue; } } else if (newLength > _buffer.length) { - List newBuffer; + TypedDataList newBuffer; if (_buffer.isEmpty) { newBuffer = _createBuffer(newLength); } else { @@ -249,7 +243,7 @@ abstract class TypedDataBuffer extends ListBase { /// be. If [requiredCapacity] is not null, it will be at least that /// size. It will always have at least have double the capacity of /// the current buffer. - List _createBiggerBuffer(int? requiredCapacity) { + TypedDataList _createBiggerBuffer(int? requiredCapacity) { var newLength = _buffer.length * 2; if (requiredCapacity != null && newLength < requiredCapacity) { newLength = requiredCapacity; @@ -283,11 +277,11 @@ abstract class TypedDataBuffer extends ListBase { // TypedData. - int get elementSizeInBytes => _typedBuffer.elementSizeInBytes; + int get elementSizeInBytes => _buffer.elementSizeInBytes; - int get lengthInBytes => _length * _typedBuffer.elementSizeInBytes; + int get lengthInBytes => _length * _buffer.elementSizeInBytes; - int get offsetInBytes => _typedBuffer.offsetInBytes; + int get offsetInBytes => _buffer.offsetInBytes; /// Returns the underlying [ByteBuffer]. /// @@ -295,7 +289,7 @@ abstract class TypedDataBuffer extends ListBase { /// of this list. /// /// The buffer may be larger than [lengthInBytes] bytes, but never smaller. - ByteBuffer get buffer => _typedBuffer.buffer; + ByteBuffer get buffer => _buffer.buffer; // Specialization for the specific type. @@ -304,7 +298,7 @@ abstract class TypedDataBuffer extends ListBase { E get _defaultValue; // Create a new typed list to use as buffer. - List _createBuffer(int size); + TypedDataList _createBuffer(int size); } abstract class _IntBuffer extends TypedDataBuffer { diff --git a/pkgs/typed_data/lib/src/typed_queue.dart b/pkgs/typed_data/lib/src/typed_queue.dart index c7929178..84ce5297 100644 --- a/pkgs/typed_data/lib/src/typed_queue.dart +++ b/pkgs/typed_data/lib/src/typed_queue.dart @@ -10,20 +10,16 @@ import 'package:collection/collection.dart'; import 'typed_buffer.dart'; /// The shared superclass of all the typed queue subclasses. -abstract class _TypedQueue> with ListMixin { +abstract class _TypedQueue> with ListMixin { /// The underlying data buffer. - /// - /// This is always both a List and a TypedData, which we don't have a type - /// for that. For example, for a `Uint8Queue`, this is a `Uint8List`. - L _table; + TypedDataList _table; int _head; int _tail; /// Create an empty queue. - _TypedQueue(List table) - : _table = table as L, - _head = 0, + _TypedQueue(this._table) + : _head = 0, _tail = 0; // Iterable interface. @@ -330,20 +326,21 @@ abstract class _TypedQueue> with ListMixin { L _createList(int size); // Create a new typed buffer of the given type. - List _createBuffer(int size); + TypedDataBuffer _createBuffer(int size); /// The default value used to fill the queue when changing length. E get _defaultValue; } -abstract class _IntQueue> extends _TypedQueue { +abstract class _IntQueue> + extends _TypedQueue { _IntQueue(super.queue); @override int get _defaultValue => 0; } -abstract class _FloatQueue> +abstract class _FloatQueue> extends _TypedQueue { _FloatQueue(super.queue); diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8b595d7f..8984b2b9 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.3.3-wip +version: 1.4.0-wip description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/typed_data @@ -8,7 +8,7 @@ topics: - data-structures environment: - sdk: ^3.1.0 + sdk: ^3.5.0 dependencies: collection: ^1.15.0 From 5f6b7f5f509dd8b9f633fd418b33daa7761335ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:20:50 +0000 Subject: [PATCH 111/113] Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (dart-lang/typed_data#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.7 to 4.2.0
Release notes

Sourced from actions/checkout's releases.

v4.2.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.7...v4.2.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.7&new-version=4.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/typed_data/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/pkgs/typed_data/.github/workflows/test-package.yml index a39c2df0..dae44cb9 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/pkgs/typed_data/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [3.5, dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 4e32b75e32963cc51ddf020dc942e4d6be60091a Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 16:46:03 +0200 Subject: [PATCH 112/113] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/typed_data.md | 5 +++++ pkgs/typed_data/CONTRIBUTING.md | 33 ---------------------------- pkgs/typed_data/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 34 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/typed_data.md delete mode 100644 pkgs/typed_data/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/typed_data.md b/.github/ISSUE_TEMPLATE/typed_data.md new file mode 100644 index 00000000..81670b6c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/typed_data.md @@ -0,0 +1,5 @@ +--- +name: "package:typed_data" +about: "Create a bug or file a feature request against package:typed_data." +labels: "package:typed_data" +--- \ No newline at end of file diff --git a/pkgs/typed_data/CONTRIBUTING.md b/pkgs/typed_data/CONTRIBUTING.md deleted file mode 100644 index 6f5e0ea6..00000000 --- a/pkgs/typed_data/CONTRIBUTING.md +++ /dev/null @@ -1,33 +0,0 @@ -Want to contribute? Great! First, read this page (including the small print at -the end). - -### Before you contribute -Before we can use your code, you must sign the -[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) -(CLA), which you can do online. The CLA is necessary mainly because you own the -copyright to your changes, even after your contribution becomes part of our -codebase, so we need your permission to use and distribute your code. We also -need to be sure of various other things—for instance that you'll tell us if you -know that your code infringes on other people's patents. You don't have to sign -the CLA until after you've submitted your code for review and a member has -approved it, but you must do it before we can put your code into our codebase. - -Before you start working on a larger contribution, you should get in touch with -us first through the issue tracker with your idea so that we can help out and -possibly guide you. Coordinating up front makes it much easier to avoid -frustration later on. - -### Code reviews -All submissions, including submissions by project members, require review. - -### File headers -All files in the project must start with the following header. - - // Copyright (c) 2015, 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. - -### The small print -Contributions made by corporations are covered by a different agreement than the -one above, the -[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index 8984b2b9..b2c7f349 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -2,7 +2,7 @@ name: typed_data version: 1.4.0-wip description: >- Utility functions and classes related to the dart:typed_data library. -repository: https://github.com/dart-lang/typed_data +repository: https://github.com/dart-lang/core/tree/main/pkgs/typed_data topics: - data-structures From 8e43206eca5dc1a4804c733bf2924bf019c9a7ac Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 16:49:38 +0200 Subject: [PATCH 113/113] Ignore licenses for package:platform --- .github/labeler.yml | 4 ++ .../workflows/typed_data.yaml | 19 +++++++--- README.md | 1 + pkgs/typed_data/.github/dependabot.yml | 15 -------- .../.github/workflows/no-response.yml | 37 ------------------- .../typed_data/.github/workflows/publish.yaml | 17 --------- pkgs/typed_data/CHANGELOG.md | 3 +- pkgs/typed_data/README.md | 2 +- pkgs/typed_data/pubspec.yaml | 2 +- 9 files changed, 23 insertions(+), 77 deletions(-) rename pkgs/typed_data/.github/workflows/test-package.yml => .github/workflows/typed_data.yaml (84%) delete mode 100644 pkgs/typed_data/.github/dependabot.yml delete mode 100644 pkgs/typed_data/.github/workflows/no-response.yml delete mode 100644 pkgs/typed_data/.github/workflows/publish.yaml diff --git a/.github/labeler.yml b/.github/labeler.yml index fc71da29..a855702f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -23,3 +23,7 @@ "package:fixnum": - changed-files: - any-glob-to-any-file: 'pkgs/fixnum/**' + +"package:typed_data": + - changed-files: + - any-glob-to-any-file: 'pkgs/typed_data/**' diff --git a/pkgs/typed_data/.github/workflows/test-package.yml b/.github/workflows/typed_data.yaml similarity index 84% rename from pkgs/typed_data/.github/workflows/test-package.yml rename to .github/workflows/typed_data.yaml index dae44cb9..dcd63c6a 100644 --- a/pkgs/typed_data/.github/workflows/test-package.yml +++ b/.github/workflows/typed_data.yaml @@ -1,17 +1,26 @@ -name: Dart CI +name: package:typed_data on: - # Run on PRs and pushes to the default branch. + # Run CI on pushes to the main branch, and on PRs against main. push: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/typed_data.yaml' + - 'pkgs/typed_data/**' pull_request: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/typed_data.yaml' + - 'pkgs/typed_data/**' schedule: - cron: "0 0 * * 0" - env: PUB_ENVIRONMENT: bot.github +defaults: + run: + working-directory: pkgs/typed_data/ + jobs: # Check code formatting and static analysis on a single OS (linux) # against Dart dev. diff --git a/README.md b/README.md index 77c5fdb3..1ffc6f10 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu | [convert](pkgs/convert/) | Utilities for converting between data representations. | [![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert) | | [crypto](pkgs/crypto/) | Implementations of SHA, MD5, and HMAC cryptographic functions. | [![pub package](https://img.shields.io/pub/v/crypto.svg)](https://pub.dev/packages/crypto) | | [fixnum](pkgs/fixnum/) | Library for 32- and 64-bit signed fixed-width integers. | [![pub package](https://img.shields.io/pub/v/fixnum.svg)](https://pub.dev/packages/fixnum) | +| [typed_data](pkgs/typed_data/) | Utility functions and classes related to the dart:typed_data library. | [![pub package](https://img.shields.io/pub/v/typed_data.svg)](https://pub.dev/packages/typed_data) | ## Publishing automation diff --git a/pkgs/typed_data/.github/dependabot.yml b/pkgs/typed_data/.github/dependabot.yml deleted file mode 100644 index cde02ad6..00000000 --- a/pkgs/typed_data/.github/dependabot.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Dependabot configuration file. -# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates -version: 2 - -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit - groups: - github-actions: - patterns: - - "*" diff --git a/pkgs/typed_data/.github/workflows/no-response.yml b/pkgs/typed_data/.github/workflows/no-response.yml deleted file mode 100644 index ab1ac498..00000000 --- a/pkgs/typed_data/.github/workflows/no-response.yml +++ /dev/null @@ -1,37 +0,0 @@ -# A workflow to close issues where the author hasn't responded to a request for -# more information; see https://github.com/actions/stale. - -name: No Response - -# Run as a daily cron. -on: - schedule: - # Every day at 8am - - cron: '0 8 * * *' - -# All permissions not specified are set to 'none'. -permissions: - issues: write - pull-requests: write - -jobs: - no-response: - runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dart-lang' }} - steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e - with: - # Don't automatically mark inactive issues+PRs as stale. - days-before-stale: -1 - # Close needs-info issues and PRs after 14 days of inactivity. - days-before-close: 14 - stale-issue-label: "needs-info" - close-issue-message: > - Without additional information we're not able to resolve this issue. - Feel free to add more info or respond to any questions above and we - can reopen the case. Thanks for your contribution! - stale-pr-label: "needs-info" - close-pr-message: > - Without additional information we're not able to resolve this PR. - Feel free to add more info or respond to any questions above. - Thanks for your contribution! diff --git a/pkgs/typed_data/.github/workflows/publish.yaml b/pkgs/typed_data/.github/workflows/publish.yaml deleted file mode 100644 index 27157a04..00000000 --- a/pkgs/typed_data/.github/workflows/publish.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# A CI configuration to auto-publish pub packages. - -name: Publish - -on: - pull_request: - branches: [ master ] - push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] - -jobs: - publish: - if: ${{ github.repository_owner == 'dart-lang' }} - uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main - permissions: - id-token: write # Required for authentication using OIDC - pull-requests: write # Required for writing the pull request note diff --git a/pkgs/typed_data/CHANGELOG.md b/pkgs/typed_data/CHANGELOG.md index af74b2fb..8763a879 100644 --- a/pkgs/typed_data/CHANGELOG.md +++ b/pkgs/typed_data/CHANGELOG.md @@ -1,10 +1,11 @@ -## 1.4.0-wip +## 1.4.0 * The type of the `buffer` constructor argument to `TypedDataBuffer` is now `TypeDataList` (instead of `List`). While this is breaking change statically there was a runtime cast that makes this change a no-op in practice. * Require Dart 3.5 +* Move to `dart-lang/core` monorepo. ## 1.3.2 diff --git a/pkgs/typed_data/README.md b/pkgs/typed_data/README.md index 212c48e4..512f43bb 100644 --- a/pkgs/typed_data/README.md +++ b/pkgs/typed_data/README.md @@ -1,4 +1,4 @@ -[![Dart CI](https://github.com/dart-lang/typed_data/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/typed_data/actions/workflows/test-package.yml) +[![Dart CI](https://github.com/dart-lang/core/actions/workflows/typed_data.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/typed_data.yaml) [![pub package](https://img.shields.io/pub/v/typed_data.svg)](https://pub.dev/packages/typed_data) [![package publisher](https://img.shields.io/pub/publisher/typed_data.svg)](https://pub.dev/packages/typed_data/publisher) diff --git a/pkgs/typed_data/pubspec.yaml b/pkgs/typed_data/pubspec.yaml index b2c7f349..a03331fc 100644 --- a/pkgs/typed_data/pubspec.yaml +++ b/pkgs/typed_data/pubspec.yaml @@ -1,5 +1,5 @@ name: typed_data -version: 1.4.0-wip +version: 1.4.0 description: >- Utility functions and classes related to the dart:typed_data library. repository: https://github.com/dart-lang/core/tree/main/pkgs/typed_data