-
Notifications
You must be signed in to change notification settings - Fork 66
[JExtract/JNI] Add support for async Swift methods
#413
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
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftJavaConfigurationShared/JExtract/JExtractAsyncMode.swift
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift
Outdated
Show resolved
Hide resolved
SwiftKitCore/src/main/java/org/swift/swiftkit/core/ConfinedSwiftMemorySession.java
Show resolved
Hide resolved
SwiftKitCore/src/main/java/org/swift/swiftkit/core/SwiftAsync.java
Outdated
Show resolved
Hide resolved
Samples/SwiftJavaExtractJNISampleApp/src/jmh/java/com/example/swift/AsyncBenchmark.java
Outdated
Show resolved
Hide resolved
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift
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.
This is looking very good, thanks!
| if swiftFunctionResultType.isVoid { | ||
| printer.print("environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])") | ||
| } else { | ||
| printer.printBraceBlock("withVaList([SwiftJavaRuntimeSupport._JNIBoxedConversions.box(\(inner), in: environment)])") { printer in |
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.
On Android, I'm getting this compilation error:
withVaList([SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNIValue(in: environment), in: environment)]) {
| `- error: cannot convert value of type 'jobject' (aka 'UnsafeMutableRawPointer') to expected element type 'any CVarArg'
This appears to originate from this code, though it compiles fine on Darwin. I'm not certain if this is an issue with my local Android sdk or not so just wanted to flag it.
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.
@0xZaph thanks for reporting this! seems like the issue is that the Android JNI imports jobjects as UnsafeRawMutablePointer, but that does not conform to CVarArg. And the "normal" JNI, imports it as OpaquePointer, which does.
I'll move away from withVaList, which also should fix swiftlang/swift-android-examples#15
Adds support for extracting
asyncmethods from Swift.We use an upcall from Swift to Java to complete a
CompletableFutureAdditional changes:
SwiftKitSwifttoSwiftRuntimeFunctionsSwiftJavaRuntimeSupportfor runtime files needed by JExtract