45 lines
893 B
Go
45 lines
893 B
Go
package functions
|
|
|
|
import (
|
|
"maps"
|
|
"sync"
|
|
|
|
"Moonshark/functions/http"
|
|
|
|
luajit "git.sharkk.net/Sky/LuaJIT-to-Go"
|
|
)
|
|
|
|
// Registry holds all available Go functions for Lua modules
|
|
type Registry map[string]luajit.GoFunction
|
|
|
|
// GetAll returns all registered functions
|
|
func GetAll() Registry {
|
|
registry := make(Registry)
|
|
|
|
maps.Copy(registry, GetJSONFunctions())
|
|
maps.Copy(registry, GetStringFunctions())
|
|
maps.Copy(registry, GetMathFunctions())
|
|
maps.Copy(registry, GetFSFunctions())
|
|
maps.Copy(registry, GetCryptoFunctions())
|
|
maps.Copy(registry, http.GetHTTPFunctions())
|
|
|
|
return registry
|
|
}
|
|
|
|
var (
|
|
storedBytecode []byte
|
|
bytecodeMutex sync.RWMutex
|
|
)
|
|
|
|
func SetStoredBytecode(bytecode []byte) {
|
|
bytecodeMutex.Lock()
|
|
defer bytecodeMutex.Unlock()
|
|
storedBytecode = bytecode
|
|
}
|
|
|
|
func GetStoredBytecode() []byte {
|
|
bytecodeMutex.RLock()
|
|
defer bytecodeMutex.RUnlock()
|
|
return storedBytecode
|
|
}
|