Skip to content

jextract: support typed unsafepointer/unsafebufferpointer in FFM and JNI generators - #904

Open
Tatenda-k wants to merge 2 commits into
swiftlang:mainfrom
Tatenda-k:jextract-pointer-support
Open

jextract: support typed unsafepointer/unsafebufferpointer in FFM and JNI generators#904
Tatenda-k wants to merge 2 commits into
swiftlang:mainfrom
Tatenda-k:jextract-pointer-support

Conversation

@Tatenda-k

@Tatenda-k Tatenda-k commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Added support for case .unsafePointer, .unsafeMutablePointer, case .unsafePointer, .unsafeMutablePointer, and case .unsafeBufferPointer, .unsafeMutableBufferPointer for FFM and JNI.
#840

@Tatenda-k
Tatenda-k requested a review from ktoso as a code owner August 22, 2026 23:28
Comment thread Tests/JExtractSwiftTests/MethodImportTests.swift Outdated
Comment thread SwiftKitCore/src/main/java/org/swift/swiftkit/core/SwiftBufferPointer.java Outdated
Comment thread SwiftKitCore/src/main/java/org/swift/swiftkit/core/SwiftBufferPointer.java Outdated

@ktoso ktoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good work! Almost there 👍

Please add runtime tests by adding functions returning such buffers to Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary and then adding tests in Java using them in Samples/SwiftJavaExtractJNISampleApp/src/test/java

@ktoso

ktoso commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Also same tests in FFM since we claim to support it now

Comment thread Tests/JExtractSwiftTests/JNI/JNIPointerTests.swift Outdated
Comment thread Package.swift Outdated
public func bufferCount(data: UnsafeRawBufferPointer) -> Int64 {
Int64(data.count)
}
// snippet.end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break existing snippets

@Tatenda-k
Tatenda-k force-pushed the jextract-pointer-support branch from 22d7ddd to ba02d62 Compare August 27, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants