Skip to content

Commit 8de76ba

Browse files
authored
Lower SDK lower bound to 3.0.0 (dart-archive/native_synchronization#5)
1 parent ef45ca3 commit 8de76ba

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

pkgs/native_synchronization/.github/workflows/dart.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ permissions: read-all
1414

1515
jobs:
1616
analyze:
17-
runs-on: ubuntu-latest
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
sdk: [dev, stable]
1822

1923
steps:
2024
# These are the latest versions of the github actions; dependabot will
2125
# send PRs to keep these up-to-date.
2226
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2327
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
2428
with:
25-
sdk: dev
29+
sdk: ${{ matrix.sdk }}
2630

2731
- name: Install dependencies
2832
run: dart pub get
@@ -39,7 +43,7 @@ jobs:
3943
strategy:
4044
matrix:
4145
os: [ubuntu-latest, macos-latest, windows-latest]
42-
sdk: [dev]
46+
sdk: [dev, stable]
4347
steps:
4448
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
4549
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f

pkgs/native_synchronization/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.0
2+
3+
- Lower SDK lower bound to 3.0.0.
4+
15
## 0.1.0
26

37
- Initial version.

pkgs/native_synchronization/lib/mailbox.dart

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,22 @@ class Mailbox {
103103
static final _emptyResponse = Uint8List(0);
104104

105105
static Uint8List _toList(Pointer<Uint8> buffer, int length) {
106-
return length == 0
107-
? _emptyResponse
108-
// We have to ignore sdk_version_since warning due to dartbug.com/53142.
109-
// ignore: sdk_version_since
110-
: buffer.asTypedList(length, finalizer: malloc.nativeFree);
106+
if (length == 0) {
107+
return _emptyResponse;
108+
}
109+
110+
// TODO: remove feature detection once 3.1 becomes stable.
111+
// ignore: omit_local_variable_types
112+
final Uint8List Function(int) asTypedList = buffer.asTypedList;
113+
if (asTypedList is Uint8List Function(int,
114+
{Pointer<NativeFinalizerFunction> finalizer})) {
115+
return asTypedList(length, finalizer: malloc.nativeFree);
116+
}
117+
118+
final result = Uint8List(length);
119+
result.setRange(0, length, buffer.asTypedList(length));
120+
malloc.free(buffer);
121+
return result;
111122
}
112123

113124
static Pointer<Uint8> _toBuffer(Uint8List list) {

pkgs/native_synchronization/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: native_synchronization
22
description: Low level synchronization primitives built on dart:ffi.
3-
version: 0.1.0
3+
version: 0.2.0
44
repository: https://github.com/dart-lang/native_synchronization
55

66
environment:
7-
sdk: ">=3.1.0-348.0.dev <4.0.0"
7+
sdk: ">=3.0.0 <4.0.0"
88

99
dependencies:
1010
ffi: ^2.1.0

0 commit comments

Comments
 (0)