[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
@@ -98,7 +98,7 @@ external fun is123Array(x: EI): Boolean
|
||||
external fun create123Array(): EI
|
||||
|
||||
data class DC(val x: Int, val y: Int)
|
||||
typealias JSDC = JsHandle<DC>
|
||||
typealias JSDC = JsReference<DC>
|
||||
|
||||
external fun extenalWithLambda(
|
||||
x: (Boolean, Byte, Short, Char, Int, Long, Float, Double, String, EI, JSDC) -> Unit,
|
||||
@@ -179,7 +179,7 @@ fun box(): String {
|
||||
test(string == "S")
|
||||
test(is123Array(ei))
|
||||
test(dc.x == 100 && dc.y == 200)
|
||||
}, DC(100, 200).toJsHandle())
|
||||
}, DC(100, 200).toJsReference())
|
||||
|
||||
|
||||
if (extenalWithLambdasCount != 11) return "Fail 1"
|
||||
@@ -195,7 +195,7 @@ fun box(): String {
|
||||
double = { 600.5 },
|
||||
string = { "700" },
|
||||
ei = { create123Array() },
|
||||
dc = { DC(800, 800).toJsHandle() },
|
||||
dc = { DC(800, 800).toJsReference() },
|
||||
dcGetY = { it.get().y }
|
||||
)
|
||||
if (externalWithLambdas2Count != 11) return "Fail externalWithLambdas2"
|
||||
@@ -212,7 +212,7 @@ fun box(): String {
|
||||
{ 600.5 },
|
||||
{ "700" },
|
||||
{ create123Array() },
|
||||
{ DC(800, 800).toJsHandle() },
|
||||
{ DC(800, 800).toJsReference() },
|
||||
{ it.get().y }
|
||||
)
|
||||
if (externalWithLambdas2RefCount != 11) return "Fail externalWithLambdas2"
|
||||
@@ -230,7 +230,7 @@ fun box(): String {
|
||||
600.5,
|
||||
"700",
|
||||
create123Array(),
|
||||
DC(800, 800).toJsHandle(),
|
||||
DC(800, 800).toJsReference(),
|
||||
{ it.get().y }
|
||||
)
|
||||
if (jsLambdaCount != 11)
|
||||
|
||||
+4
-4
@@ -5,10 +5,10 @@
|
||||
class C(val x: Int)
|
||||
|
||||
@JsExport
|
||||
fun makeC(x: Int): JsHandle<C> = C(x).toJsHandle()
|
||||
fun makeC(x: Int): JsReference<C> = C(x).toJsReference()
|
||||
|
||||
@JsExport
|
||||
fun getX(c: JsHandle<C>): Int = c.get().x
|
||||
fun getX(c: JsReference<C>): Int = c.get().x
|
||||
|
||||
@JsExport
|
||||
fun getString(s: String): String = "Test string $s";
|
||||
@@ -19,10 +19,10 @@ fun isEven(x: Int): Boolean = x % 2 == 0
|
||||
external interface EI
|
||||
|
||||
@JsExport
|
||||
fun eiAsAny(ei: EI): JsHandle<Any> = ei.toJsHandle()
|
||||
fun eiAsAny(ei: EI): JsReference<Any> = ei.toJsReference()
|
||||
|
||||
@JsExport
|
||||
fun anyAsEI(any: JsHandle<Any>): EI = any.get() as EI
|
||||
fun anyAsEI(any: JsReference<Any>): EI = any.get() as EI
|
||||
|
||||
fun box(): String = "OK"
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ fun testExterRef() {
|
||||
}
|
||||
|
||||
class DataRefImpl
|
||||
typealias DataRef = JsHandle<DataRefImpl>
|
||||
typealias DataRef = JsReference<DataRefImpl>
|
||||
|
||||
fun notNullDataRef(x: DataRef): DataRef = js("x")
|
||||
|
||||
@@ -55,7 +55,7 @@ fun nullDataRef(x: DataRef): DataRef? = js("x")
|
||||
fun null2DataRef(x: DataRef): DataRef? = js("null")
|
||||
|
||||
fun testDataRef() {
|
||||
val dataRef = DataRefImpl().toJsHandle()
|
||||
val dataRef = DataRefImpl().toJsReference()
|
||||
check(notNullDataRef(dataRef) == dataRef)
|
||||
checkNPE { notNull2DataRef(dataRef) }
|
||||
check (nullDataRef(dataRef) == dataRef)
|
||||
|
||||
+6
-6
@@ -49,13 +49,13 @@ fun box(): String {
|
||||
assertTrue(jsArray[1] == "element1".toJsString())
|
||||
assertTrue(jsRepresentation(jsArray) == "object:element0,element1,element2")
|
||||
|
||||
// JsHandle
|
||||
val jsHandle: JsHandle<Int> = 10.toJsHandle()
|
||||
assertTrue(jsHandle.get() == 10)
|
||||
assertTrue(jsHandle.toJsHandle().get() == jsHandle)
|
||||
// JsReference
|
||||
val jsReference: JsReference<Int> = 10.toJsReference()
|
||||
assertTrue(jsReference.get() == 10)
|
||||
assertTrue(jsReference.toJsReference().get() == jsReference)
|
||||
val c = listOf(1)
|
||||
assertTrue(c.toJsHandle().get() === c.toJsHandle().get())
|
||||
assertTrue(c.toJsHandle() === c.toJsHandle())
|
||||
assertTrue(c.toJsReference().get() === c.toJsReference().get())
|
||||
assertTrue(c.toJsReference() === c.toJsReference())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user