Skip to content

Commit e9840c5

Browse files
committed
optin to experimentalforeignapi
1 parent 47d62fd commit e9840c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/iosMain/kotlin/util/UtilFunctions.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import platform.posix.memcpy
66
import platform.posix.size_t
77

88
actual fun runBlocking(block: suspend () -> Unit) = kotlinx.coroutines.runBlocking{block()}
9-
9+
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
1010
internal fun isPlatformBigEndian(): Boolean {
1111
memScoped {
1212
val i = alloc<IntVar>()
@@ -22,10 +22,12 @@ internal fun reverseOrd(varr: UInt): UInt = ((reverseOrd((varr and 0xffffu).toUS
2222

2323
internal fun reverseOrd(varr: ULong): ULong = ((reverseOrd((varr and 0xffffffffu).toUInt()).toLong() shl 32) or (reverseOrd((varr shr 32).toUInt()).toLong() and 0xffffffff)).toULong()
2424

25+
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2526
fun ByteArray.toNative(): NSData = memScoped {
2627
NSData.create(bytes = allocArrayOf(this@toNative), length = castToNativeSize(this@toNative.size))
2728
}
2829

30+
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2931
fun KUtil.byteArrayFromNative(arr: NSData): ByteArray = ByteArray(arr.length.toInt()).apply {
3032
if (this.isNotEmpty()) {
3133
usePinned {
@@ -34,6 +36,7 @@ fun KUtil.byteArrayFromNative(arr: NSData): ByteArray = ByteArray(arr.length.toI
3436
}
3537
}
3638

39+
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
3740
internal fun castToNativeSize(v: Int): size_t {
3841
@Suppress("CAST_NEVER_SUCCEEDS", "USELESS_CAST") // Depending on the platform different side of if will trigger, lets ignore
3942
return if (size_t.SIZE_BITS == 32) {

0 commit comments

Comments
 (0)