| 17 | |
| 18 | |
| 19 | Value toValue(lua_State* L, int idx, int depth, Allocator& allocator) { |
| 20 | int t = lua_type(L, idx); |
| 21 | switch (t) { |
| 22 | case LUA_TBOOLEAN: |
| 23 | return Value(lua_toboolean(L, idx) != 0); |
| 24 | case LUA_TNUMBER: |
| 25 | return NumberValue(L, idx); |
| 26 | case LUA_TSTRING: |
| 27 | return StringValue(L, idx, allocator); |
| 28 | case LUA_TTABLE: |
| 29 | return TableValue(L, idx, depth + 1, allocator); |
| 30 | case LUA_TNIL: |
| 31 | return Value(); |
| 32 | case LUA_TLIGHTUSERDATA: |
| 33 | if (isnull(L, idx)) |
| 34 | return Value(); |
| 35 | // otherwise fall thought |
| 36 | case LUA_TFUNCTION: // fall thought |
| 37 | case LUA_TUSERDATA: // fall thought |
| 38 | case LUA_TTHREAD: // fall thought |
| 39 | case LUA_TNONE: // fall thought |
| 40 | default: |
| 41 | luaL_error(L, "value type %s is not a valid json value", lua_typename(L, t)); |
| 42 | return Value(); // Just make compiler happy |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | Value NumberValue(lua_State* L, int idx) { |
| 47 | int64_t integer; |
no test coverage detected