From c77930c1ea099c31a28b356371716ec1998d8929 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 12 Nov 2023 02:10:27 +0100 Subject: [PATCH] [stdlib] Explicit visibility and return types: Native --- .../JsRuntime/src/main/kotlin/jsinterop.kt | 2 +- .../main/kotlin/kotlinx/cinterop/Generated.kt | 132 +++++++++--------- .../main/kotlin/kotlinx/cinterop/StableRef.kt | 12 +- .../src/main/kotlin/kotlinx/cinterop/Types.kt | 48 +++---- .../src/main/kotlin/kotlinx/cinterop/Utils.kt | 38 ++--- .../kotlinx/cinterop/ForeignException.kt | 2 +- .../kotlinx/cinterop/FunctionPointers.kt | 69 ++++++--- .../kotlin/kotlinx/cinterop/ManagedType.kt | 8 +- .../kotlin/kotlinx/cinterop/NativeMem.kt | 4 +- .../kotlin/kotlinx/cinterop/NativeTypes.kt | 83 +++++++---- .../kotlin/kotlinx/cinterop/NativeUtils.kt | 48 ++++--- .../kotlin/kotlinx/cinterop/ObjectiveCImpl.kt | 42 +++--- .../native/kotlin/kotlinx/cinterop/Pinning.kt | 58 ++++---- .../kotlin/kotlinx/cinterop/Vector128.kt | 20 +-- .../kotlinx/cinterop/internal/Annotations.kt | 48 +++---- .../runtime/src/main/kotlin/kotlin/Arrays.kt | 66 ++++----- .../src/main/kotlin/kotlin/Exceptions.kt | 94 ++++++------- .../runtime/src/main/kotlin/kotlin/String.kt | 2 +- .../src/main/kotlin/kotlin/Throwable.kt | 8 +- .../runtime/src/main/kotlin/kotlin/Unit.kt | 2 +- .../cancellation/CancellationException.kt | 8 +- .../coroutines/intrinsics/IntrinsicsNative.kt | 2 +- .../src/main/kotlin/kotlin/native/BitSet.kt | 52 +++---- .../src/main/kotlin/kotlin/native/Platform.kt | 4 +- .../src/main/kotlin/kotlin/native/Runtime.kt | 4 +- .../kotlin/native/concurrent/Atomics.kt | 2 +- .../kotlin/native/concurrent/Continuation.kt | 2 +- .../kotlin/native/concurrent/Freezing.kt | 2 +- .../kotlin/kotlin/native/concurrent/Future.kt | 4 +- .../kotlin/native/concurrent/MutableData.kt | 8 +- .../native/concurrent/ObjectTransfer.kt | 4 +- .../kotlin/kotlin/native/concurrent/Worker.kt | 4 +- .../native/concurrent/WorkerBoundReference.kt | 6 +- .../kotlin/native/internal/Annotations.kt | 2 +- .../kotlin/kotlin/native/internal/Cleaner.kt | 8 +- .../main/kotlin/kotlin/native/internal/GC.kt | 2 + .../kotlin/native/internal/MemoryUsageInfo.kt | 4 +- .../kotlin/native/internal/NativePtr.kt | 28 ++-- .../kotlin/native/internal/ObjCExportUtils.kt | 2 +- .../kotlin/native/internal/RuntimeUtils.kt | 4 +- .../kotlin/native/internal/gc/GCInfo.kt | 2 + .../kotlin/native/internal/test/Launcher.kt | 14 +- .../kotlin/native/internal/test/TestSuite.kt | 84 ++++++----- .../src/main/kotlin/kotlin/native/ref/Weak.kt | 2 +- .../main/kotlin/kotlin/native/runtime/GC.kt | 44 +++--- .../kotlin/kotlin/native/runtime/GCInfo.kt | 44 +++--- .../src/main/kotlin/kotlin/native/simd.kt | 4 +- .../kotlin/text/CharacterCodingException.kt | 2 +- 48 files changed, 595 insertions(+), 539 deletions(-) diff --git a/kotlin-native/Interop/JsRuntime/src/main/kotlin/jsinterop.kt b/kotlin-native/Interop/JsRuntime/src/main/kotlin/jsinterop.kt index 44193880d84..7b27e83a057 100644 --- a/kotlin-native/Interop/JsRuntime/src/main/kotlin/jsinterop.kt +++ b/kotlin-native/Interop/JsRuntime/src/main/kotlin/jsinterop.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION_ERROR", "TYPEALIAS_EXPANSION_DEPRECATION_ERROR", "UNUSED_PARAMETER") // Everything is scheduled for removal +@file:Suppress("DEPRECATION_ERROR", "TYPEALIAS_EXPANSION_DEPRECATION_ERROR", "UNUSED_PARAMETER", "NO_EXPLICIT_VISIBILITY_IN_API_MODE", "NO_EXPLICIT_RETURN_TYPE_IN_API_MODE") // Everything is scheduled for removal @file:OptIn(ExperimentalForeignApi::class) package kotlinx.wasm.jsinterop diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Generated.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Generated.kt index d52673fd5a9..514f1b93e8a 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Generated.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Generated.kt @@ -9,312 +9,312 @@ package kotlinx.cinterop @ExperimentalForeignApi @JvmName("plus\$Byte") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 1) @ExperimentalForeignApi @JvmName("plus\$Byte") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Byte") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Byte") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Byte") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Byte") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$Short") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 2) @ExperimentalForeignApi @JvmName("plus\$Short") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Short") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Short") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Short") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Short") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$Int") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 4) @ExperimentalForeignApi @JvmName("plus\$Int") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Int") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Int") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Int") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Int") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$Long") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 8) @ExperimentalForeignApi @JvmName("plus\$Long") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Long") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Long") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Long") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Long") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$UByte") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 1) @ExperimentalForeignApi @JvmName("plus\$UByte") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$UByte") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$UShort") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 2) @ExperimentalForeignApi @JvmName("plus\$UShort") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$UShort") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$UShort") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$UInt") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 4) @ExperimentalForeignApi @JvmName("plus\$UInt") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$UInt") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$UInt") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$ULong") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 8) @ExperimentalForeignApi @JvmName("plus\$ULong") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$ULong") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$ULong") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$Float") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 4) @ExperimentalForeignApi @JvmName("plus\$Float") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Float") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Float") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Float") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Float") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("plus\$Double") -inline operator fun > CPointer?.plus(index: Long): CPointer? = +public inline operator fun > CPointer?.plus(index: Long): CPointer? = interpretCPointer(this.rawValue + index * 8) @ExperimentalForeignApi @JvmName("plus\$Double") -inline operator fun > CPointer?.plus(index: Int): CPointer? = +public inline operator fun > CPointer?.plus(index: Int): CPointer? = this + index.toLong() @ExperimentalForeignApi @JvmName("get\$Double") -inline operator fun CPointer>.get(index: Int): T = +public inline operator fun CPointer>.get(index: Int): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Double") -inline operator fun CPointer>.set(index: Int, value: T) { +public inline operator fun CPointer>.set(index: Int, value: T) { (this + index)!!.pointed.value = value } @ExperimentalForeignApi @JvmName("get\$Double") -inline operator fun CPointer>.get(index: Long): T = +public inline operator fun CPointer>.get(index: Long): T = (this + index)!!.pointed.value @ExperimentalForeignApi @JvmName("set\$Double") -inline operator fun CPointer>.set(index: Long, value: T) { +public inline operator fun CPointer>.set(index: Long, value: T) { (this + index)!!.pointed.value = value } @@ -326,28 +326,28 @@ Seva: It probably means the reasoning of this API and is general applicability s function gen { echo "@JvmName(\"plus\\\$$1\")" -echo "inline operator fun > CPointer?.plus(index: Long): CPointer? =" +echo "public inline operator fun > CPointer?.plus(index: Long): CPointer? =" echo " interpretCPointer(this.rawValue + index * ${2})" echo echo "@JvmName(\"plus\\\$$1\")" -echo "inline operator fun > CPointer?.plus(index: Int): CPointer? =" +echo "public inline operator fun > CPointer?.plus(index: Int): CPointer? =" echo " this + index.toLong()" echo echo "@JvmName(\"get\\\$$1\")" -echo "inline operator fun CPointer<${1}VarOf>.get(index: Int): T =" +echo "public inline operator fun CPointer<${1}VarOf>.get(index: Int): T =" echo " (this + index)!!.pointed.value" echo echo "@JvmName(\"set\\\$$1\")" -echo "inline operator fun CPointer<${1}VarOf>.set(index: Int, value: T) {" +echo "public inline operator fun CPointer<${1}VarOf>.set(index: Int, value: T) {" echo " (this + index)!!.pointed.value = value" echo '}' echo echo "@JvmName(\"get\\\$$1\")" -echo "inline operator fun CPointer<${1}VarOf>.get(index: Long): T =" +echo "public inline operator fun CPointer<${1}VarOf>.get(index: Long): T =" echo " (this + index)!!.pointed.value" echo echo "@JvmName(\"set\\\$$1\")" -echo "inline operator fun CPointer<${1}VarOf>.set(index: Long, value: T) {" +echo "public inline operator fun CPointer<${1}VarOf>.set(index: Long, value: T) {" echo " (this + index)!!.pointed.value = value" echo '}' echo diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/StableRef.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/StableRef.kt index e37cbac959e..d9f1b04f71f 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/StableRef.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/StableRef.kt @@ -19,12 +19,12 @@ public value class StableRef @PublishedApi internal constructor( private val stablePtr: COpaquePointer ) { - companion object { + public companion object { /** * Creates a handle for given object. */ - fun create(any: T) = StableRef(createStablePointer(any)) + public fun create(any: T): StableRef = StableRef(createStablePointer(any)) } @@ -32,12 +32,12 @@ public value class StableRef @PublishedApi internal constructor( * Converts the handle to C pointer. * @see [asStableRef] */ - fun asCPointer(): COpaquePointer = this.stablePtr + public fun asCPointer(): COpaquePointer = this.stablePtr /** * Disposes the handle. It must not be used after that. */ - fun dispose() { + public fun dispose() { disposeStablePointer(this.stablePtr) } @@ -45,7 +45,7 @@ public value class StableRef @PublishedApi internal constructor( * Returns the object this handle was [created][StableRef.create] for. */ @Suppress("UNCHECKED_CAST") - fun get() = derefStablePointer(this.stablePtr) as T + public fun get(): T = derefStablePointer(this.stablePtr) as T } @@ -53,4 +53,4 @@ public value class StableRef @PublishedApi internal constructor( * Converts to [StableRef] this opaque pointer produced by [StableRef.asCPointer]. */ @ExperimentalForeignApi -inline fun CPointer<*>.asStableRef(): StableRef = StableRef(this).also { it.get() } +public inline fun CPointer<*>.asStableRef(): StableRef = StableRef(this).also { it.get() } diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Types.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Types.kt index 7c4901ef85e..065d29e9679 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Types.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Types.kt @@ -17,7 +17,7 @@ import kotlin.native.* */ @ExperimentalForeignApi public open class NativePointed internal constructor(rawPtr: NonNullNativePtr) { - var rawPtr = rawPtr.toNativePtr() + public var rawPtr: NativePtr = rawPtr.toNativePtr() internal set } @@ -128,7 +128,7 @@ public abstract class CValues : CValuesRef() { } @ExperimentalForeignApi -public fun CValues.placeTo(scope: AutofreeScope) = this.getPointer(scope) +public fun CValues.placeTo(scope: AutofreeScope): CPointer = this.getPointer(scope) /** * The single immutable C value. @@ -161,9 +161,9 @@ public class CPointer internal constructor(@PublishedApi internal return rawValue.hashCode() } - public override fun toString() = this.cPointerToString() + public override fun toString(): String = this.cPointerToString() - public override fun getPointer(scope: AutofreeScope) = this + public override fun getPointer(scope: AutofreeScope): CPointer = this } /** @@ -191,7 +191,7 @@ public val CPointer<*>?.rawValue: NativePtr public fun CPointer<*>.reinterpret(): CPointer = interpretCPointer(this.rawValue)!! @ExperimentalForeignApi -public fun CPointer?.toLong() = this.rawValue.toLong() +public fun CPointer?.toLong(): Long = this.rawValue.toLong() @ExperimentalForeignApi public fun Long.toCPointer(): CPointer? = interpretCPointer(nativeNullPtr + this) @@ -238,7 +238,7 @@ public abstract class CVariable(rawPtr: NativePtr) : CPointed(rawPtr) { * It may be greater than actually required for simplicity. */ @Deprecated("Use sizeOf() or alignOf() instead.") - public open class Type(val size: Long, val align: Int) { + public open class Type(public val size: Long, public val align: Int) { init { require(size % align == 0L) @@ -249,11 +249,11 @@ public abstract class CVariable(rawPtr: NativePtr) : CPointed(rawPtr) { @Suppress("DEPRECATION") @ExperimentalForeignApi -public inline fun sizeOf() = typeOf().size +public inline fun sizeOf(): Long = typeOf().size @Suppress("DEPRECATION") @ExperimentalForeignApi -public inline fun alignOf() = typeOf().align +public inline fun alignOf(): Int = typeOf().align /** * Returns the member of this [CStructVar] which is located by given offset in bytes. @@ -275,18 +275,18 @@ public inline fun CStructVar.arrayMemberAt(offset: Long) public abstract class CStructVar(rawPtr: NativePtr) : CVariable(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - open class Type(size: Long, align: Int) : CVariable.Type(size, align) + public open class Type(size: Long, align: Int) : CVariable.Type(size, align) } /** * The C primitive-typed variable located in memory. */ @ExperimentalForeignApi -sealed class CPrimitiveVar(rawPtr: NativePtr) : CVariable(rawPtr) { +public sealed class CPrimitiveVar(rawPtr: NativePtr) : CVariable(rawPtr) { // aligning by size is obviously enough @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - open class Type(size: Int) : CVariable.Type(size.toLong(), align = size) + public open class Type(size: Int) : CVariable.Type(size.toLong(), align = size) } @Deprecated("Will be removed.") @@ -305,7 +305,7 @@ public abstract class CEnumVar(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) public class BooleanVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(1) + public companion object : Type(1) } @ExperimentalForeignApi @@ -313,7 +313,7 @@ public class BooleanVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr public class ByteVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(1) + public companion object : Type(1) } @ExperimentalForeignApi @@ -321,7 +321,7 @@ public class ByteVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class ShortVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(2) + public companion object : Type(2) } @ExperimentalForeignApi @@ -329,7 +329,7 @@ public class ShortVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class IntVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(4) + public companion object : Type(4) } @ExperimentalForeignApi @@ -337,7 +337,7 @@ public class IntVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class LongVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(8) + public companion object : Type(8) } @ExperimentalForeignApi @@ -345,7 +345,7 @@ public class LongVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class UByteVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(1) + public companion object : Type(1) } @ExperimentalForeignApi @@ -353,7 +353,7 @@ public class UByteVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class UShortVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(2) + public companion object : Type(2) } @ExperimentalForeignApi @@ -361,7 +361,7 @@ public class UShortVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) public class UIntVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(4) + public companion object : Type(4) } @ExperimentalForeignApi @@ -369,7 +369,7 @@ public class UIntVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class ULongVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(8) + public companion object : Type(8) } @ExperimentalForeignApi @@ -377,7 +377,7 @@ public class ULongVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class FloatVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(4) + public companion object : Type(4) } @ExperimentalForeignApi @@ -385,7 +385,7 @@ public class FloatVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { public class DoubleVarOf(rawPtr: NativePtr) : CPrimitiveVar(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(8) + public companion object : Type(8) } @ExperimentalForeignApi @@ -428,7 +428,7 @@ public inline fun Boolean.toByte(): Byte = if (this) 1 else 0 @Suppress("NOTHING_TO_INLINE") @ExperimentalForeignApi -public inline fun Byte.toBoolean() = (this.toInt() != 0) +public inline fun Byte.toBoolean(): Boolean = (this.toInt() != 0) @ExperimentalForeignApi @Suppress("FINAL_UPPER_BOUND", "UNCHECKED_CAST") @@ -497,7 +497,7 @@ public var DoubleVarOf.value: T public class CPointerVarOf>(rawPtr: NativePtr) : CVariable(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : CVariable.Type(pointerSize.toLong(), pointerSize) + public companion object : CVariable.Type(pointerSize.toLong(), pointerSize) } /** diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt index b049b292b4a..3ae73ca6e19 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt @@ -19,15 +19,15 @@ public interface NativeFreeablePlacement : NativePlacement { } @ExperimentalForeignApi -public fun NativeFreeablePlacement.free(pointer: CPointer<*>) = this.free(pointer.rawValue) +public fun NativeFreeablePlacement.free(pointer: CPointer<*>): Unit = this.free(pointer.rawValue) @ExperimentalForeignApi -public fun NativeFreeablePlacement.free(pointed: NativePointed) = this.free(pointed.rawPtr) +public fun NativeFreeablePlacement.free(pointed: NativePointed): Unit = this.free(pointed.rawPtr) @ExperimentalForeignApi public object nativeHeap : NativeFreeablePlacement { - override fun alloc(size: Long, align: Int) = nativeMemUtils.alloc(size, align) + override fun alloc(size: Long, align: Int): NativePointed = nativeMemUtils.alloc(size, align) - override fun free(mem: NativePtr) = nativeMemUtils.free(mem) + override fun free(mem: NativePtr): Unit = nativeMemUtils.free(mem) } @ExperimentalForeignApi @@ -46,7 +46,7 @@ public open class DeferScope { } } - inline fun defer(crossinline block: () -> Unit) { + public inline fun defer(crossinline block: () -> Unit) { val currentTop = topDeferred topDeferred = { try { @@ -97,7 +97,7 @@ public open class ArenaBase(private val parent: NativeFreeablePlacement = native @ExperimentalForeignApi public class Arena(parent: NativeFreeablePlacement = nativeHeap) : ArenaBase(parent) { - fun clear() = this.clearImpl() + public fun clear(): Unit = this.clearImpl() } /** @@ -188,7 +188,7 @@ public fun NativePlacement.allocArrayOfPointersTo(elements: List< * Allocates C array of pointers to given elements. */ @ExperimentalForeignApi -public fun NativePlacement.allocArrayOfPointersTo(vararg elements: T?) = +public fun NativePlacement.allocArrayOfPointersTo(vararg elements: T?): CArrayPointer> = allocArrayOfPointersTo(listOf(*elements)) /** @@ -235,7 +235,7 @@ public fun NativePlacement.allocArrayOf(vararg elements: Float): CArrayPointer NativePlacement.allocPointerTo() = alloc>() +public fun NativePlacement.allocPointerTo(): CPointerVar = alloc>() @PublishedApi @ExperimentalForeignApi @@ -354,7 +354,7 @@ public inline fun cValue(initialize: T.() -> Unit): CVa zeroValue().copy(modify = initialize) @ExperimentalForeignApi -public inline fun createValues(count: Int, initializer: T.(index: Int) -> Unit) = memScoped { +public inline fun createValues(count: Int, initializer: T.(index: Int) -> Unit): CValues = memScoped { val array = allocArray(count, initializer) array[0].readValues(count) } @@ -403,21 +403,21 @@ public fun cValuesOf(vararg elements: CPointer?): CValues this.value = elements[index] } @ExperimentalForeignApi -public fun ByteArray.toCValues() = cValuesOf(*this) +public fun ByteArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun ShortArray.toCValues() = cValuesOf(*this) +public fun ShortArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun IntArray.toCValues() = cValuesOf(*this) +public fun IntArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun LongArray.toCValues() = cValuesOf(*this) +public fun LongArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun FloatArray.toCValues() = cValuesOf(*this) +public fun FloatArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun DoubleArray.toCValues() = cValuesOf(*this) +public fun DoubleArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -public fun Array?>.toCValues() = cValuesOf(*this) +public fun Array?>.toCValues(): CValues> = cValuesOf(*this) @ExperimentalForeignApi -public fun List?>.toCValues() = this.toTypedArray().toCValues() +public fun List?>.toCValues(): CValues> = this.toTypedArray().toCValues() @ExperimentalForeignApi private class CString(val bytes: ByteArray) : CValues() { @@ -683,10 +683,10 @@ private fun checkBoundsIndexes(startIndex: Int, endIndex: Int, size: Int) { @ExperimentalForeignApi public class MemScope : ArenaBase() { - val memScope: MemScope + public val memScope: MemScope get() = this - val CValues.ptr: CPointer + public val CValues.ptr: CPointer get() = this@ptr.getPointer(this@MemScope) } diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ForeignException.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ForeignException.kt index 160f3abb419..94c0b0a3fba 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ForeignException.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ForeignException.kt @@ -9,7 +9,7 @@ import kotlin.native.internal.ExportForCppRuntime import kotlin.native.internal.GCUnsafeCall @BetaInteropApi -public class ForeignException internal constructor(val nativeException: Any?) : Exception() { +public class ForeignException internal constructor(public val nativeException: Any?) : Exception() { override val message: String = nativeException?.let { kotlin_ObjCExport_ExceptionDetails(nativeException) }?: "" diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/FunctionPointers.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/FunctionPointers.kt index 31465b7d49c..a5fa74c4047 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/FunctionPointers.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/FunctionPointers.kt @@ -10,70 +10,93 @@ import kotlin.native.internal.IntrinsicType import kotlin.native.internal.ExportForCompiler @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R +@TypedIntrinsic(IntrinsicType.INTEROP_FUNPTR_INVOKE) +public external operator fun CPointer R>>.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ManagedType.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ManagedType.kt index a6119e7063a..38f7c915a0f 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ManagedType.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ManagedType.kt @@ -8,13 +8,13 @@ package kotlinx.cinterop import kotlinx.cinterop.CStructVar @ExperimentalForeignApi -interface SkiaRefCnt +public interface SkiaRefCnt @ExperimentalForeignApi -interface CPlusPlusClass +public interface CPlusPlusClass @ExperimentalForeignApi -abstract class ManagedType(val cpp: T) +public abstract class ManagedType(public val cpp: T) @ExperimentalForeignApi -val ManagedType.ptr: CPointer get() = this.cpp.ptr +public val ManagedType.ptr: CPointer get() = this.cpp.ptr diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt index 3a00eed1663..96ed55f5dba 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeMem.kt @@ -159,8 +159,8 @@ private external fun cfree(ptr: NativePtr) @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.INTEROP_READ_BITS) -external fun readBits(ptr: NativePtr, offset: Long, size: Int, signed: Boolean): Long +public external fun readBits(ptr: NativePtr, offset: Long, size: Int, signed: Boolean): Long @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.INTEROP_WRITE_BITS) -external fun writeBits(ptr: NativePtr, offset: Long, size: Int, value: Long) +public external fun writeBits(ptr: NativePtr, offset: Long, size: Int, value: Long) diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeTypes.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeTypes.kt index af0d8089d79..e8716c1ce87 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeTypes.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeTypes.kt @@ -11,7 +11,7 @@ import kotlin.native.internal.TypedIntrinsic import kotlin.native.internal.IntrinsicType @ExperimentalForeignApi -typealias NativePtr = kotlin.native.internal.NativePtr +public typealias NativePtr = kotlin.native.internal.NativePtr internal typealias NonNullNativePtr = kotlin.native.internal.NonNullNativePtr @Suppress("NOTHING_TO_INLINE") @@ -19,13 +19,13 @@ internal typealias NonNullNativePtr = kotlin.native.internal.NonNullNativePtr internal inline fun NativePtr.toNonNull() = this.reinterpret() @ExperimentalForeignApi -inline val nativeNullPtr: NativePtr +public inline val nativeNullPtr: NativePtr get() = NativePtr.NULL @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") @ExperimentalForeignApi -fun typeOf(): CVariable.Type = throw Error("typeOf() is called with erased argument") +public fun typeOf(): CVariable.Type = throw Error("typeOf() is called with erased argument") /** * Performs type cast of the native pointer to given interop type, including null values. @@ -34,22 +34,22 @@ fun typeOf(): CVariable.Type = throw Error("typeOf() is called w */ @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.IDENTITY) -external fun interpretNullablePointed(ptr: NativePtr): T? +public external fun interpretNullablePointed(ptr: NativePtr): T? /** * Performs type cast of the [CPointer] from the given raw pointer. */ @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.IDENTITY) -external fun interpretCPointer(rawValue: NativePtr): CPointer? +public external fun interpretCPointer(rawValue: NativePtr): CPointer? @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.IDENTITY) -external fun NativePointed.getRawPointer(): NativePtr +public external fun NativePointed.getRawPointer(): NativePtr @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.IDENTITY) -external fun CPointer<*>.getRawValue(): NativePtr +public external fun CPointer<*>.getRawValue(): NativePtr @ExperimentalForeignApi internal fun CPointer<*>.cPointerToString() = "CPointer(raw=$rawValue)" @@ -61,70 +61,93 @@ internal fun CPointer<*>.cPointerToString() = "CPointer(raw=$rawValue)" * a closure which doesn't capture any variable */ @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: () -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: () -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21) -> R): CPointer R>> @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R): CPointer R>> +@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION) +public external fun staticCFunction(@VolatileLambda function: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22) -> R): CPointer R>> diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt index f5f5bd9d4d0..48427e2f4f6 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt @@ -18,62 +18,70 @@ internal external fun CPointer.toKStringFromUtf8Impl(): String @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.INTEROP_BITS_TO_FLOAT) -external fun bitsToFloat(bits: Int): Float +public external fun bitsToFloat(bits: Int): Float @ExperimentalForeignApi @TypedIntrinsic(IntrinsicType.INTEROP_BITS_TO_DOUBLE) -external fun bitsToDouble(bits: Long): Double +public external fun bitsToDouble(bits: Long): Double @Deprecated("Deprecated without replacement as part of the obsolete interop API", level = DeprecationLevel.WARNING) @TypedIntrinsic(IntrinsicType.INTEROP_SIGN_EXTEND) -external inline fun Number.signExtend(): R +public external inline fun Number.signExtend(): R @Deprecated("Deprecated without replacement as part of the obsolete interop API", level = DeprecationLevel.WARNING) @TypedIntrinsic(IntrinsicType.INTEROP_NARROW) -external inline fun Number.narrow(): R +public external inline fun Number.narrow(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun Byte.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun Byte.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun Short.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun Short.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun Int.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun Int.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun Long.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun Long.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun UByte.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun UByte.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun UShort.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun UShort.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun UInt.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun UInt.convert(): R @ExperimentalForeignApi -@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) external inline fun ULong.convert(): R +@TypedIntrinsic(IntrinsicType.INTEROP_CONVERT) +public external inline fun ULong.convert(): R @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE) @Retention(AnnotationRetention.SOURCE) internal annotation class JvmName(val name: String) @ExperimentalForeignApi -fun cValuesOf(vararg elements: UByte): CValues = +public fun cValuesOf(vararg elements: UByte): CValues = createValues(elements.size) { index -> this.value = elements[index] } @ExperimentalForeignApi -fun cValuesOf(vararg elements: UShort): CValues = +public fun cValuesOf(vararg elements: UShort): CValues = createValues(elements.size) { index -> this.value = elements[index] } @ExperimentalForeignApi -fun cValuesOf(vararg elements: UInt): CValues = +public fun cValuesOf(vararg elements: UInt): CValues = createValues(elements.size) { index -> this.value = elements[index] } @ExperimentalForeignApi -fun cValuesOf(vararg elements: ULong): CValues = +public fun cValuesOf(vararg elements: ULong): CValues = createValues(elements.size) { index -> this.value = elements[index] } @ExperimentalForeignApi -fun UByteArray.toCValues() = cValuesOf(*this) +public fun UByteArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -fun UShortArray.toCValues() = cValuesOf(*this) +public fun UShortArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -fun UIntArray.toCValues() = cValuesOf(*this) +public fun UIntArray.toCValues(): CValues = cValuesOf(*this) @ExperimentalForeignApi -fun ULongArray.toCValues() = cValuesOf(*this) +public fun ULongArray.toCValues(): CValues = cValuesOf(*this) diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt index fee555316ed..b9a929f66e1 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/ObjectiveCImpl.kt @@ -13,16 +13,16 @@ import kotlin.native.internal.* import kotlin.native.internal.InternalForKotlinNative @BetaInteropApi -interface ObjCObject +public interface ObjCObject @BetaInteropApi -interface ObjCClass : ObjCObject +public interface ObjCClass : ObjCObject @BetaInteropApi -interface ObjCClassOf : ObjCClass // TODO: T should be added to ObjCClass and all meta-classes instead. +public interface ObjCClassOf : ObjCClass // TODO: T should be added to ObjCClass and all meta-classes instead. @BetaInteropApi -typealias ObjCObjectMeta = ObjCClass +public typealias ObjCObjectMeta = ObjCClass @BetaInteropApi -interface ObjCProtocol : ObjCObject +public interface ObjCProtocol : ObjCObject @ExportTypeInfo("theForeignObjCObjectTypeInfo") @OptIn(FreezingIsDeprecated::class) @@ -30,24 +30,24 @@ interface ObjCProtocol : ObjCObject internal open class ForeignObjCObject : kotlin.native.internal.ObjCObjectWrapper @BetaInteropApi -abstract class ObjCObjectBase protected constructor() : ObjCObject { +public abstract class ObjCObjectBase protected constructor() : ObjCObject { @Target(AnnotationTarget.CONSTRUCTOR) @Retention(AnnotationRetention.SOURCE) - annotation class OverrideInit + public annotation class OverrideInit } @BetaInteropApi -abstract class ObjCObjectBaseMeta protected constructor() : ObjCObjectBase(), ObjCObjectMeta {} +public abstract class ObjCObjectBaseMeta protected constructor() : ObjCObjectBase(), ObjCObjectMeta {} @BetaInteropApi -fun optional(): Nothing = throw RuntimeException("Do not call me!!!") +public fun optional(): Nothing = throw RuntimeException("Do not call me!!!") @Deprecated( "Add @OverrideInit to constructor to make it override Objective-C initializer", level = DeprecationLevel.ERROR ) @TypedIntrinsic(IntrinsicType.OBJC_INIT_BY) -external fun T.initBy(constructorCall: T): T +public external fun T.initBy(constructorCall: T): T @BetaInteropApi @kotlin.native.internal.ExportForCompiler @@ -64,11 +64,11 @@ internal fun Any?.uncheckedCast(): T = @Suppress("UNCHECKED_CAST") (t // Note: if this is called for non-frozen object on a wrong worker, the program will terminate. @ExperimentalForeignApi @GCUnsafeCall("Kotlin_Interop_refFromObjC") -external fun interpretObjCPointerOrNull(objcPtr: NativePtr): T? +public external fun interpretObjCPointerOrNull(objcPtr: NativePtr): T? @ExportForCppRuntime @ExperimentalForeignApi -inline fun interpretObjCPointer(objcPtr: NativePtr): T = interpretObjCPointerOrNull(objcPtr)!! +public inline fun interpretObjCPointer(objcPtr: NativePtr): T = interpretObjCPointerOrNull(objcPtr)!! @GCUnsafeCall("Kotlin_Interop_refToObjC") @ExperimentalForeignApi @@ -89,28 +89,28 @@ public inline fun unwrapKotlinObjectHolder(holder: Any?): T { external internal fun unwrapKotlinObjectHolderImpl(ptr: NativePtr): Any @ExperimentalForeignApi -class ObjCObjectVar(rawPtr: NativePtr) : CVariable(rawPtr) { +public class ObjCObjectVar(rawPtr: NativePtr) : CVariable(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : CVariable.Type(pointerSize.toLong(), pointerSize) + public companion object : CVariable.Type(pointerSize.toLong(), pointerSize) } @ExperimentalForeignApi -class ObjCNotImplementedVar(rawPtr: NativePtr) : CVariable(rawPtr) { +public class ObjCNotImplementedVar(rawPtr: NativePtr) : CVariable(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : CVariable.Type(pointerSize.toLong(), pointerSize) + public companion object : CVariable.Type(pointerSize.toLong(), pointerSize) } @ExperimentalForeignApi -var ObjCNotImplementedVar.value: T +public var ObjCNotImplementedVar.value: T get() = TODO() set(_) = TODO() @ExperimentalForeignApi -typealias ObjCStringVarOf = ObjCNotImplementedVar +public typealias ObjCStringVarOf = ObjCNotImplementedVar @ExperimentalForeignApi -typealias ObjCBlockVar = ObjCNotImplementedVar +public typealias ObjCBlockVar = ObjCNotImplementedVar @TypedIntrinsic(IntrinsicType.OBJC_CREATE_SUPER_STRUCT) @PublishedApi @@ -198,11 +198,11 @@ private external fun ObjCWeakReferenceImpl.init(objcPtr: NativePtr) @Deprecated("Use plain Kotlin cast of String to NSString", level = DeprecationLevel.ERROR) @GCUnsafeCall("Kotlin_Interop_CreateNSStringFromKString") -external fun CreateNSStringFromKString(str: String?): NativePtr +public external fun CreateNSStringFromKString(str: String?): NativePtr @Deprecated("Use plain Kotlin cast of NSString to String", level = DeprecationLevel.ERROR) @GCUnsafeCall("Kotlin_Interop_CreateKStringFromNSString") -external fun CreateKStringFromNSString(ptr: NativePtr): String? +public external fun CreateKStringFromNSString(ptr: NativePtr): String? @PublishedApi @GCUnsafeCall("Kotlin_Interop_CreateObjCObjectHolder") diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Pinning.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Pinning.kt index e1ed911eba3..1ddf55cf48c 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Pinning.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Pinning.kt @@ -9,27 +9,27 @@ import kotlin.native.* import kotlin.native.internal.GCUnsafeCall @ExperimentalForeignApi -data class Pinned internal constructor(private val stablePtr: COpaquePointer) { +public data class Pinned internal constructor(private val stablePtr: COpaquePointer) { /** * Disposes the handle. It must not be [used][get] after that. */ - fun unpin() { + public fun unpin() { disposeStablePointer(this.stablePtr) } /** * Returns the underlying pinned object. */ - fun get(): T = @Suppress("UNCHECKED_CAST") (derefStablePointer(stablePtr) as T) + public fun get(): T = @Suppress("UNCHECKED_CAST") (derefStablePointer(stablePtr) as T) } @ExperimentalForeignApi -fun T.pin() = Pinned(createStablePointer(this)) +public fun T.pin(): Pinned = Pinned(createStablePointer(this)) @ExperimentalForeignApi -inline fun T.usePinned(block: (Pinned) -> R): R { +public inline fun T.usePinned(block: (Pinned) -> R): R { val pinned = this.pin() return try { block(pinned) @@ -39,65 +39,65 @@ inline fun T.usePinned(block: (Pinned) -> R): R { } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun ByteArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun ByteArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun String.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun String.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun CharArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun CharArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun ShortArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun ShortArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun IntArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun IntArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun LongArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun LongArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } // TODO: pinning of unsigned arrays involves boxing as they are inline classes wrapping signed arrays. @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun UByteArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun UByteArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun UShortArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun UShortArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun UIntArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun UIntArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun ULongArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun ULongArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun FloatArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun FloatArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi -fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) +public fun Pinned.addressOf(index: Int): CPointer = this.get().addressOfElement(index) @ExperimentalForeignApi -fun DoubleArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } +public fun DoubleArray.refTo(index: Int): CValuesRef = this.usingPinned { addressOf(index) } @ExperimentalForeignApi private inline fun T.usingPinned( diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Vector128.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Vector128.kt index 1410bb5b130..b68501efcfc 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Vector128.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/Vector128.kt @@ -14,30 +14,30 @@ import kotlinx.cinterop.ExperimentalForeignApi @ExperimentalForeignApi public final class Vector128 private constructor() { @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getByteAt(index: Int): Byte + public external fun getByteAt(index: Int): Byte @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getIntAt(index: Int): Int + public external fun getIntAt(index: Int): Int @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getLongAt(index: Int): Long + public external fun getLongAt(index: Int): Long @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getFloatAt(index: Int): Float + public external fun getFloatAt(index: Int): Float @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getDoubleAt(index: Int): Double + public external fun getDoubleAt(index: Int): Double @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getUByteAt(index: Int): UByte + public external fun getUByteAt(index: Int): UByte @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getUIntAt(index: Int): UInt + public external fun getUIntAt(index: Int): UInt @TypedIntrinsic(IntrinsicType.EXTRACT_ELEMENT) - external fun getULongAt(index: Int): ULong + public external fun getULongAt(index: Int): ULong - public override fun toString() = + public override fun toString(): String = "(0x${getUIntAt(0).toString(16)}, 0x${getUIntAt(1).toString(16)}, 0x${getUIntAt(2).toString(16)}, 0x${getUIntAt(3).toString(16)})" // Not as good for floating types @@ -69,7 +69,7 @@ public external fun vectorOf(f0: Int, f1: Int, f2: Int, f3: Int): Vector128 public class Vector128VarOf(rawPtr: NativePtr) : CVariable(rawPtr) { @Deprecated("Use sizeOf() or alignOf() instead.") @Suppress("DEPRECATION") - companion object : Type(size = 16, align = 16) + public companion object : Type(size = 16, align = 16) } @SinceKotlin("1.9") diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/internal/Annotations.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/internal/Annotations.kt index 840cb4c704b..1343e6adbff 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/internal/Annotations.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/internal/Annotations.kt @@ -6,35 +6,35 @@ import kotlin.native.internal.InternalForKotlinNative @InternalForKotlinNative @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class CStruct(val spelling: String) { +public annotation class CStruct(val spelling: String) { @Retention(AnnotationRetention.BINARY) @Target( AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER ) - annotation class MemberAt(val offset: Long) + public annotation class MemberAt(val offset: Long) @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.PROPERTY_GETTER) - annotation class ArrayMemberAt(val offset: Long) + public annotation class ArrayMemberAt(val offset: Long) @Retention(AnnotationRetention.BINARY) @Target( AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER ) - annotation class BitField(val offset: Long, val size: Int) + public annotation class BitField(val offset: Long, val size: Int) @Retention(AnnotationRetention.BINARY) - annotation class VarType(val size: Long, val align: Int) + public annotation class VarType(val size: Long, val align: Int) @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) - annotation class CPlusPlusClass + public annotation class CPlusPlusClass @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) - annotation class ManagedType + public annotation class ManagedType } @Target( @@ -47,11 +47,11 @@ annotation class CStruct(val spelling: String) { public annotation class CCall(val id: String) { @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.BINARY) - annotation class CString + public annotation class CString @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.BINARY) - annotation class WCString + public annotation class WCString @Target( AnnotationTarget.FUNCTION, @@ -59,7 +59,7 @@ public annotation class CCall(val id: String) { AnnotationTarget.PROPERTY_SETTER ) @Retention(AnnotationRetention.BINARY) - annotation class ReturnsRetained + public annotation class ReturnsRetained @Target( AnnotationTarget.FUNCTION, @@ -67,15 +67,15 @@ public annotation class CCall(val id: String) { AnnotationTarget.PROPERTY_SETTER ) @Retention(AnnotationRetention.BINARY) - annotation class ConsumesReceiver + public annotation class ConsumesReceiver @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.BINARY) - annotation class Consumed + public annotation class Consumed @Target(AnnotationTarget.CONSTRUCTOR) @Retention(AnnotationRetention.BINARY) - annotation class CppClassConstructor + public annotation class CppClassConstructor } /** @@ -85,27 +85,27 @@ public annotation class CCall(val id: String) { @InternalForKotlinNative public object ConstantValue { @Retention(AnnotationRetention.BINARY) - annotation class Byte(val value: kotlin.Byte) + public annotation class Byte(val value: kotlin.Byte) @Retention(AnnotationRetention.BINARY) - annotation class Short(val value: kotlin.Short) + public annotation class Short(val value: kotlin.Short) @Retention(AnnotationRetention.BINARY) - annotation class Int(val value: kotlin.Int) + public annotation class Int(val value: kotlin.Int) @Retention(AnnotationRetention.BINARY) - annotation class Long(val value: kotlin.Long) + public annotation class Long(val value: kotlin.Long) @Retention(AnnotationRetention.BINARY) - annotation class UByte(val value: kotlin.UByte) + public annotation class UByte(val value: kotlin.UByte) @Retention(AnnotationRetention.BINARY) - annotation class UShort(val value: kotlin.UShort) + public annotation class UShort(val value: kotlin.UShort) @Retention(AnnotationRetention.BINARY) - annotation class UInt(val value: kotlin.UInt) + public annotation class UInt(val value: kotlin.UInt) @Retention(AnnotationRetention.BINARY) - annotation class ULong(val value: kotlin.ULong) + public annotation class ULong(val value: kotlin.ULong) @Retention(AnnotationRetention.BINARY) - annotation class Float(val value: kotlin.Float) + public annotation class Float(val value: kotlin.Float) @Retention(AnnotationRetention.BINARY) - annotation class Double(val value: kotlin.Double) + public annotation class Double(val value: kotlin.Double) @Retention(AnnotationRetention.BINARY) - annotation class String(val value: kotlin.String) + public annotation class String(val value: kotlin.String) } /** diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt index fddcc5234ae..059bb4cd407 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Arrays.kt @@ -53,7 +53,7 @@ public final class ByteArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_ByteArray_get") - external public operator fun get(index: Int): Byte + public external operator fun get(index: Int): Byte /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -61,10 +61,10 @@ public final class ByteArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_ByteArray_set") - external public operator fun set(index: Int, value: Byte): Unit + public external operator fun set(index: Int, value: Byte): Unit @GCUnsafeCall("Kotlin_ByteArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): ByteIterator { @@ -124,7 +124,7 @@ public final class CharArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_CharArray_get") - external public operator fun get(index: Int): Char + public external operator fun get(index: Int): Char /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -132,10 +132,10 @@ public final class CharArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_CharArray_set") - external public operator fun set(index: Int, value: Char): Unit + public external operator fun set(index: Int, value: Char): Unit @GCUnsafeCall("Kotlin_CharArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.CharIterator { @@ -195,7 +195,7 @@ public final class ShortArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_ShortArray_get") - external public operator fun get(index: Int): Short + public external operator fun get(index: Int): Short /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -203,10 +203,10 @@ public final class ShortArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_ShortArray_set") - external public operator fun set(index: Int, value: Short): Unit + public external operator fun set(index: Int, value: Short): Unit @GCUnsafeCall("Kotlin_ShortArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.ShortIterator { @@ -266,7 +266,7 @@ public final class IntArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_IntArray_get") - external public operator fun get(index: Int): Int + public external operator fun get(index: Int): Int /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -274,10 +274,10 @@ public final class IntArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_IntArray_set") - external public operator fun set(index: Int, value: Int): Unit + public external operator fun set(index: Int, value: Int): Unit @GCUnsafeCall("Kotlin_IntArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.IntIterator { @@ -337,7 +337,7 @@ public final class LongArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_LongArray_get") - external public operator fun get(index: Int): Long + public external operator fun get(index: Int): Long /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -345,10 +345,10 @@ public final class LongArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_LongArray_set") - external public operator fun set(index: Int, value: Long): Unit + public external operator fun set(index: Int, value: Long): Unit @GCUnsafeCall("Kotlin_LongArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.LongIterator { @@ -408,7 +408,7 @@ public final class FloatArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_FloatArray_get") - external public operator fun get(index: Int): Float + public external operator fun get(index: Int): Float /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -416,10 +416,10 @@ public final class FloatArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_FloatArray_set") - external public operator fun set(index: Int, value: Float): Unit + public external operator fun set(index: Int, value: Float): Unit @GCUnsafeCall("Kotlin_FloatArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.FloatIterator { @@ -479,7 +479,7 @@ public final class DoubleArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_DoubleArray_get") - external public operator fun get(index: Int): Double + public external operator fun get(index: Int): Double /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -487,10 +487,10 @@ public final class DoubleArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_DoubleArray_set") - external public operator fun set(index: Int, value: Double): Unit + public external operator fun set(index: Int, value: Double): Unit @GCUnsafeCall("Kotlin_DoubleArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.DoubleIterator { @@ -550,7 +550,7 @@ public final class BooleanArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_BooleanArray_get") - external public operator fun get(index: Int): Boolean + public external operator fun get(index: Int): Boolean /** * Sets the element at the given [index] to the given [value]. This method can be called using the index operator. @@ -558,10 +558,10 @@ public final class BooleanArray { * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException]. */ @GCUnsafeCall("Kotlin_BooleanArray_set") - external public operator fun set(index: Int, value: Boolean): Unit + public external operator fun set(index: Int, value: Boolean): Unit @GCUnsafeCall("Kotlin_BooleanArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int /** Creates an iterator over the elements of the array. */ public operator fun iterator(): kotlin.collections.BooleanIterator { @@ -599,52 +599,52 @@ public inline fun arrayOfNulls(size: Int): Array = public external inline fun arrayOf(vararg elements: T): Array @GCUnsafeCall("Kotlin_emptyArray") -external public fun emptyArray(): Array +public external fun emptyArray(): Array /** * Returns an array containing the specified [Double] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun doubleArrayOf(vararg elements: Double) = elements +public inline fun doubleArrayOf(vararg elements: Double): DoubleArray = elements /** * Returns an array containing the specified [Float] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun floatArrayOf(vararg elements: Float) = elements +public inline fun floatArrayOf(vararg elements: Float): FloatArray = elements /** * Returns an array containing the specified [Long] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun longArrayOf(vararg elements: Long) = elements +public inline fun longArrayOf(vararg elements: Long): LongArray = elements /** * Returns an array containing the specified [Int] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun intArrayOf(vararg elements: Int) = elements +public inline fun intArrayOf(vararg elements: Int): IntArray = elements /** * Returns an array containing the specified characters. */ @Suppress("NOTHING_TO_INLINE") -public inline fun charArrayOf(vararg elements: Char) = elements +public inline fun charArrayOf(vararg elements: Char): CharArray = elements /** * Returns an array containing the specified [Short] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun shortArrayOf(vararg elements: Short) = elements +public inline fun shortArrayOf(vararg elements: Short): ShortArray = elements /** * Returns an array containing the specified [Byte] numbers. */ @Suppress("NOTHING_TO_INLINE") -public inline fun byteArrayOf(vararg elements: Byte) = elements +public inline fun byteArrayOf(vararg elements: Byte): ByteArray = elements /** * Returns an array containing the specified boolean values. */ @Suppress("NOTHING_TO_INLINE") -public inline fun booleanArrayOf(vararg elements: Boolean) = elements +public inline fun booleanArrayOf(vararg elements: Boolean): BooleanArray = elements diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt index e24b75386dd..c5c8e558304 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt @@ -7,105 +7,105 @@ package kotlin public actual open class Error : Throwable { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class Exception : Throwable { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class RuntimeException : Exception { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class NullPointerException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } public actual open class NoSuchElementException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } public actual open class IllegalArgumentException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class IllegalStateException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class UnsupportedOperationException : RuntimeException { - actual constructor() + public actual constructor() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) - actual constructor(cause: Throwable?) : super(cause) + public actual constructor(cause: Throwable?) : super(cause) } public actual open class IndexOutOfBoundsException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } @Deprecated("Use IndexOutOfBoundsException instead.") @DeprecatedSinceKotlin(warningSince = "1.9") public open class ArrayIndexOutOfBoundsException : IndexOutOfBoundsException { - constructor() : super() + public constructor() : super() - constructor(message: String?) : super(message) + public constructor(message: String?) : super(message) } public actual open class ClassCastException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } @PublishedApi @@ -117,21 +117,21 @@ internal open class TypeCastException : ClassCastException { } public actual open class ArithmeticException : RuntimeException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } public actual open class AssertionError : Error { - actual constructor() + public actual constructor() @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) - constructor(cause: Throwable?) : super(cause) + public constructor(cause: Throwable?) : super(cause) - actual constructor(message: Any?) : super(message?.toString(), message as? Throwable) + public actual constructor(message: Any?) : super(message?.toString(), message as? Throwable) - actual constructor(message: String?, cause: Throwable?) : super(message, cause) + public actual constructor(message: String?, cause: Throwable?) : super(message, cause) } @Suppress("ACTUAL_WITHOUT_EXPECT") @@ -160,24 +160,24 @@ internal actual open class UninitializedPropertyAccessException : RuntimeExcepti public open class OutOfMemoryError : Error { - constructor() : super() + public constructor() : super() - constructor(message: String?) : super(message) + public constructor(message: String?) : super(message) } public actual open class NumberFormatException : IllegalArgumentException { - actual constructor() : super() + public actual constructor() : super() - actual constructor(message: String?) : super(message) + public actual constructor(message: String?) : super(message) } public actual open class ConcurrentModificationException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { - actual constructor() : this(null, null) + public actual constructor() : this(null, null) - actual constructor(message: String?) : this(message, null) + public actual constructor(message: String?) : this(message, null) - actual constructor(cause: Throwable?) : this(null, cause) + public actual constructor(cause: Throwable?) : this(null, cause) } \ No newline at end of file diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/String.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/String.kt index 81591d3f3a1..e724392df24 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/String.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/String.kt @@ -68,4 +68,4 @@ public inline operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.Strin (this?.toString() ?: "null").plus(other?.toString() ?: "null") -public inline fun Any?.toString() = this?.toString() ?: "null" \ No newline at end of file +public inline fun Any?.toString(): String = this?.toString() ?: "null" \ No newline at end of file diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt index 308988593e2..9e7f36c12c9 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt @@ -23,13 +23,13 @@ import kotlinx.cinterop.ExperimentalForeignApi */ @ExportTypeInfo("theThrowableTypeInfo") @OptIn(FreezingIsDeprecated::class) -public open class Throwable(open val message: String?, open val cause: Throwable?) { +public open class Throwable(public open val message: String?, public open val cause: Throwable?) { - constructor(message: String?) : this(message, null) + public constructor(message: String?) : this(message, null) - constructor(cause: Throwable?) : this(cause?.toString(), cause) + public constructor(cause: Throwable?) : this(cause?.toString(), cause) - constructor() : this(null, null) + public constructor() : this(null, null) @get:ExportForCppRuntime("Kotlin_Throwable_getStackTrace") private val stackTrace: NativePtrArray = getCurrentStackTrace() diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Unit.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Unit.kt index fca7a20e47c..5ec31cea334 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Unit.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Unit.kt @@ -12,5 +12,5 @@ import kotlin.native.internal.ExportTypeInfo */ @ExportTypeInfo("theUnitTypeInfo") public object Unit { - override fun toString() = "kotlin.Unit" + override fun toString(): String = "kotlin.Unit" } \ No newline at end of file diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/cancellation/CancellationException.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/cancellation/CancellationException.kt index 13e8c4215c4..1359a1db058 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/cancellation/CancellationException.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/cancellation/CancellationException.kt @@ -7,8 +7,8 @@ package kotlin.coroutines.cancellation @SinceKotlin("1.4") public actual open class CancellationException : IllegalStateException { - actual constructor() : super() - actual constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) + public actual constructor() : super() + public actual constructor(message: String?) : super(message) + public constructor(message: String?, cause: Throwable?) : super(message, cause) + public constructor(cause: Throwable?) : super(cause) } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/intrinsics/IntrinsicsNative.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/intrinsics/IntrinsicsNative.kt index 0b96621ece8..4fa89e2af63 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/intrinsics/IntrinsicsNative.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/intrinsics/IntrinsicsNative.kt @@ -294,7 +294,7 @@ internal inline fun createContinuationArgumentFromCallback( } @PublishedApi -internal fun wrapWithContinuationImpl(completion: Continuation) = +internal fun wrapWithContinuationImpl(completion: Continuation): Continuation = createSimpleCoroutineForSuspendFunction(probeCoroutineCreated(completion)) /** diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/BitSet.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/BitSet.kt index 917b1fe95c4..3fb7ca5cfac 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/BitSet.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/BitSet.kt @@ -15,7 +15,7 @@ package kotlin.native public class BitSet(size: Int = ELEMENT_SIZE) { @kotlin.native.internal.CanBePrecreated - companion object { + public companion object { // Default size of one element in the array used to store bits. private const val ELEMENT_SIZE = 64 private const val MAX_BIT_OFFSET = ELEMENT_SIZE - 1 @@ -29,21 +29,21 @@ public class BitSet(size: Int = ELEMENT_SIZE) { get() = size - 1 /** Returns an index of the last bit that has `true` value. Returns -1 if the set is empty. */ - val lastTrueIndex: Int + public val lastTrueIndex: Int get() = previousSetBit(size) /** True if this BitSet contains no bits set to true. */ - val isEmpty: Boolean + public val isEmpty: Boolean get() = bits.all { it == ALL_FALSE } /** Actual number of bits available in the set. All bits with indices >= size assumed to be 0 */ - var size: Int = size + public var size: Int = size private set /** * Creates a bit set of given [length] filling elements using [initializer] */ - constructor(length: Int, initializer: (Int) -> Boolean): this(length) { + public constructor(length: Int, initializer: (Int) -> Boolean): this(length) { for (i in 0 until length) { set(i, initializer(i)) } @@ -135,17 +135,17 @@ public class BitSet(size: Int = ELEMENT_SIZE) { } /** Set the bit specified to the specified value. */ - fun set(index: Int, value: Boolean = true) { + public fun set(index: Int, value: Boolean = true) { ensureCapacity(index) val (elementIndex, offset) = index.asBitCoordinates setBitsWithMask(elementIndex, offset.asMask, value) } /** Sets the bits with indices between [from] (inclusive) and [to] (exclusive) to the specified value. */ - fun set(from : Int, to: Int, value: Boolean = true) = set(from until to, value) + public fun set(from : Int, to: Int, value: Boolean = true): Unit = set(from until to, value) /** Sets the bits from the range specified to the specified value. */ - fun set(range: IntRange, value: Boolean = true) { + public fun set(range: IntRange, value: Boolean = true) { if (range.start < 0 || range.endInclusive < 0) { throw IndexOutOfBoundsException() } @@ -172,31 +172,31 @@ public class BitSet(size: Int = ELEMENT_SIZE) { /** Clears the bit specified */ - fun clear(index: Int) = set(index, false) + public fun clear(index: Int): Unit = set(index, false) /** Clears the bits with indices between [from] (inclusive) and [to] (exclusive) to the specified value. */ - fun clear(from : Int, to: Int) = set(from, to, false) + public fun clear(from : Int, to: Int): Unit = set(from, to, false) /** Clears the bit specified */ - fun clear(range: IntRange) = set(range, false) + public fun clear(range: IntRange): Unit = set(range, false) /** Sets all bits in the BitSet to `false`. */ - fun clear() { + public fun clear() { for (i in bits.indices) { bits[i] = ALL_FALSE } } /** Reverses the bit specified. */ - fun flip(index: Int) { + public fun flip(index: Int) { ensureCapacity(index) val (elementIndex, offset) = index.asBitCoordinates flipBitsWithMask(elementIndex, offset.asMask) } /** Reverses the bits with indices between [from] (inclusive) and [to] (exclusive). */ - fun flip(from: Int, to: Int) = flip(from until to) + public fun flip(from: Int, to: Int): Unit = flip(from until to) /** Reverses the bits from the range specified. */ - fun flip(range: IntRange) { + public fun flip(range: IntRange) { if (range.start < 0 || range.endInclusive < 0) { throw IndexOutOfBoundsException() } @@ -262,7 +262,7 @@ public class BitSet(size: Int = ELEMENT_SIZE) { * Returns -1 if there is no such bits after [startIndex]. * @throws IndexOutOfBoundException if [startIndex] < 0. */ - fun nextSetBit(startIndex: Int = 0): Int = nextBit(startIndex, true) + public fun nextSetBit(startIndex: Int = 0): Int = nextBit(startIndex, true) /** * Returns an index of a next bit which value is `false` after [startIndex] (inclusive). @@ -270,14 +270,14 @@ public class BitSet(size: Int = ELEMENT_SIZE) { * sequence of `false` bits after (size - 1)-th. * @throws IndexOutOfBoundException if [startIndex] < 0. */ - fun nextClearBit(startIndex: Int = 0): Int = nextBit(startIndex, false) + public fun nextClearBit(startIndex: Int = 0): Int = nextBit(startIndex, false) /** * Returns the biggest index of a bit which value is [lookFor] before [startIndex] (inclusive). * Returns -1 if there is no such bits before [startIndex]. * If [startIndex] >= [size] returns -1 */ - fun previousBit(startIndex: Int, lookFor: Boolean): Int { + public fun previousBit(startIndex: Int, lookFor: Boolean): Int { var correctStartIndex = startIndex if (startIndex >= size) { // We assume that all bits after `size - 1` are 0. So we can return the start index if we are looking for 0. @@ -323,7 +323,7 @@ public class BitSet(size: Int = ELEMENT_SIZE) { * If [startIndex] >= size will search from (size - 1)-th bit. * @throws IndexOutOfBoundException if [startIndex] < -1. */ - fun previousSetBit(startIndex: Int): Int = previousBit(startIndex, true) + public fun previousSetBit(startIndex: Int): Int = previousBit(startIndex, true) /** * Returns the biggest index of a bit which value is `false` before [startIndex] (inclusive). @@ -332,10 +332,10 @@ public class BitSet(size: Int = ELEMENT_SIZE) { * sequence of `false` bits after (size - 1)-th. * @throws IndexOutOfBoundException if [startIndex] < -1. */ - fun previousClearBit(startIndex: Int): Int = previousBit(startIndex, false) + public fun previousClearBit(startIndex: Int): Int = previousBit(startIndex, false) /** Returns a value of a bit with the [index] specified. */ - operator fun get(index: Int): Boolean { + public operator fun get(index: Int): Boolean { if (index < 0) { throw IndexOutOfBoundsException() } @@ -360,16 +360,16 @@ public class BitSet(size: Int = ELEMENT_SIZE) { } /** Performs a logical and operation over corresponding bits of this and [another] BitSets. The result is saved in this BitSet. */ - fun and(another: BitSet) = doOperation(another, Long::and) + public fun and(another: BitSet): Unit = doOperation(another, Long::and) /** Performs a logical or operation over corresponding bits of this and [another] BitSets. The result is saved in this BitSet. */ - fun or(another: BitSet) = doOperation(another, Long::or) + public fun or(another: BitSet): Unit = doOperation(another, Long::or) /** Performs a logical xor operation over corresponding bits of this and [another] BitSets. The result is saved in this BitSet. */ - fun xor(another: BitSet) = doOperation(another, Long::xor) + public fun xor(another: BitSet): Unit = doOperation(another, Long::xor) /** Performs a logical and + not operations over corresponding bits of this and [another] BitSets. The result is saved in this BitSet. */ - fun andNot(another: BitSet) { + public fun andNot(another: BitSet) { ensureCapacity(another.lastIndex) var index = 0 while (index < another.bits.size) { @@ -383,7 +383,7 @@ public class BitSet(size: Int = ELEMENT_SIZE) { } /** Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet. */ - fun intersects(another: BitSet): Boolean = + public fun intersects(another: BitSet): Boolean = (0 until minOf(bits.size, another.bits.size)).any { bits[it] and another.bits[it] != 0L } override fun toString(): String { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Platform.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Platform.kt index 7e8712edfe1..680b6509f69 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Platform.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Platform.kt @@ -29,7 +29,7 @@ public enum class OsFamily { * Central Processor Unit architecture. */ @ExperimentalNativeApi -public enum class CpuArchitecture(val bitness: Int) { +public enum class CpuArchitecture(public val bitness: Int) { UNKNOWN(-1), ARM32(32), ARM64(64), @@ -182,4 +182,4 @@ private external fun Platform_getAvailableProcessors(): Int @TypedIntrinsic(IntrinsicType.IS_EXPERIMENTAL_MM) @ExperimentalStdlibApi -external fun isExperimentalMM(): Boolean +public external fun isExperimentalMM(): Boolean diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt index 2c07f59a7a6..8dd12e93e9d 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt @@ -32,9 +32,9 @@ external public fun deinitRuntimeIfNeeded(): Unit */ @FreezingIsDeprecated public class IncorrectDereferenceException : RuntimeException { - constructor() : super() + public constructor() : super() - constructor(message: String) : super(message) + public constructor(message: String) : super(message) } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt index f4ff06fe16f..5bfab7478fa 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt @@ -166,7 +166,7 @@ public class AtomicLong(public @Volatile var value: Long = 0L) { * Atomically decrements the current value by one. */ @Deprecated("Use decrementAndGet() or getAndDecrement() instead.", ReplaceWith("this.decrementAndGet()"), DeprecationLevel.ERROR) - fun decrement(): Unit { + public fun decrement(): Unit { addAndGet(-1L) } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Continuation.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Continuation.kt index e6898f1787f..28fb82e64d5 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Continuation.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Continuation.kt @@ -98,7 +98,7 @@ public class Continuation2( } } - fun dispose() { + public fun dispose() { assert(!singleShot) stable.dispose() } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt index 5e495b66fa3..ee806e7cd01 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt @@ -45,7 +45,7 @@ public fun T.freeze(): T { * @return true if given object is null or frozen or permanent */ @FreezingIsDeprecated -public val Any?.isFrozen +public val Any?.isFrozen: Boolean get() = isFrozenInternal(this) /** diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Future.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Future.kt index 9193cdc1e4f..bbbd874b25b 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Future.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Future.kt @@ -11,7 +11,7 @@ import kotlin.native.internal.Frozen * State of the future object. */ @ObsoleteWorkersApi -enum class FutureState(val value: Int) { +public enum class FutureState(public val value: Int) { INVALID(0), /** Future is scheduled for execution. */ SCHEDULED(1), @@ -28,7 +28,7 @@ enum class FutureState(val value: Int) { */ @Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") @ObsoleteWorkersApi -public value class Future @PublishedApi internal constructor(val id: Int) { +public value class Future @PublishedApi internal constructor(public val id: Int) { /** * Blocks execution until the future is ready. * diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/MutableData.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/MutableData.kt index cddc0508942..8b22e93c5ab 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/MutableData.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/MutableData.kt @@ -68,14 +68,14 @@ public class MutableData constructor(capacity: Int = 16) { /** * Reset the data buffer, makings its size 0. */ - public fun reset() = locked(lock) { + public fun reset(): Unit = locked(lock) { size_ = 0 } /** * Appends data to the buffer. */ - public fun append(data: MutableData) = locked(lock) { + public fun append(data: MutableData): Unit = locked(lock) { val toCopy = data.size val where = resizeDataLocked(size + toCopy) data.copyInto(buffer, 0, toCopy, where) @@ -126,7 +126,7 @@ public class MutableData constructor(capacity: Int = 16) { * Executes provided block under lock with raw pointer to the data stored in the buffer. * Block is executed under the spinlock, and must be short. */ - public fun withPointerLocked(block: (COpaquePointer, dataSize: Int) -> R) = locked(lock) { + public fun withPointerLocked(block: (COpaquePointer, dataSize: Int) -> R): R = locked(lock) { buffer.usePinned { it -> block(it.addressOf(0), size) } @@ -136,7 +136,7 @@ public class MutableData constructor(capacity: Int = 16) { * Executes provided block under lock with the raw data buffer. * Block is executed under the spinlock, and must be short. */ - public fun withBufferLocked(block: (array: ByteArray, dataSize: Int) -> R) = locked(lock) { + public fun withBufferLocked(block: (array: ByteArray, dataSize: Int) -> R): R = locked(lock) { block(buffer, size) } } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/ObjectTransfer.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/ObjectTransfer.kt index 345837bc9fb..34976c61f48 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/ObjectTransfer.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/ObjectTransfer.kt @@ -38,7 +38,7 @@ import kotlin.concurrent.AtomicNativePtr */ // Not @FreezingIsDeprecated: every `Worker.execute` uses this. @ObsoleteWorkersApi -public enum class TransferMode(val value: Int) { +public enum class TransferMode(public val value: Int) { /** * Reachability check is performed. */ @@ -59,7 +59,7 @@ public enum class TransferMode(val value: Int) { @ObsoleteWorkersApi public class DetachedObjectGraph internal constructor(pointer: NativePtr) { @PublishedApi - internal val stable = AtomicNativePtr(pointer) + internal val stable: AtomicNativePtr = AtomicNativePtr(pointer) /** * Creates stable pointer to object, ensuring associated object subgraph is disjoint in specified mode diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt index 37b0687d190..b5e0904e611 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt @@ -35,8 +35,8 @@ import kotlinx.cinterop.* @Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") @OptIn(FreezingIsDeprecated::class) @ObsoleteWorkersApi -public value class Worker @PublishedApi internal constructor(val id: Int) { - companion object { +public value class Worker @PublishedApi internal constructor(public val id: Int) { + public companion object { /** * Start new scheduling primitive, such as thread, to accept new tasks via `execute` interface. * Typically new worker may be needed for computations offload to another core, for IO it may be diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/WorkerBoundReference.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/WorkerBoundReference.kt index 58a47c07f0e..9b7c1afb101 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/WorkerBoundReference.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/WorkerBoundReference.kt @@ -51,19 +51,19 @@ public class WorkerBoundReference(value: T) { * The referenced value. * @throws IncorrectDereferenceException if referred object is not frozen and current worker is different from the one created [this]. */ - val value: T + public val value: T get() = valueOrNull ?: throw IncorrectDereferenceException("illegal attempt to access non-shared $valueDescription bound to `$ownerName` from `${Worker.current.name}`") /** * The referenced value or null if referred object is not frozen and current worker is different from the one created [this]. */ - val valueOrNull: T? + public val valueOrNull: T? get() = valueBeforeFreezing ?: @Suppress("UNCHECKED_CAST") (derefWorkerBoundReference(ptr) as T?) /** * Worker that [value] is bound to. */ - val worker: Worker = Worker.current + public val worker: Worker = Worker.current @ExportForCppRuntime("Kotlin_WorkerBoundReference_freezeHook") private fun freezeHook() { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Annotations.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Annotations.kt index c13e4042668..3d2c0be0a30 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Annotations.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Annotations.kt @@ -168,7 +168,7 @@ internal annotation class HasFreezeHook @Target(AnnotationTarget.FUNCTION) @Retention(value = AnnotationRetention.BINARY) @InternalForKotlinNative -annotation class GCUnsafeCall(val callee: String) +public annotation class GCUnsafeCall(val callee: String) /** * Marks a declaration that is internal for Kotlin/Native tests and shouldn't be used externally. diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Cleaner.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Cleaner.kt index f9915e5d5e0..631bf938690 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Cleaner.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Cleaner.kt @@ -77,7 +77,7 @@ public interface Cleaner @ExperimentalStdlibApi @ExportForCompiler @OptIn(ExperimentalNativeApi::class, ObsoleteWorkersApi::class) -fun createCleaner(argument: T, block: (T) -> Unit): Cleaner = +public fun createCleaner(argument: T, block: (T) -> Unit): Cleaner = kotlin.native.ref.createCleanerImpl(argument, block) as Cleaner /** @@ -85,7 +85,7 @@ fun createCleaner(argument: T, block: (T) -> Unit): Cleaner = */ @InternalForKotlinNative @OptIn(kotlin.native.runtime.NativeRuntimeApi::class, ObsoleteWorkersApi::class) -fun performGCOnCleanerWorker() = +public fun performGCOnCleanerWorker(): Unit = getCleanerWorker().execute(TransferMode.SAFE, {}) { GC.collect() }.result @@ -95,14 +95,14 @@ fun performGCOnCleanerWorker() = */ @InternalForKotlinNative @OptIn(ObsoleteWorkersApi::class) -fun waitCleanerWorker() = +public fun waitCleanerWorker(): Unit = getCleanerWorker().execute(TransferMode.SAFE, {}) { Unit }.result @GCUnsafeCall("Kotlin_CleanerImpl_getCleanerWorker") @OptIn(ObsoleteWorkersApi::class) -external internal fun getCleanerWorker(): Worker +internal external fun getCleanerWorker(): Worker @ExportForCppRuntime("Kotlin_CleanerImpl_shutdownCleanerWorker") @OptIn(ObsoleteWorkersApi::class) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt index b1ecd7cb15d..b238115a280 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt @@ -3,6 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE") // Scheduled for eventual removal + package kotlin.native.internal import kotlin.time.* diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/MemoryUsageInfo.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/MemoryUsageInfo.kt index 85193f08463..1a631a2811a 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/MemoryUsageInfo.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/MemoryUsageInfo.kt @@ -5,11 +5,11 @@ package kotlin.native.internal @InternalForKotlinNative -object MemoryUsageInfo { +public object MemoryUsageInfo { // An estimate of how much memory was committed by the process at its peak. // Resident Set Size in *nix, Working Set Size in Windows. // May return 0 if unimplemented on some platform, or in case of an error. - val peakResidentSetSizeBytes: Long + public val peakResidentSetSizeBytes: Long get() = MemoryUsageInfo_getPeakResidentSetSizeBytes() } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NativePtr.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NativePtr.kt index 1862865b0d4..2d893190edf 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NativePtr.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NativePtr.kt @@ -14,23 +14,23 @@ import kotlinx.cinterop.* internal external fun getNativeNullPtr(): NativePtr @ExperimentalForeignApi -class NativePtr @PublishedApi internal constructor(private val value: NonNullNativePtr?) { - companion object { +public class NativePtr @PublishedApi internal constructor(private val value: NonNullNativePtr?) { + public companion object { // TODO: make it properly precreated, maybe use an intrinsic for that. - val NULL = getNativeNullPtr() + public val NULL: NativePtr = getNativeNullPtr() } @TypedIntrinsic(IntrinsicType.INTEROP_NATIVE_PTR_PLUS_LONG) - external operator fun plus(offset: Long): NativePtr + public external operator fun plus(offset: Long): NativePtr @TypedIntrinsic(IntrinsicType.INTEROP_NATIVE_PTR_TO_LONG) - external fun toLong(): Long + public external fun toLong(): Long - override fun equals(other: Any?) = (other is NativePtr) && kotlin.native.internal.areEqualByValue(this, other) + override fun equals(other: Any?): Boolean = (other is NativePtr) && kotlin.native.internal.areEqualByValue(this, other) - override fun hashCode() = this.toLong().hashCode() + override fun hashCode(): Int = this.toLong().hashCode() - override fun toString() = "0x${this.toLong().toString(16)}" + override fun toString(): String = "0x${this.toLong().toString(16)}" internal fun isNull(): Boolean = (value == null) } @@ -40,11 +40,11 @@ internal class NonNullNativePtr private constructor() { // TODO: refactor to use @Suppress("NOTHING_TO_INLINE") inline fun toNativePtr() = NativePtr(this) - override fun toString() = toNativePtr().toString() + override fun toString(): String = toNativePtr().toString() - override fun hashCode() = toNativePtr().hashCode() + override fun hashCode(): Int = toNativePtr().hashCode() - override fun equals(other: Any?) = other is NonNullNativePtr + override fun equals(other: Any?): Boolean = other is NonNullNativePtr && kotlin.native.internal.areEqualByValue(this.toNativePtr(), other.toNativePtr()) } @@ -52,14 +52,14 @@ internal class NonNullNativePtr private constructor() { // TODO: refactor to use internal class NativePtrArray { @GCUnsafeCall("Kotlin_NativePtrArray_get") - external public operator fun get(index: Int): NativePtr + public external operator fun get(index: Int): NativePtr @GCUnsafeCall("Kotlin_NativePtrArray_set") - external public operator fun set(index: Int, value: NativePtr): Unit + public external operator fun set(index: Int, value: NativePtr): Unit val size: Int get() = getArrayLength() @GCUnsafeCall("Kotlin_NativePtrArray_getArrayLength") - external private fun getArrayLength(): Int + private external fun getArrayLength(): Int } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/ObjCExportUtils.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/ObjCExportUtils.kt index 95160cde177..1c9e36be71f 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/ObjCExportUtils.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/ObjCExportUtils.kt @@ -271,7 +271,7 @@ internal class NSEnumeratorAsKIterator : AbstractIterator() { error: Any ) = ObjCErrorException(message, error) -class ObjCErrorException( +public class ObjCErrorException( message: String?, internal val error: Any ) : Exception(message) { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index 08043289333..11446b7d74b 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -225,10 +225,10 @@ internal external fun initInstance(thiz: Any, constructorCall: Any): Unit internal external fun isSubtype(objTypeInfo: NativePtr): Boolean @PublishedApi -internal fun checkProgressionStep(step: Int) = +internal fun checkProgressionStep(step: Int): Int = if (step > 0) step else throw IllegalArgumentException("Step must be positive, was: $step.") @PublishedApi -internal fun checkProgressionStep(step: Long) = +internal fun checkProgressionStep(step: Long): Long = if (step > 0) step else throw IllegalArgumentException("Step must be positive, was: $step.") @PublishedApi diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/gc/GCInfo.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/gc/GCInfo.kt index e2032fc7793..f3de7a42c7e 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/gc/GCInfo.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/gc/GCInfo.kt @@ -3,6 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +@file:Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE") // Scheduled for eventual removal + package kotlin.native.internal.gc /** diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt index 9f9db60f3f7..f4f5f85a2e2 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt @@ -13,14 +13,14 @@ import kotlin.native.concurrent.* // Advanced users may need an access to test suites generated by the compiler to integrate // our test machinery with third party test runners (e.g. with xctestrun). -// So we keep this object public but protect it with @ExperimentalStdlibApi +// So we keep this object public but protect it with @ExperimentalNativeApi // to stress that it is not a part of the stable API. // Related YT issue: KT-47915. @ExperimentalNativeApi @ThreadLocal public object GeneratedSuites { - val suites = mutableListOf() - fun add(suite: TestSuite) = suites.add(suite) + public val suites: MutableList = mutableListOf() + public fun add(suite: TestSuite): Boolean = suites.add(suite) } @ExperimentalNativeApi @@ -29,12 +29,12 @@ public fun registerSuite(suite: TestSuite): Unit { } @ExperimentalNativeApi -fun testLauncherEntryPoint(args: Array): Int { +public fun testLauncherEntryPoint(args: Array): Int { return TestRunner(GeneratedSuites.suites, args).run() } @ExperimentalNativeApi -fun main(args: Array) { +public fun main(args: Array) { val exitCode = testLauncherEntryPoint(args) if (exitCode != 0) { exitProcess(exitCode) @@ -44,7 +44,7 @@ fun main(args: Array) { @OptIn(FreezingIsDeprecated::class) @ExperimentalNativeApi @ObsoleteWorkersApi -fun worker(args: Array) { +public fun worker(args: Array) { val worker = Worker.start() val exitCode = worker.execute(TransferMode.SAFE, { args.freeze() }) { it -> testLauncherEntryPoint(it) @@ -56,6 +56,6 @@ fun worker(args: Array) { } @ExperimentalNativeApi -fun mainNoExit(args: Array) { +public fun mainNoExit(args: Array) { testLauncherEntryPoint(args) } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt index a0b7d110921..b5201f4b433 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt @@ -7,8 +7,6 @@ package kotlin.native.internal.test import kotlin.experimental.ExperimentalNativeApi import kotlin.IllegalArgumentException -import kotlin.system.getTimeMillis -import kotlin.system.measureTimeMillis /** * Represents a test case, that is a Kotlin test method marked with `@Test` annotaion. @@ -17,38 +15,38 @@ import kotlin.system.measureTimeMillis */ @ExperimentalNativeApi public interface TestCase { - val name: String + public val name: String /** * Shows if this test is ignored by the `@Ignore` annotation. * * @see kotlin.test.Ignore */ - val ignored: Boolean + public val ignored: Boolean /** * Test Suite the test belongs to. */ - val suite: TestSuite + public val suite: TestSuite /** * Runs all methods that were marked with `@BeforeTest` annotation. * * @see kotlin.test.BeforeTest */ - fun doBefore() + public fun doBefore() /** * Runs the test method itself * * @see kotlin.test.Test */ - fun doRun() + public fun doRun() /** * Runs test with its before and after functions. */ - fun run() { + public fun run() { try { doBefore() doRun() @@ -62,7 +60,7 @@ public interface TestCase { * * @see kotlin.test.AfterTest */ - fun doAfter() + public fun doAfter() } @ExperimentalNativeApi @@ -79,38 +77,38 @@ public interface TestSuite { /** * Test suite name. */ - val name: String + public val name: String /** * Shows if the suite is ignored with `@Ignore` annotation. * * @see kotlin.test.Ignore */ - val ignored: Boolean + public val ignored: Boolean /** * Test cases this test suite contains */ - val testCases: Map + public val testCases: Map /** * Number of test cases */ - val size : Int + public val size : Int /** * Executes all methods marked with `@BeforeClass` annotation * * @see kotlin.test.BeforeClass */ - fun doBeforeClass() + public fun doBeforeClass() /** * Executes all methods marked with `@AfterClass` annotation * * @see @see kotlin.test.AfterClass */ - fun doAfterClass() + public fun doAfterClass() } @ExperimentalNativeApi @@ -127,10 +125,10 @@ public abstract class AbstractTestSuite>(override val name: St override fun toString(): String = name // TODO: Make inner and remove the type param when the bug is fixed. - abstract class BasicTestCase>( + public abstract class BasicTestCase>( override val name: String, override val suite: AbstractTestSuite, - val testFunction: F, + public val testFunction: F, override val ignored: Boolean ) : TestCase { override fun toString(): String = "$name ($suite)" @@ -142,10 +140,10 @@ public abstract class AbstractTestSuite>(override val name: St private fun registerTestCase(testCase: BasicTestCase) = _testCases.put(testCase.name, testCase) - fun registerTestCase(name: String, testFunction: F, ignored: Boolean) = + public fun registerTestCase(name: String, testFunction: F, ignored: Boolean): BasicTestCase? = registerTestCase(createTestCase(name, testFunction, ignored)) - abstract fun createTestCase(name: String, testFunction: F, ignored: Boolean): BasicTestCase + public abstract fun createTestCase(name: String, testFunction: F, ignored: Boolean): BasicTestCase init { registerSuite(this) @@ -159,10 +157,10 @@ public abstract class AbstractTestSuite>(override val name: St public abstract class BaseClassSuite(name: String, ignored: Boolean) : AbstractTestSuite Unit>(name, ignored) { - class TestCase(name: String, - override val suite: BaseClassSuite, - testFunction: INSTANCE.() -> Unit, - ignored: Boolean) + public class TestCase(name: String, + override val suite: BaseClassSuite, + testFunction: INSTANCE.() -> Unit, + ignored: Boolean) : BasicTestCase Unit>(name, suite, testFunction, ignored) { internal val instance: INSTANCE by lazy { suite.createInstance() } @@ -181,12 +179,12 @@ public abstract class BaseClassSuite(name: String, ignored: } // These two methods are overridden in test suite classes generated by the compiler. - abstract fun createInstance(): INSTANCE - open fun getCompanion(): COMPANION = throw NotImplementedError("Test class has no companion object") + public abstract fun createInstance(): INSTANCE + public open fun getCompanion(): COMPANION = throw NotImplementedError("Test class has no companion object") - companion object { - val INSTANCE_KINDS = listOf(TestFunctionKind.BEFORE_TEST, TestFunctionKind.AFTER_TEST) - val COMPANION_KINDS = listOf(TestFunctionKind.BEFORE_CLASS, TestFunctionKind.AFTER_CLASS) + public companion object { + public val INSTANCE_KINDS: List = listOf(TestFunctionKind.BEFORE_TEST, TestFunctionKind.AFTER_TEST) + public val COMPANION_KINDS: List = listOf(TestFunctionKind.BEFORE_CLASS, TestFunctionKind.AFTER_CLASS) } private val instanceFunctions = mutableMapOf Unit>>() @@ -201,22 +199,22 @@ public abstract class BaseClassSuite(name: String, ignored: return companionFunction.getOrPut(kind) { mutableSetOf() } } - val before: Collection Unit> get() = getInstanceFunctions(TestFunctionKind.BEFORE_TEST) - val after: Collection Unit> get() = getInstanceFunctions(TestFunctionKind.AFTER_TEST) + public val before: Collection Unit> get() = getInstanceFunctions(TestFunctionKind.BEFORE_TEST) + public val after: Collection Unit> get() = getInstanceFunctions(TestFunctionKind.AFTER_TEST) - val beforeClass: Collection Unit> get() = getCompanionFunctions(TestFunctionKind.BEFORE_CLASS) - val afterClass: Collection Unit> get() = getCompanionFunctions(TestFunctionKind.AFTER_CLASS) + public val beforeClass: Collection Unit> get() = getCompanionFunctions(TestFunctionKind.BEFORE_CLASS) + public val afterClass: Collection Unit> get() = getCompanionFunctions(TestFunctionKind.AFTER_CLASS) @Suppress("UNCHECKED_CAST") - fun registerFunction(kind: TestFunctionKind, function: Function1<*, Unit>) = + public fun registerFunction(kind: TestFunctionKind, function: Function1<*, Unit>): Boolean = when (kind) { in INSTANCE_KINDS -> getInstanceFunctions(kind).add(function as INSTANCE.() -> Unit) in COMPANION_KINDS -> getCompanionFunctions(kind).add(function as COMPANION.() -> Unit) else -> throw IllegalArgumentException("Unknown function kind: $kind") } - override fun doBeforeClass() = beforeClass.forEach { getCompanion().it() } - override fun doAfterClass() = afterClass.forEach { getCompanion().it() } + override fun doBeforeClass(): Unit = beforeClass.forEach { getCompanion().it() } + override fun doAfterClass(): Unit = afterClass.forEach { getCompanion().it() } override fun createTestCase(name: String, testFunction: INSTANCE.() -> Unit, ignored: Boolean) : BasicTestCase Unit> = @@ -228,7 +226,7 @@ private typealias TopLevelFun = () -> Unit @ExperimentalNativeApi public class TopLevelSuite(name: String): AbstractTestSuite(name, false) { - class TestCase(name: String, override val suite: TopLevelSuite, testFunction: TopLevelFun, ignored: Boolean) + public class TestCase(name: String, override val suite: TopLevelSuite, testFunction: TopLevelFun, ignored: Boolean) : BasicTestCase(name, suite, testFunction, ignored) { override fun doBefore() { suite.before.forEach { it() } @@ -246,15 +244,15 @@ public class TopLevelSuite(name: String): AbstractTestSuite(name, f private val specialFunctions = mutableMapOf>() private fun getFunctions(type: TestFunctionKind) = specialFunctions.getOrPut(type) { mutableSetOf() } - val before: Collection get() = getFunctions(TestFunctionKind.BEFORE_TEST) - val after: Collection get() = getFunctions(TestFunctionKind.AFTER_TEST) - val beforeClass: Collection get() = getFunctions(TestFunctionKind.BEFORE_CLASS) - val afterClass: Collection get() = getFunctions(TestFunctionKind.AFTER_CLASS) + public val before: Collection get() = getFunctions(TestFunctionKind.BEFORE_TEST) + public val after: Collection get() = getFunctions(TestFunctionKind.AFTER_TEST) + public val beforeClass: Collection get() = getFunctions(TestFunctionKind.BEFORE_CLASS) + public val afterClass: Collection get() = getFunctions(TestFunctionKind.AFTER_CLASS) - fun registerFunction(kind: TestFunctionKind, function: TopLevelFun) = getFunctions(kind).add(function) + public fun registerFunction(kind: TestFunctionKind, function: TopLevelFun): Boolean = getFunctions(kind).add(function) - override fun doBeforeClass() = beforeClass.forEach { it() } - override fun doAfterClass() = afterClass.forEach { it() } + override fun doBeforeClass(): Unit = beforeClass.forEach { it() } + override fun doAfterClass(): Unit = afterClass.forEach { it() } override fun createTestCase(name: String, testFunction: TopLevelFun, ignored: Boolean) : BasicTestCase = TestCase(name, this, testFunction, ignored) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/ref/Weak.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/ref/Weak.kt index b97e034021e..af3416edd33 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/ref/Weak.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/ref/Weak.kt @@ -18,7 +18,7 @@ public class WeakReference { * Creates a weak reference object pointing to an object. Weak reference doesn't prevent * removing object, and is nullified once object is collected. */ - constructor(referred: T) { + public constructor(referred: T) { pointer = getWeakReferenceImpl(referred) } diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt index c8d30be9234..220a455fed7 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt @@ -44,13 +44,13 @@ public object GC { * with [stop] operation. Even if GC is suspended, [collect] still triggers collection. */ @GCUnsafeCall("Kotlin_native_internal_GC_collect") - external fun collect() + public external fun collect() /** * Trigger new collection without waiting for its completion. */ @GCUnsafeCall("Kotlin_native_internal_GC_schedule") - external fun schedule() + public external fun schedule() /** * Deprecated and unused. @@ -59,7 +59,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_collectCyclic") @Deprecated("No-op in modern GC implementation") - external fun collectCyclic() + public external fun collectCyclic() /** * Deprecated and unused. @@ -68,7 +68,7 @@ public object GC { * GC algorithm is not executed. */ @GCUnsafeCall("Kotlin_native_internal_GC_suspend") - external fun suspend() + public external fun suspend() /** * Deprecated and unused. @@ -77,7 +77,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_resume") @Deprecated("No-op in modern GC implementation") - external fun resume() + public external fun resume() /** * Deprecated and unused. @@ -86,7 +86,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_stop") @Deprecated("No-op in modern GC implementation") - external fun stop() + public external fun stop() /** * Deprecated and unused. @@ -96,7 +96,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_start") @Deprecated("No-op in modern GC implementation") - external fun start() + public external fun start() /** * Deprecated and unused. @@ -109,7 +109,7 @@ public object GC { * @throws [IllegalArgumentException] when value is not positive. */ @Deprecated("No-op in modern GC implementation") - var threshold: Int + public var threshold: Int get() = getThreshold() set(value) { require(value > 0) { "threshold must be positive: $value" } @@ -127,7 +127,7 @@ public object GC { * @throws [IllegalArgumentException] when value is not positive. */ @Deprecated("No-op in modern GC implementation") - var collectCyclesThreshold: Long + public var collectCyclesThreshold: Long get() = getCollectCyclesThreshold() set(value) { require(value > 0) { "collectCyclesThreshold must be positive: $value" } @@ -144,7 +144,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is not positive. */ - var thresholdAllocations: Long + public var thresholdAllocations: Long get() = getThresholdAllocations() set(value) { require(value > 0) { "thresholdAllocations must be positive: $value" } @@ -158,7 +158,7 @@ public object GC { * * Default: true */ - var autotune: Boolean + public var autotune: Boolean get() = getTuneThreshold() set(value) = setTuneThreshold(value) @@ -169,7 +169,7 @@ public object GC { * Legacy MM: If cyclic collector for atomic references to be deployed. */ @Deprecated("No-op in modern GC implementation") - var cyclicCollectorEnabled: Boolean + public var cyclicCollectorEnabled: Boolean get() = getCyclicCollectorEnabled() set(value) = setCyclicCollectorEnabled(value) @@ -184,7 +184,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is negative. */ - var regularGCInterval: Duration + public var regularGCInterval: Duration get() = getRegularGCIntervalMicroseconds().microseconds set(value) { require(!value.isNegative()) { "regularGCInterval must not be negative: $value" } @@ -207,7 +207,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is negative. */ - var targetHeapBytes: Long + public var targetHeapBytes: Long get() = getTargetHeapBytes() set(value) { require(value >= 0) { "targetHeapBytes must not be negative: $value" } @@ -224,7 +224,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is outside (0, 1] interval. */ - var targetHeapUtilization: Double + public var targetHeapUtilization: Double get() = getTargetHeapUtilization() set(value) { require(value > 0 && value <= 1) { "targetHeapUtilization must be in (0, 1] interval: $value" } @@ -241,7 +241,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is negative. */ - var minHeapBytes: Long + public var minHeapBytes: Long get() = getMinHeapBytes() set(value) { require(value >= 0) { "minHeapBytes must not be negative: $value" } @@ -258,7 +258,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is negative. */ - var maxHeapBytes: Long + public var maxHeapBytes: Long get() = getMaxHeapBytes() set(value) { require(value >= 0) { "maxHeapBytes must not be negative: $value" } @@ -272,7 +272,7 @@ public object GC { * * @throws [IllegalArgumentException] when value is outside (0, 1] interval. */ - var heapTriggerCoefficient: Double + public var heapTriggerCoefficient: Double get() = getHeapTriggerCoefficient() set(value) { require(value > 0 && value <= 1) { "heapTriggerCoefficient must be in (0, 1] interval: $value" } @@ -285,7 +285,7 @@ public object GC { * * Default: true, unless [autotune] is false or [maxHeapBytes] is less than [Long.MAX_VALUE]. */ - var pauseOnTargetHeapOverflow: Boolean + public var pauseOnTargetHeapOverflow: Boolean get() = getPauseOnTargetHeapOverflow() set(value) = setPauseOnTargetHeapOverflow(value) @@ -298,7 +298,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_detectCycles") @Deprecated("No-op in modern GC implementation") - external fun detectCycles(): Array? + public external fun detectCycles(): Array? /** * Returns statistics of the last finished garbage collection run. @@ -309,7 +309,7 @@ public object GC { * Legacy MM: Always returns null */ @ExperimentalStdlibApi - val lastGCInfo: GCInfo? + public val lastGCInfo: GCInfo? get() = GCInfo.lastGCInfo /** @@ -319,7 +319,7 @@ public object GC { */ @GCUnsafeCall("Kotlin_native_internal_GC_findCycle") @Deprecated("No-op in modern GC implementation") - external fun findCycle(root: Any): Array? + public external fun findCycle(root: Any): Array? @GCUnsafeCall("Kotlin_native_internal_GC_getThreshold") private external fun getThreshold(): Int diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GCInfo.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GCInfo.kt index 5cbb371c945..1f0a85c1cf9 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GCInfo.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GCInfo.kt @@ -24,7 +24,7 @@ import kotlin.system.* @NativeRuntimeApi @SinceKotlin("1.9") public class MemoryUsage( - val totalObjectsSizeBytes: Long, + public val totalObjectsSizeBytes: Long, ) /** @@ -36,8 +36,8 @@ public class MemoryUsage( @NativeRuntimeApi @SinceKotlin("1.9") public class SweepStatistics( - val sweptCount: Long, - val keptCount: Long, + public val sweptCount: Long, + public val keptCount: Long, ) /** @@ -57,10 +57,10 @@ public class SweepStatistics( @NativeRuntimeApi @SinceKotlin("1.9") public class RootSetStatistics( - val threadLocalReferences: Long, - val stackReferences: Long, - val globalReferences: Long, - val stableReferences: Long + public val threadLocalReferences: Long, + public val stackReferences: Long, + public val globalReferences: Long, + public val stableReferences: Long ) /** @@ -96,21 +96,21 @@ public class RootSetStatistics( @NativeRuntimeApi @SinceKotlin("1.9") public class GCInfo( - val epoch: Long, - val startTimeNs: Long, - val endTimeNs: Long, - val firstPauseRequestTimeNs: Long, - val firstPauseStartTimeNs: Long, - val firstPauseEndTimeNs: Long, - val secondPauseRequestTimeNs: Long?, - val secondPauseStartTimeNs: Long?, - val secondPauseEndTimeNs: Long?, - val postGcCleanupTimeNs: Long?, - val rootSet: RootSetStatistics, - val markedCount: Long, - val sweepStatistics: Map, - val memoryUsageBefore: Map, - val memoryUsageAfter: Map, + public val epoch: Long, + public val startTimeNs: Long, + public val endTimeNs: Long, + public val firstPauseRequestTimeNs: Long, + public val firstPauseStartTimeNs: Long, + public val firstPauseEndTimeNs: Long, + public val secondPauseRequestTimeNs: Long?, + public val secondPauseStartTimeNs: Long?, + public val secondPauseEndTimeNs: Long?, + public val postGcCleanupTimeNs: Long?, + public val rootSet: RootSetStatistics, + public val markedCount: Long, + public val sweepStatistics: Map, + public val memoryUsageBefore: Map, + public val memoryUsageAfter: Map, ) { internal companion object { val lastGCInfo: GCInfo? diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt index d9897132388..a7b4110d3ad 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt @@ -20,11 +20,11 @@ public typealias Vector128 = kotlinx.cinterop.Vector128 @DeprecatedSinceKotlin(warningSince = "1.9") @ExperimentalForeignApi @GCUnsafeCall("Kotlin_Interop_Vector4f_of") -external fun vectorOf(f0: Float, f1: Float, f2: Float, f3: Float): Vector128 +public external fun vectorOf(f0: Float, f1: Float, f2: Float, f3: Float): Vector128 @Suppress("DEPRECATION") @Deprecated("Use kotlinx.cinterop.vectorOf instead.", ReplaceWith("kotlinx.cinterop.vectorOf(f0, f1, f2, f3)")) @DeprecatedSinceKotlin(warningSince = "1.9") @ExperimentalForeignApi @GCUnsafeCall("Kotlin_Interop_Vector4i32_of") -external fun vectorOf(f0: Int, f1: Int, f2: Int, f3: Int): Vector128 +public external fun vectorOf(f0: Int, f1: Int, f2: Int, f3: Int): Vector128 diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharacterCodingException.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharacterCodingException.kt index b17aa0164ca..78fa0d79335 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharacterCodingException.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharacterCodingException.kt @@ -10,5 +10,5 @@ package kotlin.text */ @SinceKotlin("1.3") public actual open class CharacterCodingException(message: String?) : Exception(message) { - actual constructor() : this(null) + public actual constructor() : this(null) }