| 47 | */ |
| 48 | |
| 49 | static int JsonToLuaInternal(lua_State* L, int options_index, const char* json, size_t json_len, int protected_mode) |
| 50 | { |
| 51 | int top = lua_gettop(L); |
| 52 | char buffer[256] = {0}; |
| 53 | int ret = lua_cjson_decode(L, json, json_len, options_index, protected_mode, buffer, sizeof(buffer)); |
| 54 | if (ret != 1) |
| 55 | { |
| 56 | lua_pop(L, lua_gettop(L) - top); |
| 57 | } |
| 58 | |
| 59 | if (protected_mode) |
| 60 | { |
| 61 | assert(top + 1 == lua_gettop(L)); |
| 62 | } |
| 63 | else if(!protected_mode && (ret == 0)) // let's restore the stack if we couldn't create |
| 64 | { |
| 65 | int num_to_pop = lua_gettop(L) - top; |
| 66 | lua_pop(L, num_to_pop); |
| 67 | |
| 68 | dmLogError("%s", buffer); |
| 69 | } |
| 70 | return ret; |
| 71 | } |
| 72 | |
| 73 | int JsonToLua(lua_State* L, const char* json, size_t json_len) |
| 74 | { |
no test coverage detected