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. */
| 1334 | * luaL_setfuncs() is used to create a module table where the functions have |
| 1335 | * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */ |
| 1336 | static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup) |
| 1337 | { |
| 1338 | int i; |
| 1339 | |
| 1340 | luaL_checkstack(l, nup, "too many upvalues"); |
| 1341 | for (; reg->name != NULL; reg++) { /* fill the table with given functions */ |
| 1342 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
| 1343 | lua_pushvalue(l, -nup); |
| 1344 | lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */ |
| 1345 | lua_setfield(l, -(nup + 2), reg->name); |
| 1346 | } |
| 1347 | lua_pop(l, nup); /* remove upvalues */ |
| 1348 | } |
| 1349 | #endif |
| 1350 | |
| 1351 | /* Call target function in protected mode with all supplied args. |
no test coverage detected