[Wasm] Rename JsHandle to JsReference
Decision to do this was made at Kotlin/Wasm interop design meeting
This commit is contained in:
committed by
teamcity
parent
7ba8f7cce2
commit
933f47aaf9
@@ -16,8 +16,8 @@ public external interface Dynamic : JsAny
|
||||
/**
|
||||
* Reinterprets this value as a value of the Dynamic type.
|
||||
*/
|
||||
@Deprecated("If value is a subtype of JsAny, use JsAny instead. Otherwise, use toJsHandle", level = DeprecationLevel.ERROR)
|
||||
fun Any.asDynamic(): JsAny = this.toJsHandle()
|
||||
@Deprecated("If value is a subtype of JsAny, use JsAny instead. Otherwise, use toJsReference", level = DeprecationLevel.ERROR)
|
||||
fun Any.asDynamic(): JsAny = this.toJsReference()
|
||||
|
||||
/**
|
||||
* Reinterprets this value as a value of the Dynamic type.
|
||||
|
||||
+6
-6
@@ -10,20 +10,20 @@ import kotlin.wasm.internal.implementedAsIntrinsic
|
||||
import kotlin.wasm.internal.returnArgumentIfItIsKotlinAny
|
||||
|
||||
/**
|
||||
* JavaScript value that can serve as a handle for any Kotlin value.
|
||||
* JavaScript value that can serve as a reference for any Kotlin value.
|
||||
*
|
||||
* In JavaScript, it behaves like an immutable empty object with a null prototype.
|
||||
* When passed back to Kotlin/Wasm, the original value can be retrieved using the [get] method.
|
||||
*/
|
||||
@Suppress("WRONG_JS_INTEROP_TYPE") // Exception to the rule
|
||||
public sealed external interface JsHandle<out T : Any> : JsAny
|
||||
public sealed external interface JsReference<out T : Any> : JsAny
|
||||
|
||||
@WasmOp(WasmOp.EXTERN_EXTERNALIZE)
|
||||
public fun <T : Any> T.toJsHandle(): JsHandle<T> =
|
||||
public fun <T : Any> T.toJsReference(): JsReference<T> =
|
||||
implementedAsIntrinsic
|
||||
|
||||
/** Retrieve original Kotlin value from JsHandle */
|
||||
public fun <T : Any> JsHandle<T>.get(): T {
|
||||
/** Retrieve original Kotlin value from JsReference */
|
||||
public fun <T : Any> JsReference<T>.get(): T {
|
||||
returnArgumentIfItIsKotlinAny(this)
|
||||
throw ClassCastException("JsHandle doesn't contain a Kotlin type")
|
||||
throw ClassCastException("JsReference doesn't contain a Kotlin type")
|
||||
}
|
||||
Reference in New Issue
Block a user