| 89 | } |
| 90 | |
| 91 | static int json_decode(lua_State* L) |
| 92 | { |
| 93 | size_t len = 0; |
| 94 | const char* contents = nullptr; |
| 95 | switch(lua_type(L, 1)) { |
| 96 | case LUA_TSTRING: |
| 97 | contents = luaL_checklstring(L, 1, &len); |
| 98 | break; |
| 99 | case LUA_TLIGHTUSERDATA: |
| 100 | contents = reinterpret_cast<const char*>(lua_touserdata(L, 1)); |
| 101 | len = luaL_checkinteger(L, 2); |
| 102 | break; |
| 103 | default: |
| 104 | return luaL_argerror(L, 1, "required string or lightuserdata (points to a memory of a string)"); |
| 105 | } |
| 106 | |
| 107 | rapidjson::extend::StringStream s(contents, len); |
| 108 | return values::pushDecoded(L, s); |
| 109 | } |
| 110 | |
| 111 | |
| 112 |
nothing calls this directly
no test coverage detected