-
Notifications
You must be signed in to change notification settings - Fork 45
[JExtract] Generate JNI code for classes (static methods and initializers) #298
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
Merged
Conversation
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
Nice, and here's the issue to track the swiftkit split-up #299 |
ktoso
reviewed
Jul 3, 2025
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Outdated
Show resolved
Hide resolved
ktoso
reviewed
Jul 3, 2025
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift
Show resolved
Hide resolved
ktoso
reviewed
Jul 3, 2025
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift
Outdated
Show resolved
Hide resolved
ktoso
reviewed
Jul 3, 2025
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaTranslation.swift
Outdated
Show resolved
Hide resolved
ktoso
reviewed
Jul 3, 2025
Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift
Show resolved
Hide resolved
Very nice so far! :-) |
ktoso
reviewed
Jul 3, 2025
Samples/JExtractJNISampleApp/src/main/java/com/example/swift/HelloJava2SwiftJNI.java
Show resolved
Hide resolved
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.
This PR adds support for generating Java wrappers for Swift classes. It generates static methods and initializers.
Currently, this PR is only focused on actual allocation and initialization. Memory management is not yet addressed. We first need to provide a non-FFM version of
SwiftKit
and its tools for memory management, @ktoso said he would look into this.This PR differs from the way FFM does it by delegating memory allocations to Swift instead of Java. This means we do not have to rely on any "unsafe" Java APIs for allocating memory without FFM. It also simplifies the code needed to allocate for structs, for example. We can easily change this approach later, if we decide to.
The code generates a java method
init
, which calls down into a nativeallocatingInit
which does the actual allocation and returns the pointer to Java, for it to store. The plan is later to migrate over to something similiar toSwiftInstance
to be used for memory cleanup.