** 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. */
| 900 | ** Returns with only the table at the stack. |
| 901 | */ |
| 902 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
| 903 | luaL_checkstack(L, nup, "too many upvalues"); |
| 904 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 905 | if (l->func == NULL) /* place holder? */ |
| 906 | lua_pushboolean(L, 0); |
| 907 | else { |
| 908 | int i; |
| 909 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 910 | lua_pushvalue(L, -nup); |
| 911 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 912 | } |
| 913 | lua_setfield(L, -(nup + 2), l->name); |
| 914 | } |
| 915 | lua_pop(L, nup); /* remove upvalues */ |
| 916 | } |
| 917 | |
| 918 | |
| 919 | /* |
no test coverage detected