** 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. */
| 924 | ** Returns with only the table at the stack. |
| 925 | */ |
| 926 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
| 927 | luaL_checkstack(L, nup, "too many upvalues"); |
| 928 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 929 | if (l->func == NULL) /* place holder? */ |
| 930 | lua_pushboolean(L, 0); |
| 931 | else { |
| 932 | int i; |
| 933 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 934 | lua_pushvalue(L, -nup); |
| 935 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 936 | } |
| 937 | lua_setfield(L, -(nup + 2), l->name); |
| 938 | } |
| 939 | lua_pop(L, nup); /* remove upvalues */ |
| 940 | } |
| 941 | |
| 942 | |
| 943 | /* |
no test coverage detected