Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Better typedefs for NativeFunctions #621

Merged
merged 7 commits into from
Sep 19, 2023
Merged

Better typedefs for NativeFunctions #621

merged 7 commits into from
Sep 19, 2023

Conversation

liamappelbe
Copy link
Contributor

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

Fixes dart-lang/native#431.

@@ -10432,6 +10434,11 @@ typedef CXInclusionVisitor = ffi.Pointer<
ffi.Pointer<CXSourceLocation> inclusion_stack,
ffi.UnsignedInt include_len,
CXClientData client_data)>>;
typedef CXInclusionVisitor_function = ffi.Void Function(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming-wise, it feels like this one should be without _function and the other one should be renamed _pointer. Do you know if we have a lot of uses of these typedefs, if it would be worth the breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but we could avoid a breaking change by putting this behind a flag. Eg, add a flag called use-function-typedefs, and if it's true we add _pointer to the existing definition and then define the function definition with the current name. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just merge as is.

Copy link
Contributor

@dcharkes dcharkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@liamappelbe liamappelbe merged commit 2811206 into main Sep 19, 2023
6 checks passed
@liamappelbe liamappelbe deleted the func_typedef branch September 19, 2023 21:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Ffigen doesn't generate typedefs compatible with NativeCallable's APIs
2 participants