Skip to content

Commit

Permalink
feat(scripting/interfaces): new thread function
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunk committed Aug 21, 2024
1 parent 4bd7328 commit 7d06d1c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
)
}
}
}
}
}

0 comments on commit 7d06d1c

Please sign in to comment.