Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4ad4851

Browse files
committedOct 27, 2024·
build with old librime
1 parent 5819dca commit 4ad4851

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed
 

‎src/types.cc

+19-10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ struct COMPAT {
5050
static string get_sync_dir() {
5151
return string(rime_get_api()->get_sync_dir());
5252
}
53+
54+
bool Config_load_from_file(Config &t, const string &f) {
55+
return t.LoadFromFile(f);
56+
}
57+
58+
bool Config_save_to_file(Config &t, const string &f) {
59+
return t.SaveToFile(f);
60+
}
5361
};
5462

5563
template<typename T>
@@ -73,6 +81,14 @@ struct COMPAT<T, void_t<decltype(std::declval<T>().user_data_dir.string())>> {
7381
T &deployer = Service::instance().deployer();
7482
return deployer.sync_dir.string();
7583
}
84+
85+
bool Config_load_from_file(Config &t, const string &f) {
86+
return t.LoadFromFile(path(f));
87+
}
88+
89+
bool Config_save_to_file(Config &t, const string &f) {
90+
return t.SaveToFile(path(f));
91+
}
7692
};
7793

7894
//--- wrappers for Segment
@@ -1217,7 +1233,7 @@ namespace ConfigReg {
12171233
int raw_make(lua_State *L) {
12181234
an<T> config = New<T>();
12191235
if (auto cstr = lua_tostring(L, 1)) {
1220-
config->LoadFromFile(path(cstr));
1236+
COMPAT<Deployer>::Config_load_from_file(config, cstr);
12211237
}
12221238
LuaType<an<T>>::pushdata(L, config);
12231239
return 1;
@@ -1281,13 +1297,6 @@ namespace ConfigReg {
12811297
return t.SetItem(path, value);
12821298
}
12831299

1284-
bool load_from_file(T &t, const string &f) {
1285-
return t.LoadFromFile(path(f));
1286-
}
1287-
bool save_to_file(T &t, const string &f) {
1288-
return t.SaveToFile(path(f));
1289-
}
1290-
12911300
static const luaL_Reg funcs[] = {
12921301
{ "Config", (raw_make)},
12931302
{ NULL, NULL },
@@ -1296,8 +1305,8 @@ namespace ConfigReg {
12961305
static const luaL_Reg methods[] = {
12971306
//bool LoadFromStream(std::istream& stream);
12981307
//bool SaveToStream(std::ostream& stream);
1299-
{ "load_from_file", WRAP(load_from_file) },
1300-
{ "save_to_file", WRAP(save_to_file) },
1308+
{ "load_from_file", WRAP(COMPAT<Deployer>::Config_load_from_file) },
1309+
{ "save_to_file", WRAP(COMPAT<Deployer>::Config_save_to_file) },
13011310

13021311
{ "is_null", WRAPMEM(T::IsNull) },
13031312
{ "is_value", WRAPMEM(T::IsValue) },

0 commit comments

Comments
 (0)
Please sign in to comment.