-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-native-interopUsed for native interop related issues, including FFI.Used for native interop related issues, including FFI.contributions-welcomeContributions welcome to help resolve this (the resolution is expected to be clear from the issue)Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)library-ffi
Description
Many functions with buffers take a void*
, for example https://en.cppreference.com/w/c/io/fread.
However, using a Uint8List
and .address
yields a Pointer<Uint8>
.
It would be useful to be able to pass uint8list.address.cast()
. That would prevent having to modify the FFIgen generated function signature.
Thanks for the suggestion @brianquinlan!
For anyone willing to contribute, the implementation is in:
sdk/pkg/vm/lib/modular/transformations/ffi/use_sites.dart
Lines 1489 to 1504 in 05d9e5b
/// Converts a single parameter with argument for [_replaceNativeCall]. | |
( | |
/// '' for non-Pointer. | |
/// 'P' for Pointer. | |
/// 'T' for TypedData. | |
/// 'C' for _Compound (TypedData/Pointer and offset in bytes). | |
/// 'E' for errors. | |
String methodPostFix, | |
DartType parameterType, | |
Expression argument, | |
) _replaceNativeCallParameterAndArgument( | |
VariableDeclaration parameter, | |
DartType parameterType, | |
Expression argument, | |
int fileOffset, | |
) { |
The implementation should find the
cast()
invocation and use its receiver instead (effectively ignoring the cast expression as a no-op).Metadata
Metadata
Assignees
Labels
area-native-interopUsed for native interop related issues, including FFI.Used for native interop related issues, including FFI.contributions-welcomeContributions welcome to help resolve this (the resolution is expected to be clear from the issue)Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)library-ffi