File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import platform.posix.memcpy
66import platform.posix.size_t
77
88actual fun runBlocking (block : suspend () -> Unit ) = kotlinx.coroutines.runBlocking{block()}
9-
9+ @OptIn(kotlinx.cinterop. ExperimentalForeignApi :: class )
1010internal 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
2323internal 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 )
2526fun ByteArray.toNative (): NSData = memScoped {
2627 NSData .create(bytes = allocArrayOf(this @toNative), length = castToNativeSize(this @toNative.size))
2728}
2829
30+ @OptIn(kotlinx.cinterop.ExperimentalForeignApi ::class )
2931fun 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 )
3740internal 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 ) {
You can’t perform that action at this time.
0 commit comments