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

Function lua_setfenv

lua/lapi.c:741–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739
740
741LUA_API int lua_setfenv (lua_State *L, int idx) {
742 StkId o;
743 int res = 1;
744 lua_lock(L);
745 api_checknelems(L, 1);
746 o = index2adr(L, idx);
747 api_checkvalidindex(L, o);
748 api_check(L, ttistable(L->top - 1));
749 switch (ttype(o)) {
750 case LUA_TFUNCTION:
751 clvalue(o)->c.env = hvalue(L->top - 1);
752 break;
753 case LUA_TUSERDATA:
754 uvalue(o)->env = hvalue(L->top - 1);
755 break;
756 case LUA_TTHREAD:
757 sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
758 break;
759 default:
760 res = 0;
761 break;
762 }
763 if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
764 L->top--;
765 lua_unlock(L);
766 return res;
767}
768
769
770/*

Callers 5

luaB_setfenvFunction · 0.85
setfenvFunction · 0.85
createstdfileFunction · 0.85
luaopen_ioFunction · 0.85
db_setfenvFunction · 0.85

Calls 1

index2adrFunction · 0.85

Tested by

no test coverage detected