@@ -50,6 +50,14 @@ struct COMPAT {
50
50
static string get_sync_dir () {
51
51
return string (rime_get_api ()->get_sync_dir ());
52
52
}
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
+ }
53
61
};
54
62
55
63
template <typename T>
@@ -73,6 +81,14 @@ struct COMPAT<T, void_t<decltype(std::declval<T>().user_data_dir.string())>> {
73
81
T &deployer = Service::instance ().deployer ();
74
82
return deployer.sync_dir .string ();
75
83
}
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
+ }
76
92
};
77
93
78
94
// --- wrappers for Segment
@@ -1217,7 +1233,7 @@ namespace ConfigReg {
1217
1233
int raw_make (lua_State *L) {
1218
1234
an<T> config = New<T>();
1219
1235
if (auto cstr = lua_tostring (L, 1 )) {
1220
- config-> LoadFromFile ( path ( cstr) );
1236
+ COMPAT<Deployer>:: Config_load_from_file (config, cstr);
1221
1237
}
1222
1238
LuaType<an<T>>::pushdata (L, config);
1223
1239
return 1 ;
@@ -1281,13 +1297,6 @@ namespace ConfigReg {
1281
1297
return t.SetItem (path, value);
1282
1298
}
1283
1299
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
-
1291
1300
static const luaL_Reg funcs[] = {
1292
1301
{ " Config" , (raw_make)},
1293
1302
{ NULL , NULL },
@@ -1296,8 +1305,8 @@ namespace ConfigReg {
1296
1305
static const luaL_Reg methods[] = {
1297
1306
// bool LoadFromStream(std::istream& stream);
1298
1307
// 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 ) },
1301
1310
1302
1311
{ " is_null" , WRAPMEM (T::IsNull) },
1303
1312
{ " is_value" , WRAPMEM (T::IsValue) },
0 commit comments