| // Copyright (c) 2026, 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'; | |
| @Native<Int32 Function(Int32, Double)>(symbol: 'foo') | |
| external int nativeFoo(int a, double b); | |
| int Function(int, double) asFunction( | |
| Pointer<NativeFunction<Int32 Function(Int32, Double)>> ptr, | |
| ) => ptr.asFunction(); | |
| Pointer<Void> Function(Pointer<Void>, int) asFunctionLeaf( | |
| Pointer<NativeFunction<Pointer<Void> Function(Pointer<Void>, IntPtr)>> ptr, | |
| ) => ptr.asFunction(isLeaf: true); | |
| void asFunctionVoid(Pointer<NativeFunction<Void Function()>> ptr) { | |
| final f = ptr.asFunction<void Function()>(); | |
| f(); | |
| } | |
| @Native<Int64 Function(Handle, Int32)>(symbol: 'handle') | |
| external int nativeHandle(Object a, int b); | |
| int Function(Object) asFunctionHandle( | |
| Pointer<NativeFunction<Int64 Function(Handle)>> ptr, | |
| ) => ptr.asFunction(); | |
| void main() {} |