| 1 | #include "compat.h" |
| 2 | |
| 3 | #if LUA_VERSION_NUM==501 |
| 4 | /* |
| 5 | ** Adapted from Lua 5.2 |
| 6 | */ |
| 7 | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
| 8 | luaL_checkstack(L, nup+1, "too many upvalues" ); |
| 9 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 10 | int i; |
| 11 | lua_pushstring(L, l->name); |
| 12 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 13 | lua_pushvalue(L, -(nup+1)); |
| 14 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ |
| 15 | lua_settable(L, -(nup + 3)); |
| 16 | } |
| 17 | lua_pop(L, nup); /* remove upvalues */ |
| 18 | } |
| 19 | #endif |
| 20 | |