diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Boxing.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Boxing.kt index 86f07eee711..1c8e8a56f93 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Boxing.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/Boxing.kt @@ -6,124 +6,124 @@ package kotlin.native.internal @GCUnsafeCall("getCachedBooleanBox") -external fun getCachedBooleanBox(value: Boolean): Boolean? +@PublishedApi internal external fun getCachedBooleanBox(value: Boolean): Boolean? @GCUnsafeCall("inBooleanBoxCache") -external fun inBooleanBoxCache(value: Boolean): Boolean +@PublishedApi internal external fun inBooleanBoxCache(value: Boolean): Boolean @GCUnsafeCall("getCachedByteBox") -external fun getCachedByteBox(value: Byte): Byte? +@PublishedApi internal external fun getCachedByteBox(value: Byte): Byte? @GCUnsafeCall("inByteBoxCache") -external fun inByteBoxCache(value: Byte): Boolean +@PublishedApi internal external fun inByteBoxCache(value: Byte): Boolean @GCUnsafeCall("getCachedCharBox") -external fun getCachedCharBox(value: Char): Char? +@PublishedApi internal external fun getCachedCharBox(value: Char): Char? @GCUnsafeCall("inCharBoxCache") -external fun inCharBoxCache(value: Char): Boolean +@PublishedApi internal external fun inCharBoxCache(value: Char): Boolean @GCUnsafeCall("getCachedShortBox") -external fun getCachedShortBox(value: Short): Short? +@PublishedApi internal external fun getCachedShortBox(value: Short): Short? @GCUnsafeCall("inShortBoxCache") -external fun inShortBoxCache(value: Short): Boolean +@PublishedApi internal external fun inShortBoxCache(value: Short): Boolean @GCUnsafeCall("getCachedIntBox") -external fun getCachedIntBox(idx: Int): Int? +@PublishedApi internal external fun getCachedIntBox(idx: Int): Int? @GCUnsafeCall("inIntBoxCache") -external fun inIntBoxCache(value: Int): Boolean +@PublishedApi internal external fun inIntBoxCache(value: Int): Boolean @GCUnsafeCall("getCachedLongBox") -external fun getCachedLongBox(value: Long): Long? +@PublishedApi internal external fun getCachedLongBox(value: Long): Long? @GCUnsafeCall("inLongBoxCache") -external fun inLongBoxCache(value: Long): Boolean +@PublishedApi internal external fun inLongBoxCache(value: Long): Boolean // TODO: functions below are used for ObjCExport and CAdapterGenerator, move and rename them correspondingly. @ExportForCppRuntime("Kotlin_boxBoolean") -fun boxBoolean(value: Boolean): Boolean? = value +@PublishedApi internal fun boxBoolean(value: Boolean): Boolean? = value @ExportForCppRuntime("Kotlin_boxChar") -fun boxChar(value: Char): Char? = value +@PublishedApi internal fun boxChar(value: Char): Char? = value @ExportForCppRuntime("Kotlin_boxByte") -fun boxByte(value: Byte): Byte? = value +@PublishedApi internal fun boxByte(value: Byte): Byte? = value @ExportForCppRuntime("Kotlin_boxShort") -fun boxShort(value: Short): Short? = value +@PublishedApi internal fun boxShort(value: Short): Short? = value @ExportForCppRuntime("Kotlin_boxInt") -fun boxInt(value: Int): Int? = value +@PublishedApi internal fun boxInt(value: Int): Int? = value @ExportForCppRuntime("Kotlin_boxLong") -fun boxLong(value: Long): Long? = value +@PublishedApi internal fun boxLong(value: Long): Long? = value @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_boxUByte") -fun boxUByte(value: UByte): UByte? = value +@PublishedApi internal fun boxUByte(value: UByte): UByte? = value -@ExperimentalUnsignedTypes +@ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_boxUShort") -fun boxUShort(value: UShort): UShort? = value +@PublishedApi internal fun boxUShort(value: UShort): UShort? = value @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_boxUInt") -fun boxUInt(value: UInt): UInt? = value +@PublishedApi internal fun boxUInt(value: UInt): UInt? = value @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_boxULong") -fun boxULong(value: ULong): ULong? = value +@PublishedApi internal fun boxULong(value: ULong): ULong? = value @ExportForCppRuntime("Kotlin_boxFloat") -fun boxFloat(value: Float): Float? = value +@PublishedApi internal fun boxFloat(value: Float): Float? = value @ExportForCppRuntime("Kotlin_boxDouble") -fun boxDouble(value: Double): Double? = value +@PublishedApi internal fun boxDouble(value: Double): Double? = value @ExportForCppRuntime("Kotlin_boxUnit") -internal fun Kotlin_boxUnit(): Unit? = Unit +@PublishedApi internal fun Kotlin_boxUnit(): Unit? = Unit // Unbox fuctions @ExportForCppRuntime("Kotlin_unboxBoolean") -fun unboxBoolean(value: Boolean?): Boolean = value!! +@PublishedApi internal fun unboxBoolean(value: Boolean?): Boolean = value!! @ExportForCppRuntime("Kotlin_unboxChar") -fun unboxChar(value: Char?): Char = value!! +@PublishedApi internal fun unboxChar(value: Char?): Char = value!! @ExportForCppRuntime("Kotlin_unboxByte") -fun unboxByte(value: Byte?): Byte = value!! +@PublishedApi internal fun unboxByte(value: Byte?): Byte = value!! @ExportForCppRuntime("Kotlin_unboxShort") -fun unboxShort(value: Short?): Short = value!! +@PublishedApi internal fun unboxShort(value: Short?): Short = value!! @ExportForCppRuntime("Kotlin_unboxInt") -fun unboxInt(value: Int?): Int = value!! +@PublishedApi internal fun unboxInt(value: Int?): Int = value!! @ExportForCppRuntime("Kotlin_unboxLong") -fun unboxLong(value: Long?): Long = value!! +@PublishedApi internal fun unboxLong(value: Long?): Long = value!! @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_unboxUByte") -fun unboxUByte(value: UByte?): UByte = value!! +@PublishedApi internal fun unboxUByte(value: UByte?): UByte = value!! @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_unboxUShort") -fun unboxUShort(value: UShort?): UShort = value!! +@PublishedApi internal fun unboxUShort(value: UShort?): UShort = value!! @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_unboxUInt") -fun unboxUInt(value: UInt?): UInt = value!! +@PublishedApi internal fun unboxUInt(value: UInt?): UInt = value!! @ExperimentalUnsignedTypes @ExportForCppRuntime("Kotlin_unboxULong") -fun unboxULong(value: ULong?): ULong = value!! +@PublishedApi internal fun unboxULong(value: ULong?): ULong = value!! @ExportForCppRuntime("Kotlin_unboxFloat") -fun unboxFloat(value: Float?): Float = value!! +@PublishedApi internal fun unboxFloat(value: Float?): Float = value!! @ExportForCppRuntime("Kotlin_unboxDouble") -fun unboxDouble(value: Double?): Double = value!! +@PublishedApi internal fun unboxDouble(value: Double?): Double = value!! diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/InteropBoxing.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/InteropBoxing.kt deleted file mode 100644 index ef1e414a466..00000000000 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/InteropBoxing.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -package kotlin.native.internal - -import kotlinx.cinterop.* - -@Frozen -@OptIn(FreezingIsDeprecated::class) -class NativePtrBox(val value: NativePtr) { - override fun equals(other: Any?): Boolean { - if (other !is NativePtrBox) { - return false - } - - return this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() -} - -fun boxNativePtr(value: NativePtr) = NativePtrBox(value) - -@Frozen -@OptIn(FreezingIsDeprecated::class) -class NativePointedBox(val value: NativePointed) { - override fun equals(other: Any?): Boolean { - if (other !is NativePointedBox) { - return false - } - - return this.value == other.value - } - - // TODO: can't delegate the following methods to `this.value` - // because `NativePointed` doesn't provide them. - - override fun hashCode() = this.value.rawPtr.hashCode() - - override fun toString() = "NativePointed(raw=${this.value.rawPtr})" -} - -fun boxNativePointed(value: NativePointed?) = if (value != null) NativePointedBox(value) else null -fun unboxNativePointed(box: NativePointedBox?) = box?.value - -@Frozen -@OptIn(FreezingIsDeprecated::class) -class CPointerBox(val value: CPointer) : CValuesRef() { - override fun equals(other: Any?): Boolean { - if (other !is CPointerBox) { - return false - } - - return this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - override fun getPointer(scope: AutofreeScope) = value.getPointer(scope) -} - -fun boxCPointer(value: CPointer?) = if (value != null) CPointerBox(value) else null -fun unboxCPointer(box: CPointerBox?) = box?.value \ No newline at end of file