MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaL_ref

Function luaL_ref

Source/Misc/lua/src/lua.c:10693–10713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10691
10692
10693LUALIB_API int luaL_ref (lua_State *L, int t) {
10694int ref;
10695t = abs_index(L, t);
10696if (lua_isnil(L, -1)) {
10697lua_pop(L, 1); /* remove from stack */
10698return LUA_REFNIL; /* `nil' has a unique fixed reference */
10699}
10700lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
10701ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
10702lua_pop(L, 1); /* remove it from stack */
10703if (ref != 0) { /* any free element? */
10704lua_rawgeti(L, t, ref); /* remove it from list */
10705lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
10706}
10707else { /* no free elements */
10708ref = (int)lua_objlen(L, t);
10709ref++; /* create new reference */
10710}
10711lua_rawseti(L, t, ref);
10712return ref;
10713}
10714
10715
10716LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers 5

class_registryMethod · 0.85
implMethod · 0.85
handleMethod · 0.85
popMethod · 0.85

Calls 4

lua_rawgetiFunction · 0.85
lua_tointegerFunction · 0.85
lua_rawsetiFunction · 0.85
lua_objlenFunction · 0.85

Tested by

no test coverage detected