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

com.skillw.pouvoir.internal.feature.handler.Native.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.internal.feature.handler

import com.skillw.asahi.api.script.linking.Invoker
import com.skillw.asahi.api.script.linking.NativeFunction
import com.skillw.pouvoir.internal.core.asahi.linking.js.NativeJSFunction

/**
 * @className Native
 *
 * @author Glom
 * @date 2023/1/22 22:00 Copyright 2024 Glom.
 */
fun Any.toInvoker(key: String, namespaces: Collection): Invoker? {
    return when (this) {
        is Map<*, *> -> {
            val func = this as Map
            when (func["type"].toString()) {
                "js" -> NativeJSFunction.deserialize(key, func)
                else -> NativeFunction.deserialize(key, func, *namespaces.toTypedArray())
            }
        }

        is String -> {
            NativeFunction.deserialize(key, this, *namespaces.toTypedArray())
        }

        else -> null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy