Skip to content

Commit f4fdb44

Browse files
mglukhikhSpace Team
authored andcommitted
Swift export: add some simple tests for KT-66838
1 parent 1846bb6 commit f4fdb44

File tree

10 files changed

+229
-0
lines changed

10 files changed

+229
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public enum kotlin {
2+
public enum collections {
3+
}
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <Foundation/Foundation.h>
2+
#include <stdint.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
int32_t kotlin_IntArray_get__TypesOfArguments__Swift_Int32__(void * self, int32_t index);
7+
8+
void * kotlin_IntArray_iterator(void * self);
9+
10+
void kotlin_IntArray_set__TypesOfArguments__Swift_Int32_Swift_Int32__(void * self, int32_t index, int32_t value);
11+
12+
int32_t kotlin_IntArray_size_get(void * self);
13+
14+
int32_t kotlin_collections_IntIterator_next(void * self);
15+
16+
int32_t kotlin_collections_IntIterator_nextInt(void * self);
17+
18+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@file:kotlin.Suppress("DEPRECATION_ERROR")
2+
@file:kotlin.native.internal.objc.BindClassToObjCName(kotlin.IntArray::class, "22ExportedKotlinPackages6kotlinO12KotlinStdlibE8IntArrayC")
3+
@file:kotlin.native.internal.objc.BindClassToObjCName(kotlin.collections.IntIterator::class, "22ExportedKotlinPackages6kotlinO11collectionsO12KotlinStdlibE11IntIteratorC")
4+
5+
import kotlin.native.internal.ExportedBridge
6+
import kotlinx.cinterop.*
7+
import kotlinx.cinterop.internal.convertBlockPtrToKotlinFunction
8+
9+
@ExportedBridge("kotlin_IntArray_get__TypesOfArguments__Swift_Int32__")
10+
public fun kotlin_IntArray_get__TypesOfArguments__Swift_Int32__(self: kotlin.native.internal.NativePtr, index: Int): Int {
11+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.IntArray
12+
val __index = index
13+
val _result = __self.`get`(__index)
14+
return _result
15+
}
16+
17+
@ExportedBridge("kotlin_IntArray_iterator")
18+
public fun kotlin_IntArray_iterator(self: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr {
19+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.IntArray
20+
val _result = __self.iterator()
21+
return kotlin.native.internal.ref.createRetainedExternalRCRef(_result)
22+
}
23+
24+
@ExportedBridge("kotlin_IntArray_set__TypesOfArguments__Swift_Int32_Swift_Int32__")
25+
public fun kotlin_IntArray_set__TypesOfArguments__Swift_Int32_Swift_Int32__(self: kotlin.native.internal.NativePtr, index: Int, value: Int): Unit {
26+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.IntArray
27+
val __index = index
28+
val __value = value
29+
__self.`set`(__index, __value)
30+
}
31+
32+
@ExportedBridge("kotlin_IntArray_size_get")
33+
public fun kotlin_IntArray_size_get(self: kotlin.native.internal.NativePtr): Int {
34+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.IntArray
35+
val _result = __self.size
36+
return _result
37+
}
38+
39+
@ExportedBridge("kotlin_collections_IntIterator_next")
40+
public fun kotlin_collections_IntIterator_next(self: kotlin.native.internal.NativePtr): Int {
41+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.collections.IntIterator
42+
val _result = __self.next()
43+
return _result
44+
}
45+
46+
@ExportedBridge("kotlin_collections_IntIterator_nextInt")
47+
public fun kotlin_collections_IntIterator_nextInt(self: kotlin.native.internal.NativePtr): Int {
48+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as kotlin.collections.IntIterator
49+
val _result = __self.nextInt()
50+
return _result
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
@_exported import ExportedKotlinPackages
2+
@_implementationOnly import KotlinBridges_KotlinStdlib
3+
import KotlinRuntime
4+
import KotlinRuntimeSupport
5+
6+
extension ExportedKotlinPackages.kotlin.collections {
7+
open class IntIterator: KotlinRuntime.KotlinBase {
8+
package init() {
9+
fatalError()
10+
}
11+
package override init(
12+
__externalRCRefUnsafe: Swift.UnsafeMutableRawPointer?,
13+
options: KotlinRuntime.KotlinBaseConstructionOptions
14+
) {
15+
super.init(__externalRCRefUnsafe: __externalRCRefUnsafe, options: options)
16+
}
17+
public final func next() -> Swift.Int32 {
18+
return kotlin_collections_IntIterator_next(self.__externalRCRef())
19+
}
20+
open func nextInt() -> Swift.Int32 {
21+
return kotlin_collections_IntIterator_nextInt(self.__externalRCRef())
22+
}
23+
}
24+
}
25+
extension ExportedKotlinPackages.kotlin {
26+
public final class IntArray: KotlinRuntime.KotlinBase {
27+
public var size: Swift.Int32 {
28+
get {
29+
return kotlin_IntArray_size_get(self.__externalRCRef())
30+
}
31+
}
32+
public init(
33+
size: Swift.Int32
34+
) {
35+
fatalError()
36+
}
37+
package override init(
38+
__externalRCRefUnsafe: Swift.UnsafeMutableRawPointer?,
39+
options: KotlinRuntime.KotlinBaseConstructionOptions
40+
) {
41+
super.init(__externalRCRefUnsafe: __externalRCRefUnsafe, options: options)
42+
}
43+
public init(
44+
size: Swift.Int32,
45+
`init`: @escaping (Swift.Int32) -> Swift.Int32
46+
) {
47+
fatalError()
48+
}
49+
public func _get(
50+
index: Swift.Int32
51+
) -> Swift.Int32 {
52+
return kotlin_IntArray_get__TypesOfArguments__Swift_Int32__(self.__externalRCRef(), index)
53+
}
54+
public func _set(
55+
index: Swift.Int32,
56+
value: Swift.Int32
57+
) -> Swift.Void {
58+
return kotlin_IntArray_set__TypesOfArguments__Swift_Int32_Swift_Int32__(self.__externalRCRef(), index, value)
59+
}
60+
public func iterator() -> ExportedKotlinPackages.kotlin.collections.IntIterator {
61+
return ExportedKotlinPackages.kotlin.collections.IntIterator.__createClassWrapper(externalRCRef: kotlin_IntArray_iterator(self.__externalRCRef()))
62+
}
63+
public subscript(
64+
index: Swift.Int32
65+
) -> Swift.Int32 {
66+
get {
67+
_get(index: index)
68+
}
69+
set(value) {
70+
_set(index: index, value: value)
71+
}
72+
}
73+
}
74+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <Foundation/Foundation.h>
2+
#include <stdint.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
int32_t Accessor_get__TypesOfArguments__Swift_Int32__(void * self, int32_t i);
7+
8+
void * Accessor_x_get(void * self);
9+
10+
NS_ASSUME_NONNULL_END
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@file:kotlin.Suppress("DEPRECATION_ERROR")
2+
@file:kotlin.native.internal.objc.BindClassToObjCName(Accessor::class, "4main8AccessorC")
3+
4+
import kotlin.native.internal.ExportedBridge
5+
import kotlinx.cinterop.*
6+
import kotlinx.cinterop.internal.convertBlockPtrToKotlinFunction
7+
8+
@ExportedBridge("Accessor_get__TypesOfArguments__Swift_Int32__")
9+
public fun Accessor_get__TypesOfArguments__Swift_Int32__(self: kotlin.native.internal.NativePtr, i: Int): Int {
10+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Accessor
11+
val __i = i
12+
val _result = __self.`get`(__i)
13+
return _result
14+
}
15+
16+
@ExportedBridge("Accessor_x_get")
17+
public fun Accessor_x_get(self: kotlin.native.internal.NativePtr): kotlin.native.internal.NativePtr {
18+
val __self = kotlin.native.internal.ref.dereferenceExternalRCRef(self) as Accessor
19+
val _result = __self.x
20+
return kotlin.native.internal.ref.createRetainedExternalRCRef(_result)
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@_implementationOnly import KotlinBridges_main
2+
import KotlinRuntime
3+
import KotlinRuntimeSupport
4+
import KotlinStdlib
5+
6+
public final class Accessor: KotlinRuntime.KotlinBase {
7+
public var x: ExportedKotlinPackages.kotlin.IntArray {
8+
get {
9+
return ExportedKotlinPackages.kotlin.IntArray.__createClassWrapper(externalRCRef: Accessor_x_get(self.__externalRCRef()))
10+
}
11+
}
12+
package override init(
13+
__externalRCRefUnsafe: Swift.UnsafeMutableRawPointer?,
14+
options: KotlinRuntime.KotlinBaseConstructionOptions
15+
) {
16+
super.init(__externalRCRefUnsafe: __externalRCRefUnsafe, options: options)
17+
}
18+
public func _get(
19+
i: Swift.Int32
20+
) -> Swift.Int32 {
21+
return Accessor_get__TypesOfArguments__Swift_Int32__(self.__externalRCRef(), i)
22+
}
23+
public subscript(
24+
i: Swift.Int32
25+
) -> Swift.Int32 {
26+
get {
27+
_get(i: i)
28+
}
29+
}
30+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// KIND: STANDALONE
2+
// MODULE: main
3+
// FILE: main.kt
4+
5+
fun simple(vararg s: String): String = s.joinToString(separator = "")
6+
7+
class Accessor(vararg val x: Int) {
8+
operator fun get(i: Int): Int = x[i]
9+
}

native/swift/swift-export-standalone-integration-tests/simple/tests-gen/org/jetbrains/kotlin/swiftexport/standalone/test/SwiftExportWithBinaryCompilationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ public void testUnsupportedDeclarationsReporting() {
229229
runTest("native/swift/swift-export-standalone-integration-tests/simple/testData/generation/unsupportedDeclarationsReporting/");
230230
}
231231

232+
@Test
233+
@TestMetadata("vararg")
234+
public void testVararg() {
235+
runTest("native/swift/swift-export-standalone-integration-tests/simple/testData/generation/vararg/");
236+
}
237+
232238
@Test
233239
@TestMetadata("variables")
234240
public void testVariables() {

native/swift/swift-export-standalone-integration-tests/simple/tests-gen/org/jetbrains/kotlin/swiftexport/standalone/test/SwiftExportWithResultValidationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ public void testUnsupportedDeclarationsReporting() {
229229
runTest("native/swift/swift-export-standalone-integration-tests/simple/testData/generation/unsupportedDeclarationsReporting/");
230230
}
231231

232+
@Test
233+
@TestMetadata("vararg")
234+
public void testVararg() {
235+
runTest("native/swift/swift-export-standalone-integration-tests/simple/testData/generation/vararg/");
236+
}
237+
232238
@Test
233239
@TestMetadata("variables")
234240
public void testVariables() {

0 commit comments

Comments
 (0)