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

'v3.3.4.1'

This commit is contained in:
gnosygnu
2016-03-27 23:44:59 -04:00
parent de67253a9c
commit baaef32df2
903 changed files with 13339 additions and 8695 deletions

View File

@@ -44,12 +44,12 @@ public class Gfs_msg_bldr_tst {
}
class Gfs_msg_bldr_fxt {
public void Clear() {} String_bldr sb = String_bldr_.new_(); Gfs_msg_bldr msg_bldr = Gfs_msg_bldr.Instance;
public KeyVal kv_(String key, String val) {return KeyVal_.new_(key, val);}
public GfoMsg msg_(String key, KeyVal... args) {
public Keyval kv_(String key, String val) {return Keyval_.new_(key, val);}
public GfoMsg msg_(String key, Keyval... args) {
GfoMsg rv = GfoMsg_.new_parse_(key);
int len = args.length;
for (int i = 0; i < len; i++) {
KeyVal kv = args[i];
Keyval kv = args[i];
rv.Add(kv.Key(), kv.Val());
}
return rv;

View File

@@ -40,7 +40,6 @@ class Gfs_parser_ctx {
cur_idf_end = end;
} int cur_idf_bgn = -1, cur_idf_end = -1;
private void Held_word_clear() {cur_idf_bgn = -1; cur_idf_end = -1;}
public Gfs_nde Make_nde(int tkn_bgn, int tkn_end) { // "abc."; "abc("; "abc;"; "abc{"
Gfs_nde nde = new Gfs_nde().Name_rng_(cur_idf_bgn, cur_idf_end);
this.Held_word_clear();
@@ -66,17 +65,17 @@ class Gfs_parser_ctx {
}
class Gfs_err_mgr {
public void Fail_eos(Gfs_parser_ctx ctx) {Fail(ctx, Fail_msg_eos, ctx.Src_len());}
public void Fail_unknown_char(Gfs_parser_ctx ctx, int pos, byte c) {Fail(ctx, Fail_msg_unknown_char, pos, KeyVal_.new_("char", Char_.To_str((char)c)));}
public void Fail_unknown_char(Gfs_parser_ctx ctx, int pos, byte c) {Fail(ctx, Fail_msg_unknown_char, pos, Keyval_.new_("char", Char_.To_str((char)c)));}
public void Fail_nde_stack_empty(Gfs_parser_ctx ctx, int pos) {Fail(ctx, Fail_msg_nde_stack_empty, pos);}
public void Fail_invalid_lxr(Gfs_parser_ctx ctx, int pos, int lxr_tid, byte c) {
Fail(ctx, Fail_msg_invalid_lxr, pos, KeyVal_.new_("char", Char_.To_str((char)c)), KeyVal_.new_("cur_lxr", Gfs_lxr_.Tid__name(lxr_tid)), KeyVal_.new_("prv_lxr", Gfs_lxr_.Tid__name(ctx.Prv_lxr())));
Fail(ctx, Fail_msg_invalid_lxr, pos, Keyval_.new_("char", Char_.To_str((char)c)), Keyval_.new_("cur_lxr", Gfs_lxr_.Tid__name(lxr_tid)), Keyval_.new_("prv_lxr", Gfs_lxr_.Tid__name(ctx.Prv_lxr())));
}
private void Fail(Gfs_parser_ctx ctx, String msg, int pos, KeyVal... args) {
private void Fail(Gfs_parser_ctx ctx, String msg, int pos, Keyval... args) {
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
Fail_args_standard(src, src_len, pos);
int len = args.length;
for (int i = 0; i < len; i++) {
KeyVal arg = args[i];
Keyval arg = args[i];
tmp_fail_args.Add(arg.Key(), arg.Val_to_str_or_empty());
}
throw Err_.new_wo_type(Fail_msg(msg, tmp_fail_args));
@@ -87,12 +86,12 @@ class Gfs_err_mgr {
tmp_fail_args.Add("pos" , pos);
}
public static final String Fail_msg_invalid_lxr = "invalid character", Fail_msg_unknown_char = "unknown char", Fail_msg_eos = "end of stream", Fail_msg_nde_stack_empty = "node stack empty";
String Fail_msg(String type, KeyValList fail_args) {
String Fail_msg(String type, Keyval_list fail_args) {
tmp_fail_bfr.Add_str_u8(type).Add_byte(Byte_ascii.Colon);
int len = fail_args.Count();
for (int i = 0; i < len; i++) {
tmp_fail_bfr.Add_byte(Byte_ascii.Space);
KeyVal kv = fail_args.GetAt(i);
Keyval kv = fail_args.Get_at(i);
tmp_fail_bfr.Add_str_u8(kv.Key());
tmp_fail_bfr.Add_byte(Byte_ascii.Eq).Add_byte(Byte_ascii.Apos);
tmp_fail_bfr.Add_str_u8(kv.Val_to_str_or_empty()).Add_byte(Byte_ascii.Apos);
@@ -100,7 +99,7 @@ class Gfs_err_mgr {
return tmp_fail_bfr.To_str_and_clear();
}
Bry_bfr tmp_fail_bfr = Bry_bfr.reset_(255);
KeyValList tmp_fail_args = new KeyValList();
Keyval_list tmp_fail_args = new Keyval_list();
private static int excerpt_len = 50;
String Fail_excerpt_bgn(byte[] src, int src_len, int pos) {
int bgn = pos - excerpt_len; if (bgn < 0) bgn = 0;

View File

@@ -105,8 +105,9 @@ public class Gfh_tag_ {
, Script_rhs = Bry_.new_a7("</script>")
, Span_lhs = Bry_.new_a7("<span")
, Span_rhs = Bry_.new_a7("</span>")
, Strong_lhs = Bry_.new_a7("<strong>")
, Strong_rhs = Bry_.new_a7("</strong>")
;
public static final String
Comm_bgn_str = "<!--"
, Comm_end_str = "-->"

View File

@@ -102,7 +102,6 @@ public class Gfh_utl {
else
return dirty ? bfr.To_bry_and_clear() : bry;
}
private static final Btrie_slim_mgr unescape_trie = Btrie_slim_mgr.ci_a7()
.Add_bry_byte(Gfh_entity_.Lt_bry , Byte_ascii.Lt)
.Add_bry_byte(Gfh_entity_.Gt_bry , Byte_ascii.Gt)

View File

@@ -19,4 +19,4 @@ package gplx.langs.htmls.docs; import gplx.*; import gplx.langs.*; import gplx.l
public interface Gfh_doc_wkr {
byte[] Hook();
int Parse(byte[] src, int src_bgn, int src_end, int pos);
}
}

View File

@@ -86,7 +86,6 @@ public class Gfh_tag_rdr {
else
return false;
}
int depth = depth_obj.Val();
boolean tag_is_tail = tag.Tag_is_tail();
if (tail == tag_is_tail) {

View File

@@ -18,4 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.htmls.docs; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
public interface Gfh_txt_wkr {
void Parse(int rng_bgn, int rng_end);
}
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfo_url_encoder_tst {
private final Gfo_url_encoder_fxt fxt = new Gfo_url_encoder_fxt();
private final Gfo_url_encoder_fxt fxt = new Gfo_url_encoder_fxt();
@Test public void Id__nums() {fxt.Encoder_id().Test__bicode("0123456789" , "0123456789");}
@Test public void Id__ltrs_lower() {fxt.Encoder_id().Test__bicode("abcdefghijklmnopqrstuvwxyz" , "abcdefghijklmnopqrstuvwxyz");}
@Test public void Id__ltrs_upper() {fxt.Encoder_id().Test__bicode("ABCDEFGHIJKLMNOPQRSTUVWXYZ" , "ABCDEFGHIJKLMNOPQRSTUVWXYZ");}
@@ -46,7 +46,7 @@ public class Gfo_url_encoder_tst {
fxt.Encoder_href().Test__encode("%GC", "%25GC");
}
@Test public void Fsys__wnt() {
fxt.Encoder_fsys_safe().Test__encode("Help:Options/HTML", "Help%3AOptions%2FHTML");
fxt.Encoder_fsys_safe().Test__encode("Options/HTML", "Options%2FHTML");
}
}
class Gfo_url_encoder_fxt {

View File

@@ -32,4 +32,4 @@ public class Gfh_style_wkr__val_as_int implements Gfh_style_wkr {
Gfh_style_parser_.Parse(src, src_bgn, src_end, this);
return Bry_.To_int_or__lax(src, val_bgn, val_end, -1);
}
}
}

View File

@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
public class Json_kv_ary_srl {
public static KeyVal Kv_by_itm(Json_itm itm) {
public static Keyval Kv_by_itm(Json_itm itm) {
switch (itm.Tid()) {
case Json_itm_.Tid__kv:
Json_kv kv = (Json_kv)itm;
return KeyVal_.new_(kv.Key_as_str(), Val_by_itm(kv.Val()));
return Keyval_.new_(kv.Key_as_str(), Val_by_itm(kv.Val()));
default:
throw Err_.new_unhandled(itm.Tid());
}
@@ -39,19 +39,19 @@ public class Json_kv_ary_srl {
default: throw Err_.new_unhandled(itm.Tid());
}
}
private static KeyVal[] Val_by_itm_ary(Json_ary itm) {
private static Keyval[] Val_by_itm_ary(Json_ary itm) {
int subs_len = itm.Len();
KeyVal[] rv = new KeyVal[subs_len];
Keyval[] rv = new Keyval[subs_len];
for (int i = 0; i < subs_len; i++) {
Json_itm sub = itm.Get_at(i);
KeyVal kv = KeyVal_.new_(Int_.To_str(i + Int_.Base1), Val_by_itm(sub));
Keyval kv = Keyval_.new_(Int_.To_str(i + Int_.Base1), Val_by_itm(sub));
rv[i] = kv;
}
return rv;
}
public static KeyVal[] Val_by_itm_nde(Json_nde itm) {
public static Keyval[] Val_by_itm_nde(Json_nde itm) {
int subs_len = itm.Len();
KeyVal[] rv = new KeyVal[subs_len];
Keyval[] rv = new Keyval[subs_len];
for (int i = 0; i < subs_len; i++) {
Json_itm sub = itm.Get_at(i);
rv[i] = Kv_by_itm(sub);

View File

@@ -35,16 +35,16 @@ class Json_kv_ary_srl_fxt {
parser = new Json_parser();
}
} private Json_parser parser;
public void Test_parse(String raw_str, KeyVal[] expd) {
public void Test_parse(String raw_str, Keyval[] expd) {
byte[] raw_bry = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
Json_doc doc = parser.Parse(raw_bry);
KeyVal[] actl = Json_kv_ary_srl.Val_by_itm_nde(doc.Root_nde());
Tfds.Eq_str_lines(KeyVal_.Ary_to_str(expd), KeyVal_.Ary_to_str(actl));
Keyval[] actl = Json_kv_ary_srl.Val_by_itm_nde(doc.Root_nde());
Tfds.Eq_str_lines(Keyval_.Ary_to_str(expd), Keyval_.Ary_to_str(actl));
}
public KeyVal[] ary_(KeyVal... ary) {return ary;}
public KeyVal kv_obj_(String key, Object val) {return KeyVal_.new_(key, val);}
public KeyVal kv_str_(String key, String val) {return KeyVal_.new_(key, val);}
public KeyVal kv_int_(String key, int val) {return KeyVal_.new_(key, val);}
public KeyVal kv_bool_(String key, boolean val) {return KeyVal_.new_(key, Bool_.To_str_lower(val));}
public KeyVal kv_dec_(String key, Decimal_adp val) {return KeyVal_.new_(key, val.To_str());}
public Keyval[] ary_(Keyval... ary) {return ary;}
public Keyval kv_obj_(String key, Object val) {return Keyval_.new_(key, val);}
public Keyval kv_str_(String key, String val) {return Keyval_.new_(key, val);}
public Keyval kv_int_(String key, int val) {return Keyval_.new_(key, val);}
public Keyval kv_bool_(String key, boolean val) {return Keyval_.new_(key, Bool_.To_str_lower(val));}
public Keyval kv_dec_(String key, Decimal_adp val) {return Keyval_.new_(key, val.To_str());}
}

View File

@@ -62,7 +62,7 @@ public class Json_parser__list_nde__base extends Json_parser__itm__base {
Json_kv sub = nde.Get_at_as_kv(i);
byte[] key = sub.Key_as_bry();
byte[] val = Parse_to_list_as_kv__get_val(sub, key);
list.Add(key, KeyVal_.new_(String_.new_u8(key), String_.new_u8(val)));
list.Add(key, Keyval_.new_(String_.new_u8(key), String_.new_u8(val)));
}
}
@gplx.Virtual protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}

View File

@@ -211,10 +211,10 @@ public class Json_wtr {
else {
Handle_nde_as_ary_itm_0();
Write_grp_bgn(Sym_nde_bgn, Bool_.N);
KeyVal[] kvy = (KeyVal[])obj;
Keyval[] kvy = (Keyval[])obj;
int kvy_len = kvy.length;
for (int i = 0; i < kvy_len; ++i) {
KeyVal kv = kvy[i];
Keyval kv = kvy[i];
Object kv_val = kv.Val();
Kv_obj(Bry_.new_u8(kv.Key()), kv_val, Type_adp_.To_tid_obj(kv_val));
}
@@ -287,7 +287,7 @@ public class Json_wtr {
private static final int Grp_type__json_nde = 1, Grp_type__kv_ary = 2, Grp_type__json_ary = 3, Grp_type__obj_ary = 4;
private static int Grp_type__get(Object obj) {
Class<?> type = obj.getClass();
if (Type_adp_.Eq(type, KeyVal[].class)) return Grp_type__kv_ary;
if (Type_adp_.Eq(type, Keyval[].class)) return Grp_type__kv_ary;
else if (Type_adp_.Is_array(type)) return Grp_type__obj_ary;
else if (Type_adp_.Eq(type, Json_nde.class)) return Grp_type__json_nde;
else if (Type_adp_.Eq(type, Json_ary.class)) return Grp_type__json_ary;

View File

@@ -84,9 +84,9 @@ public class Json_wtr_tst {
fxt.Wtr()
.Doc_nde_bgn()
.Ary_bgn("a0")
.Ary_itm_obj(KeyVal_.Ary
( KeyVal_.new_("k1", "v1")
, KeyVal_.new_("k2", "v2")
.Ary_itm_obj(Keyval_.Ary
( Keyval_.new_("k1", "v1")
, Keyval_.new_("k2", "v2")
))
.Ary_end()
.Doc_nde_end();

View File

@@ -135,4 +135,4 @@ class Php_srl_wtr {
public static void Indent(Bry_bfr bfr, int depth) {
if (depth > 0) bfr.Add_byte_repeat(Byte_ascii.Space, depth * 2); // indent
}
}
}

View File

@@ -20,18 +20,18 @@ import gplx.core.texts.*;
public class Php_srl_parser {
@gplx.Internal protected Php_srl_factory Factory() {return factory;} Php_srl_factory factory = new Php_srl_factory();
byte[] raw; int raw_len, pos;
public KeyVal[] Parse_as_kvs(byte[] raw) {
public Keyval[] Parse_as_kvs(byte[] raw) {
Php_srl_itm_ary root = Parse(raw);
return Xto_kv_ary(root);
}
KeyVal[] Xto_kv_ary(Php_srl_itm_ary ary) {
Keyval[] Xto_kv_ary(Php_srl_itm_ary ary) {
int len = ary.Subs_len();
KeyVal[] rv = new KeyVal[len];
Keyval[] rv = new Keyval[len];
for (int i = 0; i < len; i++)
rv[i] = Xto_kv(ary.Subs_get_at(i));
return rv;
}
KeyVal Xto_kv(Php_srl_itm_kv itm) {
Keyval Xto_kv(Php_srl_itm_kv itm) {
Php_srl_itm itm_key = itm.Key();
Object key = itm_key == null ? null : itm_key.Val();
Php_srl_itm itm_val = itm.Val();
@@ -48,7 +48,7 @@ public class Php_srl_parser {
val = itm_val.Val();
break;
}
return KeyVal_.obj_(key, val);
return Keyval_.obj_(key, val);
}
@gplx.Internal protected Php_srl_itm_ary Parse(byte[] raw) {
this.raw = raw; this.raw_len = raw.length; pos = 0;