'dynamic' namespace refactor (step 1/2)
This commit is contained in:
@@ -11,22 +11,22 @@ namespace scripting {
|
||||
|
||||
static int l_json_stringify(lua_State* L) {
|
||||
auto value = scripting::state->tovalue(1);
|
||||
if (value->type != dynamic::valtype::map) {
|
||||
|
||||
if (auto mapptr = std::get_if<dynamic::Map*>(&value->value)) {
|
||||
bool nice = lua_toboolean(L, 2);
|
||||
auto string = json::stringify(*mapptr, nice, " ");
|
||||
lua_pushstring(L, string.c_str());
|
||||
return 1;
|
||||
} else {
|
||||
luaL_error(L, "table expected");
|
||||
return 0;
|
||||
}
|
||||
bool nice = lua_toboolean(L, 2);
|
||||
auto string = json::stringify(std::get<dynamic::Map*>(value->value), nice, " ");
|
||||
lua_pushstring(L, string.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
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>(
|
||||
dynamic::valtype::map, element.release()
|
||||
);
|
||||
auto value = std::make_unique<dynamic::Value>(element.release());
|
||||
scripting::state->pushvalue(*value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user