Return cjson.safe module table */
| 1418 | |
| 1419 | /* Return cjson.safe module table */ |
| 1420 | static int lua_cjson_safe_new(lua_State *l) |
| 1421 | { |
| 1422 | const char *func[] = { "decode", "encode", NULL }; |
| 1423 | int i; |
| 1424 | |
| 1425 | lua_cjson_new(l); |
| 1426 | |
| 1427 | /* Fix new() method */ |
| 1428 | lua_pushcfunction(l, lua_cjson_safe_new); |
| 1429 | lua_setfield(l, -2, "new"); |
| 1430 | |
| 1431 | for (i = 0; func[i]; i++) { |
| 1432 | lua_getfield(l, -1, func[i]); |
| 1433 | lua_pushcclosure(l, json_protect_conversion, 1); |
| 1434 | lua_setfield(l, -2, func[i]); |
| 1435 | } |
| 1436 | |
| 1437 | return 1; |
| 1438 | } |
| 1439 | |
| 1440 | int luaopen_cjson(lua_State *l) |
| 1441 | { |
no test coverage detected