refactor: 'lua' namespace expansion
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
#include "api_lua.hpp"
|
||||
#include "lua_util.hpp"
|
||||
#include "lua_commons.hpp"
|
||||
#include "LuaState.hpp"
|
||||
|
||||
#include "../../../coders/toml.hpp"
|
||||
#include "../../../data/dynamic.hpp"
|
||||
|
||||
namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
}
|
||||
using namespace scripting;
|
||||
|
||||
static int l_toml_stringify(lua_State* L) {
|
||||
@@ -16,8 +10,7 @@ static int l_toml_stringify(lua_State* L) {
|
||||
|
||||
if (auto mapptr = std::get_if<dynamic::Map_sptr>(&value)) {
|
||||
auto string = toml::stringify(**mapptr);
|
||||
lua_pushstring(L, string.c_str());
|
||||
return 1;
|
||||
return lua::pushstring(L, string);
|
||||
} else {
|
||||
throw std::runtime_error("table expected");
|
||||
}
|
||||
@@ -27,12 +20,11 @@ static int l_toml_parse(lua_State* L) {
|
||||
auto string = lua::require_string(L, 1);
|
||||
auto element = toml::parse("<string>", string);
|
||||
auto value = std::make_unique<dynamic::Value>(element);
|
||||
lua::pushvalue(L, *value);
|
||||
return 1;
|
||||
return lua::pushvalue(L, *value);
|
||||
}
|
||||
|
||||
const luaL_Reg tomllib [] = {
|
||||
{"tostring", lua_wrap_errors<l_toml_stringify>},
|
||||
{"parse", lua_wrap_errors<l_toml_parse>},
|
||||
{"tostring", lua::wrap<l_toml_stringify>},
|
||||
{"parse", lua::wrap<l_toml_parse>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user