MCPcopy Create free account
hub / github.com/axmolengine/axmol / lua_setmetatable

Function lua_setmetatable

3rdparty/lua/plainlua/lapi.c:933–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931
932
933LUA_API int lua_setmetatable (lua_State *L, int objindex) {
934 TValue *obj;
935 Table *mt;
936 lua_lock(L);
937 api_checknelems(L, 1);
938 obj = index2value(L, objindex);
939 if (ttisnil(s2v(L->top.p - 1)))
940 mt = NULL;
941 else {
942 api_check(L, ttistable(s2v(L->top.p - 1)), "table expected");
943 mt = hvalue(s2v(L->top.p - 1));
944 }
945 switch (ttype(obj)) {
946 case LUA_TTABLE: {
947 hvalue(obj)->metatable = mt;
948 if (mt) {
949 luaC_objbarrier(L, gcvalue(obj), mt);
950 luaC_checkfinalizer(L, gcvalue(obj), mt);
951 }
952 break;
953 }
954 case LUA_TUSERDATA: {
955 uvalue(obj)->metatable = mt;
956 if (mt) {
957 luaC_objbarrier(L, uvalue(obj), mt);
958 luaC_checkfinalizer(L, gcvalue(obj), mt);
959 }
960 break;
961 }
962 default: {
963 G(L)->mt[ttype(obj)] = mt;
964 break;
965 }
966 }
967 L->top.p--;
968 lua_unlock(L);
969 return 1;
970}
971
972
973LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) {

Callers 15

luaL_setmetatableFunction · 0.85
operator()Method · 0.85
push_deepMethod · 0.85
push_withMethod · 0.85
setMethod · 0.85
operator()Method · 0.85
json_create_configFunction · 0.85
set_uboxFunction · 0.85
mapinheritanceFunction · 0.85
tolua_openFunction · 0.85
tolua_moduleFunction · 0.85

Calls 2

index2valueFunction · 0.85
luaC_checkfinalizerFunction · 0.85

Tested by

no test coverage detected