Skip to content

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

Open
@axelsommerfeldt

Description

@axelsommerfeldt

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;
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueA good starting issue for contributors (issues with this label will appear in /contribute)package:ffigen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions