Skip to content

[ffi] @Native for global fixed-size arrays #54337

Closed
@dcharkes

Description

@dcharkes

https://dart-review.googlesource.com/c/sdk/+/338020 adds support for #50551, but does not add support for global fixed size arrays.

double foo[4];

double return_double() {
  return foo[1];
}

void set_double(double value) {
  foo[2] = value;
}

Could theoretically be bound to.

@Array(4)
@Native()
external Array<Double> foo;

It just so happens to be that currently the following works because the memory layout is identical.

@Native()
external Pointer<Double> foo;

The advantage of supporting the latter is that we can do bound checks on use.

@simolus3 Thanks for making the Array limitation explicit in https://dart-review.googlesource.com/c/sdk/+/338020. Here are some of my thoughts about it.

Re dart-lang/native#860, should we temporarily support generating Pointers for fixed-size global arrays? That would make it a breaking change later to make it Arrays, though. On the other hand, if users would like to use those fields than without generating Pointers, users can't use FFIgen at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffitriagedIssue has been triaged by sub team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions