Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ extension JNISwift2JavaGenerator {
printer.print(
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* \(decl.signatureString)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* \(decl.signatureString)
* }
*/
"""
)
}
Expand Down
40 changes: 20 additions & 20 deletions Tests/JExtractSwiftTests/JNI/JNIClassTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,22 @@ struct JNIClassTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public init(x: Int64, y: Int64)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public init(x: Int64, y: Int64)
* }
*/
public static MyClass init(long x, long y, SwiftArena swiftArena$) {
return MyClass.wrapMemoryAddressUnsafe(MyClass.$init(x, y), swiftArena$);
}
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public init()
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public init()
* }
*/
public static MyClass init(SwiftArena swiftArena$) {
return MyClass.wrapMemoryAddressUnsafe(MyClass.$init(), swiftArena$);
}
Expand Down Expand Up @@ -309,11 +309,11 @@ struct JNIClassTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func copy() -> MyClass
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func copy() -> MyClass
* }
*/
public MyClass copy(SwiftArena swiftArena$) {
return MyClass.wrapMemoryAddressUnsafe(MyClass.$copy(this.$memoryAddress()), swiftArena$);
}
Expand Down Expand Up @@ -361,11 +361,11 @@ struct JNIClassTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func isEqual(to other: MyClass) -> Bool
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func isEqual(to other: MyClass) -> Bool
* }
*/
public boolean isEqual(MyClass other) {
return MyClass.$isEqual(other.$memoryAddress(), this.$memoryAddress());
}
Expand Down
20 changes: 10 additions & 10 deletions Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ struct JNIClosureTests {
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func emptyClosure(closure: () -> ())
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func emptyClosure(closure: () -> ())
* }
*/
public static void emptyClosure(com.example.swift.SwiftModule.emptyClosure.closure closure) {
SwiftModule.$emptyClosure(closure);
}
Expand Down Expand Up @@ -88,11 +88,11 @@ struct JNIClosureTests {
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func closureWithArgumentsAndReturn(closure: (Int64, Bool) -> Int64)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func closureWithArgumentsAndReturn(closure: (Int64, Bool) -> Int64)
* }
*/
public static void closureWithArgumentsAndReturn(com.example.swift.SwiftModule.closureWithArgumentsAndReturn.closure closure) {
SwiftModule.$closureWithArgumentsAndReturn(closure);
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ struct JNIJavaKitTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func function(javaLong: JavaLong, javaInteger: JavaInteger, int: Int64)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func function(javaLong: JavaLong, javaInteger: JavaInteger, int: Int64)
* }
*/
public static void function(java.lang.Long javaLong, java.lang.Integer javaInteger, long int) {
SwiftModule.$function(javaLong, javaInteger, int);
}
Expand Down
60 changes: 30 additions & 30 deletions Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ struct JNIModuleTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func helloWorld()
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func helloWorld()
* }
*/
public static void helloWorld() {
SwiftModule.$helloWorld();
}
Expand All @@ -81,11 +81,11 @@ struct JNIModuleTests {
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func takeIntegers(i1: Int8, i2: Int16, i3: Int32, i4: Int64) -> UInt16
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func takeIntegers(i1: Int8, i2: Int16, i3: Int32, i4: Int64) -> UInt16
* }
*/
@Unsigned
public static char takeIntegers(byte i1, short i2, int i3, long i4) {
return SwiftModule.$takeIntegers(i1, i2, i3, i4);
Expand All @@ -96,11 +96,11 @@ struct JNIModuleTests {
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func otherPrimitives(b: Bool, f: Float, d: Double)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func otherPrimitives(b: Bool, f: Float, d: Double)
* }
*/
public static void otherPrimitives(boolean b, float f, double d) {
SwiftModule.$otherPrimitives(b, f, d);
}
Expand Down Expand Up @@ -151,11 +151,11 @@ struct JNIModuleTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func copy(_ string: String) -> String
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func copy(_ string: String) -> String
* }
*/
public static java.lang.String copy(java.lang.String string) {
return SwiftModule.$copy(string);
}
Expand Down Expand Up @@ -194,11 +194,11 @@ struct JNIModuleTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func methodA() throws
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func methodA() throws
* }
*/
public static void methodA() throws Exception {
SwiftModule.$methodA();
}
Expand All @@ -208,11 +208,11 @@ struct JNIModuleTests {
""",
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func methodB() throws -> Int64
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func methodB() throws -> Int64
* }
*/
public static long methodB() throws Exception {
return SwiftModule.$methodB();
}
Expand Down
68 changes: 34 additions & 34 deletions Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ struct JNIOptionalTests {
* public func optionalSugar(_ arg: Int64?) -> Int32?
* }
*/
public static OptionalInt optionalSugar(OptionalLong arg) {
long combined$ = SwiftModule.$optionalSugar((byte) (arg.isPresent() ? 1 : 0), arg.orElse(0L));
byte discriminator$ = (byte) (combined$ & 0xFF);
int value$ = (int) (combined$ >> 32);
return discriminator$ == 1 ? OptionalInt.of(value$) : OptionalInt.empty();
}
public static OptionalInt optionalSugar(OptionalLong arg) {
long combined$ = SwiftModule.$optionalSugar((byte) (arg.isPresent() ? 1 : 0), arg.orElse(0L));
byte discriminator$ = (byte) (combined$ & 0xFF);
int value$ = (int) (combined$ >> 32);
return discriminator$ == 1 ? OptionalInt.of(value$) : OptionalInt.empty();
}
""",
"""
private static native long $optionalSugar(byte arg_discriminator, long arg_value);
Expand Down Expand Up @@ -92,16 +92,16 @@ struct JNIOptionalTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalExplicit(_ arg: Optional<String>) -> Optional<String>
* }
*/
public static Optional<String> optionalExplicit(Optional<String> arg) {
byte[] result_discriminator$ = new byte[1];
java.lang.String result$ = SwiftModule.$optionalExplicit((byte) (arg.isPresent() ? 1 : 0), arg.orElse(null), result_discriminator$);
return (result_discriminator$[0] == 1) ? Optional.of(result$) : Optional.empty();
}
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalExplicit(_ arg: Optional<String>) -> Optional<String>
* }
*/
public static Optional<String> optionalExplicit(Optional<String> arg) {
byte[] result_discriminator$ = new byte[1];
java.lang.String result$ = SwiftModule.$optionalExplicit((byte) (arg.isPresent() ? 1 : 0), arg.orElse(null), result_discriminator$);
return (result_discriminator$[0] == 1) ? Optional.of(result$) : Optional.empty();
}
""",
"""
private static native java.lang.String $optionalExplicit(byte arg_discriminator, java.lang.String arg_value, byte[] result_discriminator$);
Expand Down Expand Up @@ -150,16 +150,16 @@ struct JNIOptionalTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalClass(_ arg: MyClass?) -> MyClass?
* }
*/
public static Optional<MyClass> optionalClass(Optional<MyClass> arg, SwiftArena swiftArena$) {
byte[] result_discriminator$ = new byte[1];
long result$ = SwiftModule.$optionalClass(arg.map(MyClass::$memoryAddress).orElse(0L), result_discriminator$);
return (result_discriminator$[0] == 1) ? Optional.of(MyClass.wrapMemoryAddressUnsafe(result$, swiftArena$)) : Optional.empty();
}
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalClass(_ arg: MyClass?) -> MyClass?
* }
*/
public static Optional<MyClass> optionalClass(Optional<MyClass> arg, SwiftArena swiftArena$) {
byte[] result_discriminator$ = new byte[1];
long result$ = SwiftModule.$optionalClass(arg.map(MyClass::$memoryAddress).orElse(0L), result_discriminator$);
return (result_discriminator$[0] == 1) ? Optional.of(MyClass.wrapMemoryAddressUnsafe(result$, swiftArena$)) : Optional.empty();
}
""",
"""
private static native long $optionalClass(long arg, byte[] result_discriminator$);
Expand Down Expand Up @@ -213,14 +213,14 @@ struct JNIOptionalTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalJavaKitClass(_ arg: JavaLong?)
* }
*/
public static void optionalJavaKitClass(Optional<java.lang.Long> arg) {
SwiftModule.$optionalJavaKitClass(arg.orElse(null));
}
* Downcall to Swift:
* {@snippet lang=swift :
* public func optionalJavaKitClass(_ arg: JavaLong?)
* }
*/
public static void optionalJavaKitClass(Optional<java.lang.Long> arg) {
SwiftModule.$optionalJavaKitClass(arg.orElse(null));
}
""",
"""
private static native void $optionalJavaKitClass(java.lang.Long arg);
Expand Down
20 changes: 10 additions & 10 deletions Tests/JExtractSwiftTests/JNI/JNIStructTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ struct JNIStructTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public init(x: Int64, y: Int64)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public init(x: Int64, y: Int64)
* }
*/
public static MyStruct init(long x, long y, SwiftArena swiftArena$) {
return MyStruct.wrapMemoryAddressUnsafe(MyStruct.$init(x, y), swiftArena$);
}
Expand Down Expand Up @@ -182,11 +182,11 @@ struct JNIStructTests {
expectedChunks: [
"""
/**
* Downcall to Swift:
* {@snippet lang=swift :
* public func doSomething(x: Int64)
* }
*/
* Downcall to Swift:
* {@snippet lang=swift :
* public func doSomething(x: Int64)
* }
*/
public void doSomething(long x) {
MyStruct.$doSomething(x, this.$memoryAddress());
}
Expand Down
Loading
Loading