2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 16:52:03 +00:00
Hilbish/moonlight/function_golua.go
sammy-ette 9e77f0ba32
refactor: change go function types
this is the only way i could think of to be able
to push go functions to lua on the clua side.

this may or may not need adjustments on golua side
though...
2025-06-14 10:06:20 -04:00

36 lines
906 B
Go

//go:build !midnight
package moonlight
import (
rt "github.com/arnodel/golua/runtime"
)
type GoFunctionFunc = rt.GoFunctionFunc
func (mlr *Runtime) CheckNArgs(num int) error {
return mlr.rt.MainThread().CurrentCont().(*rt.GoCont).CheckNArgs(num)
}
func (mlr *Runtime) Check1Arg() error {
return mlr.rt.MainThread().CurrentCont().(*rt.GoCont).Check1Arg()
}
func (mlr *Runtime) StringArg(num int) (string, error) {
return mlr.rt.MainThread().CurrentCont().(*rt.GoCont).StringArg(num)
}
func (mlr *Runtime) ClosureArg(num int) (*Closure, error) {
return mlr.rt.MainThread().CurrentCont().(*rt.GoCont).ClosureArg(num)
}
func (mlr *Runtime) Arg(c *GoCont, num int) Value {
return mlr.rt.MainThread().CurrentCont().(*rt.GoCont).Arg(num)
}
func (mlr *Runtime) GoFunction(fun GoToLuaFunc) GoFunctionFunc {
return func(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.Next(), fun(mlr)
}
}