Fix: Expand Swift variadic functions into explicit Java overloads - #859
Conversation
|
Though I wonder it it would be better to support it by generating a number of overloads with up to N parameters where we take the N from configuration maybe? |
|
Yeah, I like that approach. It seems like a much cleaner solution. |
|
Thanks! |
65e20f3 to
8c5a30f
Compare
ktoso
left a comment
There was a problem hiding this comment.
This is shaping up great, some comments still and please add runtime testing
| "sum(long arg0, long arg1, long arg2, long arg3)" | ||
| ] | ||
| ) | ||
| } |
There was a problem hiding this comment.
Please make a runtime test; we make those by adding a func in the Samples/SwiftJavaExtractJNISampleApp and exercise the functions in Java test code in the same project. This verifies it all works at runtime as well
|
Thanks this is pretty good, we might want to move the expand... outside the initializer though, but we can do it in a follow up |
|
Thanks! I'll fix the failing checks and update the PR. |
2533d08 to
fb2d5cd
Compare
|
I didn't expect to run into so many formatting issues. I'll get the formatter working locally before my next PR so I can catch these ahead of time. |
|
Hah yeah, sorry about this -- sadly the formatting can be pretty picky, definitely worth getting working locally |
|
I'll apply fixes, since I'm cutting a release now -- please look into getting formatter working locally though, it should mostly just work tbh 🤔 |
a268a44 to
277545e
Compare
|
Thanks again! |
Fixes #830.
Description
This PR introduces support for generating Java bindings for Swift variadic functions. Previously, variadic functions were not handled correctly in the generated Java code.
Changes Made
func log(items: String...)) into multiple explicit Java overloads up to a configurable limit (effectiveMaxVariadicOverloads).FFMSwift2JavaGeneratorandJNISwift2JavaGeneratorto perform the overload expansion using a local variable during initialization. This keepsanalysisas an immutableletproperty on the generator classes, addressing previous review feedback.self.analysisis fully initialized before invoking instance methods likegenerateInterfaceWrappers()inJNISwift2JavaGenerator, resolving Swift compiler errors regarding premature use ofself.This ensures we get comprehensive Java bindings for variadic functions without sacrificing the immutability of the generator's internal state.