MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / lua_setmetatable

Function lua_setmetatable

lua/lapi.c:704–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702
703
704LUA_API int lua_setmetatable (lua_State *L, int objindex) {
705 TValue *obj;
706 Table *mt;
707 lua_lock(L);
708 api_checknelems(L, 1);
709 obj = index2adr(L, objindex);
710 api_checkvalidindex(L, obj);
711 if (ttisnil(L->top - 1))
712 mt = NULL;
713 else {
714 api_check(L, ttistable(L->top - 1));
715 mt = hvalue(L->top - 1);
716 }
717 switch (ttype(obj)) {
718 case LUA_TTABLE: {
719 hvalue(obj)->metatable = mt;
720 if (mt)
721 luaC_objbarriert(L, hvalue(obj), mt);
722 break;
723 }
724 case LUA_TUSERDATA: {
725 uvalue(obj)->metatable = mt;
726 if (mt)
727 luaC_objbarrier(L, rawuvalue(obj), mt);
728 break;
729 }
730 default: {
731 G(L)->mt[ttype(obj)] = mt;
732 break;
733 }
734 }
735 L->top--;
736 lua_unlock(L);
737 return 1;
738}
739
740
741LUA_API int lua_setfenv (lua_State *L, int idx) {

Callers 15

luaB_setmetatableFunction · 0.85
luaB_newproxyFunction · 0.85
base_openFunction · 0.85
createmetatableFunction · 0.85
getsizesFunction · 0.85
enable_global_variablesFunction · 0.85
disable_global_variablesFunction · 0.85
set_sqlrow_stmtFunction · 0.85
copy_comdb2_typeFunction · 0.85
init_db_funcsFunction · 0.85
push_trigger_args_intFunction · 0.85
ll_registerFunction · 0.85

Calls 1

index2adrFunction · 0.85

Tested by

no test coverage detected