MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / lua_getmetatable

Function lua_getmetatable

3rd/lua-5.4.3/src/lapi.c:769–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767
768
769LUA_API int lua_getmetatable (lua_State *L, int objindex) {
770 const TValue *obj;
771 Table *mt;
772 int res = 0;
773 lua_lock(L);
774 obj = index2value(L, objindex);
775 switch (ttype(obj)) {
776 case LUA_TTABLE:
777 mt = hvalue(obj)->metatable;
778 break;
779 case LUA_TUSERDATA:
780 mt = uvalue(obj)->metatable;
781 break;
782 default:
783 mt = G(L)->mt[ttype(obj)];
784 break;
785 }
786 if (mt != NULL) {
787 sethvalue2s(L, L->top, mt);
788 api_incr_top(L);
789 res = 1;
790 }
791 lua_unlock(L);
792 return res;
793}
794
795
796LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) {

Callers 5

luaB_getmetatableFunction · 0.85
luaL_testudataFunction · 0.85
luaL_getmetafieldFunction · 0.85
checktabFunction · 0.85
db_getmetatableFunction · 0.85

Calls 1

index2valueFunction · 0.85

Tested by

no test coverage detected