mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Core: Refactor base classes
This commit is contained in:
@@ -63,7 +63,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
invoke_wkr.Eval_end(ctx.Page(), mod_name, fnc_name, log_time_bgn);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
Err err = Err_.cast_or_make(e);
|
||||
Err err = Err_.Cast_or_make(e);
|
||||
Error(bfr, wiki.Msg_mgr(), err);
|
||||
Scrib_err_filter_mgr err_filter_mgr = invoke_wkr == null ? null : invoke_wkr.Err_filter_mgr();
|
||||
if ( err_filter_mgr == null // no err_filter_mgr defined;
|
||||
@@ -73,7 +73,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
wiki.Parser_mgr().Scrib().Terminate_when_page_changes_y_(); // NOTE: terminate core when page changes; not terminating now, else page with many errors will be very slow due to multiple remakes of core; PAGE:th.d:all; DATE:2014-10-03
|
||||
}
|
||||
}
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, Err err) {Error(bfr, msg_mgr, Err_.cast_or_make(err).To_str__top_wo_args());}// NOTE: must use "short" error message to show in wikitext; DATE:2015-07-27
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, Err err) {Error(bfr, msg_mgr, Err_.Cast_or_make(err).To_str__top_wo_args());}// NOTE: must use "short" error message to show in wikitext; DATE:2015-07-27
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, String error) {
|
||||
// for Luaj, msg combines both err; split out traceback else error message will be very long; note that Warn_many will still log traceback; DATE:2016-09-09
|
||||
String error_visible = error;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Scrib_invoke_func_fxt {
|
||||
fxt.Test_parse_page_tmpl_str(raw, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test_error(Exception e, String expd) {
|
||||
Scrib_invoke_func.Error(tmp_bfr, fxt.Wiki().Msg_mgr(), Err_.cast_or_make(e));
|
||||
Scrib_invoke_func.Error(tmp_bfr, fxt.Wiki().Msg_mgr(), Err_.Cast_or_make(e));
|
||||
Tfds.Eq_str(expd, tmp_bfr.To_str_and_clear(), "error");
|
||||
}
|
||||
public void Test_lib_proc(Scrib_lib lib, String func_name, Object[] args, String expd) {Test_lib_proc_kv(lib, func_name, Scrib_kv_utl_.base1_many_(args), expd);}
|
||||
@@ -214,7 +214,7 @@ class Scrib_lua_rsp_bldr {
|
||||
Class<?> v_type = v.getClass();
|
||||
if (Object_.Eq(v_type, Int_.Cls_ref_type)) Bld_int(bfr, Int_.cast(v));
|
||||
else if (Object_.Eq(v_type, String_.Cls_ref_type)) Bld_str(bfr, String_.cast(v));
|
||||
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.cast(v));
|
||||
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.Cast(v));
|
||||
else if (Object_.Eq(v_type, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast(v));
|
||||
else if (Object_.Eq(v_type, Keyval[].class)) Bld_kv_ary(bfr, (Keyval[])v);
|
||||
else if (Object_.Eq(v_type, Scrib_lua_proc.class)) Bld_fnc(bfr, (Scrib_lua_proc)v);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Process_send_wtr {
|
||||
public boolean Encode_obj(Bry_bfr bfr, Object o) {
|
||||
if (o == null) {bfr.Add(CONST_nil); return true;}
|
||||
Class<?> c = Type_adp_.ClassOf_obj(o);
|
||||
if (Object_.Eq(c, Bool_.Cls_ref_type)) Encode_bool(bfr, Bool_.cast(o));
|
||||
if (Object_.Eq(c, Bool_.Cls_ref_type)) Encode_bool(bfr, Bool_.Cast(o));
|
||||
else if (Object_.Eq(c, Int_.Cls_ref_type)) Encode_int(bfr, Int_.cast(o));
|
||||
else if (Object_.Eq(c, Long_.Cls_ref_type)) bfr.Add_long_variable(Long_.cast(o));
|
||||
else if (Object_.Eq(c, Double_.Cls_ref_type)) {if (!Encode_double(bfr, Double_.cast(o))) return false;}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
|
||||
if (print_key && !kv_val_is_array)
|
||||
bfr.Add_str_u8(kv.Key()).Add_byte(Byte_ascii.Colon);
|
||||
if (Type_adp_.Eq(kv_val_type, Bool_.Cls_ref_type))
|
||||
bfr.Add(Bool_.cast(kv_val) ? gplx.langs.jsons.Json_itm_.Bry__true : gplx.langs.jsons.Json_itm_.Bry__false);
|
||||
bfr.Add(Bool_.Cast(kv_val) ? gplx.langs.jsons.Json_itm_.Bry__true : gplx.langs.jsons.Json_itm_.Bry__false);
|
||||
else if (kv_val_is_array) {
|
||||
Keyval[] sub = (Keyval[])kv_val;
|
||||
if (sub.length == 0) {bfr.Add_byte(Byte_ascii.Curly_bgn).Add_byte(Byte_ascii.Curly_end);}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class Scrib_lib_language implements Scrib_lib {
|
||||
if (kv_ary != null) {
|
||||
Object skip_commafy_obj = Keyval_.Ary_get_by_key_or_null(kv_ary, "noCommafy");
|
||||
if (skip_commafy_obj != null)
|
||||
skip_commafy = Bool_.cast(skip_commafy_obj);
|
||||
skip_commafy = Bool_.Cast(skip_commafy_obj);
|
||||
}
|
||||
}
|
||||
byte[] rv = lang.Num_mgr().Format_num(num, skip_commafy);
|
||||
|
||||
@@ -81,7 +81,7 @@ class Scrib_lib_message_data {
|
||||
break;
|
||||
case Key_tid_rawMessage: raw_msg_key = kv.Val_to_bry(); break;
|
||||
case Key_tid_lang: lang_key = kv.Val_to_bry(); break;
|
||||
case Key_tid_useDB: use_db = Bool_.cast(kv.Val()); break;
|
||||
case Key_tid_useDB: use_db = Bool_.Cast(kv.Val()); break;
|
||||
case Key_tid_title: title_bry = kv.Val_to_bry(); break;
|
||||
case Key_tid_params:
|
||||
Keyval[] args_ary = (Keyval[])kv.Val();
|
||||
|
||||
@@ -178,7 +178,7 @@ class Scrib_lib_text__json_util {
|
||||
else if (Type_adp_.Eq(type, Long_.Cls_ref_type)) wtr.Kv_long(kv.Key(), Long_.cast(kv_val));
|
||||
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) wtr.Kv_float(kv.Key(), Float_.cast(kv_val));
|
||||
else if (Type_adp_.Eq(type, Double_.Cls_ref_type)) wtr.Kv_double(kv.Key(), Double_.cast(kv_val));
|
||||
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) wtr.Kv_bool(kv.Key(), Bool_.cast(kv_val));
|
||||
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) wtr.Kv_bool(kv.Key(), Bool_.Cast(kv_val));
|
||||
else wtr.Kv_str(kv.Key(), Object_.Xto_str_strict_or_null(kv_val));
|
||||
}
|
||||
private void Encode_ary(Object ary) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Scrib_lib_ustring implements Scrib_lib {
|
||||
for (int j = 0; j < grps_len; j++) {
|
||||
Regx_group grp = grps[j];
|
||||
if ( j < capts_len // bounds check b/c null can be passed
|
||||
&& Bool_.cast(capts[j].Val()) // check if true; indicates that group is "()" or "anypos" see regex converter; DATE:2014-04-23
|
||||
&& Bool_.Cast(capts[j].Val()) // check if true; indicates that group is "()" or "anypos" see regex converter; DATE:2014-04-23
|
||||
)
|
||||
tmp_list.Add(grp.Bgn() + Scrib_lib_ustring.Base1); // return index only for "()"; NOTE: do not return as String; callers expect int and will fail typed comparisons; DATE:2016-01-21
|
||||
else
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Scrib_proc_args {
|
||||
public int Len() {return ary_len;}
|
||||
public Keyval[] Ary() {return ary;}
|
||||
public Object Pull_obj(int i) {return Get_or_fail(i);}
|
||||
public boolean Pull_bool(int i) {return Bool_.cast(Get_or_fail(i));}
|
||||
public boolean Pull_bool(int i) {return Bool_.Cast(Get_or_fail(i));}
|
||||
public String Pull_str(int i) {return String_.cast(Get_or_fail(i));}
|
||||
public byte[] Pull_bry(int i) {return Bry_.new_u8(String_.cast(Get_or_fail(i)));}
|
||||
public int Pull_int(int i) {
|
||||
@@ -118,8 +118,8 @@ public class Scrib_proc_args {
|
||||
public byte[] Cast_bry_or_empty(int i) {Object rv = Get_or_null(i); return rv == null ? Bry_.Empty : Bry_.new_u8(String_.cast (rv));}
|
||||
public byte[] Cast_bry_or(int i, byte[] or) {Object rv = Get_or_null(i); return rv == null ? or : Bry_.new_u8(String_.cast (rv));}
|
||||
public Object Cast_obj_or_null(int i) {return Get_or_null(i);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.Cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.Cast(rv);}
|
||||
public int Cast_int_or(int i, int or) {Object rv = Get_or_null(i); return rv == null ? or : Int_.coerce_(rv);} // coerce to handle "1" and 1;
|
||||
public Keyval[] Cast_kv_ary_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : (Keyval[])rv;}
|
||||
public byte[][] Cast_params_as_bry_ary_or_rest_of_ary(int params_idx) { // PAGE:ru.w:Ленин,_Владимир_Ильич; DATE:2014-07-01 MW:LanguageLibrary.php|ConvertPlural: if (is_array($args[0])) $args = $args[0]; $forms = array_values(array_map('strval', $args));
|
||||
|
||||
Reference in New Issue
Block a user