MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / lua_setmetatable

Function lua_setmetatable

deps/lua/src/lapi.c:697–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695
696
697LUA_API int lua_setmetatable (lua_State *L, int objindex) {
698 TValue *obj;
699 Table *mt;
700 lua_lock(L);
701 api_checknelems(L, 1);
702 obj = index2adr(L, objindex);
703 api_checkvalidindex(L, obj);
704 if (ttisnil(L->top - 1))
705 mt = NULL;
706 else {
707 api_check(L, ttistable(L->top - 1));
708 mt = hvalue(L->top - 1);
709 }
710 switch (ttype(obj)) {
711 case LUA_TTABLE: {
712 hvalue(obj)->metatable = mt;
713 if (mt)
714 luaC_objbarriert(L, hvalue(obj), mt);
715 break;
716 }
717 case LUA_TUSERDATA: {
718 uvalue(obj)->metatable = mt;
719 if (mt)
720 luaC_objbarrier(L, rawuvalue(obj), mt);
721 break;
722 }
723 default: {
724 G(L)->mt[ttype(obj)] = mt;
725 break;
726 }
727 }
728 L->top--;
729 lua_unlock(L);
730 return 1;
731}
732
733
734LUA_API int lua_setfenv (lua_State *L, int idx) {

Callers 10

luaB_setmetatableFunction · 0.85
luaB_newproxyFunction · 0.85
base_openFunction · 0.85
createmetatableFunction · 0.85
getsizesFunction · 0.85
json_create_configFunction · 0.85
ll_registerFunction · 0.85
ll_seeallFunction · 0.85
newfileFunction · 0.85
db_setmetatableFunction · 0.85

Calls 1

index2adrFunction · 0.85

Tested by

no test coverage detected