feat(scripting/interfaces): new thread function
This commit is contained in:
@@ -6,6 +6,7 @@ import me.rhunk.snapenhance.common.scripting.ktx.contextScope
|
||||
import me.rhunk.snapenhance.common.scripting.ktx.putFunction
|
||||
import me.rhunk.snapenhance.common.scripting.ktx.scriptableObject
|
||||
import java.lang.reflect.Proxy
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class JavaInterfaces : AbstractBinding("java-interfaces", BindingSide.COMMON) {
|
||||
override fun getObject() = scriptableObject {
|
||||
@@ -41,5 +42,20 @@ class JavaInterfaces : AbstractBinding("java-interfaces", BindingSide.COMMON) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
putFunction("thread") { arguments ->
|
||||
val function = arguments?.get(0) as? org.mozilla.javascript.Function ?: return@putFunction null
|
||||
|
||||
thread(start = false) {
|
||||
contextScope {
|
||||
function.call(
|
||||
this,
|
||||
this@scriptableObject,
|
||||
this@scriptableObject,
|
||||
emptyArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user