dynamic::Value simplified

This commit is contained in:
MihailRis
2024-05-07 18:39:12 +03:00
parent 8e83a07094
commit a4c21984d5
26 changed files with 230 additions and 297 deletions
+5 -3
View File
@@ -12,9 +12,9 @@ namespace scripting {
static int l_json_stringify(lua_State* L) {
auto value = scripting::state->tovalue(1);
if (auto mapptr = std::get_if<dynamic::Map*>(&value->value)) {
if (auto mapptr = std::get_if<dynamic::Map_sptr>(&value)) {
bool nice = lua_toboolean(L, 2);
auto string = json::stringify(*mapptr, nice, " ");
auto string = json::stringify(mapptr->get(), nice, " ");
lua_pushstring(L, string.c_str());
return 1;
} else {
@@ -26,7 +26,9 @@ static int l_json_stringify(lua_State* L) {
static int l_json_parse(lua_State* L) {
auto string = lua_tostring(L, 1);
auto element = json::parse("<string>", string);
auto value = std::make_unique<dynamic::Value>(element.release());
auto value = std::make_unique<dynamic::Value>(
dynamic::Map_sptr(element.release())
);
scripting::state->pushvalue(*value);
return 1;
}