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

ext/ffi: support alias names for symbol definitions #13089

Closed
DjDeveloperr opened this issue Dec 15, 2021 · 0 comments · Fixed by #13090
Closed

ext/ffi: support alias names for symbol definitions #13089

DjDeveloperr opened this issue Dec 15, 2021 · 0 comments · Fixed by #13090

Comments

@DjDeveloperr
Copy link
Contributor

DjDeveloperr commented Dec 15, 2021

Suggestion

An optional field name (symbol's name) to Foreign Function interface, which would default to the name of key in the function definitions in second parameter.

Why

  • Allows making a blocking variant and a non-blocking variant of same symbol. Such as a readFileSync and readFile.
  • Allows adding multiple overloads for same symbol. C functions can use varargs to do that. objc_msgSend for example.
  • Allows renaming the symbol in some other convention, such as snake_case to camelCase.

Example

const lib = Deno.dlopen("Kernel32", {
  readFileSync: {
    name: "ReadFileA",
    // ...
  },
  readFile: {
    name: "ReadFileA",
    nonblocking: true,
    // ...
  },
  // Still works
  ReadFile: {
    // ...
  },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant