dart-sdk/samples/ffi/sample_ffi_dynamic_library.dart
Daco Harkes da008fb3fc [samples] Migrate ffi samples to NNBD
Closes: https://github.com/dart-lang/sdk/issues/43600.

TEST=samples/ffi

Change-Id: I620e6a73c8e37dd72f8f3921fa37dd4f8966e45c
Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,dart-sdk-linux-try,analyzer-nnbd-linux-release-try,analyzer-linux-release-try,front-end-nnbd-linux-release-x64-try,front-end-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173542
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-11-24 18:50:28 +00:00

24 lines
643 B
Dart

// 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:ffi';
import 'dylib_utils.dart';
typedef NativeDoubleUnOp = Double Function(Double);
typedef DoubleUnOp = double Function(double);
main() {
DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
print(l);
print(l.runtimeType);
var timesFour = l.lookupFunction<NativeDoubleUnOp, DoubleUnOp>("timesFour");
print(timesFour);
print(timesFour.runtimeType);
print(timesFour(3.0));
}