1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Refactor: Clean up Int_ classes

This commit is contained in:
gnosygnu
2017-10-22 08:07:00 -04:00
parent d270cce881
commit 3157551d1d
154 changed files with 609 additions and 577 deletions

View File

@@ -62,7 +62,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
subs[subs_len] = sub;
sub.Tkn_grp_(this, subs_len);
subs_len = new_len;
} private Xop_tkn_itm[] subs = Xop_tkn_itm_.Ary_empty; int subs_max; int[] subs_pos_ary = Int_.Ary_empty;
} private Xop_tkn_itm[] subs = Xop_tkn_itm_.Ary_empty; int subs_max; int[] subs_pos_ary = Int_ary_.Empty;
public void Subs_add_grp(Xop_tkn_itm sub, Xop_tkn_grp old_grp, int old_sub_idx) {
this.Subs_add(sub);
if (sub.Tkn_immutable())
@@ -93,7 +93,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
public void Subs_clear() {
subs_len = subs_max = 0;
subs = Xop_tkn_itm_.Ary_empty;
subs_pos_ary = Int_.Ary_empty;
subs_pos_ary = Int_ary_.Empty;
}
public void Subs_move(Xop_tkn_itm tkn) {
int nxt_idx = tkn_sub_idx + 1, len = tkn.Subs_len();

View File

@@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.brys.*;
public class Mwh_atr_mgr {
private final int data_max_orig;
private final int data_max_orig;
public Mwh_atr_mgr(int max) {
this.data_max_orig = max * Idx__mult;
this.Max_(max);
@@ -41,7 +41,7 @@ public class Mwh_atr_mgr {
if (data_idx == data_max) {
int new_data_max = data_max == 0 ? Idx__mult : data_max * 2;
int[] new_data_ary = new int[new_data_max];
Int_.Ary_copy_to(data_ary, data_max, data_ary);
Int_ary_.Copy_to(data_ary, data_max, data_ary);
this.data_ary = new_data_ary;
int text_max = text_ary.length;

View File

@@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
class Mwh_doc_mgr {
private final int data_max_orig;
private final int data_max_orig;
public Mwh_doc_mgr(int max) {
this.data_max_orig = max * Idx__mult;
this.Max_(max);
@@ -38,7 +38,7 @@ class Mwh_doc_mgr {
if (data_idx == data_max) {
int new_data_max = data_max == 0 ? Idx__mult : data_max * 2;
int[] new_data_ary = new int[new_data_max];
Int_.Ary_copy_to(data_ary, data_max, data_ary);
Int_ary_.Copy_to(data_ary, data_max, data_ary);
this.data_ary = new_data_ary;
this.data_max = new_data_max;
}

View File

@@ -44,7 +44,7 @@ public class HierPosAryBldr {
}
public boolean Dirty() {return aryIdx > -1 || root > 0;}
public int[] XtoIntAry() {
if (aryIdx == -1) return Int_.Ary_empty;
if (aryIdx == -1) return Int_ary_.Empty;
int[] rv = new int[aryIdx + 1];
for (int i = 0; i < aryIdx + 1; i++)
rv[i] = ary[i];

View File

@@ -18,7 +18,7 @@ import org.junit.*;
public class HierPosAryBldr_tst {
@Before public void init() {bldr.Init();} HierPosAryBldr bldr = new HierPosAryBldr(256);
@Test public void Basic() {
tst_ary(Int_.Ary_empty);
tst_ary(Int_ary_.Empty);
}
@Test public void Move_d() {
bldr.MoveDown();

View File

@@ -19,12 +19,12 @@ public class Xop_list_tkn extends Xop_tkn_itm_base {
public int List_uid() {return list_uid;} public Xop_list_tkn List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1;
public byte List_bgn() {return list_bgn;} private byte list_bgn;
public byte List_itmTyp() {return list_itmTyp;} public Xop_list_tkn List_itmTyp_(byte v) {list_itmTyp = v; return this;} private byte list_itmTyp = Xop_list_tkn_.List_itmTyp_null;
public int[] List_path() {return path;} public Xop_list_tkn List_path_(int... v) {path = v; return this;} private int[] path = Int_.Ary_empty;
public int[] List_path() {return path;} public Xop_list_tkn List_path_(int... v) {path = v; return this;} private int[] path = Int_ary_.Empty;
public int List_path_idx() {return path[path.length - 1];}
public boolean List_sub_first() {return List_path_idx() == 0;}
public byte List_sub_last() {return list_sub_last;} public Xop_list_tkn List_sub_last_(byte v) {list_sub_last = v; return this;} private byte list_sub_last = Bool_.__byte;
public static Xop_list_tkn bgn_(int bgn, int end, byte list_itmTyp, int symLen) {return new Xop_list_tkn(bgn, end, Bool_.Y_byte, list_itmTyp);}
public static Xop_list_tkn end_(int pos, byte list_itmTyp) {return new Xop_list_tkn(pos, pos, Bool_.N_byte, list_itmTyp);}
public Xop_list_tkn(int bgn, int end, byte bgnEndType, byte list_itmTyp) {this.Tkn_ini_pos(false, bgn, end); this.list_bgn = bgnEndType; this.list_itmTyp = list_itmTyp;}
public static final Xop_list_tkn Null = new Xop_list_tkn(); Xop_list_tkn() {}
public static final Xop_list_tkn Null = new Xop_list_tkn(); Xop_list_tkn() {}
}

View File

@@ -21,7 +21,7 @@ public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base {
public int List_uid() {return list_uid;} public Xop_list_tkn_chkr List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1;
public byte List_bgn() {return list_bgn;} public Xop_list_tkn_chkr List_bgn_(byte v) {list_bgn = v; return this;} private byte list_bgn;
public byte List_itmTyp() {return list_itmTyp;} public Xop_list_tkn_chkr List_itmTyp_(byte v) {list_itmTyp = v; return this;} private byte list_itmTyp = Xop_list_tkn_.List_itmTyp_null;
public int[] List_path() {return list_path;} public Xop_list_tkn_chkr List_path_(int... v) {list_path = v; return this;} private int[] list_path = Int_.Ary_empty;
public int[] List_path() {return list_path;} public Xop_list_tkn_chkr List_path_(int... v) {list_path = v; return this;} private int[] list_path = Int_ary_.Empty;
public byte List_sub_last() {return list_sub_last;} public Xop_list_tkn_chkr List_sub_last_(byte v) {list_sub_last = v; return this;} private byte list_sub_last = Bool_.__byte;
@Override public int Chk_hook(Tst_mgr mgr, String path, Object actl_obj, int err) {
Xop_list_tkn actl = (Xop_list_tkn)actl_obj;
@@ -29,7 +29,7 @@ public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base {
err += mgr.Tst_val(list_bgn == 0, path, "list_bgn", list_bgn, actl.List_bgn());
err += mgr.Tst_val(list_itmTyp == Xop_list_tkn_.List_itmTyp_null, path, "list_itmTyp", list_itmTyp, actl.List_itmTyp());
err += mgr.Tst_val(list_sub_last == Bool_.__byte, path, "list_sub_last", list_sub_last, actl.List_sub_last());
err += mgr.Tst_val(list_path == Int_.Ary_empty, path, "list_path", Array_.To_str(list_path), Array_.To_str(actl.List_path()));
err += mgr.Tst_val(list_path == Int_ary_.Empty, path, "list_path", Array_.To_str(list_path), Array_.To_str(actl.List_path()));
return err;
}
}

View File

@@ -163,7 +163,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
tkn.Lnke_relative_(site_data.Rel());
Xow_xwiki_itm xwiki = ctx.App().Usere().Wiki().Xwiki_mgr().Get_by_mid(src, site_bgn, site_end); // NOTE: check User_wiki.Xwiki_mgr, not App.Wiki_mgr() b/c only it is guaranteed to know all wikis on system
if ( xwiki != null // lnke is to an xwiki; EX: [http://en.wikipedia.org/A a]
&& Byte_.In(proto_tid, Gfo_protocol_itm.Tid_relative_1, Gfo_protocol_itm.Tid_relative_2, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https) // only consider http / https; ignore mailto and others; PAGE:uk.w:Маскалі; DATE:2015-07-28
&& Byte_.Match_any(proto_tid, Gfo_protocol_itm.Tid_relative_1, Gfo_protocol_itm.Tid_relative_2, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https) // only consider http / https; ignore mailto and others; PAGE:uk.w:Маскалі; DATE:2015-07-28
&& Bry_.Match(src, site_bgn, site_end, xwiki.Domain_bry()) // only consider full domains, not alliases; EX: [http://w/b] should not match alias of w for en.wikipedia.org
) {
Xowe_wiki wiki = ctx.Wiki();

View File

@@ -53,7 +53,7 @@ public class Xop_link_parser {
if (proto_len + 1 < raw_len && raw[proto_len + 1] == Byte_ascii.Slash) { // next char is slash, assume xfer_itm refers to protocol; EX: file:///C/A.png
int slash_pos = Bry_find_.Find_bwd(raw, Byte_ascii.Slash);
if (slash_pos != Bry_find_.Not_found) // set xowa_title to file_name; TODO_OLD: call Xoa_url.build; note that this will fail sometimes when (a) xfer_itm is very long (File:ReallyLongName will be shortened to 128 chars) or (b) xfer_itm has invalid windows characters (EX:File:a"b"c.jpg)
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Int_.Const_dlm_len, raw.length);
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Byte_ascii.Len_1, raw.length);
}
else // next char is not slash; assume xfer_itm refers to ns; EX:File:A.png
raw = tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(raw).To_bry_and_clear();

View File

@@ -129,7 +129,7 @@ public class Xop_lnki_arg_parser {
int len = digit_mgr.Len(); // NOTE: add non-english numbers; EX: ۲۰۰px; DATE:2015-07-18
for (int i = 0; i < len; ++i) {
Keyval kv = digit_mgr.Get_at(i);
int num = (byte)Int_.parse_or(kv.Key(), -1); if (num == -1) continue; // ignore separators; EX: "," "."
int num = (byte)Int_.Parse_or(kv.Key(), -1); if (num == -1) continue; // ignore separators; EX: "," "."
size_trie.Add((byte[])kv.Val(), Byte_obj_val.new_((byte)num)); // NOTE: num corresponds to dim_d0 -> d9 below
}
size_trie.Add(Byte_ascii.Space, Byte_obj_val.new_(Key_space));

View File

@@ -18,11 +18,11 @@ import gplx.core.tests.*;
public class Xop_tblw_tb_tkn_chkr extends Xop_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Xop_tblw_tb_tkn.class;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_tb;}
public int Caption_count() {return caption_count;} public Xop_tblw_tb_tkn_chkr Caption_count_(int v) {caption_count = v; return this;} private int caption_count = Int_.Neg1_count;
public int Caption_count() {return caption_count;} public Xop_tblw_tb_tkn_chkr Caption_count_(int v) {caption_count = v; return this;} private int caption_count = Int_.Neg1;
public Xop_tblw_tb_tkn_chkr Atrs_rng_(int bgn, int end) {this.atrs_bgn = bgn; this.atrs_end = end; return this;} private int atrs_bgn = Xop_tblw_wkr.Atrs_null, atrs_end = Xop_tblw_wkr.Atrs_null;
@Override public int Chk_hook(Tst_mgr mgr, String path, Object actl_obj, int err) {
Xop_tblw_tb_tkn actl = (Xop_tblw_tb_tkn)actl_obj;
err += mgr.Tst_val(caption_count == Int_.Neg1_count, path, "caption_count", caption_count, actl.Caption_count());
err += mgr.Tst_val(caption_count == Int_.Neg1, path, "caption_count", caption_count, actl.Caption_count());
err += mgr.Tst_val(atrs_bgn == Xop_tblw_wkr.Atrs_null, path, "atrs_bgn", atrs_bgn, actl.Atrs_bgn());
err += mgr.Tst_val(atrs_end == Xop_tblw_wkr.Atrs_null, path, "atrs_end", atrs_end, actl.Atrs_end());
return err;

View File

@@ -19,10 +19,10 @@ public class Xop_uniq_mgr__tst {
private final Xop_uniq_mgr__fxt fxt = new Xop_uniq_mgr__fxt();
@Before public void init() {fxt.Init();}
@Test public void Test__random_bry() {
fxt.Init_random_int_ary(Int_.Ary(240563374, 22728940, 1451248133));
fxt.Init_random_int_ary(Int_ary_.New(240563374, 22728940, 1451248133));
fxt.Test__uniq_bry_new("'\"`UNIQ-E56B4AE15AD0EC68");
fxt.Init_random_int_ary(Int_.Ary(1363621437, 426295411, 421041101));
fxt.Init_random_int_ary(Int_ary_.New(1363621437, 426295411, 421041101));
fxt.Test__uniq_bry_new("'\"`UNIQ-147363D968C07391");
}
@Test public void Add_and_get() {

View File

@@ -349,7 +349,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
Xop_xnde_tkn xnde_inline = Xnde_bgn(ctx, tkn_mkr, root, tag, Xop_xnde_tkn.CloseMode_open, src, bgn_pos, open_tag_end, atrs_bgn, atrs_end, atrs);
End_tag(ctx, root, xnde_inline, src, src_len, bgn_pos, gtPos, tagId, false, tag);
ctx.Msg_log().Add_itm_none(Xop_xnde_log.No_inline, src, bgn_pos, gtPos);
return gtPos + Int_.Const_position_after_char;
return gtPos + Int_.Offset_1;
}
Xop_xnde_tkn xnde = null;
xnde = Xnde_bgn(ctx, tkn_mkr, root, tag, inline ? Xop_xnde_tkn.CloseMode_inline : Xop_xnde_tkn.CloseMode_open, src, bgn_pos, open_tag_end, atrs_bgn, atrs_end, atrs);