Skip to content

Commit

Permalink
build with old librime
Browse files Browse the repository at this point in the history
  • Loading branch information
hchunhui committed Oct 27, 2024
1 parent 5819dca commit ba9d591
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
Expand All @@ -73,6 +81,14 @@ struct COMPAT<T, void_t<decltype(std::declval<T>().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
Expand Down Expand Up @@ -1217,7 +1233,7 @@ namespace ConfigReg {
int raw_make(lua_State *L) {
an<T> config = New<T>();
if (auto cstr = lua_tostring(L, 1)) {
config->LoadFromFile(path(cstr));
COMPAT<Deployer>::Config_load_from_file(config, cstr);
}
LuaType<an<T>>::pushdata(L, config);
return 1;
Expand Down Expand Up @@ -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 },
Expand All @@ -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<Deployer>::Config_load_from_file) },
{ "save_to_file", WRAP(COMPAT<Deployer>::Config_save_to_file) },

{ "is_null", WRAPMEM(T::IsNull) },
{ "is_value", WRAPMEM(T::IsValue) },
Expand Down

0 comments on commit ba9d591

Please sign in to comment.