Skip to content

[Feature] Configuration for alias for variadic C function #398

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

Closed
Sunbreak opened this issue Mar 7, 2021 · 3 comments
Closed

[Feature] Configuration for alias for variadic C function #398

Sunbreak opened this issue Mar 7, 2021 · 3 comments

Comments

@Sunbreak
Copy link
Contributor

Sunbreak commented Mar 7, 2021

Background

According to dart-lang/sdk#38578 (comment), we have to manually declare several common functions as alias for variadic C function.

Every time re-generating the open2, we have to manully edit the generated _dylib.lookupFunction<>('open2')) to _dylib.lookupFunction<>('open'))

https://github.com/Sunbreak/logic_conf.dart/blob/a2b18a947fec46859ad09fcd44050a305c14909d/linux/libc.h#L10

// FIMXE https://github.com/dart-lang/sdk/issues/38578
// Need manully change name from `open2` to `open` after `ffigen`
extern int open2 (const char *__file, int __oflag) __nonnull ((1));

https://github.com/Sunbreak/logic_conf.dart/blob/a2b18a947fec46859ad09fcd44050a305c14909d/lib/src/linux/libc.dart#L14-L22

  int open2(
    ffi.Pointer<ffi.Int8> __file,
    int __oflag,
  ) {
    return (_open2 ??= _dylib.lookupFunction<_c_open2, _dart_open2>('open'))(
      __file,
      __oflag,
    );
  }

Feature Request

Could we have some config for variadic alias?

functions:
  remap:
    'open2': 'open'
    'open3': 'open'
    'open4': 'open'
@mannprerak2
Copy link
Contributor

I see 2 workarounds for generating variadic functions -

  1. The user defines some functions in a new header file and remap its name (as Suggested by @Sunbreak above)
  2. Alternatively we could let users add part 'file.dart' to the generated file, so they can manually extend the generated file and append new functions to the generated class by hand.

cc @dcharkes

@Sunbreak
Copy link
Contributor Author

Sunbreak commented Feb 7, 2022

Any update?

@mannprerak2
Copy link
Contributor

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

No branches or pull requests

3 participants