Skip to content

Commit 773d468

Browse files
committed
rename JsType inheritors, add close method to JavaScriptEngine
1 parent b9a770d commit 773d468

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

javascript/src/commonMain/kotlin/dev/icerock/moko/javascript/JavaScriptEngine.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,15 @@
55
package dev.icerock.moko.javascript
66

77
expect class JavaScriptEngine() {
8+
/**
9+
* Evaluate some [script] with external [context].
10+
*
11+
* @throws JavaScriptEvaluationException in case of an error in the engine evaluation
12+
*/
813
fun evaluate(context: Map<String, JsType>, script: String): JsType
14+
15+
/**
16+
* Closes the engine and releases the allocated memory.
17+
*/
18+
fun close()
919
}

javascript/src/commonMain/kotlin/dev/icerock/moko/javascript/JsType.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
package dev.icerock.moko.javascript
66

7+
import kotlinx.serialization.json.JsonElement
8+
79
sealed class JsType {
8-
data class Boolean(val value: Boolean): JsType
9-
data class String(val value: String): JsType
10-
data class Int(val value: Int): JsType
11-
data class Double(val value: Double): JsType
12-
data class Json(val value: JsonElement): JsType
10+
data class Bool(val value: Boolean): JsType()
11+
data class Str(val value: String): JsType()
12+
data class IntNum(val value: Int): JsType()
13+
data class DoubleNum(val value: Double): JsType()
14+
data class Json(val value: JsonElement): JsType()
15+
16+
/**
17+
* For "undefined" and "null".
18+
*/
19+
object Null : JsType()
1320
}

0 commit comments

Comments
 (0)