Lines 1292-1317
static int json_decode(lua_State *l)
Link Here
|
1292 |
|
1292 |
|
1293 |
/* ===== INITIALISATION ===== */ |
1293 |
/* ===== INITIALISATION ===== */ |
1294 |
|
1294 |
|
1295 |
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 |
|
|
1296 |
/* Compatibility for Lua 5.1. |
1297 |
* |
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. |
1295 |
/* Call target function in protected mode with all supplied args. |
1316 |
* Assumes target function only returns a single non-nil value. |
1296 |
* Assumes target function only returns a single non-nil value. |
1317 |
* Convert and return thrown errors as: nil, "error message" */ |
1297 |
* Convert and return thrown errors as: nil, "error message" */ |