MCPcopy Create free account
hub / github.com/defold/defold / lua_setmetatable

Function lua_setmetatable

engine/lua/src/lua/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 15

NewScriptFunction · 0.85
NewScriptInstanceFunction · 0.85
PushURLFunction · 0.85
InitializeFunction · 0.85
CreateLuaHashUserdataFunction · 0.85
PushVectorFunction · 0.85
PushVector3Function · 0.85
PushVector4Function · 0.85
PushQuatFunction · 0.85
PushMatrix4Function · 0.85
NewUserTypeFunction · 0.85
TEST_FFunction · 0.85

Calls 2

index2adrFunction · 0.85
GFunction · 0.50

Tested by 7

NewUserTypeFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
CreateAndPushInstanceFunction · 0.68
SetUpMethod · 0.68
CreateScriptInstanceFunction · 0.68
SetUpMethod · 0.68