Repository navigation
JVM targets, primitive arrays, sealed value hierarchies and default arguments - #1
Merged
Merged
Conversation
- A Kotlin Multiplatform module's jvm() target runs the façades in its own JVM: nja-client gets a jvm target whose transport calls the server's dispatcher on the calling thread (callbacks served back on it, as on iOS without JNI); the plugin puts the façades on the target's runtime class path and checks that their proxies have a package of their own (njaFacade.clientPackage), as both are on it. - IntArray, LongArray, FloatArray and DoubleArray cross the bridge as a count and their elements. - A sealed interface or class whose nested cases are all data classes or objects travels by value (its case, then the case's fields), copied verbatim like a data class; value types now reference each other by name, so they may be recursive (a sealed value holding a list of itself, through a data class...). - examples/calculator: a jvm target running the same suites, the proxies in their own packages, tests for the arrays and the sealed values. Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
- A façade's close() is the proxy's: it calls the JVM object's close(), then releases it, once (it was generated as a member hiding JvmObject's). - Private and internal declarations are left out of the symbol table, private constructor properties out of the API, and a class whose constructor is private, internal or takes what can't cross the bridge isn't constructible from the app (its constructor's unsupported parameters were dropped). Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
A method's (or a companion's) trailing parameters with default values get overloads, as constructors do: the app leaves them out, the JVM applies the façade's defaults. A function with a parameter or a result that can't cross the bridge is left out (the parameter was dropped, the result taken for Unit). Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
The test names also have to be valid DEX and Kotlin/Native names (no comma, no apostrophe). Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What Zayit's search needs to use NJA for Lucene on every platform (kdroidFilter/SeforimLibrary#134, kdroidFilter/Zayit#698), as general NJA features.
jvm()targets (a desktop app):nja-clientgets a JVM target whose transport calls the server's dispatcher on the calling thread. Callbacks are served back on that thread, as on iOS but without JNI. The plugin puts the façades on the target's runtime class path. The app's code is therefore the same on every platform, and the messages are still encoded.njaFacade.clientPackage).nja-packages.properties, and acheckNja<Target>ClientPackagestask fails clearly before the JVM target compiles if the packages collide.IntArray,LongArray,FloatArrayandDoubleArraycross as a count and their elements.AutoCloseablefaçades: theirclose()is generated as the proxy'soverride fun close(). It closes the JVM object, then releases it, once. It used to be generated as a member hidingJvmObject.close(), which didn't compile.Unit.examples/calculator:jvm()target running the same suites.AutoCloseable, internal constructors and default arguments.Verification
examples/calculator: 2,008 tests pass on all three platforms:jvmTest,iosSimulatorArm64Test(jdk-mobile-27b35.3) andconnectedAndroidDeviceTest(Android 11 emulator).Notes
clientPackage, so the example's tests are incom.example.calculator.client. Other consumers keep the default package unless they add a JVM target.searchkituses SeforimLibrary'ssearch) gets Android for free through the library's AAR. Its iOS binaries, though, still have to link the runtime and copy NJA's bundle by hand. Supporting that case in the plugin would be a natural follow-up.