MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaL_ref

Function luaL_ref

extlibs/lua/src/lauxlib.c:644–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642
643
644LUALIB_API int luaL_ref (lua_State *L, int t) {
645 int ref;
646 if (lua_isnil(L, -1)) {
647 lua_pop(L, 1); /* remove from stack */
648 return LUA_REFNIL; /* 'nil' has a unique fixed reference */
649 }
650 t = lua_absindex(L, t);
651 lua_rawgeti(L, t, freelist); /* get first free element */
652 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
653 lua_pop(L, 1); /* remove it from stack */
654 if (ref != 0) { /* any free element? */
655 lua_rawgeti(L, t, ref); /* remove it from list */
656 lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
657 }
658 else /* no free elements */
659 ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
660 lua_rawseti(L, t, ref);
661 return ref;
662}
663
664
665LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers 8

luaL_newstateFunction · 0.85
copyMethod · 0.85
stateless_referenceMethod · 0.85
copy_assignMethod · 0.85
move_assignMethod · 0.85
basic_referenceMethod · 0.85
set_refFunction · 0.85
handle_policyFunction · 0.85

Calls 3

lua_rawgetiFunction · 0.85
lua_rawsetiFunction · 0.85
lua_absindexFunction · 0.70

Tested by

no test coverage detected