MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lua_getmetatable

Function lua_getmetatable

freebsd/contrib/openzfs/module/lua/lapi.c:683–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681
682
683LUA_API int lua_getmetatable (lua_State *L, int objindex) {
684 const TValue *obj;
685 Table *mt = NULL;
686 int res;
687 lua_lock(L);
688 obj = index2addr(L, objindex);
689 switch (ttypenv(obj)) {
690 case LUA_TTABLE:
691 mt = hvalue(obj)->metatable;
692 break;
693 case LUA_TUSERDATA:
694 mt = uvalue(obj)->metatable;
695 break;
696 default:
697 mt = G(L)->mt[ttypenv(obj)];
698 break;
699 }
700 if (mt == NULL)
701 res = 0;
702 else {
703 sethvalue(L, L->top, mt);
704 api_incr_top(L);
705 res = 1;
706 }
707 lua_unlock(L);
708 return res;
709}
710
711
712LUA_API void lua_getuservalue (lua_State *L, int idx) {

Callers 3

luaB_getmetatableFunction · 0.70
luaL_testudataFunction · 0.70
luaL_getmetafieldFunction · 0.70

Calls 1

index2addrFunction · 0.85

Tested by

no test coverage detected