2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-14 14:52:02 +00:00
Hilbish/util/export.go
sammyette 4524c1451a
feat: add moonlight lua abstraction library
future plans: add the ability to use c lua
(or luajit) with hilbish

benefits? speed, i guess?
2024-07-19 16:54:15 -04:00

22 lines
503 B
Go

package util
import (
"hilbish/moonlight"
rt "github.com/arnodel/golua/runtime"
)
// LuaExport represents a Go function which can be exported to Lua.
type LuaExport struct {
Function moonlight.GoFunctionFunc
ArgNum int
Variadic bool
}
// SetExports puts the Lua function exports in the table.
func SetExports(rtm *rt.Runtime, tbl *rt.Table, exports map[string]LuaExport) {
for name, export := range exports {
rtm.SetEnvGoFunc(tbl, name, export.Function, export.ArgNum, export.Variadic)
}
}