Skip to content

Commit

Permalink
add Config([string])
Browse files Browse the repository at this point in the history
  • Loading branch information
shewer authored Sep 19, 2024
1 parent 7568c94 commit 5819dca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,15 @@ namespace ProjectionReg{
namespace ConfigReg {
using T = Config;

int raw_make(lua_State *L) {
an<T> config = New<T>();
if (auto cstr = lua_tostring(L, 1)) {
config->LoadFromFile(path(cstr));
}
LuaType<an<T>>::pushdata(L, config);
return 1;
}

optional<bool> get_bool(T &t, const string &path) {
bool v;
if (t.GetBool(path, &v))
Expand Down Expand Up @@ -1280,6 +1289,7 @@ namespace ConfigReg {
}

static const luaL_Reg funcs[] = {
{ "Config", (raw_make)},
{ NULL, NULL },
};

Expand Down

0 comments on commit 5819dca

Please sign in to comment.