Repository navigation
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
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.
Problem
JNI extraction does not expose APIs using Swift's half-open
Range<Bound>: the built-in Swift type catalog and JNI conversions have no range mapping.For example:
With this change, Java callers can construct a range, pass it to Swift, and read its bounds:
Equal bounds represent an empty range. Invalid bounds are rejected before constructing a Swift range or calling the target function.
Changes
Swift.Rangeand its bound type in the Swift type catalog and JNI generator.org.swift.swiftkit.core.SwiftRange<T>Java container and copy bounds through the existingJobjectBridgeconversions.Comparable. Java's comparison rules can differ, and wrappers of Swift-comparable types need not implement Java'sComparable.IllegalArgumentExceptionfor invalid types, reversed bounds, and unordered floating-point bounds. Reject null ranges and constructor bounds withNullPointerException. Stop argument conversion immediately when range conversion posts a Java exception.Scope
This adds direct JNI range parameters and results with concrete, bridgeable bound types. The Java container itself requires no
SwiftArena; bounds wrapping Swift objects retain their usual lifetime requirements.FFM,
ClosedRange, partial ranges, Optional/collection nesting, tuple parameters containing ranges, and protocol callback conversions remain outside this feature. This does not add unrestricted generic-bound API support.Validation
swift test --disable-sandbox --disable-experimental-prebuilts --filter 'JExtractSwiftTests|SwiftExtractTests': all 642 extraction and generator tests passed../gradlew :Samples:SwiftJavaExtractJNISampleApp:test: all 307 Java tests passed with no failures or skips, including 11 new range tests. Runtime coverage includesInt,Int32,Int64,UInt64,Double,String, and a custom Swift-comparable struct.swift format lint --stricton changed Swift files andgit diff --checkpassed.Tested with Apple Swift 6.4 and JetBrains Runtime 25.0.2 on macOS.