When generating typedefs for `NativeFunction<Function>`, also generate a typedef for the `Function`.
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 52
Description
In version 10.0.0 of ffigen the following feature was implemented:
"When generating typedefs for `Pointer>`, also generate a typedef for the `Function`."
It would be great if this would work for typedefs for `NativeFunction` as well.
Example:
```
typedef void (*list_callback)( string_list_t *list );
void test_list( list_callback callback );
```
ffigen generates:
```
typedef list_callback = ffi.Pointer>;
typedef list_callbackFunction = ffi.Void Function(ffi.Pointer list);
```
but for
```
typedef void list_callback( string_list_t *list );
void test_list( list_callback *callback );
```
ffigen generates:
```
typedef list_callback = ffi.NativeFunction list)>;
```
which cannot be used with `ffi.NativeCallable`.
If ffigen would generate this code instead:
```
typedef list_callback = ffi.NativeFunction;
typedef list_callbackFunction = ffi.Void Function(ffi.Pointer list);
```
Then `list_callbackFunction` could be used in the dart code (using `NativeCallable`):
```
late final ffi.NativeCallable list_callback;
...
```
Contributor guide
Research direction
Start in ffigen's typedef generation logic and compare handling of NativeFunction with the existing Pointer> case described in the issue. Use the two C typedef examples as inputs and verify that the direct NativeFunction case produces both the native alias and the callable Dart Function alias needed by NativeCallable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100