godot.core.ParametersReader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of godot-library-release Show documentation
Show all versions of godot-library-release Show documentation
Contains godot api as kotlin classes and jvm cpp interaction code.
package godot.core
import godot.core.memory.TransferContext
import godot.tools.common.constants.Constraints
import godot.util.threadLocal
internal open class ParametersReader {
val paramsArray by threadLocal {
Array(Constraints.MAX_FUNCTION_ARG_COUNT) {
null
}
}
private fun resetParamsArray() {
paramsArray.fill(null)
}
internal inline fun withParameters(types: Array, code: () -> Unit) {
TransferContext.readArguments(types, paramsArray)
code()
resetParamsArray()
}
internal inline fun withParametersReturn(
types: Array,
code: () -> R
): Any? {
TransferContext.readArguments(types, paramsArray)
val ret = code()
resetParamsArray()
return ret
}
}