-
Notifications
You must be signed in to change notification settings - Fork 49
[JExtract/JNI] Add support for classes/structs as parameters and return values #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@rintaro As I refactored the code to match the way FFM does things, with |
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now!
@@ -110,7 +110,7 @@ extension JNISwift2JavaGenerator { | |||
// so we pass the pointer. | |||
return NativeResult( | |||
javaType: .long, | |||
conversion: .getJNIValue(.allocateSwiftValue(name: "_result", swiftType: swiftResult.type)) | |||
conversion: .getJNIValue(.allocateSwiftValue(name: "result", swiftType: swiftResult.type)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
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.