Compatibility for Lua 5.1 and older LuaJIT. * * compat_luaL_setfuncs() is used to create a module table where the functions * have json_config_t as their first upvalue. Code borrowed from Lua 5.2 * source's luaL_setfuncs(). */
| 1686 | * source's luaL_setfuncs(). |
| 1687 | */ |
| 1688 | static void compat_luaL_setfuncs(lua_State *l, const luaL_Reg *reg, int nup) |
| 1689 | { |
| 1690 | int i; |
| 1691 | |
| 1692 | luaL_checkstack(l, nup, "too many upvalues"); |
| 1693 | for (; reg->name != NULL; reg++) { /* fill the table with given functions */ |
| 1694 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 1695 | lua_pushvalue(l, -nup); |
| 1696 | lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */ |
| 1697 | lua_setfield(l, -(nup + 2), reg->name); |
| 1698 | } |
| 1699 | lua_pop(l, nup); /* remove upvalues */ |
| 1700 | } |
| 1701 | #else |
| 1702 | #define compat_luaL_setfuncs(L, reg, nup) luaL_setfuncs(L, reg, nup) |
| 1703 | #endif |
no test coverage detected