W3cubDocs

/Kotlin

StableRef

Platform and version requirements: Native (1.3)
inline class StableRef<out T : Any>

This class provides a way to create a stable handle to any Kotlin object. After converting to CPointer it can be safely passed to native code e.g. to be received in a Kotlin callback.

Any StableRef should be manually disposed

Properties

Platform and version requirements: Native (1.3)

value

val value: COpaquePointer

Functions

Platform and version requirements: Native (1.3)

asCPointer

Converts the handle to C pointer.

fun asCPointer(): COpaquePointer
Platform and version requirements: Native (1.3)

dispose

Disposes the handle. It must not be used after that.

fun dispose()
Platform and version requirements: Native (1.3)

get

Returns the object this handle was created for.

fun get(): T

Companion Object Functions

Platform and version requirements: Native (1.3)

create

Creates a handle for given object.

fun <T : Any> create(any: T): StableRef<T>
Platform and version requirements: Native (1.3)

fromValue

Creates StableRef from given raw value.

fun fromValue(value: COpaquePointer): StableRef<Any>

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlinx.cinterop/-stable-ref/index.html