diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 3af713a..a39c2df 100644 --- a/.github/workflows/test-package.yml +++ b/.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/CHANGELOG.md b/CHANGELOG.md index 2b3af0e..af74b2f 100644 --- a/CHANGELOG.md +++ b/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/lib/src/typed_buffer.dart b/lib/src/typed_buffer.dart index b79e7a6..dcb2c58 100644 --- a/lib/src/typed_buffer.dart +++ b/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/lib/src/typed_queue.dart b/lib/src/typed_queue.dart index c792917..84ce529 100644 --- a/lib/src/typed_queue.dart +++ b/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/pubspec.yaml b/pubspec.yaml index 8b595d7..8984b2b 100644 --- a/pubspec.yaml +++ b/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