-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-ffi
Milestone
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-ffi
Type
Projects
Relationships
Development
Select code repository
Activity
djpnewton commentedon Jul 13, 2019
also support for fixed size arrays.
its quite common to have a struct with fixed sized arrays to pass around in C
dcharkes commentedon Oct 25, 2019
We have
asTypedList
for exposing the native memory as a Dart array.For structs with inline arrays:
We need a dart syntax of representing an inline array.
We could opt for exposing this as a pointer, which provides
[]
and[]=
access.Using a
Pointer
as the representing type does not allow us to distinguish pointers and inline arrays by the Dart type. However, this is not really a problem since C does not support passing fixed-size arrays by value in calls.cc @mkustermann
edit: We do not want to expose it as a pointer, rather as a
CArray
which represents a fixed-size inlined array.CArray
would be a view on top of the underlying pointer (kind of like struct).If we expose the nested structs and the inline array as getter/setter pair, the setters would do a memcopy of the whole underlying structure.
(As sidenote, we should also introduce memcopy on structs:
)
[-]dart:ffi Arrays[/-][+][dart:ffi] Inline arrays in Structs[/+]kakyoism commentedon Mar 30, 2020
@dcharkes
I got this error when trying your solution to getting static arrays on Dart side
Code
Result
Does it mean that this is just a proposal?
What would be the canonical way of getting array data from FFI C pointers?
I'm referring to my latest question.
Thanks in advance!
dcharkes commentedon Mar 30, 2020
Yes, for now it's just a proposal.
See the workaround made by @timsneath here for now.
I'll get around to implementing this in the future, I'm working on other
dart:ffi
features at the moment.34 remaining items