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

Loading multiple dynamic libraries with the same bindings #532

Closed
dcharkes opened this issue Jun 23, 2020 · 0 comments · Fixed by dart-archive/ffigen#25
Closed

Loading multiple dynamic libraries with the same bindings #532

dcharkes opened this issue Jun 23, 2020 · 0 comments · Fixed by dart-archive/ffigen#25

Comments

@dcharkes
Copy link
Collaborator

See dart-lang/sdk#42082.

While I think the use case is a bit uncommon, we should explore enabling this. However, preferably without complicating the API for the case in which there is just one.

Currently we have a top-level init, and top-level functions that can be called.

DynamicLibrary _dylib;

/// Initialises dynamic library
void init(DynamicLibrary dylib) {
  _dylib = dylib;
}

int sum(int a,int b) {
  return _sum(a,b);
}

final _dart_sum _sum = _dylib.lookupFunction<_c_sum, _dart_sum>('sum');

typedef _c_sum = Int32 Function(Int32 a,Int32 b);

typedef _dart_sum = int Function(int a,int b);

We could consider wrapping those in a class that has as a single member the DynamicLibrary and having all the functions as methods on the object.

That does slightly regress the usage, but if people use it with named imports, it does not really matter whether they write named_import.someFfiFunction() or an_object.someFfiFunction(), and they can just make that object a toplevel definition that they import everywhere.

@mannprerak2, maybe we should address this before releasing v0.1 because it changes the API.

dcharkes referenced this issue in dart-archive/ffigen Jul 10, 2020
…de (#25)

Closes #10.

Moves the functions from toplevel to a class to facilitate being able to use the bindings more flexibly.

* Replaced config init-function-name with name and description.
* Handled name conflicts - Function-Function, Typedef - Function - Struct/Enum.
* Updated examples and clang_bindings, Updated tests.
@liamappelbe liamappelbe transferred this issue from dart-archive/ffigen Nov 15, 2023
parlough pushed a commit to parlough/native that referenced this issue Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants