** set functions from list 'l' into table at top - 'nup'; each ** function gets the 'nup' elements at the top as upvalues. ** Returns with only the table at the stack. */
| 846 | ** Returns with only the table at the stack. |
| 847 | */ |
| 848 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
| 849 | luaL_checkversion(L); |
| 850 | luaL_checkstack(L, nup, "too many upvalues"); |
| 851 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 852 | int i; |
| 853 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 854 | lua_pushvalue(L, -nup); |
| 855 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 856 | lua_setfield(L, -(nup + 2), l->name); |
| 857 | } |
| 858 | lua_pop(L, nup); /* remove upvalues */ |
| 859 | } |
| 860 | |
| 861 | |
| 862 | /* |
no test coverage detected