All Downloads are FREE. Search and download functionalities are using the official Maven repository.

godot.core.ParametersReader.kt Maven / Gradle / Ivy

There is a newer version: 0.10.0-4.3.0
Show newest version
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
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy