mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:43:57 +00:00
fbee607329
Address all warnings and errors in positive tests. Move all static checks tests to tests/ffi/static_checks/ so it's easier to ignore them in the analyzer. Change-Id: I16ac2c00432a4e1b6750bffd9b03ac8a2e988fe6 Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351123 Reviewed-by: Liam Appelbe <liama@google.com>
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
// Copyright (c) 2023, 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:ffi';
|
|
|
|
import 'dylib_utils.dart';
|
|
|
|
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
|
|
|
|
typedef NativeAsyncCallbackTest = Void Function(Pointer);
|
|
typedef NativeAsyncCallbackTestFn = void Function(Pointer);
|
|
|
|
class AsyncCallbackTest {
|
|
final String name;
|
|
final Future<void> Function() afterCallbackChecks;
|
|
|
|
// Either a NativeCallable or a Pointer.fromFunction.
|
|
final Object callback;
|
|
|
|
AsyncCallbackTest(this.name, this.callback, this.afterCallbackChecks) {}
|
|
|
|
Future<void> run() async {
|
|
final NativeAsyncCallbackTestFn tester = ffiTestFunctions.lookupFunction<
|
|
NativeAsyncCallbackTest, NativeAsyncCallbackTestFn>("TestAsync$name");
|
|
|
|
final cb = callback;
|
|
tester(cb is NativeCallable ? cb.nativeFunction : cb as Pointer);
|
|
|
|
await afterCallbackChecks();
|
|
if (cb is NativeCallable) {
|
|
cb.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
void noChecks() {}
|