Skip to content

Commit 716c599

Browse files
committed
adjust swift source gen tests
1 parent 4382e42 commit 716c599

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

Samples/SwiftKitSampleApp/src/main/java/com/example/swift/HelloJava2Swift.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ public static void main(String[] args) {
3232
boolean traceDowncalls = Boolean.getBoolean("jextract.trace.downcalls");
3333
System.out.println("Property: jextract.trace.downcalls = " + traceDowncalls);
3434

35-
System.out.print("Property: java.library.path = \n");
36-
System.out.println(SwiftKit.getJavaLibraryPath());
37-
System.out.println(" " + path);
38-
}
35+
System.out.print("Property: java.library.path = " +SwiftKit.getJavaLibraryPath());
3936

4037
examples();
41-
4238
}
4339

4440
static void examples() {

SwiftKit/src/main/java/org/swift/swiftkit/SwiftKit.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ public class SwiftKit {
2929

3030
public static final String STDLIB_DYLIB_NAME = "swiftCore";
3131
public static final String SWIFTKITSWIFT_DYLIB_NAME = "SwiftKitSwift";
32+
public static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls");
33+
3234
private static final String STDLIB_MACOS_DYLIB_PATH = "/usr/lib/swift/libswiftCore.dylib";
3335

3436
private static final Arena LIBRARY_ARENA = Arena.ofAuto();
35-
static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls");
3637

3738
@SuppressWarnings("unused")
3839
private static final boolean INITIALIZED_LIBS = loadLibraries(false);

Tests/JExtractSwiftTests/FuncCallbackImportTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ final class FuncCallbackImportTests {
6969
callMe_callback_handle$ = callMe_callback_handle$.bindTo(callback);
7070
Linker linker = Linker.nativeLinker();
7171
MemorySegment callback$ = linker.upcallStub(callMe_callback_handle$, callMe_callback_desc$, arena);
72-
if (TRACE_DOWNCALLS) {
73-
traceDowncall(callback$);
72+
if (SwiftKit.TRACE_DOWNCALLS) {
73+
SwiftKit.traceDowncall(callback$);
7474
}
7575
mh$.invokeExact(callback$);
7676
} catch (Throwable ex$) {

Tests/JExtractSwiftTests/MethodImportTests.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ final class MethodImportTests {
9191
public static void helloWorld() {
9292
var mh$ = helloWorld.HANDLE;
9393
try {
94-
if (TRACE_DOWNCALLS) {
95-
traceDowncall();
94+
if (SwiftKit.TRACE_DOWNCALLS) {
95+
SwiftKit.traceDowncall();
9696
}
9797
mh$.invokeExact();
9898
} catch (Throwable ex$) {
@@ -134,8 +134,8 @@ final class MethodImportTests {
134134
public static void globalTakeInt(long i) {
135135
var mh$ = globalTakeInt.HANDLE;
136136
try {
137-
if (TRACE_DOWNCALLS) {
138-
traceDowncall(i);
137+
if (SwiftKit.TRACE_DOWNCALLS) {
138+
SwiftKit.traceDowncall(i);
139139
}
140140
mh$.invokeExact(i);
141141
} catch (Throwable ex$) {
@@ -177,8 +177,8 @@ final class MethodImportTests {
177177
public static void globalTakeIntLongString(int i32, long l, com.example.swift.String s) {
178178
var mh$ = globalTakeIntLongString.HANDLE;
179179
try {
180-
if (TRACE_DOWNCALLS) {
181-
traceDowncall(i32, l, s.$memorySegment());
180+
if (SwiftKit.TRACE_DOWNCALLS) {
181+
SwiftKit.traceDowncall(i32, l, s.$memorySegment());
182182
}
183183
mh$.invokeExact(i32, l, s.$memorySegment());
184184
} catch (Throwable ex$) {
@@ -220,8 +220,8 @@ final class MethodImportTests {
220220
public static void helloMemberFunction(java.lang.foreign.MemorySegment self$) {
221221
var mh$ = helloMemberFunction.HANDLE;
222222
try {
223-
if (TRACE_DOWNCALLS) {
224-
traceDowncall(self$);
223+
if (SwiftKit.TRACE_DOWNCALLS) {
224+
SwiftKit.traceDowncall(self$);
225225
}
226226
mh$.invokeExact(self$);
227227
} catch (Throwable ex$) {
@@ -263,8 +263,8 @@ final class MethodImportTests {
263263
public static void helloMemberInExtension(java.lang.foreign.MemorySegment self$) {
264264
var mh$ = helloMemberInExtension.HANDLE;
265265
try {
266-
if (TRACE_DOWNCALLS) {
267-
traceDowncall(self$);
266+
if (SwiftKit.TRACE_DOWNCALLS) {
267+
SwiftKit.traceDowncall(self$);
268268
}
269269
mh$.invokeExact(self$);
270270
} catch (Throwable ex$) {
@@ -306,8 +306,8 @@ final class MethodImportTests {
306306
public static void helloMemberFunction(java.lang.foreign.MemorySegment self$) {
307307
var mh$ = helloMemberFunction.HANDLE;
308308
try {
309-
if (TRACE_DOWNCALLS) {
310-
traceDowncall(self$);
309+
if (SwiftKit.TRACE_DOWNCALLS) {
310+
SwiftKit.traceDowncall(self$);
311311
}
312312
mh$.invokeExact(self$);
313313
} catch (Throwable ex$) {
@@ -431,8 +431,8 @@ final class MethodImportTests {
431431
public MySwiftClass(SwiftArena arena, long len, long cap) {
432432
var mh$ = init_len_cap.HANDLE;
433433
try {
434-
if (TRACE_DOWNCALLS) {
435-
traceDowncall(len, cap);
434+
if (SwiftKit.TRACE_DOWNCALLS) {
435+
SwiftKit.traceDowncall(len, cap);
436436
}
437437
this.selfMemorySegment = (MemorySegment) mh$.invokeExact(len, cap, TYPE_METADATA.$memorySegment());
438438
if (arena != null) {

Tests/JExtractSwiftTests/MethodThunkTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ final class MethodThunkTests {
4040
"""
4141
@_cdecl("swiftjava_FakeModule_globalFunc_a_b")
4242
public func swiftjava_FakeModule_globalFunc_a_b(a: Int32, b: Int64) /* Void */ {
43-
globalFunc(a: a, b: b)
43+
return globalFunc(a: a, b: b)
4444
}
4545
""",
4646
"""
4747
@_cdecl("swiftjava_FakeModule_globalFunc_a_b$1")
4848
public func swiftjava_FakeModule_globalFunc_a_b$1(a: Double, b: Int64) /* Void */ {
49-
globalFunc(a: a, b: b)
49+
return globalFunc(a: a, b: b)
5050
}
5151
"""
5252
]

Tests/JExtractSwiftTests/VariableImportTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ final class VariableImportTests {
143143
public static long getCounterInt(java.lang.foreign.MemorySegment self$) {
144144
var mh$ = counterInt.HANDLE_GET;
145145
try {
146-
if (TRACE_DOWNCALLS) {
147-
traceDowncall(self$);
146+
if (SwiftKit.TRACE_DOWNCALLS) {
147+
SwiftKit.traceDowncall(self$);
148148
}
149149
return (long) mh$.invokeExact(self$);
150150
} catch (Throwable ex$) {
@@ -173,8 +173,8 @@ final class VariableImportTests {
173173
public static void setCounterInt(long newValue, java.lang.foreign.MemorySegment self$) {
174174
var mh$ = counterInt.HANDLE_SET;
175175
try {
176-
if (TRACE_DOWNCALLS) {
177-
traceDowncall(newValue, self$);
176+
if (SwiftKit.TRACE_DOWNCALLS) {
177+
SwiftKit.traceDowncall(newValue, self$);
178178
}
179179
mh$.invokeExact(newValue, self$);
180180
} catch (Throwable ex$) {

0 commit comments

Comments
 (0)