jsMain.internal.ConstructFromKClass.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lf-kotlin-js Show documentation
Show all versions of lf-kotlin-js Show documentation
Kotlin integration for Lightweightform
package pt.lightweightform.lfkotlin.internal
import kotlin.reflect.KClass
/** JavaScript's `Object` object. */
private external val Object: dynamic
/** Creates a Kotlin class instance given a [KClass] and the constructor arguments. */
internal fun constructFromKClass(kClass: KClass, vararg arguments: Any?): T {
// XXX: Work around not having access to `kClass.constructors` or to the `new` keyword
val obj = Object.create(kClass.js.asDynamic().prototype)
obj.constructor.apply(obj, arguments)
return obj as T
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy