Skip to content

jextract: support Swift custom operators - #829

Merged
ktoso merged 14 commits into
swiftlang:mainfrom
AbdAlRahmanGad:operators
Aug 7, 2026
Merged

jextract: support Swift custom operators#829
ktoso merged 14 commits into
swiftlang:mainfrom
AbdAlRahmanGad:operators

Conversation

@AbdAlRahmanGad

Copy link
Copy Markdown
Member

Comment thread Sources/SwiftExtract/SwiftAnalysisVisitor.swift
Comment thread Sources/JExtractSwiftLib/JavaIdentifierFactory.swift
Comment thread Sources/SwiftExtract/SwiftAnalysisVisitor.swift Outdated
Comment thread Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift Outdated
Comment thread Sources/JExtractSwiftLib/JavaIdentifierFactory.swift
Comment thread Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift
Comment thread Tests/SwiftExtractTests/AnalysisResultTests.swift Outdated
Comment thread Tests/JExtractSwiftTests/JNI/JNIOperatorsTests.swift Outdated
Comment thread Sources/JExtractSwiftLib/JavaIdentifierFactory.swift
@ktoso

ktoso commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

This is very close, we just broke the FFM mode by accident:


/Users/runner/actions-runner/_work/swift-java/swift-java/Samples/SwiftJavaExtractFFMSampleApp/.build/plugins/outputs/swiftjavaextractffmsampleapp/MySwiftLibrary/destination/JExtractSwiftPlugin/Sources/MySwiftStruct+SwiftJava.swift:158:67: error: expected ',' separator
156 | @_cdecl("swiftjava_MySwiftLibrary_MySwiftStruct_==_lhs_rhs")
157 | public func swiftjava_MySwiftLibrary_MySwiftStruct_==_lhs_rhs(_ lhs: UnsafeRawPointer, _ rhs: UnsafeRawPointer) -> Bool {
158 |   return (lhs.assumingMemoryBound(to: MySwiftStruct.self).pointee MySwiftStruct.== rhs.assumingMemoryBound(to: MySwiftStruct.self).pointee)
    |                                                                   `- error: expected ',' separator
159 | }
160 | 

/Users/runner/actions-runner/_work/swift-java/swift-java/Samples/SwiftJavaExtractFFMSampleApp/.build/plugins/outputs/swiftjavaextractffmsampleapp/MySwiftLibrary/destination/JExtractSwiftPlugin/Sources/MySwiftStruct+SwiftJava.swift:158:67: error: expected ',' separator
156 | @_cdecl("swiftjava_MySwiftLibrary_MySwiftStruct_==_lhs_rhs")
157 | public func swiftjava_MySwiftLibrary_MySwiftStruct_==_lhs_rhs(_ lhs: UnsafeRawPointer, _ rhs: UnsafeRawPointer) -> Bool {
158 |   return (lhs.assumingMemoryBound(to: MySwiftStruct.self).pointee MySwiftStruct.== rhs.assumingMemoryBound(to: MySwiftStruct.self).pointee)
    |                                                                   `- error: expected ',' separator
159 | }
160 | 

the cdecl naming needs to be fixed to handle the == same as we desugar them elsewhere.

Fixes should be in ThunkNameRegistry.functionThunkName and FFMSwift2JavaGenerator+FunctionLowering.cdeclThunk, would you mind following up on this @AbdAlRahmanGad ?

@AbdAlRahmanGad

Copy link
Copy Markdown
Member Author

looks like github actions are kinda down : https://www.githubstatus.com/

I'll re-push when it's resolved

@ktoso

ktoso commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Ugh yeah seems gh is having issues.

@ktoso
ktoso merged commit bacb1c4 into swiftlang:main Aug 7, 2026
42 checks passed
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