** 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. */
| 940 | ** Returns with only the table at the stack. |
| 941 | */ |
| 942 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
| 943 | luaL_checkstack(L, nup, "too many upvalues"); |
| 944 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 945 | if (l->func == NULL) /* placeholder? */ |
| 946 | lua_pushboolean(L, 0); |
| 947 | else { |
| 948 | int i; |
| 949 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 950 | lua_pushvalue(L, -nup); |
| 951 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 952 | } |
| 953 | lua_setfield(L, -(nup + 2), l->name); |
| 954 | } |
| 955 | lua_pop(L, nup); /* remove upvalues */ |
| 956 | } |
| 957 | |
| 958 | |
| 959 | /* |
no test coverage detected