Skip to content

Conversation

@madsodgaard
Copy link
Contributor

Adds support for passing in classes/structs as parameters to functions and returning them as well. All functions now generate both a public "user-facing" Java method and a native method that is called from that. Any classes are passed as pointers and returned as pointers.

I also refactored quite a bit of the internal code to make it match the FFM style more, this should make it easier to understand and contribute to both modes.

@madsodgaard
Copy link
Contributor Author

@rintaro As I refactored the code to match the way FFM does things, with ConversionSteps and so on, it would be nice if you could take a look at this PR as well 😄

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Overall looks good to me! I did have some small nitpicks here and there. @rintaro could you also give it a look? This duplicates some small types the FFM side used, but maybe this way we'll be able to head towards converging them a bit... rather than do it all right away 🤔

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Looks good now!

return NativeResult(
javaType: .long,
conversion: .getJNIValue(.allocateSwiftValue(name: "_result", swiftType: swiftResult.type))
conversion: .getJNIValue(.allocateSwiftValue(name: "result", swiftType: swiftResult.type))
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks :)

@ktoso ktoso merged commit a25d216 into swiftlang:main Jul 22, 2025
79 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants