Moonshark/functions/registry.go
2025-07-16 20:54:15 -05:00

42 lines
818 B
Go

package functions
import (
"maps"
"sync"
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())
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
}