Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ffi] Explore more concise dynamic library binding #36854

Closed
dcharkes opened this issue May 6, 2019 · 4 comments
Closed

[ffi] Explore more concise dynamic library binding #36854

dcharkes opened this issue May 6, 2019 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi

Comments

@dcharkes
Copy link
Contributor

dcharkes commented May 6, 2019

Explore if we could use type annotations on dynamic library function signatures (similar to struct fields) to avoid writing two signatures.

Moreover, the asLibrary would dynamically link all functions in one go.

abstract class FooBar extends Library {
  @Int32
  int Truncate64(@Int64 int x);
}

// Part of dart:ffi
class DynamicLibrary {
  // ...
  T asLibrary<T extends Library>();
}

Suggested in #34452 (comment)

/cc @mraleph @sjindel-google

@dcharkes dcharkes added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi labels May 6, 2019
@dcharkes
Copy link
Contributor Author

Annotations on typedefs? It's more likely than you think!
@eernst Erik, where are we with filling in the annotation holes in the grammar?

Originally posted by @lrhn in #34452 (comment)

@eernstg and @lrhn: Are typedefs inlined in the dart compiler? And if so, are annotations preserved?

typedef FunctionPointer = @Int32 int TruncationFunction(@Int64 int x);

Pointer<FunctionPointer> myPointer = //...

@lrhn
Copy link
Member

lrhn commented May 20, 2019

Ah, I meant something like:

@Something
typedef MyType = int Function(int);

Putting annotations into the value is probably not going to work. Annoatations in Dart goes on declarations, in general, things that have a name or identity. Structural types are not such a thing.

@dcharkes
Copy link
Contributor Author

dcharkes commented Sep 7, 2020

Now that we have https://pub.dev/packages/ffigen, we might not need this as much as before.

@dcharkes
Copy link
Contributor Author

We will address this by introducing assets:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi
Projects
None yet
Development

No branches or pull requests

2 participants