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

Function lua_setmetatable

other_src/lua/src/lapi.cpp:729–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727
728
729LUA_API int lua_setmetatable (lua_State *L, int objindex) {
730 TValue *obj;
731 Table *mt;
732 lua_lock(L);
733 api_checknelems(L, 1);
734 obj = index2adr(L, objindex);
735 api_checkvalidindex(L, obj);
736 if (ttisnil(L->top - 1))
737 mt = NULL;
738 else {
739 api_check(L, ttistable(L->top - 1));
740 mt = hvalue(L->top - 1);
741 }
742 switch (ttype(obj)) {
743 case LUA_TTABLE: {
744 hvalue(obj)->metatable = mt;
745 if (mt)
746 luaC_objbarriert(L, hvalue(obj), mt);
747 break;
748 }
749 case LUA_TUSERDATA: {
750 uvalue(obj)->metatable = mt;
751 if (mt)
752 luaC_objbarrier(L, rawuvalue(obj), mt);
753 break;
754 }
755 default: {
756 G(L)->mt[ttype(obj)] = mt;
757 break;
758 }
759 }
760 L->top--;
761 lua_unlock(L);
762 return 1;
763}
764
765
766LUA_API int lua_setfenv (lua_State *L, int idx) {

Callers 15

ll_registerFunction · 0.70
ll_seeallFunction · 0.70
newpattFunction · 0.70
createmetatableFunction · 0.70
newfileFunction · 0.70
getsizesFunction · 0.70
db_setmetatableFunction · 0.70
luaB_setmetatableFunction · 0.70
luaB_newproxyFunction · 0.70
base_openFunction · 0.70
CreateMeshMethod · 0.50
PushDoubleMethod · 0.50

Calls 1

index2adrFunction · 0.70

Tested by

no test coverage detected