From ba0fb22db0d663871562c96c78789ff69e593a7b Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 19 Jul 2024 20:45:30 +0530 Subject: [PATCH] feat: complete lua.h bindings ref system --- internal/lua.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/lua.go b/internal/lua.go index 5f3e127..2263818 100644 --- a/internal/lua.go +++ b/internal/lua.go @@ -660,5 +660,24 @@ func GetAllocF(L *LuaState, ud *unsafe.Pointer) LuaAlloc { return *(*LuaAlloc)(unsafe.Pointer(C.lua_getallocf(L, ud))) } +// +// ========================== +// Reference System +// ========================== +// + +const ( + LUA_NOREF = iota - 1 + LUA_REFNIL +) + +func Ref(L *LuaState, idx int32) int32 { + return int32(C.lua_ref(L, C.int(idx))) +} + +func Unref(L *LuaState, ref int32) { + C.lua_unref(L, C.int(ref)) +} + // TODO: Free udtor's after func // TODO: Rest of it