2022-03-28 02:14:53 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
rt "github.com/arnodel/golua/runtime"
|
|
|
|
)
|
|
|
|
|
2022-03-30 01:02:15 +00:00
|
|
|
// LuaExport represents a Go function which can be exported to Lua.
|
2022-03-28 02:14:53 +00:00
|
|
|
type LuaExport struct {
|
|
|
|
Function rt.GoFunctionFunc
|
|
|
|
ArgNum int
|
|
|
|
Variadic bool
|
|
|
|
}
|
|
|
|
|
2022-03-30 01:02:15 +00:00
|
|
|
// SetExports puts the Lua function exports in the table.
|
2022-03-28 02:14:53 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|