** 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. */
| 2934 | ** Returns with only the table at the stack. |
| 2935 | */ |
| 2936 | LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { |
| 2937 | luaL_checkstack(L, nup, "too many upvalues"); |
| 2938 | for (; l->name != nullptr; l++) { /* fill the table with given functions */ |
| 2939 | int i; |
| 2940 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 2941 | lua_pushvalue(L, -nup); |
| 2942 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 2943 | lua_setfield(L, -(nup + 2), l->name); |
| 2944 | } |
| 2945 | lua_pop(L, nup); /* remove upvalues */ |
| 2946 | } |
| 2947 | |
| 2948 | |
| 2949 | /* |
no test coverage detected