diff --git a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift index d3452cef..6d82175f 100644 --- a/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift +++ b/Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift @@ -369,11 +369,11 @@ extension JNISwift2JavaGenerator { printer.print( """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * \(decl.signatureString) - * } - */ + * Downcall to Swift: + * {@snippet lang=swift : + * \(decl.signatureString) + * } + */ """ ) } diff --git a/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift b/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift index 1e33efcb..30bb7433 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIClassTests.swift @@ -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$); } @@ -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$); } @@ -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()); } diff --git a/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift b/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift index 9a388da1..b374d24e 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift @@ -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); } @@ -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); } diff --git a/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift b/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift index 1f19c8f9..ac6b8384 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift @@ -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); } diff --git a/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift b/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift index 198276ba..ad55f491 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift @@ -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(); } @@ -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); @@ -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); } @@ -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); } @@ -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(); } @@ -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(); } diff --git a/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift b/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift index f9c70ba4..2186e227 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIOptionalTests.swift @@ -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); @@ -92,16 +92,16 @@ struct JNIOptionalTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func optionalExplicit(_ arg: Optional) -> Optional - * } - */ - public static Optional optionalExplicit(Optional 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) -> Optional + * } + */ + public static Optional optionalExplicit(Optional 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$); @@ -150,16 +150,16 @@ struct JNIOptionalTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func optionalClass(_ arg: MyClass?) -> MyClass? - * } - */ - public static Optional optionalClass(Optional 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 optionalClass(Optional 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$); @@ -213,14 +213,14 @@ struct JNIOptionalTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func optionalJavaKitClass(_ arg: JavaLong?) - * } - */ - public static void optionalJavaKitClass(Optional arg) { - SwiftModule.$optionalJavaKitClass(arg.orElse(null)); - } + * Downcall to Swift: + * {@snippet lang=swift : + * public func optionalJavaKitClass(_ arg: JavaLong?) + * } + */ + public static void optionalJavaKitClass(Optional arg) { + SwiftModule.$optionalJavaKitClass(arg.orElse(null)); + } """, """ private static native void $optionalJavaKitClass(java.lang.Long arg); diff --git a/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift b/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift index 59d7ee6b..7f54fa7e 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIStructTests.swift @@ -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$); } @@ -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()); } diff --git a/Tests/JExtractSwiftTests/JNI/JNIUnsignedNumberTests.swift b/Tests/JExtractSwiftTests/JNI/JNIUnsignedNumberTests.swift index f4dbffed..bfae447a 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIUnsignedNumberTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIUnsignedNumberTests.swift @@ -27,11 +27,11 @@ final class JNIUnsignedNumberTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func unsignedChar(_ arg: UInt16) - * } - */ + * Downcall to Swift: + * {@snippet lang=swift : + * public func unsignedChar(_ arg: UInt16) + * } + */ public static void unsignedChar(@Unsigned char arg) { SwiftModule.$unsignedChar(arg); } @@ -57,11 +57,11 @@ final class JNIUnsignedNumberTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func unsignedInt(_ arg: UInt32) - * } - */ + * Downcall to Swift: + * {@snippet lang=swift : + * public func unsignedInt(_ arg: UInt32) + * } + */ public static void unsignedInt(@Unsigned int arg) { SwiftModule.$unsignedInt(arg); } @@ -83,11 +83,11 @@ final class JNIUnsignedNumberTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func returnUnsignedInt() -> UInt32 - * } - */ + * Downcall to Swift: + * {@snippet lang=swift : + * public func returnUnsignedInt() -> UInt32 + * } + */ @Unsigned public static int returnUnsignedInt() { return SwiftModule.$returnUnsignedInt(); @@ -137,11 +137,11 @@ final class JNIUnsignedNumberTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func unsignedLong(first: UInt64, second: UInt32) -> UInt32 - * } - */ + * Downcall to Swift: + * {@snippet lang=swift : + * public func unsignedLong(first: UInt64, second: UInt32) -> UInt32 + * } + */ @Unsigned public static int unsignedLong(@Unsigned long first, @Unsigned int second) { return SwiftModule.$unsignedLong(first, second); diff --git a/Tests/JExtractSwiftTests/MemoryManagementModeTests.swift b/Tests/JExtractSwiftTests/MemoryManagementModeTests.swift index e64d4397..3ce839b9 100644 --- a/Tests/JExtractSwiftTests/MemoryManagementModeTests.swift +++ b/Tests/JExtractSwiftTests/MemoryManagementModeTests.swift @@ -37,14 +37,14 @@ struct MemoryManagementModeTests { expectedChunks: [ """ /** - * Downcall to Swift: - * {@snippet lang=swift : - * public func f() -> MyClass - * } - */ - public static MyClass f(SwiftArena swiftArena$) { - return MyClass.wrapMemoryAddressUnsafe(SwiftModule.$f(), swiftArena$); - } + * Downcall to Swift: + * {@snippet lang=swift : + * public func f() -> MyClass + * } + */ + public static MyClass f(SwiftArena swiftArena$) { + return MyClass.wrapMemoryAddressUnsafe(SwiftModule.$f(), swiftArena$); + } """, ] )