MCPcopy Create free account
hub / github.com/Tencent/xLua / lua_setmetatable

Function lua_setmetatable

WebGLPlugins/lapi.c:845–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

luaB_setmetatableFunction · 0.85
createmetatableFunction · 0.85
xlua_pushcsobjFunction · 0.85
xlua_pushstructFunction · 0.85
xlua_pushcstableFunction · 0.85
xlua_newstructFunction · 0.85
css_cloneFunction · 0.85
luaL_setmetatableFunction · 0.85
newboxFunction · 0.85
ll_seeallFunction · 0.85
createclibstableFunction · 0.85
lua_pushint64Function · 0.85

Calls 2

index2addrFunction · 0.85
luaC_checkfinalizerFunction · 0.85

Tested by

no test coverage detected