Return cjson.safe module table */
| 1382 | |
| 1383 | /* Return cjson.safe module table */ |
| 1384 | static int lua_cjson_safe_new(lua_State *l) |
| 1385 | { |
| 1386 | const char *func[] = { "decode", "encode", NULL }; |
| 1387 | int i; |
| 1388 | |
| 1389 | lua_cjson_new(l); |
| 1390 | |
| 1391 | /* Fix new() method */ |
| 1392 | lua_pushcfunction(l, lua_cjson_safe_new); |
| 1393 | lua_setfield(l, -2, "new"); |
| 1394 | |
| 1395 | for (i = 0; func[i]; i++) { |
| 1396 | lua_getfield(l, -1, func[i]); |
| 1397 | lua_pushcclosure(l, json_protect_conversion, 1); |
| 1398 | lua_setfield(l, -2, func[i]); |
| 1399 | } |
| 1400 | |
| 1401 | return 1; |
| 1402 | } |
| 1403 | |
| 1404 | int luaopen_cjson(lua_State *l) |
| 1405 | { |
no test coverage detected