diff --git a/src/types.cc b/src/types.cc index 14e115a..2ded253 100644 --- a/src/types.cc +++ b/src/types.cc @@ -50,6 +50,14 @@ struct COMPAT { static string get_sync_dir() { return string(rime_get_api()->get_sync_dir()); } + + static bool Config_load_from_file(Config &t, const string &f) { + return t.LoadFromFile(f); + } + + static bool Config_save_to_file(Config &t, const string &f) { + return t.SaveToFile(f); + } }; template @@ -73,6 +81,14 @@ struct COMPAT().user_data_dir.string())>> { T &deployer = Service::instance().deployer(); return deployer.sync_dir.string(); } + + bool Config_load_from_file(Config &t, const string &f) { + return t.LoadFromFile(path(f)); + } + + bool Config_save_to_file(Config &t, const string &f) { + return t.SaveToFile(path(f)); + } }; //--- wrappers for Segment @@ -1217,7 +1233,7 @@ namespace ConfigReg { int raw_make(lua_State *L) { an config = New(); if (auto cstr = lua_tostring(L, 1)) { - config->LoadFromFile(path(cstr)); + COMPAT::Config_load_from_file(config, cstr); } LuaType>::pushdata(L, config); return 1; @@ -1281,13 +1297,6 @@ namespace ConfigReg { return t.SetItem(path, value); } - bool load_from_file(T &t, const string &f) { - return t.LoadFromFile(path(f)); - } - bool save_to_file(T &t, const string &f) { - return t.SaveToFile(path(f)); - } - static const luaL_Reg funcs[] = { { "Config", (raw_make)}, { NULL, NULL }, @@ -1296,8 +1305,8 @@ namespace ConfigReg { static const luaL_Reg methods[] = { //bool LoadFromStream(std::istream& stream); //bool SaveToStream(std::ostream& stream); - { "load_from_file", WRAP(load_from_file) }, - { "save_to_file", WRAP(save_to_file) }, + { "load_from_file", WRAP(COMPAT::Config_load_from_file) }, + { "save_to_file", WRAP(COMPAT::Config_save_to_file) }, { "is_null", WRAPMEM(T::IsNull) }, { "is_value", WRAPMEM(T::IsValue) },