Skip to content

[vm/ffi] Expose persistent handles to Dart through FFI #36858

Closed
@sjindel-google

Description

@sjindel-google

The native API (dart_api.h) exposes persistent handles to native code through pointers. We should add support to the FFI to creating persistent handles in dart (as ffi.Pointers) which can be passed back into native calls. This would be useful, for example, for passing state through native callbacks.

I imagine the API would look something like:

abstract class PersistentHandle extends Pointer<Void> {
  PersistentHandle(Object target) native "...";
  Object get target native "...";
  set target(Object val) native "...";
  void destroy() native "...";
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sjindel-google

        Issue actions

          [vm/ffi] Expose persistent handles to Dart through FFI · Issue #36858 · dart-lang/sdk