native
native copied to clipboard
When generating typedefs for `NativeFunction<Function>`, also generate a typedef for the `Function`.
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;
...