MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / lua_setfenv

Function lua_setfenv

other_src/lua/src/lapi.cpp:766–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764
765
766LUA_API int lua_setfenv (lua_State *L, int idx) {
767 StkId o;
768 int res = 1;
769 lua_lock(L);
770 api_checknelems(L, 1);
771 o = index2adr(L, idx);
772 api_checkvalidindex(L, o);
773 api_check(L, ttistable(L->top - 1));
774 switch (ttype(o)) {
775 case LUA_TFUNCTION:
776 clvalue(o)->c.env = hvalue(L->top - 1);
777 break;
778 case LUA_TUSERDATA:
779 uvalue(o)->env = hvalue(L->top - 1);
780 break;
781 case LUA_TTHREAD:
782 sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
783 break;
784 default:
785 res = 0;
786 break;
787 }
788 if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
789 L->top--;
790 lua_unlock(L);
791 return res;
792}
793
794
795/*

Callers 9

setfenvFunction · 0.70
jointableFunction · 0.70
value2fenvFunction · 0.70
capconst_lFunction · 0.70
createstdfileFunction · 0.70
luaopen_ioFunction · 0.70
db_setfenvFunction · 0.70
luaB_setfenvFunction · 0.70
IncludeMethod · 0.50

Calls 1

index2adrFunction · 0.70

Tested by

no test coverage detected