Hilbish/moonlight/function_golua.go

34 lines
720 B
Go
Raw Normal View History

package moonlight
import (
rt "github.com/arnodel/golua/runtime"
)
type GoFunctionFunc = rt.GoFunctionFunc
func (mlr *Runtime) CheckNArgs(c *GoCont, num int) error {
2024-07-20 15:34:39 +00:00
return c.cont.CheckNArgs(num)
}
func (mlr *Runtime) Check1Arg(c *GoCont) error {
return c.cont.CheckNArgs(1)
}
func (mlr *Runtime) StringArg(c *GoCont, num int) (string, error) {
2024-07-20 15:34:39 +00:00
return c.cont.StringArg(num)
}
func (mlr *Runtime) GoFunction(fun GoToLuaFunc) rt.GoFunctionFunc {
return func(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
2024-07-20 15:34:39 +00:00
gocont := GoCont{
cont: c,
thread: t,
}
return fun(mlr, &gocont)
}
}
func (mlr *Runtime) Call1(val Value, args ...Value) (Value, error) {
return rt.Call1(mlr.rt.MainThread(), val, args...)
}