KotlinScript

class KotlinScript(nullGlobalContext: Boolean = false) : AbstractScript, Closeable

A script engine wrapper for dynamically evaluating Kotlin source code using the kts extension.

Manages variable bindings via the JSR 223 Bindings mechanism, generates Kotlin val declarations that cast bound values to their appropriate types, and prepends import statements to evaluated code.

Parameters

nullGlobalContext

if true, sets the global scope bindings to null on initialization

See also

Constructors

Link copied to clipboard
constructor(nullGlobalContext: Boolean = false)

Properties

Link copied to clipboard
Link copied to clipboard

Generates Kotlin import statements for all registered import classes.

Link copied to clipboard

Generates Kotlin val declarations that retrieve bound variables from the engine's bindings and cast them to their appropriate types with type parameters.

Functions

Link copied to clipboard
open fun add(name: String, value: Any, vararg types: KType)
Link copied to clipboard
open override fun close()
Link copied to clipboard
Link copied to clipboard
open fun params(name: String, types: Array<out KType>): String
Link copied to clipboard
fun resetContext(nullGlobalContext: Boolean)