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

Function luaL_ref

other_src/lua/src/lauxlib.cpp:506–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504
505
506LUALIB_API int luaL_ref (lua_State *L, int t) {
507 int ref;
508 t = abs_index(L, t);
509 if (lua_isnil(L, -1)) {
510 lua_pop(L, 1); /* remove from stack */
511 return LUA_REFNIL; /* `nil' has a unique fixed reference */
512 }
513 lua_rawgeti(L, t, FREELIST_REF); /* get first free element */
514 ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */
515 lua_pop(L, 1); /* remove it from stack */
516 if (ref != 0) { /* any free element? */
517 lua_rawgeti(L, t, ref); /* remove it from list */
518 lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */
519 }
520 else { /* no free elements */
521 ref = (int)lua_objlen(L, t);
522 ref++; /* create new reference */
523 }
524 lua_rawseti(L, t, ref);
525 return ref;
526}
527
528
529LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers 15

SlashCmdHandlerMethod · 0.50
LinkMethod · 0.50
CreateLuaStateFunction · 0.50
MapHandlerMethod · 0.50
LuaTableMethod · 0.50
LuaTable.cppFile · 0.50
setupLuaEnvMethod · 0.50
CreateFBOMethod · 0.50
SetupEnvironmentMethod · 0.50
LuaHTTPMethod · 0.50
CreateScreamMethod · 0.50
SetSceneNodeFuncMethod · 0.50

Calls 4

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

Tested by

no test coverage detected