-
Notifications
You must be signed in to change notification settings - Fork 49
[JExtract/JNI] Add support for primitive non-escaping closures. #327
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+JavaBindingsPrinting.swift
Show resolved
Hide resolved
Overall looks good! I was looking at the last commit in here :) |
2012bd1
to
0e798f0
Compare
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Show resolved
Hide resolved
let methodID$ = environment!.interface.GetMethodID(environment, class$, "apply", "(JZ)J")! | ||
let arguments$: [jvalue] = [_0.getJValue(in: environment!), _1.getJValue(in: environment!)] | ||
return Int64(fromJNI: environment!.interface.CallLongMethodA(environment, closure, methodID$, arguments$), in: environment!) | ||
} |
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.
I'd kinda want to do one guard
for the environment like we did elsewhere but this is minor, let's revisit holistically someday 👍
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.
LGTM!
Adds support for importing non-escaping closures that only handle primitive types supported by
JavaKit
.Just like FFM, each closure is imported as an
@FunctionalInterface
that gets passed down to JNI. Then we call the apply method using JNI.