MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / lua_setmetatable

Function lua_setmetatable

ThirdParty/lua/lua/lapi.c:817–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

815
816
817LUA_API int lua_setmetatable (lua_State *L, int objindex) {
818 TValue *obj;
819 Table *mt;
820 lua_lock(L);
821 api_checknelems(L, 1);
822 obj = index2addr(L, objindex);
823 if (ttisnil(L->top - 1))
824 mt = NULL;
825 else {
826 api_check(ttistable(L->top - 1), "table expected");
827 mt = hvalue(L->top - 1);
828 }
829 switch (ttnov(obj)) {
830 case LUA_TTABLE: {
831 hvalue(obj)->metatable = mt;
832 if (mt) {
833 luaC_objbarrier(L, gcvalue(obj), mt);
834 luaC_checkfinalizer(L, gcvalue(obj), mt);
835 }
836 break;
837 }
838 case LUA_TUSERDATA: {
839 uvalue(obj)->metatable = mt;
840 if (mt) {
841 luaC_objbarrier(L, uvalue(obj), mt);
842 luaC_checkfinalizer(L, gcvalue(obj), mt);
843 }
844 break;
845 }
846 default: {
847 G(L)->mt[ttnov(obj)] = mt;
848 break;
849 }
850 }
851 L->top--;
852 lua_unlock(L);
853 return 1;
854}
855
856
857LUA_API void lua_setuservalue (lua_State *L, int idx) {

Callers 8

SetMetaTableFunction · 0.85
luaB_setmetatableFunction · 0.85
createmetatableFunction · 0.85
luaL_setmetatableFunction · 0.85
ll_seeallFunction · 0.85
createclibstableFunction · 0.85
db_setmetatableFunction · 0.85
db_sethookFunction · 0.85

Calls 3

index2addrFunction · 0.85
luaC_checkfinalizerFunction · 0.85
GFunction · 0.50

Tested by

no test coverage detected