Files
kotlin-fork/kotlin-native/backend.native/tests/interop/cpp/skia.kt
T
Vsevolod Tolstopyatov f4e8ae5191 Explicitly declare stability levels of declarations in kotlinx.cinterop package
* @ExperimentalForeignApi for all declarations that operate on
    unmanaged memory (i.e. pointers and references)
* @BetaInteropApi for the rest of the interoperability declarations,
    namely Swift/CInterop-specific interfaces and convenience-functions

### Implementation details

* Some typealiases are not marked explicitly because it crashes the compiler,
    yet their experimentality is properly propagated
* License header is adjusted where it previously had been existing
* Deprecated with ERROR interop declarations that are deprecated for more than
    two years are removed
* WASM target interop declarations are deprecated
* Deliberately make Boolean.toByte and Byte.toBoolean foreign-experimental to scare
    people away

^KT-57728 fixed

Merge-request: KT-MR-9788
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-05-04 13:52:21 +00:00

34 lines
971 B
Kotlin

@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
@file:Suppress("OPT_IN_USAGE_ERROR")
import kotlinx.cinterop.*
import kotlin.test.*
import kotlin.native.internal.*
import org.jetbrains.skiko.skia.native.*
import platform.posix.printf
fun main() {
// TODO: the test used to work with forceCheckedShutdown,
// but it is broken now. Revisit after it is fixed.
// kotlin.native.runtime.Debugging.forceCheckedShutdown = true
Platform.isCleanersLeakCheckerActive = true
val f = Foo()
val a = Data()
a.setData(17)
val b = f.qux()!!
b.setData(19)
val v = f.foo(a)
val c = f.bar(v)!!
// Use printf instead of println to avoid messages
// appearing out of order with the native code.
// The native code uses printf.
printf("MANAGED: f: ${f.managed}, a: ${a.managed}, b: ${b.managed}, v: ${v.managed}, c: ${c.managed}\n")
printf("DATA: ${a.cpp.data} ${b.cpp.data} ${v.cpp.data} ${c.cpp.data}\n")
}