1515import JExtractSwiftLib
1616import Testing
1717
18- /// FFM tuple binding tests, aligned with `JNITupleTests` where lowering allows it.
19- ///
20- /// JNI uses `(Int64, String)` for `returnPair` / `takePair`; FFM `lowerResult` does not support
21- /// `String` in tuple results yet, so those signatures use `(Int64, Int64)` here.
2218@Suite
2319struct FFMTupleTests {
2420 let source = """
@@ -40,7 +36,7 @@ struct FFMTupleTests {
4036 MemorySegment _result_0 = arena$.allocate(SwiftValueLayout.SWIFT_INT64);
4137 MemorySegment _result_1 = arena$.allocate(SwiftValueLayout.SWIFT_INT64);
4238 swiftjava_SwiftModule_returnPair.call(_result_0, _result_1);
43- return new org.swift.swiftkit.core.tuple.Tuple2<>(_result_0.get(SwiftValueLayout.SWIFT_INT64, 0), _result_1.get(SwiftValueLayout.SWIFT_INT64, 0));
39+ return new org.swift.swiftkit.core.tuple.Tuple2<Long, Long >(_result_0.get(SwiftValueLayout.SWIFT_INT64, 0), _result_1.get(SwiftValueLayout.SWIFT_INT64, 0));
4440 }
4541 }
4642 """
@@ -76,7 +72,7 @@ struct FFMTupleTests {
7672 public static org.swift.swiftkit.core.tuple.Tuple2<Integer, Integer> labeledTuple() {
7773 """ ,
7874 """
79- return new org.swift.swiftkit.core.tuple.Tuple2<>(_result_0.get(SwiftValueLayout.SWIFT_INT32, 0), _result_1.get(SwiftValueLayout.SWIFT_INT32, 0));
75+ return new org.swift.swiftkit.core.tuple.Tuple2<Integer, Integer >(_result_0.get(SwiftValueLayout.SWIFT_INT32, 0), _result_1.get(SwiftValueLayout.SWIFT_INT32, 0));
8076 """
8177 ]
8278 )
@@ -88,12 +84,15 @@ struct FFMTupleTests {
8884 input: source,
8985 . ffm,
9086 . swift,
91- detectChunkByInitialLines: 1 ,
87+ detectChunkByInitialLines: 2 ,
9288 expectedChunks: [
9389 """
94- let _result = returnPair()
95- _result_0.initialize(to: _result.0)
96- _result_1.initialize(to: _result.1)
90+ @_cdecl( " swiftjava_SwiftModule_returnPair " )
91+ public func swiftjava_SwiftModule_returnPair(_ _result_0: UnsafeMutablePointer<Int64>, _ _result_1: UnsafeMutablePointer<Int64>) {
92+ let _result = returnPair()
93+ _result_0.initialize(to: _result.0)
94+ _result_1.initialize(to: _result.1)
95+ }
9796 """
9897 ]
9998 )
@@ -105,10 +104,13 @@ struct FFMTupleTests {
105104 input: source,
106105 . ffm,
107106 . swift,
108- detectChunkByInitialLines: 1 ,
107+ detectChunkByInitialLines: 2 ,
109108 expectedChunks: [
110109 """
111- takePair((arg_0, arg_1))
110+ @_cdecl( " swiftjava_SwiftModule_takePair__ " )
111+ public func swiftjava_SwiftModule_takePair__(_ arg_0: Int64, _ arg_1: Int64) {
112+ takePair((arg_0, arg_1))
113+ }
112114 """
113115 ]
114116 )
@@ -120,12 +122,15 @@ struct FFMTupleTests {
120122 input: source,
121123 . ffm,
122124 . swift,
123- detectChunkByInitialLines: 1 ,
125+ detectChunkByInitialLines: 2 ,
124126 expectedChunks: [
125127 """
126- let _result = labeledTuple()
127- _result_0.initialize(to: _result.0)
128- _result_1.initialize(to: _result.1)
128+ @_cdecl( " swiftjava_SwiftModule_labeledTuple " )
129+ public func swiftjava_SwiftModule_labeledTuple(_ _result_0: UnsafeMutablePointer<Int32>, _ _result_1: UnsafeMutablePointer<Int32>) {
130+ let _result = labeledTuple()
131+ _result_0.initialize(to: _result.0)
132+ _result_1.initialize(to: _result.1)
133+ }
129134 """
130135 ]
131136 )
0 commit comments