---@diagnostic disable local LUA_REFNIL = -1 -- lib_aux.c local FREELIST_REF = 0 local function __ref(value) if rawequal(value, nil) then return LUA_REFNIL end local ref = __registry[FREELIST_REF] if ref ~= nil and ref ~= 0 then __registry[FREELIST_REF] = __registry[ref] else ref = rawlen(__registry) + 1 end __registry[ref] = value return ref end local function __unref(ref) if ref > 0 then __registry[ref] = __registry[FREELIST_REF] __registry[FREELIST_REF] = ref end end