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

When generating typedefs for NativeFunction<Function>, also generate a typedef for the Function. #944

Open
axelsommerfeldt opened this issue Jan 18, 2024 · 0 comments
Labels
good first issue A good starting issue for contributors (issues with this label will appear in /contribute) package:ffigen

Comments

@axelsommerfeldt
Copy link

In version 10.0.0 of ffigen the following feature was implemented:
"When generating typedefs for Pointer<NativeFunction<Function>>, also generate a typedef for the Function."

It would be great if this would work for typedefs for NativeFunction<Function> as well.

Example:

typedef void (*list_callback)( string_list_t *list );
void test_list( list_callback callback );

ffigen generates:

typedef list_callback = ffi.Pointer<ffi.NativeFunction<list_callbackFunction>>;
typedef list_callbackFunction = ffi.Void Function(ffi.Pointer<string_list_t> list);

but for

typedef void list_callback( string_list_t *list );
void test_list( list_callback *callback );

ffigen generates:

typedef list_callback = ffi.NativeFunction<ffi.Void Function(ffi.Pointer<string_list_t> list)>;

which cannot be used with ffi.NativeCallable.

If ffigen would generate this code instead:

typedef list_callback = ffi.NativeFunction<list_callbackFunction>;
typedef list_callbackFunction = ffi.Void Function(ffi.Pointer<string_list_t> list);

Then list_callbackFunction could be used in the dart code (using NativeCallable):

late final ffi.NativeCallable<list_callbackFunction> list_callback;
...
@liamappelbe liamappelbe added the good first issue A good starting issue for contributors (issues with this label will appear in /contribute) label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A good starting issue for contributors (issues with this label will appear in /contribute) package:ffigen
Projects
None yet
Development

No branches or pull requests

2 participants