1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
9529292821 add PushLuaFunction to functions 2025-08-01 20:52:52 -05:00
d2b65ffde4 add luafunction pointer to pushvalue 2025-08-01 20:47:22 -05:00
2 changed files with 11 additions and 0 deletions

View File

@ -302,3 +302,8 @@ func (s *State) GetAllLuaFunctions(names ...string) (map[string]*LuaFunction, er
}
return funcs, nil
}
// PushLuaFunction pushes a stored LuaFunction reference onto the stack
func (s *State) PushLuaFunction(lf *LuaFunction) {
C.lua_rawgeti(s.L, C.LUA_REGISTRYINDEX, C.int(lf.ref))
}

View File

@ -207,6 +207,12 @@ func (s *State) PushValue(v any) error {
s.PushString(val)
case GoFunction:
return s.PushGoFunction(val)
case *LuaFunction:
C.lua_rawgeti(s.L, C.LUA_REGISTRYINDEX, C.int(val.ref))
if val.ref == C.LUA_NOREF || val.ref == C.LUA_REFNIL {
s.Pop(1)
s.PushNil()
}
case []int:
return s.pushIntSlice(val)
case []string: