MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaL_ref

Function luaL_ref

src/Chain/libraries/glua/lauxlib.cpp:598–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596
597
598LUALIB_API int luaL_ref(lua_State *L, int t) {
599 int ref;
600 if (lua_isnil(L, -1)) {
601 lua_pop(L, 1); /* remove from stack */
602 return LUA_REFNIL; /* 'nil' has a unique fixed reference */
603 }
604 t = lua_absindex(L, t);
605 lua_rawgeti(L, t, freelist); /* get first free element */
606 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
607 lua_pop(L, 1); /* remove it from stack */
608 if (ref != 0) { /* any free element? */
609 lua_rawgeti(L, t, ref); /* remove it from list */
610 lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
611 }
612 else /* no free elements */
613 ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
614 lua_rawseti(L, t, ref);
615 return ref;
616}
617
618
619LUALIB_API void luaL_unref(lua_State *L, int t, int ref) {

Callers

nothing calls this directly

Calls 4

lua_absindexFunction · 0.85
lua_rawgetiFunction · 0.85
lua_rawsetiFunction · 0.85
lua_rawlenFunction · 0.85

Tested by

no test coverage detected