Compatibility for Lua 5.1. * * 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. */
| 1298 | * luaL_setfuncs() is used to create a module table where the functions have |
| 1299 | * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */ |
| 1300 | static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup) |
| 1301 | { |
| 1302 | int i; |
| 1303 | |
| 1304 | luaL_checkstack(l, nup, "too many upvalues"); |
| 1305 | for (; reg->name != NULL; reg++) { /* fill the table with given functions */ |
| 1306 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 1307 | lua_pushvalue(l, -nup); |
| 1308 | lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */ |
| 1309 | lua_setfield(l, -(nup + 2), reg->name); |
| 1310 | } |
| 1311 | lua_pop(l, nup); /* remove upvalues */ |
| 1312 | } |
| 1313 | #endif |
| 1314 | |
| 1315 | /* Call target function in protected mode with all supplied args. |
no test coverage detected