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

Function lua_setmetatable

src/Chain/libraries/glua/lapi.cpp:848–885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846
847
848LUA_API int lua_setmetatable(lua_State *L, int objindex) {
849 TValue *obj;
850 Table *mt;
851 lua_lock(L);
852 api_checknelems(L, 1);
853 obj = index2addr(L, objindex);
854 if (ttisnil(L->top - 1))
855 mt = nullptr;
856 else {
857 api_check(L, ttistable(L->top - 1), "table expected");
858 mt = hvalue(L->top - 1);
859 }
860 switch (ttnov(obj)) {
861 case LUA_TTABLE: {
862 hvalue(obj)->metatable = mt;
863 if (mt) {
864 luaC_objbarrier(L, gcvalue(obj), mt);
865 luaC_checkfinalizer(L, gcvalue(obj), mt);
866 }
867 break;
868 }
869 case LUA_TUSERDATA: {
870 uvalue(obj)->metatable = mt;
871 if (mt) {
872 luaC_objbarrier(L, uvalue(obj), mt);
873 luaC_checkfinalizer(L, gcvalue(obj), mt);
874 }
875 break;
876 }
877 default: {
878 G(L)->mt[ttnov(obj)] = mt;
879 break;
880 }
881 }
882 L->top--;
883 lua_unlock(L);
884 return 1;
885}
886
887
888LUA_API void lua_setuservalue(lua_State *L, int idx) {

Callers 11

ll_seeallFunction · 0.85
createclibstableFunction · 0.85
createmetatableFunction · 0.85
lua_push_storage_valueFunction · 0.85
luaL_setmetatableFunction · 0.85
newboxFunction · 0.85
db_setmetatableFunction · 0.85
db_sethookFunction · 0.85
luaB_setmetatableFunction · 0.85
glua_core_lib_StreamFunction · 0.85

Calls 2

index2addrFunction · 0.85
luaC_checkfinalizerFunction · 0.85

Tested by

no test coverage detected