mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.9.1.1
This commit is contained in:
parent
5fc4eb41ec
commit
2145f6382c
@ -37,7 +37,7 @@ public class Err extends RuntimeException {
|
||||
if (msgs_idx == msgs_len) {
|
||||
int new_len = msgs_len * 2;
|
||||
Err_msg[] new_ary = new Err_msg[new_len];
|
||||
Array_.CopyTo(msgs_ary, new_ary, 0);
|
||||
Array_.Copy_to(msgs_ary, new_ary, 0);
|
||||
this.msgs_ary = new_ary;
|
||||
this.msgs_len = new_len;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class Regx_adp__tst implements TfdsEqListItmStr {
|
||||
Regx_match match_(int bgn) {return match_(bgn, Int_.Min_value);}
|
||||
Regx_match match_(int bgn, int len) {return new Regx_match(true, bgn, bgn + len, Regx_group.Ary_empty);}
|
||||
void tst_Matches(String find, String input, Regx_match... expd) {
|
||||
List_adp expdList = Array_.XtoList(expd);
|
||||
List_adp expdList = Array_.To_list(expd);
|
||||
List_adp actlList = Regx_adp_.Find_all(input, find);
|
||||
Tfds.Eq_list(expdList, actlList, this);
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ public class Byte_ {
|
||||
catch (Exception e) {Err_.Noop(e); return or;}
|
||||
}
|
||||
public static byte By_int(int v) {return v > 127 ? (byte)(v - 256) : (byte)v;} // PERF?: (byte)(v & 0xff)
|
||||
public static int Xto_int(byte v) {return v < 0 ? (int)v + 256 : v;}
|
||||
public static String Xto_str(byte v) {return new Byte(v).toString();}
|
||||
public static int To_int(byte v) {return v < 0 ? (int)v + 256 : v;}
|
||||
public static String To_str(byte v) {return new Byte(v).toString();}
|
||||
public static boolean In(byte v, byte... ary) {
|
||||
for (byte itm : ary)
|
||||
if (v == itm) return true;
|
||||
|
@ -31,5 +31,5 @@ public class Byte__tst {
|
||||
tst_XtoInt( 128, 128);
|
||||
tst_XtoInt( 255, 255);
|
||||
tst_XtoInt( 256, 0);
|
||||
} void tst_XtoInt(int v, int expd) {Tfds.Eq(expd, Byte_.Xto_int((byte)v));} // WORKAROUND/JAVA: v is of type int b/c java promotes numbers to ints
|
||||
} void tst_XtoInt(int v, int expd) {Tfds.Eq(expd, Byte_.To_int((byte)v));} // WORKAROUND/JAVA: v is of type int b/c java promotes numbers to ints
|
||||
}
|
||||
|
@ -22,16 +22,9 @@ public class Array_ {
|
||||
public static Object cast(Object o) {return (Object)o;}
|
||||
public static void Sort(Object[] obj) {List_adp_sorter.new_().Sort(obj, obj.length);}
|
||||
public static void Sort(Object[] obj, gplx.lists.ComparerAble comparer) {List_adp_sorter.new_().Sort(obj, obj.length, true, comparer);}
|
||||
public static List_adp XtoList(Object ary) {
|
||||
int aryLen = Array_.Len(ary);
|
||||
List_adp rv = List_adp_.new_();
|
||||
for (int i = 0; i < aryLen; i++)
|
||||
rv.Add(Array_.Get(ary, i));
|
||||
return rv;
|
||||
}
|
||||
public static Object[] Insert(Object[] cur, Object[] add, int addPos) {
|
||||
int curLen = cur.length, addLen = add.length;
|
||||
Object[] rv = (Object[])Array_.Create(Array_.ComponentType(cur), curLen + addLen);
|
||||
Object[] rv = (Object[])Array_.Create(Array_.Component_type(cur), curLen + addLen);
|
||||
for (int i = 0; i < addPos; i++) // copy old up to addPos
|
||||
rv[i] = cur[i];
|
||||
for (int i = 0; i < addLen; i++) // insert add
|
||||
@ -40,9 +33,9 @@ public class Array_ {
|
||||
rv[i + addLen] = cur[i];
|
||||
return rv;
|
||||
}
|
||||
public static Object[] ReplaceInsert(Object[] cur, Object[] add, int curReplacePos, int addInsertPos) {
|
||||
public static Object[] Replace_insert(Object[] cur, Object[] add, int curReplacePos, int addInsertPos) {
|
||||
int curLen = cur.length, addLen = add.length; int newLen = addLen - addInsertPos;
|
||||
Object[] rv = (Object[])Array_.Create(Array_.ComponentType(cur), curLen + newLen);
|
||||
Object[] rv = (Object[])Array_.Create(Array_.Component_type(cur), curLen + newLen);
|
||||
for (int i = 0; i < curReplacePos; i++) // copy old up to curInsertPos; EX: curReplacePos=5, addInsertPos=2; copy up to element 3; 4, 5 are dropped
|
||||
rv[i] = cur[i];
|
||||
for (int i = 0; i < addLen; i++) // insert add
|
||||
@ -53,48 +46,72 @@ public class Array_ {
|
||||
}
|
||||
public static Object Resize_add_one(Object src, int src_len, Object new_obj) {
|
||||
Object rv = Resize(src, src_len + 1);
|
||||
Set(rv, src_len, new_obj);
|
||||
Set_at(rv, src_len, new_obj);
|
||||
return rv;
|
||||
}
|
||||
public static Object Resize(Object src, int trg_len) {
|
||||
Object trg = Create(ComponentType(src), trg_len);
|
||||
Object trg = Create(Component_type(src), trg_len);
|
||||
int src_len = Array.getLength(src);
|
||||
int copy_len = src_len > trg_len ? trg_len : src_len; // trg_len can either expand or shrink
|
||||
CopyTo(src, 0, trg, 0, copy_len);
|
||||
Copy_to(src, 0, trg, 0, copy_len);
|
||||
return trg;
|
||||
}
|
||||
public static List_adp To_list(Object ary) {
|
||||
int aryLen = Array_.Len(ary);
|
||||
List_adp rv = List_adp_.new_();
|
||||
for (int i = 0; i < aryLen; i++)
|
||||
rv.Add(Array_.Get_at(ary, i));
|
||||
return rv;
|
||||
}
|
||||
public static String To_str_nested_obj(Object o) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
To_str_nested_ary(bfr, (Object)o, 0);
|
||||
return bfr.Xto_str_and_clear();
|
||||
}
|
||||
private static void To_str_nested_ary(Bry_bfr bfr, Object ary, int indent) {
|
||||
int len = Len(ary);
|
||||
for (int i = 0; i < len; i++) {
|
||||
Object itm = Get_at(ary, i);
|
||||
if (itm != null && Type_adp_.Is_array(itm.getClass()))
|
||||
To_str_nested_ary(bfr, (Object)itm, indent + 1);
|
||||
else {
|
||||
if (indent > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);
|
||||
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(itm)).Add_byte_nl();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String To_str_obj(Object o) {return To_str((Object)o);}
|
||||
public static String To_str(Object ary) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
int ary_len = Len(ary);
|
||||
for (int i = 0; i < ary_len; i++)
|
||||
sb.Add_obj(Get(ary, i)).Add_char_nl();
|
||||
sb.Add_obj(Get_at(ary, i)).Add_char_nl();
|
||||
return sb.To_str();
|
||||
}
|
||||
public static int Len(Object ary) {return Array.getLength(ary);}
|
||||
public static final int LenAry(Object[] ary) {return ary == null ? 0 : ary.length;}
|
||||
public static Object Get_at(Object ary, int i) {return Array.get(ary, i); }
|
||||
public static final int Len_obj(Object[] ary) {return ary == null ? 0 : ary.length;}
|
||||
public static Object Get_at(Object ary, int i) {return Array.get(ary, i);}
|
||||
public static void Set_at(Object ary, int i, Object o) {Array.set(ary, i, o);}
|
||||
public static Object Create(Class<?> t, int count) {return Array.newInstance(t, count);}
|
||||
public static Object Get(Object ary, int i) {return Array.get(ary, i);}
|
||||
public static void Set(Object ary, int i, Object o) {Array.set(ary, i, o);}
|
||||
public static Object Expand(Object src, Object trg, int src_len) {
|
||||
try {System.arraycopy(src, 0, trg, 0, src_len);}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "core", "Array_.Expand failed", "src_len", src_len);}
|
||||
return trg;
|
||||
}
|
||||
public static void Copy(Object src, Object trg) {System.arraycopy(src, 0, trg, 0, Len(src));}
|
||||
public static void CopyTo(Object src, Object trg, int trgPos) {System.arraycopy(src, 0, trg, trgPos, Len(src));}
|
||||
public static void CopyTo(Object src, int srcBgn, Object trg, int trgBgn, int srcLen) {System.arraycopy(src, srcBgn, trg, trgBgn, srcLen);}
|
||||
public static Class<?> ComponentType(Object ary) {
|
||||
public static void Copy_to(Object src, Object trg, int trgPos) {System.arraycopy(src, 0, trg, trgPos, Len(src));}
|
||||
public static void Copy_to(Object src, int srcBgn, Object trg, int trgBgn, int srcLen) {System.arraycopy(src, srcBgn, trg, trgBgn, srcLen);}
|
||||
private static Class<?> Component_type(Object ary) {
|
||||
if (ary == null) throw Err_.new_null();
|
||||
return ary.getClass().getComponentType();
|
||||
}
|
||||
public static Object Resize_add(Object src, Object add) {
|
||||
int srcLen = Len(src);
|
||||
int trgLen = srcLen + Len(add);
|
||||
Object trg = Create(ComponentType(src), trgLen);
|
||||
Object trg = Create(Component_type(src), trgLen);
|
||||
Copy(src, trg);
|
||||
for (int i = srcLen; i < trgLen; i++)
|
||||
Set(trg, i, Get(add, i - srcLen));
|
||||
Set_at(trg, i, Get_at(add, i - srcLen));
|
||||
return trg;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class Array__tst {
|
||||
tst_ReplaceInsert(ary_obj(0, 1, 2, 4, 5) , ary_obj(1, 2, 3), 1, 2, ary_obj(0, 1, 2, 3, 4, 5));
|
||||
tst_ReplaceInsert(ary_obj(0, 1, 2, 3, 4, 5) , ary_obj(1, 2, 3), 1, 3, ary_obj(0, 1, 2, 3, 4, 5));
|
||||
tst_ReplaceInsert(ary_obj(0, 1, 9, 4, 5) , ary_obj(2, 3) , 2, 1, ary_obj(0, 1, 2, 3, 4, 5));
|
||||
} void tst_ReplaceInsert(Object[] cur, Object[] add, int curReplacePos, int addInsertPos, Object[] expd) {Tfds.Eq_ary(expd, Array_.ReplaceInsert(cur, add, curReplacePos, addInsertPos));}
|
||||
} void tst_ReplaceInsert(Object[] cur, Object[] add, int curReplacePos, int addInsertPos, Object[] expd) {Tfds.Eq_ary(expd, Array_.Replace_insert(cur, add, curReplacePos, addInsertPos));}
|
||||
Object[] ary_obj(Object... ary) {return ary;}
|
||||
int[] ary_(int... ary) {return ary;}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ public class String_ implements GfoInvkAble {
|
||||
public static String[] Split_lang(String s, char c) {return s.split(Character.toString(c));}
|
||||
|
||||
static String Format_do(String s, Object[] ary) {
|
||||
int aryLength = Array_.LenAry(ary); if (aryLength == 0) return s; // nothing to format
|
||||
int aryLength = Array_.Len_obj(ary); if (aryLength == 0) return s; // nothing to format
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
char bracketBgn = '{', bracketEnd = '}';
|
||||
String aryVal = null; char c, next;
|
||||
|
@ -606,7 +606,7 @@ public class Bry_ {
|
||||
else return new byte[] {b3};
|
||||
}
|
||||
public static boolean To_bool_by_int(byte[] ary) {
|
||||
int rv = To_int_or(ary, null, 0, ary.length, Int_.Min_value);
|
||||
int rv = To_int_or(ary, 0, ary.length, Int_.Min_value, Bool_.Y, null);
|
||||
switch (rv) {
|
||||
case 0: return false;
|
||||
case 1: return true;
|
||||
@ -615,15 +615,15 @@ public class Bry_ {
|
||||
}
|
||||
public static byte To_int_as_byte(byte[] ary, int bgn, int end, byte or) {return (byte)To_int_or(ary, bgn, end, or);}
|
||||
public static int To_int(byte[] ary) {
|
||||
int rv = To_int_or(ary, null, 0, ary.length, Int_.Min_value);
|
||||
int rv = To_int_or(ary, 0, ary.length, Int_.Min_value, Bool_.Y, null);
|
||||
if (rv == Int_.Min_value) throw Err_.new_wo_type("could not parse to int", "val", String_.new_u8(ary));
|
||||
return rv;
|
||||
}
|
||||
public static int To_int_or_neg1(byte[] ary) {return To_int_or(ary, null, 0, ary.length, -1);}
|
||||
public static int To_int_or(byte[] ary, int or) {return To_int_or(ary, null, 0, ary.length, or);}
|
||||
public static int To_int_or(byte[] ary, int bgn, int end, int or) {return To_int_or(ary, null, bgn, end, or);}
|
||||
public static int To_int_or(byte[] ary, byte[] ignore_ary, int or) {return To_int_or(ary, ignore_ary, 0, ary.length, or);}
|
||||
public static int To_int_or(byte[] ary, byte[] ignore_ary, int bgn, int end, int or) {
|
||||
public static int To_int_or_neg1(byte[] ary) {return To_int_or(ary, 0 , ary.length, -1, Bool_.Y, null);}
|
||||
public static int To_int_or(byte[] ary, int or) {return To_int_or(ary, 0 , ary.length, or, Bool_.Y, null);}
|
||||
public static int To_int_or(byte[] ary, int bgn, int end, int or) {return To_int_or(ary, bgn , end , or, Bool_.Y, null);}
|
||||
public static int To_int_or__strict(byte[] ary, int or) {return To_int_or(ary, 0 , ary.length, or, Bool_.N, null);}
|
||||
private static int To_int_or(byte[] ary, int bgn, int end, int or, boolean sign_is_valid, byte[] ignore_ary) {
|
||||
if ( ary == null
|
||||
|| end == bgn // null-len
|
||||
) return or;
|
||||
@ -637,44 +637,9 @@ public class Bry_ {
|
||||
multiple *= 10;
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
return i == bgn ? rv * -1 : or;
|
||||
return i == bgn && sign_is_valid ? rv * -1 : or;
|
||||
case Byte_ascii.Plus:
|
||||
return i == bgn ? rv : or;
|
||||
default:
|
||||
boolean invalid = true;
|
||||
if (ignore_ary != null) {
|
||||
int ignore_ary_len = ignore_ary.length;
|
||||
for (int j = 0; j < ignore_ary_len; j++) {
|
||||
if (b == ignore_ary[j]) {
|
||||
invalid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid) return or;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static long To_long_or(byte[] ary, long or) {return To_long_or(ary, null, 0, ary.length, or);}
|
||||
public static long To_long_or(byte[] ary, byte[] ignore_ary, int bgn, int end, long or) {
|
||||
if ( ary == null
|
||||
|| end == bgn // null-len
|
||||
) return or;
|
||||
long rv = 0, multiple = 1;
|
||||
for (int i = end - 1; i >= bgn; i--) { // -1 b/c end will always be next char; EX: {{{1}}}; bgn = 3, end = 4
|
||||
byte b = ary[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
rv += multiple * (b - Byte_ascii.Num_0);
|
||||
multiple *= 10;
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
return i == bgn ? rv * -1 : or;
|
||||
case Byte_ascii.Plus:
|
||||
return i == bgn ? rv : or;
|
||||
return i == bgn && sign_is_valid ? rv : or;
|
||||
default:
|
||||
boolean invalid = true;
|
||||
if (ignore_ary != null) {
|
||||
@ -741,6 +706,41 @@ public class Bry_ {
|
||||
}
|
||||
return To_int_or(ary, bgn, end_num, or);
|
||||
}
|
||||
public static long To_long_or(byte[] ary, long or) {return To_long_or(ary, null, 0, ary.length, or);}
|
||||
public static long To_long_or(byte[] ary, byte[] ignore_ary, int bgn, int end, long or) {
|
||||
if ( ary == null
|
||||
|| end == bgn // null-len
|
||||
) return or;
|
||||
long rv = 0, multiple = 1;
|
||||
for (int i = end - 1; i >= bgn; i--) { // -1 b/c end will always be next char; EX: {{{1}}}; bgn = 3, end = 4
|
||||
byte b = ary[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
rv += multiple * (b - Byte_ascii.Num_0);
|
||||
multiple *= 10;
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
return i == bgn ? rv * -1 : or;
|
||||
case Byte_ascii.Plus:
|
||||
return i == bgn ? rv : or;
|
||||
default:
|
||||
boolean invalid = true;
|
||||
if (ignore_ary != null) {
|
||||
int ignore_ary_len = ignore_ary.length;
|
||||
for (int j = 0; j < ignore_ary_len; j++) {
|
||||
if (b == ignore_ary[j]) {
|
||||
invalid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid) return or;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static double To_double(byte[] ary, int bgn, int end) {return Double_.parse(String_.new_u8(ary, bgn, end));}
|
||||
public static double To_double_or(byte[] bry, double or) {return Double_.parse_or(String_.new_u8(bry, 0, bry.length), or);}
|
||||
public static double To_double_or(byte[] ary, int bgn, int end, double or) {return Double_.parse_or(String_.new_u8(ary, bgn, end), or);}
|
||||
|
@ -83,7 +83,7 @@ public class Bry_bfr {
|
||||
int val_len = val.length;
|
||||
if (bfr_len + val_len > bfr_max) Resize((bfr_max + val_len) * 2);
|
||||
Bry_.Copy_by_pos(val, 0, val_len, bfr, bfr_len);
|
||||
// Array_.CopyTo(val, 0, bfr, bfr_len, val_len);
|
||||
// Array_.Copy_to(val, 0, bfr, bfr_len, val_len);
|
||||
bfr_len += val_len;
|
||||
return this;
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class Bry_bfr {
|
||||
if (len < 0) throw Err_.new_wo_type("negative len", "bgn", bgn, "end", end, "excerpt", String_.new_u8_by_len(val, bgn, bgn + 16)); // NOTE: check for invalid end < bgn, else difficult to debug errors later; DATE:2014-05-11
|
||||
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
|
||||
Bry_.Copy_by_pos(val, bgn, end, bfr, bfr_len);
|
||||
// Array_.CopyTo(val, bgn, bfr, bfr_len, len);
|
||||
// Array_.Copy_to(val, bgn, bfr, bfr_len, len);
|
||||
bfr_len += len;
|
||||
return this;
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class Bry_bfr {
|
||||
int len = src.bfr_len;
|
||||
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
|
||||
Bry_.Copy_by_pos(src.bfr, 0, len, bfr, bfr_len);
|
||||
// Array_.CopyTo(src.bfr, 0, bfr, bfr_len, len);
|
||||
// Array_.Copy_to(src.bfr, 0, bfr, bfr_len, len);
|
||||
bfr_len += len;
|
||||
return this;
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class Bry_bfr {
|
||||
}
|
||||
src_len = src_end - src_bgn;
|
||||
Bry_.Copy_by_pos(src.bfr, src_bgn, src_end, bfr, bfr_len);
|
||||
// Array_.CopyTo(src.bfr, src_bgn, bfr, bfr_len, src_len);
|
||||
// Array_.Copy_to(src.bfr, src_bgn, bfr, bfr_len, src_len);
|
||||
bfr_len += src_len;
|
||||
src.Clear();
|
||||
return this;
|
||||
|
@ -125,11 +125,11 @@ class Bry_bfr_mkr_mgr {
|
||||
private void Expand() {
|
||||
int new_max = ary_max == 0 ? 2 : ary_max * 2;
|
||||
Bry_bfr[] new_ary = new Bry_bfr[new_max];
|
||||
Array_.CopyTo(ary, 0, new_ary, 0, ary_max);
|
||||
Array_.Copy_to(ary, 0, new_ary, 0, ary_max);
|
||||
ary = new_ary;
|
||||
ary_max = new_max;
|
||||
int[] new_free = new int[ary_max];
|
||||
Array_.CopyTo(free, 0, new_free, 0, free_len);
|
||||
Array_.Copy_to(free, 0, new_free, 0, free_len);
|
||||
free = new_free;
|
||||
}
|
||||
// public void Rls(Bry_bfr v) {
|
||||
|
@ -58,7 +58,7 @@ public class List_adp_ {
|
||||
int ary_len = Array_.Len(ary);
|
||||
List_adp rv = size_(ary_len);
|
||||
for (int i = 0; i < ary_len; i++)
|
||||
rv.Add(Array_.Get(ary, i));
|
||||
rv.Add(Array_.Get_at(ary, i));
|
||||
return rv;
|
||||
}
|
||||
public static final int Capacity_initial = 8;
|
||||
|
@ -23,7 +23,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
public Object To_ary(Class<?> memberType) {
|
||||
Object rv = Array_.Create(memberType, count);
|
||||
for (int i = 0; i < count; i++)
|
||||
Array_.Set(rv, i, list[i]);
|
||||
Array_.Set_at(rv, i, list[i]);
|
||||
return rv;
|
||||
}
|
||||
public Object[] To_obj_ary() {
|
||||
@ -45,7 +45,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
return list[index];
|
||||
}
|
||||
protected void Add_base(Object o) {
|
||||
if (count == Array_.LenAry(list)) Resize_expand();
|
||||
if (count == Array_.Len_obj(list)) Resize_expand();
|
||||
list[count] = o;
|
||||
count++;
|
||||
}
|
||||
@ -64,9 +64,9 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
int newLen = count - delLen;
|
||||
Object[] newList = new Object[newLen];
|
||||
if (delBgn != 0) // copy elements < delBgn; skip if delBgn == 0
|
||||
Array_.CopyTo(list, 0, newList, 0, delBgn);
|
||||
Array_.Copy_to(list, 0, newList, 0, delBgn);
|
||||
if (delEnd != count -1 ) // copy elements > delEnd; skip if delEnd == lastIdx
|
||||
Array_.CopyTo(list, delEnd + 1, newList, delBgn, newLen - delBgn);
|
||||
Array_.Copy_to(list, delEnd + 1, newList, delBgn, newLen - delBgn);
|
||||
list = newList;
|
||||
count = list.length;
|
||||
}
|
||||
@ -93,7 +93,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
list[trg] = o;
|
||||
}
|
||||
protected void AddAt_base(int pos, Object o) {
|
||||
if (count + 1 >= Array_.LenAry(list)) Resize_expand();
|
||||
if (count + 1 >= Array_.Len_obj(list)) Resize_expand();
|
||||
for (int i = count; i > pos; i--)
|
||||
list[i] = list[i - 1];
|
||||
list[pos] = o;
|
||||
@ -156,7 +156,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
list[i] = (i == count - 1) ? null : list[i + 1];
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected int Capacity() {return Array_.LenAry(list);}
|
||||
@gplx.Internal protected int Capacity() {return Array_.Len_obj(list);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_len)) return count;
|
||||
else if (ctx.Match(k, Invk_get_at)) return Get_at(m.ReadInt("v"));
|
||||
|
@ -88,8 +88,8 @@ public class HashAlgo_tth192 implements HashAlgo {
|
||||
if (branchRv == null || branchRv.length != blockA.length + blockB.length + 1)
|
||||
branchRv = new byte[blockA.length + blockB.length + 1];
|
||||
branchRv[0] = 0x01; // branch hash mark.
|
||||
Array_.CopyTo(blockA, branchRv, 1);
|
||||
Array_.CopyTo(blockB, branchRv, blockA.length + 1);
|
||||
Array_.Copy_to(blockA, branchRv, 1);
|
||||
Array_.Copy_to(blockB, branchRv, blockA.length + 1);
|
||||
return CalcHash(branchRv);
|
||||
}
|
||||
byte[] CalcHash_leaf(byte[] raw, int i) {
|
||||
@ -109,7 +109,7 @@ public class HashAlgo_tth192 implements HashAlgo {
|
||||
}
|
||||
|
||||
rv[0] = 0x00; // leaf hash mark.
|
||||
Array_.CopyTo(raw, rv, 1);
|
||||
Array_.Copy_to(raw, rv, 1);
|
||||
return CalcHash(rv);
|
||||
}
|
||||
byte[] CalcHash(byte[] raw) {
|
||||
|
@ -84,17 +84,17 @@ public class XmlFileSplitter {
|
||||
}
|
||||
public byte[] SplitHdr(byte[] src, int findPos) {
|
||||
hdr = new byte[findPos];
|
||||
Array_.CopyTo(src, 0, hdr, 0, findPos);
|
||||
Array_.Copy_to(src, 0, hdr, 0, findPos);
|
||||
byte[] rv = new byte[src.length - findPos];
|
||||
Array_.CopyTo(src, findPos, rv, 0, rv.length);
|
||||
Array_.Copy_to(src, findPos, rv, 0, rv.length);
|
||||
return rv;
|
||||
}
|
||||
public byte[][] SplitRest(byte[] src, int findPos) {
|
||||
byte[][] rv = new byte[2][];
|
||||
rv[0] = new byte[findPos];
|
||||
Array_.CopyTo(src, 0, rv[0], 0, findPos);
|
||||
Array_.Copy_to(src, 0, rv[0], 0, findPos);
|
||||
rv[1] = new byte[src.length - findPos];
|
||||
Array_.CopyTo(src, findPos, rv[1], 0, rv[1].length);
|
||||
Array_.Copy_to(src, findPos, rv[1], 0, rv[1].length);
|
||||
return rv;
|
||||
}
|
||||
public int FindMatchPos(byte[] src, byte[][] wordAry) {return FindMatchPos(src, wordAry, true);}
|
||||
|
@ -33,7 +33,7 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
|
||||
public Db_stmt Val_byte(String k, byte v) {return Add_byte(Bool_.N, k, v);}
|
||||
public Db_stmt Val_byte(byte v) {return Add_byte(Bool_.N, Key_na, v);}
|
||||
private Db_stmt Add_byte(boolean where, String k, byte v) {
|
||||
try {Add(k, Byte_.Xto_str(v));} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to add value", "type", "byte", "val", v);}
|
||||
try {Add(k, Byte_.To_str(v));} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to add value", "type", "byte", "val", v);}
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_int(String k, int v) {return Add_int(Bool_.Y, k, v);}
|
||||
|
@ -39,7 +39,7 @@ public class Json_ary extends Json_itm_base implements Json_grp {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Json_itm[] new_subs = new Json_itm[subs_max];
|
||||
Array_.CopyTo(subs, 0, new_subs, 0, subs_len);
|
||||
Array_.Copy_to(subs, 0, new_subs, 0, subs_len);
|
||||
subs = new_subs;
|
||||
}
|
||||
subs[subs_len] = itm;
|
||||
|
@ -18,34 +18,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_doc {
|
||||
private final byte[][] tmp_qry_bry = new byte[1][];
|
||||
public void Ctor(byte[] src, Json_nde root) {this.src = src; this.root = root;}
|
||||
public void Ctor(byte[] src, Json_grp new_root) {
|
||||
this.src = src;
|
||||
this.root_grp = new_root;
|
||||
switch (root_grp.Tid()) {
|
||||
case Json_itm_.Tid__nde: this.root_ary = null; this.root_nde = (Json_nde)root_grp; break;
|
||||
case Json_itm_.Tid__ary: this.root_nde = null; this.root_ary = (Json_ary)root_grp; break;
|
||||
default: throw Err_.new_unhandled(root_grp.Tid());
|
||||
}
|
||||
}
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public Json_nde Root_nde() {return root;} private Json_nde root;
|
||||
public Json_grp Root_grp() {return root_grp;} private Json_grp root_grp;
|
||||
public Json_nde Root_nde() {return root_nde;} private Json_nde root_nde;
|
||||
public Json_ary Root_ary() {return root_ary;} private Json_ary root_ary;
|
||||
public Bry_bfr Bfr() {return bfr;} private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
public Number_parser Utl_num_parser() {return utl_num_parser;} private final Number_parser utl_num_parser = new Number_parser();
|
||||
public byte[] Tmp_u8_bry() {return tmp_u8_bry;} private final byte[] tmp_u8_bry = new byte[6]; // tmp bry[] for decoding sequences like \u0008
|
||||
public byte[] Get_val_as_bry_or(byte[] qry_bry, byte[] or) {tmp_qry_bry[0] = qry_bry; return Get_val_as_bry_or(tmp_qry_bry, or);}
|
||||
public byte[] Get_val_as_bry_or(byte[][] qry_bry, byte[] or) {
|
||||
Json_itm nde = Find_nde(root, qry_bry, qry_bry.length - 1, 0);
|
||||
Json_itm nde = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0);
|
||||
return nde == null || nde.Tid() != Json_itm_.Tid__str ? or : nde.Data_bry();
|
||||
}
|
||||
public String Get_val_as_str_or(byte[] qry_bry, String or) {tmp_qry_bry[0] = qry_bry; return Get_val_as_str_or(tmp_qry_bry, or);}
|
||||
public String Get_val_as_str_or(byte[][] qry_bry, String or) {
|
||||
Json_itm nde = Find_nde(root, qry_bry, qry_bry.length - 1, 0);
|
||||
Json_itm nde = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0);
|
||||
return nde == null || nde.Tid() != Json_itm_.Tid__str ? or : (String)nde.Data();
|
||||
}
|
||||
public Json_grp Get_grp(byte[] qry_bry) {
|
||||
tmp_qry_bry[0] = qry_bry;
|
||||
Json_itm rv = Find_nde(root, tmp_qry_bry, 0, 0); if (rv == null) return null;
|
||||
Json_itm rv = Find_nde(root_nde, tmp_qry_bry, 0, 0); if (rv == null) return null;
|
||||
return (Json_grp)rv;
|
||||
}
|
||||
public Json_grp Get_grp(byte[][] qry_bry) {
|
||||
Json_itm rv = Find_nde(root, qry_bry, qry_bry.length - 1, 0); if (rv == null) return null;
|
||||
Json_itm rv = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0); if (rv == null) return null;
|
||||
return (Json_grp)rv;
|
||||
}
|
||||
public Json_itm Find_nde(byte[] key) {
|
||||
tmp_qry_bry[0] = key;
|
||||
return Find_nde(root, tmp_qry_bry, 0, 0);
|
||||
return Find_nde(root_nde, tmp_qry_bry, 0, 0);
|
||||
}
|
||||
private Json_itm Find_nde(Json_nde owner, byte[][] paths, int paths_last, int paths_idx) {
|
||||
byte[] path = paths[paths_idx];
|
||||
@ -59,4 +69,5 @@ public class Json_doc {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String Make_str_by_apos(String... ary) {return String_.Replace(String_.Concat_lines_nl_skip_last(ary), "'", "\"");}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Json_itm[] new_subs = new Json_itm[subs_max];
|
||||
Array_.CopyTo(subs, 0, new_subs, 0, subs_len);
|
||||
Array_.Copy_to(subs, 0, new_subs, 0, subs_len);
|
||||
subs = new_subs;
|
||||
}
|
||||
subs[subs_len] = (Json_itm)itm;
|
||||
|
@ -36,8 +36,11 @@ public class Json_parser {
|
||||
}
|
||||
Skip_ws();
|
||||
Json_doc doc = new Json_doc();
|
||||
Json_nde root = Make_nde(doc);
|
||||
if (root_is_nde) {}
|
||||
Json_grp root = null;
|
||||
if (root_is_nde)
|
||||
root = Make_nde(doc);
|
||||
else
|
||||
root = Make_ary(doc);
|
||||
doc.Ctor(src, root);
|
||||
return doc;
|
||||
}
|
||||
|
74
400_xowa/src/gplx/core/json/Json_parser__itm__base.java
Normal file
74
400_xowa/src/gplx/core/json/Json_parser__itm__base.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.json; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.primitives.*;
|
||||
public abstract class Json_parser__itm__base {
|
||||
protected String context;
|
||||
protected final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
protected final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
protected String[] keys;
|
||||
protected Json_kv[] atrs;
|
||||
protected Json_itm cur_itm;
|
||||
protected int keys_len;
|
||||
public void Ctor(String... keys) {
|
||||
this.keys = keys;
|
||||
this.keys_len = keys.length;
|
||||
for (int i = 0; i < keys_len; ++i)
|
||||
hash.Add(Bry_.new_u8(keys[i]), Int_obj_val.new_(i));
|
||||
this.atrs = new Json_kv[keys_len];
|
||||
}
|
||||
public int Kv__int(Json_kv[] ary, int i) {return Bry_.To_int(ary[i].Val_as_bry());}
|
||||
public long Kv__long(Json_kv[] ary, int i) {return Bry_.To_long_or(ary[i].Val_as_bry(), 0);}
|
||||
public long Kv__long_or_0(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return 0;
|
||||
return Bry_.To_long_or(kv.Val_as_bry(), 0);
|
||||
}
|
||||
public byte[] Kv__bry(Json_kv[] ary, int i) {
|
||||
byte[] rv = Kv__bry_or_null(ary, i); if (rv == null) throw Err_.new_("json.parser", "missing val", "key", context + "." + keys[i], "excerpt", Json_itm_.To_bry(tmp_bfr, cur_itm));
|
||||
return rv;
|
||||
}
|
||||
public byte[][] Kv__bry_ary(Json_kv[] ary, int i) {
|
||||
return ary[i].Val_as_ary().Xto_bry_ary();
|
||||
}
|
||||
public byte[] Kv__bry_or_empty(Json_kv[] ary, int i) {
|
||||
byte[] rv = Kv__bry_or_null(ary, i);
|
||||
return rv == null ? Bry_.Empty : rv;
|
||||
}
|
||||
public byte[] Kv__bry_or_null(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return null;
|
||||
Json_itm val = kv.Val();
|
||||
return kv == null ? null : val.Data_bry();
|
||||
}
|
||||
public boolean Kv__mw_bool(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return false;
|
||||
Json_itm val = kv.Val();
|
||||
if ( val.Tid() == Json_itm_.Tid__str
|
||||
&& Bry_.Len_eq_0(val.Data_bry())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Warn("unknown val: val=" + String_.new_u8(kv.Data_bry()) + " excerpt=" + String_.new_u8(Json_itm_.To_bry(tmp_bfr, cur_itm)), kv);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean Kv__has(Json_kv[] ary, int i) {return Kv__bry_or_empty(ary, i) != null;}
|
||||
protected abstract void Parse_hook_nde(Json_nde sub, Json_kv[] atrs);
|
||||
protected void Warn(String msg, Json_kv kv) {
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", msg + ": path=~{0}.~{1} excerpt=~{2}", context, kv.Key_as_bry(), Json_itm_.To_bry(tmp_bfr, cur_itm));
|
||||
}
|
||||
}
|
70
400_xowa/src/gplx/core/json/Json_parser__list_nde__base.java
Normal file
70
400_xowa/src/gplx/core/json/Json_parser__list_nde__base.java
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.json; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Json_parser__list_nde__base extends Json_parser__itm__base {
|
||||
public void Parse_grp(String context, Json_grp grp) {
|
||||
this.context = context;
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = null;
|
||||
if (grp.Tid() == Json_itm_.Tid__nde) {
|
||||
Json_kv kv = Json_nde.cast(grp).Get_at_as_kv(i);
|
||||
sub = kv.Val_as_nde();
|
||||
}
|
||||
else {
|
||||
sub = Json_nde.cast(grp.Get_at(i));
|
||||
}
|
||||
Parse_nde(context, sub);
|
||||
}
|
||||
}
|
||||
public void Parse_nde(String context, Json_nde nde) {
|
||||
this.cur_itm = nde;
|
||||
for (int j = 0; j < keys_len; ++j)
|
||||
atrs[j] = null;
|
||||
int atr_len = nde.Len();
|
||||
for (int j = 0; j < atr_len; ++j) {
|
||||
Json_kv atr = nde.Get_at_as_kv(j);
|
||||
Object idx_obj = hash.Get_by_bry(atr.Key_as_bry());
|
||||
if (idx_obj == null) {Warn("unknown key", atr); continue;}
|
||||
int idx_int = ((Int_obj_val)idx_obj).Val();
|
||||
atrs[idx_int] = atr;
|
||||
}
|
||||
Parse_hook_nde(nde, atrs);
|
||||
}
|
||||
public void Parse_to_list_as_bry(String context, Json_ary ary, Ordered_hash list) {
|
||||
this.cur_itm = ary;
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] val = ary.Get_at(i).Data_bry();
|
||||
list.Add(val, val);
|
||||
}
|
||||
}
|
||||
public void Parse_to_list_as_kv(String context, Json_nde nde, Ordered_hash list) {
|
||||
this.cur_itm = nde;
|
||||
int len = nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
@gplx.Virtual protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
|
||||
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {}
|
||||
}
|
@ -40,6 +40,7 @@ public class Json_parser_tst {
|
||||
@Test public void Subs_empty() {fxt.Test_parse("{'k0':{}}", fxt.itm_nde_().Add_many(fxt.itm_kv_("k0", fxt.itm_nde_())));}
|
||||
@Test public void Subs_ws() {fxt.Test_parse("{'k0': { 'k00' : 1 } }", fxt.itm_nde_().Add_many(fxt.itm_kv_("k0", fxt.itm_nde_().Add_many(fxt.itm_kv_("k00", 1)))));}
|
||||
@Test public void Ws() {fxt.Test_parse(" { 'k0' : 'v0' } ", fxt.itm_nde_().Add_many(fxt.itm_kv_("k0", "v0")));}
|
||||
@Test public void Root_is_ary() {fxt.Test_parse("[ 1 , 2 , 3 ]", fxt.itm_ary_().Add_many(fxt.itm_int_(1), fxt.itm_int_(2), fxt.itm_int_(3)));}
|
||||
public static String Replace_apos_as_str(String v) {return String_.new_u8(Replace_apos(Bry_.new_u8(v)));}
|
||||
public static byte[] Replace_apos(byte[] v) {return Bry_.Replace(v, Byte_ascii.Apos, Byte_ascii.Quote);}
|
||||
}
|
||||
@ -50,10 +51,10 @@ class Json_parser_fxt {
|
||||
factory = parser.Factory();
|
||||
}
|
||||
} Json_parser parser; Json_factory factory; Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
Json_itm itm_int_(int v) {return Json_itm_tmp.new_int_(v);}
|
||||
Json_itm itm_str_(String v) {return Json_itm_tmp.new_str_(v);}
|
||||
public Json_itm itm_int_(int v) {return Json_itm_tmp.new_int_(v);}
|
||||
Json_itm itm_str_(String v) {return Json_itm_tmp.new_str_(v);}
|
||||
public Json_ary itm_ary_() {return factory.Ary(-1, -1);}
|
||||
public Json_nde itm_nde_() {return factory.Nde(null, -1);}
|
||||
public Json_nde itm_nde_() {return factory.Nde(null, -1);}
|
||||
public Json_kv itm_kv_null_(String k) {return factory.Kv(itm_str_(k), factory.Null());}
|
||||
public Json_kv itm_kv_(String k, String v) {return factory.Kv(itm_str_(k), itm_str_(v));}
|
||||
public Json_kv itm_kv_(String k, int v) {return factory.Kv(itm_str_(k), itm_int_(v));}
|
||||
@ -77,7 +78,7 @@ class Json_parser_fxt {
|
||||
public void Test_parse(String raw_str, Json_itm... expd_ary) {
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
|
||||
Json_doc doc = parser.Parse(raw);
|
||||
doc.Root_nde().Print_as_json(tmp_bfr, 0);
|
||||
doc.Root_grp().Print_as_json(tmp_bfr, 0);
|
||||
String actl = tmp_bfr.Xto_str_and_clear();
|
||||
String expd = Xto_str(raw, doc, expd_ary, 0, expd_ary.length);
|
||||
Tfds.Eq_str_lines(expd, actl, actl);
|
||||
|
@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_wtr {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(255);
|
||||
private final Int_ary idx_stack = new Int_ary(4);
|
||||
private int idx = 0;
|
||||
private int indent;
|
||||
private boolean nde_itm_is_first;
|
||||
private boolean ary_itm_is_first;
|
||||
public Bry_bfr Bfr() {return bfr;}
|
||||
public void Indent_(int v) {this.indent = v;}
|
||||
public byte Opt_quote_byte() {return opt_quote_byte;} public Json_wtr Opt_quote_byte_(byte v) {opt_quote_byte = v; return this;} private byte opt_quote_byte = Byte_ascii.Quote;
|
||||
@ -28,38 +28,49 @@ public class Json_wtr {
|
||||
public byte[] To_bry_and_clear() {return bfr.Xto_bry_and_clear();}
|
||||
public String To_str_and_clear() {return bfr.Xto_str_and_clear();}
|
||||
public Json_wtr Clear() {
|
||||
indent = 0;
|
||||
nde_itm_is_first = ary_itm_is_first = true;
|
||||
indent = -1;
|
||||
idx_stack.Clear();
|
||||
idx = 0;
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Doc_bgn() {return Add_grp_bgn(Sym_nde_bgn);}
|
||||
public Json_wtr Doc_end() {Add_grp_end(Bool_.Y, Sym_nde_end); return Add_nl();}
|
||||
public Json_wtr Doc_nde_bgn() {return Write_grp_bgn(Sym_nde_bgn);}
|
||||
public Json_wtr Doc_nde_end() {Write_grp_end(Bool_.Y, Sym_nde_end); return Write_nl();}
|
||||
public Json_wtr Doc_ary_bgn() {return Write_grp_bgn(Sym_ary_bgn);}
|
||||
public Json_wtr Doc_ary_end() {Write_grp_end(Bool_.N, Sym_ary_end); return Write_nl();}
|
||||
public Json_wtr Nde_bgn(String key) {return Nde_bgn(Bry_.new_u8(key));}
|
||||
public Json_wtr Nde_bgn(byte[] key) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(key);
|
||||
Add_nl();
|
||||
return Add_grp_bgn(Sym_nde_bgn);
|
||||
Write_indent_itm();
|
||||
Write_key(key);
|
||||
Write_nl();
|
||||
return Write_grp_bgn(Sym_nde_bgn);
|
||||
}
|
||||
public Json_wtr Nde_end() {
|
||||
Write_grp_end(Bool_.Y, Sym_nde_end);
|
||||
return Write_nl();
|
||||
}
|
||||
public Json_wtr Nde_end() {Add_grp_end(Bool_.Y, Sym_nde_end); return Add_nl();}
|
||||
public Json_wtr Ary_bgn(String nde) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(Bry_.new_u8(nde));
|
||||
Add_nl();
|
||||
ary_itm_is_first = true;
|
||||
return Add_grp_bgn(Sym_ary_bgn);
|
||||
Write_indent_itm();
|
||||
Write_key(Bry_.new_u8(nde));
|
||||
return Ary_bgn_keyless();
|
||||
}
|
||||
private Json_wtr Ary_bgn_keyless() {
|
||||
Write_nl();
|
||||
return Write_grp_bgn(Sym_ary_bgn);
|
||||
}
|
||||
public Json_wtr Ary_itm_str(String itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__str, itm);}
|
||||
public Json_wtr Ary_itm_bry(byte[] itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__bry, itm);}
|
||||
public Json_wtr Ary_itm_obj(Object itm) {return Ary_itm_by_type_tid(Type_adp_.To_tid_obj(itm), itm);}
|
||||
public Json_wtr Ary_itm_by_type_tid(int itm_type_tid, Object itm) {
|
||||
Add_indent_itm(ary_itm_is_first);
|
||||
Add_itm_by_tid(itm_type_tid, itm);
|
||||
Add_nl();
|
||||
ary_itm_is_first = false;
|
||||
Write_indent_itm();
|
||||
Write_val_obj(itm_type_tid, itm);
|
||||
Write_nl();
|
||||
++idx;
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Ary_end() {Add_grp_end(Bool_.N, Sym_ary_end); return Add_nl();}
|
||||
public Json_wtr Ary_end() {
|
||||
Write_grp_end(Bool_.N, Sym_ary_end);
|
||||
return Write_nl();
|
||||
}
|
||||
public Json_wtr Kv_bool(String key, boolean val) {return Kv_bool(Bry_.new_u8(key), val);}
|
||||
public Json_wtr Kv_bool(byte[] key, boolean val) {return Kv_raw(key, val ? Bool_.True_bry : Bool_.False_bry);}
|
||||
public Json_wtr Kv_int(String key, int val) {return Kv_raw(Bry_.new_u8(key), Int_.Xto_bry(val));}
|
||||
@ -67,83 +78,111 @@ public class Json_wtr {
|
||||
public Json_wtr Kv_float(String key, float val) {return Kv_raw(Bry_.new_u8(key), Bry_.new_a7(Float_.Xto_str(val)));}
|
||||
public Json_wtr Kv_double(String key, double val) {return Kv_raw(Bry_.new_u8(key), Bry_.new_a7(Double_.Xto_str(val)));}
|
||||
private Json_wtr Kv_raw(byte[] key, byte[] val) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(key);
|
||||
Write_indent_itm();
|
||||
Write_key(key);
|
||||
bfr.Add(val);
|
||||
Add_nl();
|
||||
nde_itm_is_first = false;
|
||||
Write_nl();
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Kv_str(String key, String val) {return Kv_bry(Bry_.new_u8(key), Bry_.new_u8(val));}
|
||||
public Json_wtr Kv_str(byte[] key, String val) {return Kv_bry(key, Bry_.new_u8(val));}
|
||||
public Json_wtr Kv_bry(String key, byte[] val) {return Kv_bry(Bry_.new_u8(key), val);}
|
||||
public Json_wtr Kv_bry(byte[] key, byte[] val) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(key);
|
||||
Add_itm_bry(val);
|
||||
Add_nl();
|
||||
nde_itm_is_first = false;
|
||||
Write_indent_itm();
|
||||
Write_key(key);
|
||||
Write_str(val);
|
||||
Write_nl();
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Kv_obj(byte[] key, Object val, int val_tid) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(key);
|
||||
Add_itm_by_tid(val_tid, val);
|
||||
Add_nl();
|
||||
nde_itm_is_first = false;
|
||||
Write_indent_itm();
|
||||
Write_key(key);
|
||||
Write_val_obj(val_tid, val);
|
||||
Write_nl();
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Kv_bfr(String key, Bry_bfr val) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(Bry_.new_u8(key));
|
||||
Add_itm_bry(val.Bfr(), 0, val.Len());
|
||||
Add_nl();
|
||||
nde_itm_is_first = false;
|
||||
val.Clear();
|
||||
return this;
|
||||
}
|
||||
private Json_wtr Add_grp_bgn(byte[] grp_sym) {
|
||||
Add_indent(0);
|
||||
bfr.Add(grp_sym);
|
||||
private Json_wtr Write_grp_bgn(byte[] grp_sym) {return Write_grp_bgn(grp_sym, Bool_.Y);}
|
||||
private Json_wtr Write_grp_bgn(byte[] grp_sym, boolean write_indent) {
|
||||
idx_stack.Add(idx);
|
||||
idx = 0;
|
||||
++indent;
|
||||
nde_itm_is_first = true;
|
||||
return this;
|
||||
}
|
||||
private Json_wtr Add_grp_end(boolean grp_is_nde, byte[] grp_sym) {
|
||||
--indent;
|
||||
if ((grp_is_nde && nde_itm_is_first) || (!grp_is_nde && ary_itm_is_first))
|
||||
Add_nl();
|
||||
Add_indent(0);
|
||||
nde_itm_is_first = false;
|
||||
if (write_indent) Write_indent();
|
||||
bfr.Add(grp_sym);
|
||||
return this;
|
||||
}
|
||||
private Json_wtr Add_key(byte[] bry) {
|
||||
Add_itm_bry(bry);
|
||||
bfr.Add_byte_colon();
|
||||
private Json_wtr Write_grp_end(boolean grp_is_nde, byte[] grp_sym) {
|
||||
if ((grp_is_nde && idx == 0) || (!grp_is_nde && idx == 0))
|
||||
Write_nl();
|
||||
Write_indent();
|
||||
--indent;
|
||||
bfr.Add(grp_sym);
|
||||
this.idx = idx_stack.Pop_or(0);
|
||||
return this;
|
||||
}
|
||||
private void Add_itm_by_tid(int type_tid, Object obj) {
|
||||
private Json_wtr Write_key(byte[] bry) {
|
||||
Write_str(bry); // "key"
|
||||
bfr.Add_byte_colon(); // ":"
|
||||
++idx;
|
||||
return this;
|
||||
}
|
||||
private void Write_val_obj(int type_tid, Object obj) {
|
||||
switch (type_tid) {
|
||||
case Type_adp_.Tid__null: bfr.Add(Object_.Bry__null); break;
|
||||
case Type_adp_.Tid__bool: bfr.Add_bool(Bool_.cast(obj)); break;
|
||||
case Type_adp_.Tid__byte: bfr.Add_byte(Byte_.cast(obj)); break;
|
||||
case Type_adp_.Tid__int: bfr.Add_int_variable(Int_.cast(obj)); break;
|
||||
case Type_adp_.Tid__long: bfr.Add_long_variable(Long_.cast(obj)); break;
|
||||
case Type_adp_.Tid__float: bfr.Add_float(Float_.cast(obj)); break;
|
||||
case Type_adp_.Tid__double: bfr.Add_double(Double_.cast(obj)); break;
|
||||
case Type_adp_.Tid__str: Add_itm_bry(Bry_.new_u8((String)obj)); break;
|
||||
case Type_adp_.Tid__bry: Add_itm_bry((byte[])obj); break;
|
||||
case Type_adp_.Tid__str: Write_str(Bry_.new_u8((String)obj)); break;
|
||||
case Type_adp_.Tid__bry: Write_str((byte[])obj); break;
|
||||
case Type_adp_.Tid__char:
|
||||
case Type_adp_.Tid__date:
|
||||
case Type_adp_.Tid__decimal: Add_itm_bry(Bry_.new_u8(Object_.Xto_str_strict_or_empty(obj))); break;
|
||||
case Type_adp_.Tid__null:
|
||||
case Type_adp_.Tid__decimal: Write_str(Bry_.new_u8(Object_.Xto_str_strict_or_empty(obj))); break;
|
||||
case Type_adp_.Tid__obj:
|
||||
Class<?> type = obj.getClass();
|
||||
if (Type_adp_.Eq(type, KeyVal[].class)) {
|
||||
if (idx == 0) { // if nde, and first item, then put on new line
|
||||
bfr.Del_by_1();
|
||||
if (opt_ws) {
|
||||
bfr.Add_byte_nl();
|
||||
++indent;
|
||||
Write_indent();
|
||||
--indent;
|
||||
}
|
||||
}
|
||||
KeyVal[] kvy = (KeyVal[])obj;
|
||||
Write_grp_bgn(Sym_nde_bgn, Bool_.N);
|
||||
int kvy_len = kvy.length;
|
||||
for (int i = 0; i < kvy_len; ++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));
|
||||
}
|
||||
Write_grp_end(Bool_.Y, Sym_nde_end);
|
||||
}
|
||||
else if (Type_adp_.Is_array(type))
|
||||
Write_val_ary(obj);
|
||||
else
|
||||
throw Err_.new_unhandled(type);
|
||||
break;
|
||||
default: throw Err_.new_unhandled(type_tid);
|
||||
}
|
||||
}
|
||||
private void Add_itm_bry(byte[] bry) {Add_itm_bry(bry, 0, bry.length);}
|
||||
private void Add_itm_bry(byte[] bry, int bgn, int end) {
|
||||
private void Write_val_ary(Object ary_obj) {
|
||||
Ary_bgn_keyless();
|
||||
Object ary = Array_.cast(ary_obj);
|
||||
int len = Array_.Len(ary);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object itm = Array_.Get_at(ary, i);
|
||||
Ary_itm_obj(itm);
|
||||
}
|
||||
Write_grp_end(Bool_.N, Sym_ary_end);
|
||||
}
|
||||
private void Write_str(byte[] bry) {
|
||||
int len = bry.length;
|
||||
bfr.Add_byte(opt_quote_byte);
|
||||
for (int i = bgn; i < end; i++) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte b = bry[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Backslash: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(b); break; // "\" -> "\\"; needed else js will usurp \ as escape; EX: "\&" -> "&"; DATE:2014-06-24
|
||||
@ -156,30 +195,30 @@ public class Json_wtr {
|
||||
}
|
||||
bfr.Add_byte(opt_quote_byte);
|
||||
}
|
||||
private void Add_indent_itm(boolean v) {
|
||||
if (v) {
|
||||
bfr.Add_byte_space();
|
||||
private void Write_indent_itm() {
|
||||
if (idx == 0) {
|
||||
if (opt_ws)
|
||||
bfr.Add_byte_space();
|
||||
}
|
||||
else {
|
||||
Add_indent(-1);
|
||||
Write_indent();
|
||||
bfr.Add(Sym_itm_spr);
|
||||
if (opt_ws) bfr.Add_byte_space();
|
||||
}
|
||||
}
|
||||
private Json_wtr Add_nl() {
|
||||
if (opt_ws)
|
||||
bfr.Add_byte_nl();
|
||||
return this;
|
||||
private void Write_indent() {
|
||||
if (opt_ws && indent > 0)
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);
|
||||
}
|
||||
private void Add_indent(int adj) {
|
||||
int level = indent + adj;
|
||||
if (opt_ws && level > 0)
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, level * 2);
|
||||
private Json_wtr Write_nl() {
|
||||
if (opt_ws) bfr.Add_byte_nl();
|
||||
return this;
|
||||
}
|
||||
private static final byte[]
|
||||
Sym_nde_bgn = Bry_.new_a7("{")
|
||||
, Sym_nde_end = Bry_.new_a7("}")
|
||||
, Sym_ary_bgn = Bry_.new_a7("[")
|
||||
, Sym_ary_end = Bry_.new_a7("]")
|
||||
, Sym_itm_spr = Bry_.new_a7(", ")
|
||||
, Sym_itm_spr = Bry_.new_a7(",")
|
||||
;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import org.junit.*;
|
||||
public class Json_wtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Json_wtr_fxt fxt = new Json_wtr_fxt();
|
||||
@Test public void Root() {
|
||||
fxt.Wtr().Doc_bgn().Doc_end();
|
||||
fxt.Wtr().Doc_nde_bgn().Doc_nde_end();
|
||||
fxt.Test
|
||||
( "{"
|
||||
, "}"
|
||||
@ -28,10 +28,10 @@ public class Json_wtr_tst {
|
||||
}
|
||||
@Test public void Kv() {
|
||||
fxt.Wtr()
|
||||
.Doc_bgn()
|
||||
.Doc_nde_bgn()
|
||||
.Kv_str("k0", "v0")
|
||||
.Kv_str("k1", "v1")
|
||||
.Doc_end();
|
||||
.Doc_nde_end();
|
||||
fxt.Test
|
||||
( "{ 'k0':'v0'"
|
||||
, ", 'k1':'v1'"
|
||||
@ -40,7 +40,7 @@ public class Json_wtr_tst {
|
||||
}
|
||||
@Test public void Nde() {
|
||||
fxt.Wtr()
|
||||
.Doc_bgn()
|
||||
.Doc_nde_bgn()
|
||||
.Nde_bgn("s0")
|
||||
.Nde_bgn("s00")
|
||||
.Nde_end()
|
||||
@ -49,7 +49,7 @@ public class Json_wtr_tst {
|
||||
.Nde_bgn("s10")
|
||||
.Nde_end()
|
||||
.Nde_end()
|
||||
.Doc_end();
|
||||
.Doc_nde_end();
|
||||
fxt.Test
|
||||
( "{ 's0':"
|
||||
, " { 's00':"
|
||||
@ -66,12 +66,12 @@ public class Json_wtr_tst {
|
||||
}
|
||||
@Test public void Ary() {
|
||||
fxt.Wtr()
|
||||
.Doc_bgn()
|
||||
.Doc_nde_bgn()
|
||||
.Ary_bgn("a0")
|
||||
.Ary_itm_str("v0")
|
||||
.Ary_itm_str("v1")
|
||||
.Ary_end()
|
||||
.Doc_end();
|
||||
.Doc_nde_end();
|
||||
fxt.Test
|
||||
( "{ 'a0':"
|
||||
, " [ 'v0'"
|
||||
@ -80,6 +80,26 @@ public class Json_wtr_tst {
|
||||
, "}"
|
||||
);
|
||||
}
|
||||
@Test public void Nde__nested() {
|
||||
fxt.Wtr()
|
||||
.Doc_nde_bgn()
|
||||
.Ary_bgn("a0")
|
||||
.Ary_itm_obj(KeyVal_.Ary
|
||||
( KeyVal_.new_("k1", "v1")
|
||||
, KeyVal_.new_("k2", "v2")
|
||||
))
|
||||
.Ary_end()
|
||||
.Doc_nde_end();
|
||||
fxt.Test
|
||||
( "{ 'a0':"
|
||||
, " ["
|
||||
, " { 'k1':'v1'"
|
||||
, " , 'k2':'v2'"
|
||||
, " }"
|
||||
, " ]"
|
||||
, "}"
|
||||
);
|
||||
}
|
||||
}
|
||||
class Json_wtr_fxt {
|
||||
private final Json_wtr wtr = new Json_wtr().Opt_quote_byte_(Byte_ascii.Apos);
|
||||
|
@ -17,12 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
public class Server_socket_adp__base implements Server_socket_adp {
|
||||
private ServerSocket server_socket;
|
||||
public Server_socket_adp Ctor(int port) {
|
||||
try {this.server_socket = new ServerSocket(port);}
|
||||
try {
|
||||
this.server_socket = new ServerSocket();
|
||||
server_socket.setReuseAddress(true);
|
||||
server_socket.bind(new InetSocketAddress(port));
|
||||
}
|
||||
catch (IOException e) {throw Err_.new_exc(e, "net", "Get_input_stream failed");}
|
||||
return this;
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ public class Db_cfg_itm {
|
||||
public static Db_cfg_itm new_int (String grp, String key, int val) {return new Db_cfg_itm(grp , key, Int_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_long (String key, long val) {return new Db_cfg_itm(Grp_none , key, Long_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_long (String grp, String key, long val) {return new Db_cfg_itm(grp , key, Long_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_byte (String key, byte val) {return new Db_cfg_itm(Grp_none , key, Byte_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_byte (String grp, String key, byte val) {return new Db_cfg_itm(grp , key, Byte_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_byte (String key, byte val) {return new Db_cfg_itm(Grp_none , key, Byte_.To_str(val));}
|
||||
public static Db_cfg_itm new_byte (String grp, String key, byte val) {return new Db_cfg_itm(grp , key, Byte_.To_str(val));}
|
||||
public static Db_cfg_itm new_yn (String key, boolean val) {return new Db_cfg_itm(Grp_none , key, Yn.Xto_str(val));}
|
||||
public static Db_cfg_itm new_yn (String grp, String key, boolean val) {return new Db_cfg_itm(grp , key, Yn.Xto_str(val));}
|
||||
public static Db_cfg_itm new_DateAdp (String key, DateAdp val) {return new Db_cfg_itm(Grp_none , key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
|
@ -39,7 +39,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
public void Delete_grp(String grp) {conn.Stmt_delete(tbl_name, fld_grp).Crt_str(fld_grp, grp).Exec_delete();}
|
||||
public void Delete_all() {conn.Stmt_delete(tbl_name, Db_meta_fld.Ary_empty).Exec_delete();}
|
||||
public void Insert_yn (String grp, String key, boolean val) {Insert_str(grp, key, val ? "y" : "n");}
|
||||
public void Insert_byte (String grp, String key, byte val) {Insert_str(grp, key, Byte_.Xto_str(val));}
|
||||
public void Insert_byte (String grp, String key, byte val) {Insert_str(grp, key, Byte_.To_str(val));}
|
||||
public void Insert_int (String grp, String key, int val) {Insert_str(grp, key, Int_.Xto_str(val));}
|
||||
public void Insert_long (String grp, String key, long val) {Insert_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Insert_date (String grp, String key, DateAdp val) {Insert_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
@ -52,7 +52,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
} catch (Exception e) {throw Err_.new_exc(e, "db", "db_cfg.insert failed", "grp", grp, "key", key, "val", val, "db", conn.Conn_info().Xto_api());}
|
||||
}
|
||||
public void Update_yn (String grp, String key, boolean val) {Update_str(grp, key, val ? "y" : "n");}
|
||||
public void Update_byte (String grp, String key, byte val) {Update_str(grp, key, Byte_.Xto_str(val));}
|
||||
public void Update_byte (String grp, String key, byte val) {Update_str(grp, key, Byte_.To_str(val));}
|
||||
public void Update_int (String grp, String key, int val) {Update_str(grp, key, Int_.Xto_str(val));}
|
||||
public void Update_long (String grp, String key, long val) {Update_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Update_date (String grp, String key, DateAdp val) {Update_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
|
@ -40,7 +40,7 @@ public class Gfs_nde {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Gfs_nde[] new_subs = new Gfs_nde[subs_max];
|
||||
Array_.CopyTo(subs, 0, new_subs, 0, subs_len);
|
||||
Array_.Copy_to(subs, 0, new_subs, 0, subs_len);
|
||||
subs = new_subs;
|
||||
}
|
||||
subs[subs_len] = nde;
|
||||
@ -67,7 +67,7 @@ public class Gfs_nde {
|
||||
if (new_len > args_max) { // ary too small >>> expand
|
||||
args_max = new_len * 2;
|
||||
Gfs_nde[] new_args = new Gfs_nde[args_max];
|
||||
Array_.CopyTo(args, 0, new_args, 0, args_len);
|
||||
Array_.Copy_to(args, 0, new_args, 0, args_len);
|
||||
args = new_args;
|
||||
}
|
||||
args[args_len] = nde;
|
||||
|
@ -28,7 +28,7 @@ public class Php_itm_ary implements Php_itm, Php_itm_sub {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Php_itm_sub[] new_ary = new Php_itm_sub[subs_max];
|
||||
Array_.CopyTo(ary, 0, new_ary, 0, subs_len);
|
||||
Array_.Copy_to(ary, 0, new_ary, 0, subs_len);
|
||||
ary = new_ary;
|
||||
}
|
||||
ary[subs_len] = v;
|
||||
|
@ -100,7 +100,7 @@ class Php_srl_itm_ary extends Php_srl_itm_base {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Php_srl_itm_kv[] new_subs = new Php_srl_itm_kv[subs_max];
|
||||
Array_.CopyTo(subs, 0, new_subs, 0, subs_len);
|
||||
Array_.Copy_to(subs, 0, new_subs, 0, subs_len);
|
||||
subs = new_subs;
|
||||
}
|
||||
subs[subs_len] = itm;
|
||||
|
@ -23,7 +23,7 @@ public interface Php_tkn {
|
||||
}
|
||||
class Php_tkn_ {
|
||||
public static final byte Tid_txt = 1, Tid_declaration = 2, Tid_ws = 3, Tid_comment = 4, Tid_var = 5, Tid_eq = 6, Tid_eq_kv = 7, Tid_semic = 8, Tid_comma = 9, Tid_paren_bgn = 10, Tid_paren_end = 11, Tid_null = 12, Tid_false = 13, Tid_true = 14, Tid_ary = 15, Tid_num = 16, Tid_quote = 17, Tid_brack_bgn = 18, Tid_brack_end = 19;
|
||||
public static String Xto_str(byte tid) {return Byte_.Xto_str(tid);}
|
||||
public static String Xto_str(byte tid) {return Byte_.To_str(tid);}
|
||||
}
|
||||
abstract class Php_tkn_base implements Php_tkn {
|
||||
public abstract byte Tkn_tid();
|
||||
|
@ -58,7 +58,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.8.5.1";
|
||||
public static final String Version = "2.9.1.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
@ -70,7 +70,7 @@ public class Xob_orig_regy_update_bmk_mgr implements GfoInvkAble {
|
||||
}
|
||||
public void Save() {
|
||||
if (repo_enable && repo_dirty) {
|
||||
Save(Cfg_repo_prv, Byte_.Xto_str(repo_prv));
|
||||
Save(Cfg_repo_prv, Byte_.To_str(repo_prv));
|
||||
repo_dirty = false;
|
||||
}
|
||||
if (ns_enable && ns_dirty) {
|
||||
|
@ -51,7 +51,7 @@ public class Xob_orig_regy_update_cmd extends Xob_itm_basic_base implements Xob_
|
||||
String sql = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lnki_ttl"
|
||||
, "FROM orig_regy"
|
||||
, "WHERE lnki_repo >= '" + Byte_.Xto_str(prv_repo_id) + "'"
|
||||
, "WHERE lnki_repo >= '" + Byte_.To_str(prv_repo_id) + "'"
|
||||
, "AND lnki_ttl > '" + prv_ttl + "'"
|
||||
, "AND oimg_orig_page_id = -1;"
|
||||
);
|
||||
|
@ -66,9 +66,9 @@ public class Xob_xfer_update_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
, ", cur.lnki_count"
|
||||
, ", CASE"
|
||||
, " WHEN old.lnki_ttl IS NULL THEN" // not in old table; mark todo
|
||||
, " " + Byte_.Xto_str(Xob_xfer_regy_tbl.Status_todo)
|
||||
, " " + Byte_.To_str(Xob_xfer_regy_tbl.Status_todo)
|
||||
, " ELSE" // in old table; mark processed
|
||||
, " " + Byte_.Xto_str(Xob_xfer_regy_tbl.Status_ignore_processed)
|
||||
, " " + Byte_.To_str(Xob_xfer_regy_tbl.Status_ignore_processed)
|
||||
, " END"
|
||||
, ", cur.xfer_bin_tid"
|
||||
, ", cur.xfer_bin_msg"
|
||||
|
@ -420,6 +420,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_xnde_tag_.Tid_math:
|
||||
case Xop_xnde_tag_.Tid_indicator:
|
||||
case Xop_xnde_tag_.Tid_xowa_html:
|
||||
case Xop_xnde_tag_.Tid_graph:
|
||||
Xox_xnde xtn = xnde.Xnde_xtn();
|
||||
xtn.Xtn_write(bfr, app, ctx, this, hctx, xnde, src);
|
||||
break;
|
||||
|
@ -58,7 +58,7 @@ public class Bridge_msg_bldr {
|
||||
}
|
||||
private void Bld_json() {
|
||||
wtr.Clear();
|
||||
wtr.Doc_bgn();
|
||||
wtr.Doc_nde_bgn();
|
||||
wtr.Nde_bgn(Key_rslt);
|
||||
wtr.Kv_bool(Key_rslt_pass, rslt_pass);
|
||||
if (rslt_msg != null) wtr.Kv_str(Key_rslt_msg, rslt_msg);
|
||||
@ -72,7 +72,7 @@ public class Bridge_msg_bldr {
|
||||
wtr.Nde_end();
|
||||
}
|
||||
Bld_json_for_hash(wtr, data_root);
|
||||
wtr.Doc_end();
|
||||
wtr.Doc_nde_end();
|
||||
}
|
||||
private void Bld_json_for_hash(Json_wtr wtr, Gfo_tree_list hash) {
|
||||
int len = hash.Len(); if (len == 0) return;
|
||||
|
@ -21,7 +21,7 @@ public class Bridge_msg_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Bridge_msg_bldr_fxt fxt = new Bridge_msg_bldr_fxt();
|
||||
@Test public void Bld() {
|
||||
fxt.Bldr().Rslt_pass_y_().Notify_pass_("passed").Data("key1", true).Data("key2", 1).Data("key3", "val3");
|
||||
fxt.Test_to_json_str("{ 'rslt':{ 'pass':true}, 'notify':{ 'text':'passed', 'status':'success'}, 'data':{ 'key1':true, 'key2':1, 'key3':'val3'}}");
|
||||
fxt.Test_to_json_str("{'rslt':{'pass':true},'notify':{'text':'passed','status':'success'},'data':{'key1':true,'key2':1,'key3':'val3'}}");
|
||||
}
|
||||
}
|
||||
class Bridge_msg_bldr_fxt {
|
||||
|
@ -22,6 +22,7 @@ public class Xoh_head_itm_ {
|
||||
, Key__css = Bry_.new_a7("css")
|
||||
, Key__gallery = Bry_.new_a7("gallery")
|
||||
, Key__globals = Bry_.new_a7("globals")
|
||||
, Key__graph = Bry_.new_a7("graph")
|
||||
, Key__hiero = Bry_.new_a7("hiero")
|
||||
, Key__mathjax = Bry_.new_a7("mathjax")
|
||||
, Key__navframe = Bry_.new_a7("navframe")
|
||||
|
44
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__graph.java
Normal file
44
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__graph.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__graph extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__graph;}
|
||||
@Override public int Flags() {return Flag__js_include | Flag__js_window_onload;}
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url__ary == null) {
|
||||
Io_url lib_dir = app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("Graph", "lib");
|
||||
Url__ary = new byte[][]
|
||||
{ app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("html", "res", "lib", "jquery", "jquery-1.11.3.min.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.layout.cloud.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("topojson.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("vega.js").To_http_file_bry()
|
||||
, app.Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("Graph", "js", "graph.js").To_http_file_bry()
|
||||
};
|
||||
}
|
||||
for (int i = 0; i < Url__ary_len; ++i)
|
||||
wtr.Write_js_include(Url__ary[i]);
|
||||
}
|
||||
@Override public void Write_js_window_onload(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_line(Js__graph_exec);
|
||||
}
|
||||
private static final int Url__ary_len = 6;
|
||||
private static byte[][] Url__ary;
|
||||
private static final byte[] Js__graph_exec = Bry_.new_a7("xtn__graph__exec();");
|
||||
}
|
@ -31,7 +31,7 @@ public class Xoh_head_mgr implements Bry_fmtr_arg {
|
||||
;
|
||||
public Xoh_head_mgr() {
|
||||
Itms_add(itm__css, itm__globals, itm__server, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery
|
||||
, itm__mathjax, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
|
||||
, itm__mathjax, itm__graph, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
|
||||
, itm__dbui
|
||||
);
|
||||
}
|
||||
@ -42,13 +42,14 @@ public class Xoh_head_mgr implements Bry_fmtr_arg {
|
||||
public Xoh_head_itm__toc Itm__toc() {return itm__toc;} private final Xoh_head_itm__toc itm__toc = new Xoh_head_itm__toc();
|
||||
public Xoh_head_itm__collapsible Itm__collapsible() {return itm__collapsible;} private final Xoh_head_itm__collapsible itm__collapsible = new Xoh_head_itm__collapsible();
|
||||
public Xoh_head_itm__navframe Itm__navframe() {return itm__navframe;} private final Xoh_head_itm__navframe itm__navframe = new Xoh_head_itm__navframe();
|
||||
public Xoh_head_itm__top_icon Itm__top_icon() {return itm__top_icon;} private final Xoh_head_itm__top_icon itm__top_icon = new Xoh_head_itm__top_icon();
|
||||
public Xoh_head_itm__gallery Itm__gallery() {return itm__gallery;} private final Xoh_head_itm__gallery itm__gallery = new Xoh_head_itm__gallery();
|
||||
public Xoh_head_itm__title_rewrite Itm__title_rewrite() {return itm__title_rewrite;} private final Xoh_head_itm__title_rewrite itm__title_rewrite = new Xoh_head_itm__title_rewrite();
|
||||
public Xoh_head_itm__mathjax Itm__mathjax() {return itm__mathjax;} private final Xoh_head_itm__mathjax itm__mathjax = new Xoh_head_itm__mathjax();
|
||||
public Xoh_head_itm__hiero Itm__hiero() {return itm__hiero;} private final Xoh_head_itm__hiero itm__hiero = new Xoh_head_itm__hiero();
|
||||
public Xoh_head_itm__top_icon Itm__top_icon() {return itm__top_icon;} private final Xoh_head_itm__top_icon itm__top_icon = new Xoh_head_itm__top_icon();
|
||||
public Xoh_head_itm__search_suggest Itm__search_suggest() {return itm__search_suggest;} private final Xoh_head_itm__search_suggest itm__search_suggest = new Xoh_head_itm__search_suggest();
|
||||
public Xoh_head_itm__graph Itm__graph() {return itm__graph;} private final Xoh_head_itm__graph itm__graph = new Xoh_head_itm__graph();
|
||||
public Xoh_head_itm__timeline Itm__timeline() {return itm__timeline;} private final Xoh_head_itm__timeline itm__timeline = new Xoh_head_itm__timeline();
|
||||
public Xoh_head_itm__title_rewrite Itm__title_rewrite() {return itm__title_rewrite;} private final Xoh_head_itm__title_rewrite itm__title_rewrite = new Xoh_head_itm__title_rewrite();
|
||||
public Xoh_head_itm__search_suggest Itm__search_suggest() {return itm__search_suggest;} private final Xoh_head_itm__search_suggest itm__search_suggest = new Xoh_head_itm__search_suggest();
|
||||
public Xoh_head_itm__dbui Itm__dbui() {return itm__dbui;} private final Xoh_head_itm__dbui itm__dbui = new Xoh_head_itm__dbui();
|
||||
public Xoh_head_mgr Init(Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
|
||||
this.app = app; this.wiki = wiki; this.page = page;
|
||||
@ -157,10 +158,10 @@ public class Xoh_head_mgr implements Bry_fmtr_arg {
|
||||
int flag = itms[i].Flags();
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__css_include)) list__css_include.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__css_text)) list__css_text.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_window_onload)) list__js_window_onload.Add(itm);
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,6 @@ public class Xol_func_name_regy {
|
||||
int len = end - bgn;
|
||||
if (len > lower_ary_len) {lower_ary = new byte[len]; lower_ary_len = len;}
|
||||
lower_ary_len = len;
|
||||
Array_.CopyTo(src, bgn, lower_ary, 0, len);
|
||||
Array_.Copy_to(src, bgn, lower_ary, 0, len);
|
||||
} byte[] lower_ary = new byte[255]; int lower_ary_len = 255;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Xol_case_mgr_fxt {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Xol_case_itm itm = ary[i];
|
||||
sb.Add(Byte_.Xto_str(itm.Tid())).Add_char_pipe().Add(String_.new_u8(itm.Src_ary())).Add_char_pipe().Add(String_.new_u8(itm.Trg_ary())).Add_char_nl();
|
||||
sb.Add(Byte_.To_str(itm.Tid())).Add_char_pipe().Add(String_.new_u8(itm.Src_ary())).Add_char_pipe().Add(String_.new_u8(itm.Trg_ary())).Add_char_nl();
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class Xopg_html_data {
|
||||
public int Xtn_imap_next_id() {return ++xtn_imap_next_id;} private int xtn_imap_next_id; // NOTE: must keep separate imap_id b/c html_elem_id is not always set;
|
||||
public byte[] Xtn_search_text() {return xtn_search_txt;} public void Xtn_search_text_(byte[] v) {xtn_search_txt = v;} private byte[] xtn_search_txt = Bry_.Empty;
|
||||
public byte[] Xtn_scribunto_dbg() {return xtn_scribunto_dbg;} public void Xtn_scribunto_dbg_(byte[] v) {xtn_scribunto_dbg = Bry_.Add(xtn_scribunto_dbg, v);} private byte[] xtn_scribunto_dbg = Bry_.Empty;
|
||||
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
|
||||
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
|
||||
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
|
||||
public byte[] Custom_name() {return custom_name;} public Xopg_html_data Custom_name_(byte[] v) {custom_name = v; return this;} private byte[] custom_name;
|
||||
public byte[] Custom_head_end() {return custom_head_end;}
|
||||
|
@ -28,7 +28,7 @@ public class Xopg_tmpl_prepend_mgr {
|
||||
if (new_len > stack_max) {
|
||||
stack_max += 8;
|
||||
Bry_bfr[] new_stack = new Bry_bfr[stack_max];
|
||||
Array_.CopyTo(stack, new_stack, 0);
|
||||
Array_.Copy_to(stack, new_stack, 0);
|
||||
stack = new_stack;
|
||||
}
|
||||
stack[stack_len] = bfr;
|
||||
|
@ -69,5 +69,6 @@ public class Xop_log_basic_wkr implements GfoInvkAble {
|
||||
, Tid_score = 4
|
||||
, Tid_hiero = 5
|
||||
, Tid_math = 6
|
||||
, Tid_graph = 7
|
||||
;
|
||||
}
|
||||
|
@ -27,8 +27,10 @@ public class Socket_rdr {
|
||||
public Socket_rdr Open() {
|
||||
try {
|
||||
// this.Rls();
|
||||
if (server == null)
|
||||
if (server == null) {
|
||||
server = new java.net.ServerSocket(port);
|
||||
server.setReuseAddress(true);
|
||||
}
|
||||
client = server.accept();
|
||||
client.setSoTimeout(10000);
|
||||
stream = client.getInputStream();
|
||||
|
@ -27,7 +27,7 @@ public class Xosrv_msg_rdr {
|
||||
if (bytes_read == -1) return Xosrv_msg.Exit; // stream closed; should only occur when shutting down
|
||||
else return Xosrv_msg.fail_("header is invalid; hdr:{0}", String_.new_u8(header_bry, 0, bytes_read));
|
||||
}
|
||||
byte version = header_bry[0]; if (version != Byte_ascii.Num_0) return Xosrv_msg.fail_("version must be 0; version:{0}", Byte_.Xto_str(version));
|
||||
byte version = header_bry[0]; if (version != Byte_ascii.Num_0) return Xosrv_msg.fail_("version must be 0; version:{0}", Byte_.To_str(version));
|
||||
int body_len = Bry_.To_int_or(header_bry, 2, 12, -1); if (body_len == -1) return Xosrv_msg.fail_("body_len is not number; body_len:{0}", String_.new_u8(header_bry, 2, 23));
|
||||
int cksum = Bry_.To_int_or(header_bry, 13, 23, -1); if (cksum == -1) return Xosrv_msg.fail_("checksum is not number; cksum:{0}", String_.new_u8(header_bry, 13, 23));
|
||||
if (!Chk_bytes(header_bry, Byte_ascii.Pipe, 1, 12, 23)) return Xosrv_msg.fail_("message should be delimited by pipes at 1, 12 and 23; message:{0}", String_.new_u8(header_bry, 0, 24));
|
||||
|
@ -108,7 +108,7 @@ class Wmf_dump_list_parser_fxt {
|
||||
private Wmf_dump_list_parser parser = new Wmf_dump_list_parser();
|
||||
public String itm(String wiki_abrv, String dump_date, byte status_done, String status_msg, String status_time) {
|
||||
return String_.Concat_with_str("\n", wiki_abrv, dump_date
|
||||
, Byte_.Xto_str(status_done)
|
||||
, Byte_.To_str(status_done)
|
||||
, status_msg
|
||||
, status_time
|
||||
);
|
||||
@ -128,7 +128,7 @@ class Wmf_dump_list_parser_fxt {
|
||||
DateAdp status_time = itm.Status_time();
|
||||
String status_time_str = status_time == null ? "" : status_time.XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time);
|
||||
return String_.Concat_with_str("\n", String_.new_a7(itm.Wiki_abrv()), itm.Dump_date().XtoStr_fmt("yyyyMMdd")
|
||||
, Byte_.Xto_str(itm.Status_tid())
|
||||
, Byte_.To_str(itm.Status_tid())
|
||||
, String_.new_a7(itm.Status_msg())
|
||||
, status_time_str
|
||||
);
|
||||
|
@ -105,7 +105,7 @@ class Xop_statistics_stats_ns_itm implements Bry_fmtr_arg {
|
||||
class Xop_statistics_stats_wiki_grp implements Bry_fmtr_arg {
|
||||
public void Wiki_(Xowe_wiki v) {this.wiki = v;} private Xowe_wiki wiki;
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
fmtr_wiki.Bld_bfr_many(bfr, wiki.Db_mgr().Tid_name(), wiki.Fsys_mgr().Root_dir().Raw(), Byte_.Xto_str(wiki.Db_mgr().Category_version()), wiki.Maint_mgr().Wiki_dump_date().XtoStr_fmt_iso_8561());
|
||||
fmtr_wiki.Bld_bfr_many(bfr, wiki.Db_mgr().Tid_name(), wiki.Fsys_mgr().Root_dir().Raw(), Byte_.To_str(wiki.Db_mgr().Category_version()), wiki.Maint_mgr().Wiki_dump_date().XtoStr_fmt_iso_8561());
|
||||
}
|
||||
private Bry_fmtr fmtr_wiki = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
|
@ -16,17 +16,59 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wmfs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.xowa.wmfs.*;
|
||||
interface Xowm_update_meta_wkr {
|
||||
void Fetch_meta(Ordered_hash hash, int bgn, int end);
|
||||
}
|
||||
interface Xowm_update_text_wkr {
|
||||
void Fetch_text(Ordered_hash hash, int bgn, int end);
|
||||
}
|
||||
class Xowm_update_meta_wkr__xo {
|
||||
public void Fetch_meta(Ordered_hash hash, int bgn, int end) {
|
||||
// for (int i = bgn; i < end; ++i) {
|
||||
// Xowm_rev_itm itm = (Xowm_rev_itm)hash.Get_at(i);
|
||||
// if (i != bgn) tmp_bfr.Add_byte(Byte_ascii.Pipe);
|
||||
// tmp_bfr.Add(itm.Ttl().Full_db());
|
||||
// }
|
||||
}
|
||||
}
|
||||
class Xowm_updater {
|
||||
public void Exec(byte[][] ttls_bry) {
|
||||
/*
|
||||
Xoa_ttl[] ttls_ary = Parse_ttl();
|
||||
loop (50) {
|
||||
Xowm_rev_meta_itm[] trg_revs = Get_trg_revs();
|
||||
Xowm_rev_meta_itm[] src_revs = api.Get_src_metas();
|
||||
Eliminate(src_rev, trg_revs);
|
||||
src_texts = api.Get_src_texts();
|
||||
overwrite_trgs();
|
||||
private final Ordered_hash trgs_hash = Ordered_hash_.new_bry_(), srcs_hash = Ordered_hash_.new_bry_();
|
||||
private final List_adp del_list = List_adp_.new_();
|
||||
public int Batch_size() {return batch_size;} public void Batch_size_(int v) {batch_size = v;} private int batch_size = 50;
|
||||
public Xowm_update_meta_wkr Wkr__trg_meta() {return wkr__trg_meta;} private Xowm_update_meta_wkr wkr__trg_meta;
|
||||
public Xowm_update_meta_wkr Wkr__src_meta() {return wkr__src_meta;} private Xowm_update_meta_wkr wkr__src_meta;
|
||||
public Xowm_update_text_wkr Wkr__trg_text() {return wkr__trg_text;} private Xowm_update_text_wkr wkr__trg_text;
|
||||
public void Init(Xowm_update_meta_wkr wkr__trg_meta, Xowm_update_meta_wkr wkr__src_meta, Xowm_update_text_wkr wkr__trg_text) {
|
||||
this.wkr__trg_meta = wkr__trg_meta;
|
||||
this.wkr__src_meta = wkr__src_meta;
|
||||
this.wkr__trg_text = wkr__trg_text;
|
||||
}
|
||||
public void Exec(Xoa_ttl[] ttls_ary) {
|
||||
synchronized (trgs_hash) {
|
||||
Build_itms(trgs_hash, ttls_ary);
|
||||
Build_itms(srcs_hash, ttls_ary);
|
||||
int len = trgs_hash.Count();
|
||||
for (int i = 0; i < len; i += batch_size)
|
||||
Exec_batch(i, len);
|
||||
}
|
||||
}
|
||||
private void Build_itms(Ordered_hash hash, Xoa_ttl[] ttls_ary) {
|
||||
int len = ttls_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_ttl ttl = ttls_ary[i];
|
||||
byte[] key = ttl.Full_db();
|
||||
if (hash.Has(key)) continue; // ignore dupes
|
||||
hash.Add(key, new Xowm_rev_itm(ttl));
|
||||
}
|
||||
}
|
||||
private void Exec_batch(int itms_bgn, int itms_len) {
|
||||
int itms_end = itms_bgn + batch_size; if (itms_end > itms_len) itms_end = itms_len;
|
||||
wkr__trg_meta.Fetch_meta(trgs_hash, itms_bgn, itms_end);
|
||||
wkr__src_meta.Fetch_meta(srcs_hash, itms_bgn, itms_end);
|
||||
Remove_unchanged(srcs_hash, trgs_hash, itms_bgn, itms_end);
|
||||
wkr__trg_text.Fetch_text(trgs_hash, itms_bgn, itms_end);
|
||||
/*
|
||||
loop (changed texts) {
|
||||
parse page
|
||||
}
|
||||
@ -40,9 +82,25 @@ class Xowm_updater {
|
||||
}
|
||||
*/
|
||||
}
|
||||
private void Remove_unchanged(Ordered_hash trg_hash, Ordered_hash src_hash, int bgn, int end) {
|
||||
del_list.Clear();
|
||||
for (int i = bgn; i < end; ++i) {
|
||||
Xowm_rev_itm trg_itm = (Xowm_rev_itm)trg_hash.Get_at(i);
|
||||
byte[] trg_key = trg_itm.Ttl().Full_db();
|
||||
Xowm_rev_itm src_itm = (Xowm_rev_itm)src_hash.Get_by(trg_key);
|
||||
if (src_itm == null) continue; // itm not found; ignore
|
||||
if (trg_itm.Eq_meta(src_itm)) // itm is same; add to deleted list
|
||||
del_list.Add(trg_itm);
|
||||
}
|
||||
int len = del_list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xowm_rev_itm itm = (Xowm_rev_itm)del_list.Get_at(i);
|
||||
trg_hash.Del(itm.Ttl().Full_db());
|
||||
}
|
||||
}
|
||||
}
|
||||
class Xowm_rev_meta_api__wm {
|
||||
public Xowm_rev_meta_itm[] Get(Gfo_usr_dlg usr_dlg, Xowmf_mgr wmf_mgr, Xow_wmf_api_mgr api_mgr, String domain_str, Xoa_ttl[] ttls_ary) {
|
||||
public Xowm_rev_itm[] Get(Gfo_usr_dlg usr_dlg, Xowmf_mgr wmf_mgr, Xow_wmf_api_mgr api_mgr, String domain_str, Xoa_ttl[] ttls_ary) {
|
||||
byte[] ttls_bry = To_api_arg(ttls_ary);
|
||||
byte[] json = api_mgr.Api_exec(usr_dlg, wmf_mgr, domain_str, "action=query&prop=revisions&rvprop=size|ids|timestamp&format=jsonfm&titles=" + String_.new_u8(ttls_bry));
|
||||
return Parse(json);
|
||||
@ -50,22 +108,31 @@ class Xowm_rev_meta_api__wm {
|
||||
private byte[] To_api_arg(Xoa_ttl[] ttls_ary) {
|
||||
return null;
|
||||
}
|
||||
private Xowm_rev_meta_itm[] Parse(byte[] json) {
|
||||
private Xowm_rev_itm[] Parse(byte[] json) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class Xowm_rev_meta_itm {
|
||||
public Xowm_rev_meta_itm(int page_id, int ns_id, byte[] ttl, int rev_id, int rev_len, byte[] rev_time, byte[] rev_user, byte[] rev_note) {
|
||||
this.page_id = page_id; this.ns_id = ns_id; this.ttl = ttl;
|
||||
this.rev_id = rev_id; this.rev_len = rev_len; this.rev_time = rev_time;
|
||||
class Xowm_rev_itm {
|
||||
public Xowm_rev_itm(Xoa_ttl ttl) {
|
||||
this.ttl = ttl;
|
||||
}
|
||||
public Xoa_ttl Ttl() {return ttl;} private final Xoa_ttl ttl;
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public int Rev_id() {return rev_id;} private int rev_id;
|
||||
public int Rev_len() {return rev_len;} private int rev_len;
|
||||
public byte[] Rev_time() {return rev_time;} private byte[] rev_time;
|
||||
public byte[] Rev_text() {return rev_text;} private byte[] rev_text;
|
||||
public byte[] Rev_user() {return rev_user;} private byte[] rev_user;
|
||||
public byte[] Rev_note() {return rev_note;} private byte[] rev_note;
|
||||
public void Init_meta(int page_id, int rev_id, int rev_len, byte[] rev_time, byte[] rev_user, byte[] rev_note) {
|
||||
this.page_id = page_id; this.rev_id = rev_id;
|
||||
this.rev_len = rev_len; this.rev_time = rev_time;
|
||||
this.rev_user = rev_user; this.rev_note = rev_note;
|
||||
}
|
||||
public int Page_id() {return page_id;} private final int page_id;
|
||||
public int Ns_id() {return ns_id;} private final int ns_id;
|
||||
public byte[] Ttl() {return ttl;} private final byte[] ttl;
|
||||
public int Rev_id() {return rev_id;} private final int rev_id;
|
||||
public int Rev_len() {return rev_len;} private final int rev_len;
|
||||
public byte[] Rev_time() {return rev_time;} private final byte[] rev_time;
|
||||
public byte[] Rev_user() {return rev_user;} private final byte[] rev_user;
|
||||
public byte[] Rev_note() {return rev_note;} private final byte[] rev_note;
|
||||
public void Init_text(byte[] rev_text) {
|
||||
this.rev_text = rev_text;
|
||||
}
|
||||
public boolean Eq_meta(Xowm_rev_itm comp) {
|
||||
return rev_len == comp.rev_len && Bry_.Eq(rev_time, comp.rev_time);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wmfs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.core.json.*;
|
||||
class Xowm_update_meta_wkr__wm {
|
||||
private final Json_parser json_parser = new Json_parser();
|
||||
private final Xowm_page_nde_parser nde_parser = new Xowm_page_nde_parser();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private final Xowm_rev_itm tmp_rev_itm = new Xowm_rev_itm(null);
|
||||
public void Fetch_meta(Ordered_hash hash, int bgn, int end) {
|
||||
for (int i = bgn; i < end; ++i) {
|
||||
Xowm_rev_itm itm = (Xowm_rev_itm)hash.Get_at(i);
|
||||
if (i != bgn) tmp_bfr.Add_byte(Byte_ascii.Pipe);
|
||||
tmp_bfr.Add(itm.Ttl().Full_db());
|
||||
}
|
||||
byte[] json = Get_json(tmp_bfr.Xto_bry_and_clear());
|
||||
Parse_doc(hash, json);
|
||||
}
|
||||
private byte[] Get_json(byte[] titles_arg) {
|
||||
return null;
|
||||
}
|
||||
private void Parse_doc(Ordered_hash hash, byte[] json) {
|
||||
Json_doc jdoc = json_parser.Parse(json);
|
||||
Json_nde pages_nde = Json_nde.cast(jdoc.Get_grp(Jpath__query_pages));
|
||||
int len = pages_nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Parse_page(hash, pages_nde.Get_at_as_kv(i).Val_as_nde());
|
||||
}
|
||||
}
|
||||
private void Parse_page(Ordered_hash hash, Json_nde page_nde) {
|
||||
nde_parser.Parse("update", tmp_rev_itm, page_nde);
|
||||
}
|
||||
private static final byte[][] Jpath__query_pages = Bry_.Ary("query", "pages");
|
||||
}
|
||||
class Xowm_page_nde_parser extends Json_parser__list_nde__base {
|
||||
private Xowm_rev_itm itm;
|
||||
private Xowm_rev_nde_parser rev_nde_parser = new Xowm_rev_nde_parser();
|
||||
private String nde_context;
|
||||
public Xowm_page_nde_parser() {
|
||||
this.Ctor("page_id", "ns", "title", "revisions");
|
||||
}
|
||||
public void Parse(String context, Xowm_rev_itm itm, Json_nde nde) {
|
||||
this.itm = itm;
|
||||
this.nde_context = context + ".page";
|
||||
this.Parse_nde(context, nde);
|
||||
}
|
||||
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {
|
||||
int page_id = Kv__int(atrs, 0);
|
||||
Json_ary revs_ary = atrs[3].Val_as_ary(); if (revs_ary.Len() == 0) throw Err_.new_("rev.parser", "no revisions found", sub.Doc().Src());
|
||||
Json_nde rev_nde = revs_ary.Get_at_as_nde(0);
|
||||
rev_nde_parser.Parse(nde_context, itm, rev_nde, page_id);
|
||||
}
|
||||
}
|
||||
class Xowm_rev_nde_parser extends Json_parser__list_nde__base {
|
||||
private Xowm_rev_itm itm; private int page_id;
|
||||
public Xowm_rev_nde_parser() {
|
||||
this.Ctor("revid", "parentid", "timestamp", "size", "contentformat", "contentmodel", "user", "comment", "*");
|
||||
}
|
||||
public void Parse(String context, Xowm_rev_itm itm, Json_nde nde, int page_id) {
|
||||
this.itm = itm; this.page_id = page_id;
|
||||
this.Parse_nde(context + ".rev", nde);
|
||||
}
|
||||
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {
|
||||
itm.Init_meta(page_id, Kv__int(atrs, 0), Kv__int(atrs, 3), Kv__bry(atrs, 2), Kv__bry(atrs, 5), Kv__bry(atrs, 6));
|
||||
}
|
||||
}
|
@ -17,112 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.json.*;
|
||||
abstract class Json_parser__base {
|
||||
protected String context;
|
||||
protected final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
protected final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
protected String[] keys;
|
||||
protected Json_kv[] atrs;
|
||||
protected Json_itm cur_itm;
|
||||
protected int keys_len;
|
||||
public void Ctor(String... keys) {
|
||||
this.keys = keys;
|
||||
this.keys_len = keys.length;
|
||||
for (int i = 0; i < keys_len; ++i)
|
||||
hash.Add(Bry_.new_u8(keys[i]), Int_obj_val.new_(i));
|
||||
this.atrs = new Json_kv[keys_len];
|
||||
}
|
||||
public int Kv__int(Json_kv[] ary, int i) {return Bry_.To_int(ary[i].Val_as_bry());}
|
||||
public long Kv__long(Json_kv[] ary, int i) {return Bry_.To_long_or(ary[i].Val_as_bry(), 0);}
|
||||
public long Kv__long_or_0(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return 0;
|
||||
return Bry_.To_long_or(kv.Val_as_bry(), 0);
|
||||
}
|
||||
public byte[] Kv__bry(Json_kv[] ary, int i) {
|
||||
byte[] rv = Kv__bry_or_null(ary, i); if (rv == null) throw Err_.new_("json.parser", "missing val", "key", context + "." + keys[i], "excerpt", Json_itm_.To_bry(tmp_bfr, cur_itm));
|
||||
return rv;
|
||||
}
|
||||
public byte[][] Kv__bry_ary(Json_kv[] ary, int i) {
|
||||
return ary[i].Val_as_ary().Xto_bry_ary();
|
||||
}
|
||||
public byte[] Kv__bry_or_empty(Json_kv[] ary, int i) {
|
||||
byte[] rv = Kv__bry_or_null(ary, i);
|
||||
return rv == null ? Bry_.Empty : rv;
|
||||
}
|
||||
public byte[] Kv__bry_or_null(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return null;
|
||||
Json_itm val = kv.Val();
|
||||
return kv == null ? null : val.Data_bry();
|
||||
}
|
||||
public boolean Kv__mw_bool(Json_kv[] ary, int i) {
|
||||
Json_kv kv = ary[i]; if (kv == null) return false;
|
||||
Json_itm val = kv.Val();
|
||||
if ( val.Tid() == Json_itm_.Tid__str
|
||||
&& Bry_.Len_eq_0(val.Data_bry())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Warn("unknown val: val=" + String_.new_u8(kv.Data_bry()) + " excerpt=" + String_.new_u8(Json_itm_.To_bry(tmp_bfr, cur_itm)), kv);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean Kv__has(Json_kv[] ary, int i) {return Kv__bry_or_empty(ary, i) != null;}
|
||||
protected abstract void Parse_hook_nde(Json_nde sub, Json_kv[] atrs);
|
||||
protected void Warn(String msg, Json_kv kv) {
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", msg + ": path=~{0}.~{1} excerpt=~{2}", context, kv.Key_as_bry(), Json_itm_.To_bry(tmp_bfr, cur_itm));
|
||||
}
|
||||
}
|
||||
class Json_parser__list_nde__base extends Json_parser__base {
|
||||
public void Parse_grp(String context, Json_grp grp) {
|
||||
this.context = context;
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = null;
|
||||
if (grp.Tid() == Json_itm_.Tid__nde) {
|
||||
Json_kv kv = Json_nde.cast(grp).Get_at_as_kv(i);
|
||||
sub = kv.Val_as_nde();
|
||||
}
|
||||
else {
|
||||
sub = Json_nde.cast(grp.Get_at(i));
|
||||
}
|
||||
Parse_nde(context, sub);
|
||||
}
|
||||
}
|
||||
public void Parse_nde(String context, Json_nde nde) {
|
||||
this.cur_itm = nde;
|
||||
for (int j = 0; j < keys_len; ++j)
|
||||
atrs[j] = null;
|
||||
int atr_len = nde.Len();
|
||||
for (int j = 0; j < atr_len; ++j) {
|
||||
Json_kv atr = nde.Get_at_as_kv(j);
|
||||
Object idx_obj = hash.Get_by_bry(atr.Key_as_bry());
|
||||
if (idx_obj == null) {Warn("unknown key", atr); continue;}
|
||||
int idx_int = ((Int_obj_val)idx_obj).Val();
|
||||
atrs[idx_int] = atr;
|
||||
}
|
||||
Parse_hook_nde(nde, atrs);
|
||||
}
|
||||
public void Parse_to_list_as_bry(String context, Json_ary ary, Ordered_hash list) {
|
||||
this.cur_itm = ary;
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] val = ary.Get_at(i).Data_bry();
|
||||
list.Add(val, val);
|
||||
}
|
||||
}
|
||||
public void Parse_to_list_as_kv(String context, Json_nde nde, Ordered_hash list) {
|
||||
this.cur_itm = nde;
|
||||
int len = nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
@gplx.Virtual protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
|
||||
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {}
|
||||
}
|
||||
class Site_meta_parser__general extends Json_parser__list_nde__base {
|
||||
public void Parse(String context, Ordered_hash list, Json_nde nde) {
|
||||
this.Parse_to_list_as_kv(context + ".general", nde, list);
|
@ -45,6 +45,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
Add(app, new gplx.xowa.xtns.listings.Listing_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.titleBlacklists.Blacklist_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.pfuncs.scribunto.Pfunc_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.graphs.Graph_xtn());
|
||||
return this;
|
||||
}
|
||||
public Xow_xtn_mgr Ctor_by_wiki(Xowe_wiki wiki) {
|
||||
|
42
400_xowa/src/gplx/xowa/xtns/graphs/Graph_xnde.java
Normal file
42
400_xowa/src/gplx/xowa/xtns/graphs/Graph_xnde.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.graphs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.html.*;
|
||||
public class Graph_xnde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
private Graph_xtn xtn;
|
||||
public void Xatr_parse(Xowe_wiki wiki, byte[] src, Xop_xatr_itm xatr, Object xatr_key_obj) {}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
this.xtn = (Graph_xtn)wiki.Xtn_mgr().Get_or_fail(Graph_xtn.Xtn_key_static);
|
||||
xtn.Xtn_init_assert(wiki);
|
||||
ctx.Cur_page().Html_data().Head_mgr().Itm__graph().Enabled_y_();
|
||||
boolean log_wkr_enabled = Log_wkr != Xop_log_basic_wkr.Null; if (log_wkr_enabled) Log_wkr.Log_end_xnde(ctx.Cur_page(), Xop_log_basic_wkr.Tid_graph, src, xnde);
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
bfr.Add(Html__div_bgn);
|
||||
bfr.Add_mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
bfr.Add(Html__div_end);
|
||||
}
|
||||
public static Xop_log_basic_wkr Log_wkr = Xop_log_basic_wkr.Null;
|
||||
private static final byte[]
|
||||
Html__div_bgn = Bry_.new_a7("<div class='mw-wiki-graph'>\n")
|
||||
, Html__div_end = Bry_.new_a7("</div>\n")
|
||||
;
|
||||
}
|
45
400_xowa/src/gplx/xowa/xtns/graphs/Graph_xtn.java
Normal file
45
400_xowa/src/gplx/xowa/xtns/graphs/Graph_xtn.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.graphs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.html.modules.*; import gplx.xowa.apps.fsys.*;
|
||||
public class Graph_xtn extends Xox_mgr_base implements GfoInvkAble {
|
||||
@Override public boolean Enabled_default() {return true;}
|
||||
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("graph");
|
||||
@Override public Xox_mgr Clone_new() {return new Graph_xtn();}
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {}
|
||||
private boolean xtn_init_done = false;
|
||||
public void Xtn_init_assert(Xowe_wiki wiki) {
|
||||
if (xtn_init_done) return;
|
||||
// if (!Enabled()) return;
|
||||
// Xoae_app app = wiki.Appe();
|
||||
// Io_url ext_root_dir = Hiero_root_dir(app.Fsys_mgr());
|
||||
// Img_src_dir = Bry_.new_u8(ext_root_dir.GenSubDir("img").To_http_file_str());
|
||||
// app.Gfs_mgr().Run_url_for(this, ext_root_dir.GenSubFil_nest("data", "tables.gfs"));
|
||||
// html_wtr = new Hiero_html_mgr(this);
|
||||
// parser.Init();
|
||||
// xtn_init_done = true;
|
||||
}
|
||||
public void Clear() {
|
||||
// prefab_mgr.Clear();
|
||||
// file_mgr.Clear();
|
||||
// phoneme_mgr.Clear();
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return super.Invk(ctx, ikey, k, m);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
class Math_func_ml_parser {
|
||||
private byte[] src; public int src_len;
|
||||
private Btrie_slim_mgr prop_trie;
|
||||
public void Parse(byte[] src) {
|
||||
this.prop_trie = Math_prop_itm.Trie;
|
||||
this.src = src; this.src_len = src.length;
|
||||
int pos = Bry_finder.Find_fwd(src, Bry__parse_bgn, 0); if (pos == Bry_finder.Not_found) throw Err_.new_("ml_parser", "unable to find beginning of ml file");
|
||||
pos = Bry_finder.Find_fwd(src, Byte_ascii.Quote, pos, src_len); if (pos == Bry_finder.Not_found) throw Err_.new_("ml_parser", "unable to find first func");
|
||||
while (true) {
|
||||
pos = Parse_itm(pos);
|
||||
if (pos == Bry_finder.Not_found) break;
|
||||
}
|
||||
}
|
||||
private int Parse_itm(int pos) { // pos should start at quote
|
||||
int end_quote = Bry_finder.Find_fwd(src, Byte_ascii.Quote, pos + 1); if (pos == Bry_finder.Not_found) throw Err_.new_("ml_parser", "unable to find end quote", "excerpt", Excerpt(pos));
|
||||
byte[] key = Bry_.Mid_by_len_safe(src, pos + 1, end_quote);
|
||||
Math_func_itm func_itm = new Math_func_itm(key);
|
||||
pos = end_quote + 1;
|
||||
pos = Bry_finder.Find_fwd(src, Bry__kv_spr, pos); if (pos == Bry_finder.Not_found) throw Err_.new_("ml_parser", "unable to find kv spr", "excerpt", Excerpt(pos));
|
||||
while (true) {
|
||||
pos = Bry_finder.Find_fwd_while_ws(src, pos, src_len);
|
||||
if (pos == src_len) return -1;
|
||||
byte b = src[pos];
|
||||
Object o = prop_trie.Match_bgn_w_byte(b, src, pos, src_len);
|
||||
if (o == null) {
|
||||
// throw error
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Int_obj_val prop_obj = (Int_obj_val)o;
|
||||
func_itm.Props__add(prop_obj.Val());
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
private byte[] Excerpt(int bgn) {return Bry_.Mid_by_len_safe(src, bgn, bgn + 25);}
|
||||
private static final byte[]
|
||||
Bry__parse_bgn = Bry_.new_a7("let find = function")
|
||||
, Bry__kv_spr = Bry_.new_a7("->")
|
||||
;
|
||||
}
|
||||
/*
|
||||
let find = function
|
||||
"\\alpha" -> LITERAL (HTMLABLEC (FONT_UF, "\\alpha ", "α"))
|
||||
| "\\Alpha" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
|
||||
"\\mathrm{A}", "Α")))
|
||||
| "\\beta" -> LITERAL (HTMLABLEC (FONT_UF, "\\beta ", "β"))
|
||||
| "\\Beta" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
|
||||
"\\mathrm{B}", "Β")))
|
||||
| "\\gamma" -> LITERAL (HTMLABLEC (FONT_UF, "\\gamma ", "γ"))
|
||||
| "\\text" -> raise (Failure "malformatted \\text")
|
||||
| "\\frac" -> FUN_AR2h ("\\frac ", fun num den -> Html.html_render [num], "<hr style=\"{background: black}\"/>", Html.html_render [den])
|
||||
*/
|
||||
|
@ -18,4 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
class Mwm_ctx {
|
||||
public Int_ary Stack() {return stack;} private final Int_ary stack = new Int_ary(4);
|
||||
public void Clear() {
|
||||
stack.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,11 @@ interface Mwm_lxr {
|
||||
class Mwm_lxr_ {
|
||||
public static final int
|
||||
Tid__ws = 0
|
||||
, Tid__backslash = 1
|
||||
, Tid__curly_bgn = 2
|
||||
, Tid__curly_end = 3
|
||||
, Tid__brack_bgn = 4
|
||||
, Tid__brack_end = 5
|
||||
, Tid__raw = 1
|
||||
, Tid__backslash = 2
|
||||
, Tid__curly_bgn = 3
|
||||
, Tid__curly_end = 4
|
||||
, Tid__brack_bgn = 5
|
||||
, Tid__brack_end = 6
|
||||
;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class Mwm_lxr__backslash implements Mwm_lxr {
|
||||
break;
|
||||
}
|
||||
}
|
||||
root.Regy__add(Mwm_tkn_.Tid__func, bgn_pos, cur_pos, new Mwm_tkn__node());
|
||||
root.Regy__add(Mwm_tkn_.Tid__fnc, bgn_pos, cur_pos, new Mwm_tkn__node());
|
||||
return cur_pos;
|
||||
}
|
||||
}
|
||||
|
@ -16,16 +16,11 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_trie_bldr {
|
||||
public static Btrie_fast_mgr new_() {
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.cs();
|
||||
rv.Add(" " , new Mwm_lxr__ws());
|
||||
rv.Add("\\" , new Mwm_lxr__backslash());
|
||||
rv.Add("{" , new Mwm_lxr__curly_bgn());
|
||||
rv.Add("}" , new Mwm_lxr__curly_end());
|
||||
rv.Add("[" , new Mwm_lxr__brack_bgn());
|
||||
rv.Add("]" , new Mwm_lxr__brack_end());
|
||||
return rv;
|
||||
class Mwm_lxr__leaf implements Mwm_lxr {
|
||||
public Mwm_lxr__leaf(int tkn_tid) {this.tkn_tid = tkn_tid;} private final int tkn_tid;
|
||||
public int Tid() {return Mwm_lxr_.Tid__raw;}
|
||||
public int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
root.Regy__add(tkn_tid, bgn_pos, cur_pos, null);
|
||||
return cur_pos;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_lxr_trie_bldr {
|
||||
public static Btrie_fast_mgr new_(Mwm_tkn_mkr tkn_mkr) {// REF.MW:/Math/textvccheck/lexer.mll
|
||||
tkn_mkr.Reg_leaf(Mwm_tkn_.Tid__text, new Mwm_tkn__leaf_raw());
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.cs();
|
||||
Add_lxr (rv, tkn_mkr, new Mwm_lxr__backslash() , "\\");
|
||||
Add_lxr (rv, tkn_mkr, new Mwm_lxr__curly_bgn() , "{");
|
||||
Add_lxr (rv, tkn_mkr, new Mwm_lxr__curly_end() , "}");
|
||||
Add_lxr (rv, tkn_mkr, new Mwm_lxr__brack_bgn() , "[");
|
||||
Add_lxr (rv, tkn_mkr, new Mwm_lxr__brack_end() , "]");
|
||||
Add_lxr_leaf (rv, tkn_mkr, new Mwm_lxr__ws(), Mwm_tkn_.Tid__ws , " ", "\t", "\n", "\r");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , ">", "<", "~");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_uf_lt , ",", ":", ";", "?", "!", "'");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_uf_op , "+", "-", "*", "=");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__dlm_uf_lt , "(", ")", ".");
|
||||
Add_lxr_leaf_repl (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , "%", "\\%");
|
||||
Add_lxr_leaf_repl (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , "$", "\\$");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , "\\,", "\\ ", "\\;", "\\!");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__dlm_basic , "\\{", "\\}", "\\|");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , "\\_", "\\#", "\\%", "\\$", "\\&");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__next_cell , "%");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__next_row , "\\\\");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__lit_basic , "~", ">", "<");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__sup , "^");
|
||||
Add_lxr_leaf (rv, tkn_mkr, Mwm_tkn_.Tid__sub , "_");
|
||||
return rv;
|
||||
}
|
||||
private static void Add_lxr(Btrie_fast_mgr trie, Mwm_tkn_mkr tkn_mkr, Mwm_lxr lxr, String... ary) {
|
||||
for (String itm : ary)
|
||||
trie.Add(itm, lxr);
|
||||
}
|
||||
private static void Add_lxr_leaf(Btrie_fast_mgr trie, Mwm_tkn_mkr tkn_mkr, int tid, String... ary) {
|
||||
Add_lxr_leaf(trie, tkn_mkr, new Mwm_lxr__leaf(tid), tid, new Mwm_tkn__leaf_raw(), ary);
|
||||
}
|
||||
private static void Add_lxr_leaf(Btrie_fast_mgr trie, Mwm_tkn_mkr tkn_mkr, Mwm_lxr lxr, int tkn_tid, String... ary) {
|
||||
Add_lxr_leaf(trie, tkn_mkr, lxr, tkn_tid, new Mwm_tkn__leaf_raw(), ary);
|
||||
}
|
||||
private static void Add_lxr_leaf_repl(Btrie_fast_mgr trie, Mwm_tkn_mkr tkn_mkr, int tid, String src, String trg) {
|
||||
Add_lxr_leaf(trie, tkn_mkr, new Mwm_lxr__leaf(tid), tid, new Mwm_tkn__leaf_repl(tid, Bry_.new_u8(trg)), src);
|
||||
}
|
||||
private static void Add_lxr_leaf(Btrie_fast_mgr trie, Mwm_tkn_mkr tkn_mkr, Mwm_lxr lxr, int tkn_tid, Mwm_tkn proto, String... ary) {
|
||||
tkn_mkr.Reg_leaf(tkn_tid, proto);
|
||||
for (String itm : ary)
|
||||
trie.Add(itm, lxr);
|
||||
}
|
||||
}
|
@ -18,12 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_parser {
|
||||
private final Mwm_ctx ctx = new Mwm_ctx();
|
||||
private final Btrie_fast_mgr trie;
|
||||
public Mwm_tkn_mkr Tkn_mkr() {return tkn_mkr;} private final Mwm_tkn_mkr tkn_mkr = new Mwm_tkn_mkr();
|
||||
public Mwm_parser() {
|
||||
this.trie = Mwm_lxr_trie_bldr.new_(tkn_mkr);
|
||||
}
|
||||
public void Parse(Mwm_tkn__root root, byte[] src) {
|
||||
int src_len = src.length;
|
||||
Btrie_fast_mgr trie = Mwm_trie_bldr.new_();
|
||||
Parse(trie, root, new Mwm_ctx(), src, src_len, 0, src_len);
|
||||
ctx.Clear();
|
||||
root.Init_as_root(tkn_mkr, 0, src.length);
|
||||
Parse(root, ctx, src, src_len, 0, src_len);
|
||||
}
|
||||
private int Parse(Btrie_fast_mgr trie, Mwm_tkn__root root, Mwm_ctx ctx, byte[] src, int src_len, int bgn_pos, int end_pos) {
|
||||
private int Parse(Mwm_tkn__root root, Mwm_ctx ctx, byte[] src, int src_len, int bgn_pos, int end_pos) {
|
||||
int pos = bgn_pos;
|
||||
int txt_bgn = pos, txt_uid = -1;
|
||||
byte b = src[pos];
|
||||
|
@ -65,14 +65,13 @@ class Mwm_parser_fxt {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Mwm_parser parser = new Mwm_parser();
|
||||
private final Mwm_tkn__root expd_root, actl_root;
|
||||
private final Mwm_tkn_mkr tkn_mkr = new Mwm_tkn_mkr();
|
||||
public Mwm_parser_fxt() {
|
||||
this.expd_root = new Mwm_tkn__root(tkn_mkr);
|
||||
this.actl_root = new Mwm_tkn__root(tkn_mkr);
|
||||
this.expd_root = new Mwm_tkn__root();
|
||||
this.actl_root = new Mwm_tkn__root();
|
||||
}
|
||||
public void Clear() {
|
||||
expd_root.Init_as_root(0, 8);
|
||||
actl_root.Init_as_root(0, 8);
|
||||
expd_root.Init_as_root(parser.Tkn_mkr(), 0, 8);
|
||||
actl_root.Init_as_root(parser.Tkn_mkr(), 0, 8);
|
||||
}
|
||||
public void Test_parse(String src_str, Mwm_tkn... expd_tkns) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
@ -93,7 +92,7 @@ class Mwm_parser_fxt {
|
||||
}
|
||||
private Mwm_tkn leaf(int tid, int bgn, int end) {
|
||||
int uid = expd_root.Regy__add(tid, bgn, end, null);
|
||||
return new Mwm_tkn__leaf().Init(expd_root, tid, uid, bgn, end);
|
||||
return new Mwm_tkn__leaf_raw().Init(expd_root, tid, uid, bgn, end);
|
||||
}
|
||||
private Mwm_tkn node(int tid, int bgn, int end, Mwm_tkn tkn) {
|
||||
int uid = expd_root.Regy__add(tid, bgn, end, tkn);
|
||||
@ -101,7 +100,7 @@ class Mwm_parser_fxt {
|
||||
}
|
||||
public Mwm_tkn text (int bgn, int end) {return leaf(Mwm_tkn_.Tid__text , bgn, end);}
|
||||
public Mwm_tkn ws (int bgn, int end) {return leaf(Mwm_tkn_.Tid__ws , bgn, end);}
|
||||
public Mwm_tkn func (int bgn, int end) {return node(Mwm_tkn_.Tid__func , bgn, end, new Mwm_tkn__node());}
|
||||
public Mwm_tkn func (int bgn, int end) {return node(Mwm_tkn_.Tid__fnc , bgn, end, new Mwm_tkn__node());}
|
||||
public Mwm_tkn brack(int bgn, int end, Mwm_tkn... subs) {return node_w_subs(Mwm_tkn_.Tid__brack, bgn, end, subs);}
|
||||
public Mwm_tkn curly(int bgn, int end, Mwm_tkn... subs) {return node_w_subs(Mwm_tkn_.Tid__curly, bgn, end, subs);}
|
||||
private Mwm_tkn node_w_subs(int tid, int bgn, int end, Mwm_tkn... subs) {
|
||||
|
@ -21,39 +21,104 @@ class Mwm_tkn_ {
|
||||
public static final Mwm_tkn[] Ary_empty = new Mwm_tkn[0];
|
||||
public static final int Uid__root = 0;
|
||||
public static final int
|
||||
Tid__root = 0
|
||||
, Tid__text = 1
|
||||
, Tid__ws = 2
|
||||
, Tid__func = 3
|
||||
, Tid__curly = 4
|
||||
, Tid__brack = 5
|
||||
Tid__root = 0
|
||||
, Tid__text = 1
|
||||
, Tid__ws = 2
|
||||
, Tid__curly = 3
|
||||
, Tid__brack = 4
|
||||
, Tid__lit_basic = 5
|
||||
, Tid__lit_uf_lt = 6
|
||||
, Tid__lit_uf_op = 7
|
||||
, Tid__dlm_basic = 8
|
||||
, Tid__dlm_uf_lt = 9
|
||||
, Tid__dlm_uf_op = 10
|
||||
, Tid__sub = 11
|
||||
, Tid__sup = 12
|
||||
, Tid__next_row = 13
|
||||
, Tid__next_cell = 14
|
||||
, Tid__fnc = 15
|
||||
, Tid__fnc_latex = 16
|
||||
, Tid__fnc_mw = 17
|
||||
, Tid__matrix_bgn = 18
|
||||
, Tid__matrix_end = 19
|
||||
, Tid__pmatrix_bgn = 20
|
||||
, Tid__pmatrix_end = 21
|
||||
, Tid__bmatrix_bgn = 22
|
||||
, Tid__bmatrix_end = 23
|
||||
, Tid__Bmatrix_bgn = 24
|
||||
, Tid__Bmatrix_end = 25
|
||||
, Tid__vmatrix_bgn = 26
|
||||
, Tid__vmatrix_end = 27
|
||||
, Tid__Vmatrix_bgn = 28
|
||||
, Tid__Vmatrix_end = 29
|
||||
, Tid__array_bgn = 30
|
||||
, Tid__array_end = 31
|
||||
, Tid__align_bgn = 32
|
||||
, Tid__align_end = 33
|
||||
, Tid__alignat_bgn = 34
|
||||
, Tid__alignat_end = 35
|
||||
, Tid__smallmatrix_bgn = 36
|
||||
, Tid__smallmatrix_end = 37
|
||||
, Tid__cases_bgn = 38
|
||||
, Tid__cases_end = 39
|
||||
;
|
||||
public static byte[]
|
||||
Bry__root = Bry_.new_a7("root")
|
||||
, Bry__text = Bry_.new_a7("text")
|
||||
, Bry__ws = Bry_.new_a7("ws")
|
||||
, Bry__func = Bry_.new_a7("func")
|
||||
, Bry__curly = Bry_.new_a7("curly")
|
||||
, Bry__brack = Bry_.new_a7("brack")
|
||||
;
|
||||
public static byte[] Tid_to_bry(int tid) {
|
||||
switch (tid) {
|
||||
case Tid__root: return Bry__root;
|
||||
case Tid__text: return Bry__text;
|
||||
case Tid__ws: return Bry__ws;
|
||||
case Tid__func: return Bry__func;
|
||||
case Tid__curly: return Bry__curly;
|
||||
case Tid__brack: return Bry__brack;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
public static final int Tid_len = 40;
|
||||
private static final byte[][] Bry__ary = Bry__ary__new();
|
||||
private static byte[][] Bry__ary__new() {
|
||||
byte[][] rv = new byte[Tid_len][];
|
||||
Reg_itm(rv, Tid__root , "root");
|
||||
Reg_itm(rv, Tid__text , "text");
|
||||
Reg_itm(rv, Tid__ws , "ws");
|
||||
Reg_itm(rv, Tid__fnc , "func");
|
||||
Reg_itm(rv, Tid__curly , "curly");
|
||||
Reg_itm(rv, Tid__brack , "brack");
|
||||
Reg_itm(rv, Tid__lit_basic , "literal_basic");
|
||||
Reg_itm(rv, Tid__lit_uf_lt , "literal_uf_lt");
|
||||
Reg_itm(rv, Tid__lit_uf_op , "literal_uf_op");
|
||||
Reg_itm(rv, Tid__dlm_basic , "delimiter_basic");
|
||||
Reg_itm(rv, Tid__dlm_uf_lt , "delimiter_uf_lt");
|
||||
Reg_itm(rv, Tid__dlm_uf_op , "delimiter_uf_op");
|
||||
Reg_itm(rv, Tid__sub , "sub");
|
||||
Reg_itm(rv, Tid__sup , "sup");
|
||||
Reg_itm(rv, Tid__next_row , "next_row");
|
||||
Reg_itm(rv, Tid__next_cell , "next_cell");
|
||||
Reg_itm(rv, Tid__fnc_latex , "func_latex");
|
||||
Reg_itm(rv, Tid__fnc_mw , "func_mediawiki");
|
||||
Reg_itm(rv, Tid__matrix_bgn , "matrix_bgn");
|
||||
Reg_itm(rv, Tid__matrix_end , "matrix_end");
|
||||
Reg_itm(rv, Tid__pmatrix_bgn , "pmatrix_bgn");
|
||||
Reg_itm(rv, Tid__pmatrix_end , "pmatrix_end");
|
||||
Reg_itm(rv, Tid__bmatrix_bgn , "bmatrix_bgn");
|
||||
Reg_itm(rv, Tid__bmatrix_end , "bmatrix_end");
|
||||
Reg_itm(rv, Tid__Bmatrix_bgn , "Bmatrix_bgn");
|
||||
Reg_itm(rv, Tid__Bmatrix_end , "Bmatrix_bgn");
|
||||
Reg_itm(rv, Tid__vmatrix_bgn , "vmatrix_bgn");
|
||||
Reg_itm(rv, Tid__vmatrix_end , "vmatrix_end");
|
||||
Reg_itm(rv, Tid__Vmatrix_bgn , "Vmatrix_bgn");
|
||||
Reg_itm(rv, Tid__Vmatrix_end , "Vmatrix_end");
|
||||
Reg_itm(rv, Tid__array_bgn , "array_bgn");
|
||||
Reg_itm(rv, Tid__array_end , "array_end");
|
||||
Reg_itm(rv, Tid__align_bgn , "align_bgn");
|
||||
Reg_itm(rv, Tid__align_end , "align_end");
|
||||
Reg_itm(rv, Tid__alignat_bgn , "alignat_bgn");
|
||||
Reg_itm(rv, Tid__alignat_end , "alignat_end");
|
||||
Reg_itm(rv, Tid__smallmatrix_bgn , "smallmatrix_bgn");
|
||||
Reg_itm(rv, Tid__smallmatrix_end , "smallmatrix_end");
|
||||
Reg_itm(rv, Tid__cases_bgn , "cases_bgn");
|
||||
Reg_itm(rv, Tid__cases_end , "cases_end");
|
||||
return rv;
|
||||
}
|
||||
private static void Reg_itm(byte[][] ary, int id, String name) {ary[id] = Bry_.new_a7(name);}
|
||||
public static byte[] Tid_to_bry(int tid) {return Bry__ary[tid];}
|
||||
public static boolean Tid_is_node(int tid) {
|
||||
switch (tid) {
|
||||
case Mwm_tkn_.Tid__text:
|
||||
case Mwm_tkn_.Tid__ws:
|
||||
return false;
|
||||
default:
|
||||
case Mwm_tkn_.Tid__root:
|
||||
case Mwm_tkn_.Tid__fnc:
|
||||
case Mwm_tkn_.Tid__curly:
|
||||
case Mwm_tkn_.Tid__brack:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void Tkn_to_bry__bgn(Bry_bfr bfr, int indent, Mwm_tkn tkn) {
|
||||
|
41
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func.java
Normal file
41
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_tkn__func {
|
||||
public Mwm_tkn__func(byte[] key) {
|
||||
this.key = key;
|
||||
}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public byte[] Manual() {return manual;} public Mwm_tkn__func Manual_(String v) {manual = Bry_.new_a7(v); return this;} private byte[] manual;
|
||||
public boolean Literal() {return literal;} public Mwm_tkn__func Literal_() {this.literal = true; return this;} private boolean literal;
|
||||
public boolean Big() {return big;} public Mwm_tkn__func Big_() {this.big = true; return this;} private boolean big;
|
||||
public boolean Delimiter() {return delimiter;} public Mwm_tkn__func Delimiter_() {this.delimiter = true; return this;} private boolean delimiter;
|
||||
public boolean Tex_only() {return tex_only;} public Mwm_tkn__func Tex_only_() {this.tex_only = true; return this;} private boolean tex_only;
|
||||
public boolean Fun_ar1() {return fun_ar1;} public Mwm_tkn__func Fun_ar1_() {this.fun_ar1 = true; return this;} private boolean fun_ar1;
|
||||
public boolean Fun_ar2() {return fun_ar2;} public Mwm_tkn__func Fun_ar2_() {this.fun_ar2 = true; return this;} private boolean fun_ar2;
|
||||
public boolean Fun_ar2nb() {return fun_ar2nb;} public Mwm_tkn__func Fun_ar2nb_() {this.fun_ar2nb = true; return this;} private boolean fun_ar2nb;
|
||||
public boolean Fun_infix() {return fun_infix;} public Mwm_tkn__func Fun_infix_() {this.fun_infix = true; return this;} private boolean fun_infix;
|
||||
public boolean Declh() {return declh;} public Mwm_tkn__func Declh_() {this.declh = true; return this;} private boolean declh;
|
||||
public boolean Fontforce_rm() {return fontforce_rm;} public Mwm_tkn__func Fontforce_rm_() {this.fontforce_rm = true; return this;} private boolean fontforce_rm;
|
||||
public boolean Left() {return left;} public Mwm_tkn__func Left_() {this.left = true; return this;} private boolean left;
|
||||
public boolean Right() {return right;} public Mwm_tkn__func Right_() {this.right = true; return this;} private boolean right;
|
||||
public boolean Fail() {return fail;} public Mwm_tkn__func Fail_() {this.fail = true; return this;} private boolean fail;
|
||||
public boolean Type_latex() {return type_latex;} public Mwm_tkn__func Type_latex_() {this.type_latex = true; return this;} private boolean type_latex;
|
||||
public boolean Type_mw() {return type_mw;} public Mwm_tkn__func Type_mw_() {this.type_mw = true; return this;} private boolean type_mw;
|
||||
}
|
52
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func_.java
Normal file
52
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func_.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_tkn__func_ {
|
||||
public static final int
|
||||
Tid__space = 0
|
||||
, Tid__lit_uf_lt = 1
|
||||
, Tid__dlm_uf_lt = 2
|
||||
, Tid__lit_uf_op = 3
|
||||
, Tid__dlm_uf_op = 4
|
||||
, Tid__fnc_latex = 5
|
||||
, Tid__fnc_mw = 6
|
||||
;
|
||||
public Btrie_slim_mgr Make_trie() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_a7(); // NOTE: texvc tkns are ascii
|
||||
Make_itm(rv, Tid__space , " ", "\t", "\n", "\r");
|
||||
Make_itm(rv, Tid__lit_uf_lt , ",", ":", ";", "?", "!", "'");
|
||||
Make_itm(rv, Tid__dlm_uf_lt , "(", ")", ".");
|
||||
Make_itm(rv, Tid__lit_uf_op , "+", "-", "*", "=");
|
||||
Make_itm(rv, Tid__dlm_uf_op , "/", "|");
|
||||
Make_itm(rv, Tid__fnc_latex , "arccos", "arcsin", "arctan", "arg", "cos", "cosh", "cot", "coth", "csc"
|
||||
, "deg", "det", "dim", "exp", "gcd", "hom", "inf", "ker", "lg", "lim", "liminf", "limsup", "ln", "log"
|
||||
, "max", "min", "Pr", "sec", "sin", "sinh", "sup", "tan", "tanh");
|
||||
Make_itm(rv, Tid__fnc_mw , "arccot", "arcsec", "arccsc", "sgn", "sen");
|
||||
return rv;
|
||||
}
|
||||
private void Make_itm(Btrie_slim_mgr trie, int tid, String... ary) {
|
||||
for (String itm : ary)
|
||||
trie.Add_bry_int(Bry_.new_a7(itm), tid);
|
||||
}
|
||||
//let alpha = ['a'-'z' 'A'-'Z']
|
||||
//let literal_id = ['a'-'z' 'A'-'Z']
|
||||
//let literal_mn = ['0'-'9']
|
||||
//let boxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' '\'' '`' ' ' '\128'-'\255']
|
||||
//let aboxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' '\'' '`' ' ']
|
||||
}
|
705
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func_trie.java
Normal file
705
400_xowa/src/gplx/xowa/xtns/math/parsers/Mwm_tkn__func_trie.java
Normal file
@ -0,0 +1,705 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.core.btries.*;
|
||||
class Mwm_tkn__func_trie {
|
||||
public Btrie_slim_mgr Make() {
|
||||
Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7();
|
||||
Add(trie, Make("\\AA").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\aleph").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\alpha").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\amalg").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\And").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\angle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\approx").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\approxeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ast").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\asymp").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\backepsilon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\backprime").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\backsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\backsimeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\barwedge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Bbbk").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\because").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\beta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\beth").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\between").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigcap").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigcirc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigcup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigodot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigoplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigotimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigsqcup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigstar").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigtriangledown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigtriangleup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\biguplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigvee").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bigwedge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacklozenge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacksquare").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacktriangle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacktriangledown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacktriangleleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\blacktriangleright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bowtie").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Box").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\boxdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\boxminus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\boxplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\boxtimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bullet").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\bumpeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Bumpeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\cap").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Cap").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\cdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\cdots").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\centerdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\checkmark").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\chi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circ").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circlearrowleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circlearrowright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circledast").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circledcirc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circleddash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\circledS").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\clubsuit").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\colon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\color").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\complement").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\cong").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\coprod").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\cup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Cup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curlyeqprec").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curlyeqsucc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curlyvee").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curlywedge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curvearrowleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\curvearrowright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dagger").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\daleth").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dashv").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ddagger").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ddots").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\definecolor").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\delta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Delta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\diagdown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\diagup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\diamond").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Diamond").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\diamondsuit").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\digamma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\displaystyle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\div").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\divideontimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\doteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\doteqdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dots").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotsb").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotsc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotsi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotsm").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\dotso").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\doublebarwedge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\downdownarrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\downharpoonleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\downharpoonright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ell").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\emptyset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\epsilon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eqcirc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eqsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eqslantgtr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eqslantless").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\equiv").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\eth").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\exists").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\fallingdotseq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Finv").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\flat").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\forall").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\frown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Game").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gamma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Gamma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\geq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\geqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\geqslant").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gets").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gg").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ggg").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gimel").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gnapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gnsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtrapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtrdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtreqless").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtreqqless").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtrless").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gtrsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\gvertneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\hbar").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\heartsuit").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\hline").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\hookleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\hookrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\hslash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\iff").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\iiiint").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\iiint").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\iint").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Im").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\imath").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\implies").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\in").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\infty").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\injlim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\int").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\intercal").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\iota").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\jmath").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\kappa").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lambda").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Lambda").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\land").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ldots").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Leftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftarrowtail").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftharpoondown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftharpoonup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftleftarrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Leftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftrightarrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftrightharpoons").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftrightsquigarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leftthreetimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\leqslant").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lessapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lessdot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lesseqgtr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lesseqqgtr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lessgtr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lesssim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\limits").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ll").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Lleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lll").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lnapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lnot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lnsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\longleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Longleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\longleftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Longleftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\longmapsto").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\longrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Longrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\looparrowleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\looparrowright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lor").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lozenge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Lsh").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ltimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lVert").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\lvertneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mapsto").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\measuredangle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mho").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mid").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mod").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\models").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mp").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\mu").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\multimap").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nabla").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\natural").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ncong").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nearrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\neg").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\neq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nexists").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ngeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ngeqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ngeqslant").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ngtr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ni").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nLeftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nleftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nLeftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nleq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nleqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nleqslant").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nless").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nmid").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nolimits").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\not").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\notin").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nparallel").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nprec").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\npreceq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nRightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nshortmid").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nshortparallel").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsubseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsubseteqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsucc").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsucceq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsupseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nsupseteqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ntriangleleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ntrianglelefteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ntriangleright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ntrianglerighteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nu").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nvdash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nVdash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nvDash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nVDash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\nwarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\odot").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\oint").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\omega").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Omega").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\ominus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\oplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\oslash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\otimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\overbrace").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\overleftarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\overleftrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\overline").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\overrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\P").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\pagecolor").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\parallel").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\partial").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\perp").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\phi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Phi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\pi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Pi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\pitchfork").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\pm").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\prec").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\precapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\preccurlyeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\preceq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\precnapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\precneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\precnsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\precsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\prime").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\prod").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\projlim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\propto").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\psi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Psi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\qquad").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\quad").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Re").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rho").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Rightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightarrowtail").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightharpoondown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightharpoonup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightleftarrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightrightarrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightsquigarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rightthreetimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\risingdotseq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Rrightarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Rsh").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rtimes").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\rVert").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\S").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\scriptscriptstyle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\scriptstyle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\searrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\setminus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sharp").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\shortmid").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\shortparallel").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sigma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Sigma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\simeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\smallfrown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\smallsetminus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\smallsmile").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\smile").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\spadesuit").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sphericalangle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqcap").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqcup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqsubset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqsubseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqsupset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sqsupseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\square").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\star").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\subset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Subset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\subseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\subseteqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\subsetneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\subsetneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succ").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succcurlyeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succeq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succnapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succnsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\succsim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\sum").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\supset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Supset").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\supseteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\supseteqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\supsetneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\supsetneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\surd").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\swarrow").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\tau").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\textstyle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\textvisiblespace").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\therefore").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\theta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Theta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\thickapprox").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\thicksim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\times").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\to").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\top").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\triangle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\triangledown").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\triangleleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\trianglelefteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\triangleq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\triangleright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\trianglerighteq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\underbrace").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\underline").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\upharpoonleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\upharpoonright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\uplus").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\upsilon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Upsilon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\upuparrows").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varepsilon").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varinjlim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varkappa").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varliminf").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varlimsup").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varnothing").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varphi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varpi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varprojlim").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varpropto").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varrho").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varsigma").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varsubsetneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varsubsetneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varsupsetneq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\varsupsetneqq").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vartheta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vartriangle").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vartriangleleft").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vartriangleright").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vdash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Vdash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vDash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vdots").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vee").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\veebar").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\vline").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Vvdash").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\wedge").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\widehat").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\widetilde").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\wp").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\wr").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\xi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\Xi").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\zeta").Literal_().Tex_only_());
|
||||
Add(trie, Make("\\big").Big_());
|
||||
Add(trie, Make("\\Big").Big_());
|
||||
Add(trie, Make("\\bigg").Big_());
|
||||
Add(trie, Make("\\Bigg").Big_());
|
||||
Add(trie, Make("\\biggl").Big_());
|
||||
Add(trie, Make("\\Biggl").Big_());
|
||||
Add(trie, Make("\\biggr").Big_());
|
||||
Add(trie, Make("\\Biggr").Big_());
|
||||
Add(trie, Make("\\bigl").Big_());
|
||||
Add(trie, Make("\\Bigl").Big_());
|
||||
Add(trie, Make("\\bigr").Big_());
|
||||
Add(trie, Make("\\Bigr").Big_());
|
||||
Add(trie, Make("\\backslash").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\downarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\Downarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\langle").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\lbrace").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\lceil").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\lfloor").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\llcorner").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\lrcorner").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rangle").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rbrace").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rceil").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rfloor").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rightleftharpoons").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\twoheadleftarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\twoheadrightarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\ulcorner").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\uparrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\Uparrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\updownarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\Updownarrow").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\urcorner").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\Vert").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\vert").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\lbrack").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\rbrack").Delimiter_().Tex_only_());
|
||||
Add(trie, Make("\\acute").Fun_ar1_());
|
||||
Add(trie, Make("\\bar").Fun_ar1_());
|
||||
Add(trie, Make("\\bcancel").Fun_ar1_());
|
||||
Add(trie, Make("\\bmod").Fun_ar1_());
|
||||
Add(trie, Make("\\boldsymbol").Fun_ar1_());
|
||||
Add(trie, Make("\\breve").Fun_ar1_());
|
||||
Add(trie, Make("\\cancel").Fun_ar1_());
|
||||
Add(trie, Make("\\check").Fun_ar1_());
|
||||
Add(trie, Make("\\ddot").Fun_ar1_());
|
||||
Add(trie, Make("\\dot").Fun_ar1_());
|
||||
Add(trie, Make("\\emph").Fun_ar1_());
|
||||
Add(trie, Make("\\grave").Fun_ar1_());
|
||||
Add(trie, Make("\\hat").Fun_ar1_());
|
||||
Add(trie, Make("\\mathbb").Fun_ar1_());
|
||||
Add(trie, Make("\\mathbf").Fun_ar1_());
|
||||
Add(trie, Make("\\mathbin").Fun_ar1_());
|
||||
Add(trie, Make("\\mathcal").Fun_ar1_());
|
||||
Add(trie, Make("\\mathclose").Fun_ar1_());
|
||||
Add(trie, Make("\\mathfrak").Fun_ar1_());
|
||||
Add(trie, Make("\\mathit").Fun_ar1_());
|
||||
Add(trie, Make("\\mathop").Fun_ar1_());
|
||||
Add(trie, Make("\\mathopen").Fun_ar1_());
|
||||
Add(trie, Make("\\mathord").Fun_ar1_());
|
||||
Add(trie, Make("\\mathpunct").Fun_ar1_());
|
||||
Add(trie, Make("\\mathrel").Fun_ar1_());
|
||||
Add(trie, Make("\\mathrm").Fun_ar1_());
|
||||
Add(trie, Make("\\mathsf").Fun_ar1_());
|
||||
Add(trie, Make("\\mathtt").Fun_ar1_());
|
||||
Add(trie, Make("\\operatorname").Fun_ar1_());
|
||||
Add(trie, Make("\\pmod").Fun_ar1_());
|
||||
Add(trie, Make("\\sqrt").Fun_ar1_());
|
||||
Add(trie, Make("\\textbf").Fun_ar1_());
|
||||
Add(trie, Make("\\textit").Fun_ar1_());
|
||||
Add(trie, Make("\\textrm").Fun_ar1_());
|
||||
Add(trie, Make("\\textsf").Fun_ar1_());
|
||||
Add(trie, Make("\\texttt").Fun_ar1_());
|
||||
Add(trie, Make("\\tilde").Fun_ar1_());
|
||||
Add(trie, Make("\\vec").Fun_ar1_());
|
||||
Add(trie, Make("\\xcancel").Fun_ar1_());
|
||||
Add(trie, Make("\\xleftarrow").Fun_ar1_());
|
||||
Add(trie, Make("\\xrightarrow").Fun_ar1_());
|
||||
Add(trie, Make("\\binom").Fun_ar2_());
|
||||
Add(trie, Make("\\cancelto").Fun_ar2_());
|
||||
Add(trie, Make("\\cfrac").Fun_ar2_());
|
||||
Add(trie, Make("\\dbinom").Fun_ar2_());
|
||||
Add(trie, Make("\\dfrac").Fun_ar2_());
|
||||
Add(trie, Make("\\frac").Fun_ar2_());
|
||||
Add(trie, Make("\\overset").Fun_ar2_());
|
||||
Add(trie, Make("\\stackrel").Fun_ar2_());
|
||||
Add(trie, Make("\\tbinom").Fun_ar2_());
|
||||
Add(trie, Make("\\tfrac").Fun_ar2_());
|
||||
Add(trie, Make("\\underset").Fun_ar2_());
|
||||
Add(trie, Make("\\atop").Fun_infix_());
|
||||
Add(trie, Make("\\choose").Fun_infix_());
|
||||
Add(trie, Make("\\over").Fun_infix_());
|
||||
Add(trie, Make("\\Coppa").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\coppa").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\Digamma").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\euro").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\geneuro").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\geneuronarrow").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\geneurowide").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\Koppa").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\koppa").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\officialeuro").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\Sampi").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\sampi").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\Stigma").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\stigma").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\varstigma").Literal_().Tex_only_().Manual_("\\mbox{~0}"));
|
||||
Add(trie, Make("\\C").Literal_().Tex_only_().Manual_("\\mathbb{C}"));
|
||||
Add(trie, Make("\\H").Literal_().Tex_only_().Manual_("\\mathbb{H}"));
|
||||
Add(trie, Make("\\N").Literal_().Tex_only_().Manual_("\\mathbb{N}"));
|
||||
Add(trie, Make("\\Q").Literal_().Tex_only_().Manual_("\\mathbb{Q}"));
|
||||
Add(trie, Make("\\R").Literal_().Tex_only_().Manual_("\\mathbb{R}"));
|
||||
Add(trie, Make("\\Z").Literal_().Tex_only_().Manual_("\\mathbb{Z}"));
|
||||
Add(trie, Make("\\darr").Delimiter_().Tex_only_().Manual_("\\downarrow"));
|
||||
Add(trie, Make("\\dArr").Delimiter_().Tex_only_().Manual_("\\Downarrow"));
|
||||
Add(trie, Make("\\Darr").Delimiter_().Tex_only_().Manual_("\\Downarrow"));
|
||||
Add(trie, Make("\\lang").Delimiter_().Tex_only_().Manual_("\\langle"));
|
||||
Add(trie, Make("\\rang").Delimiter_().Tex_only_().Manual_("\\rangle"));
|
||||
Add(trie, Make("\\uarr").Delimiter_().Tex_only_().Manual_("\\uparrow"));
|
||||
Add(trie, Make("\\uArr").Delimiter_().Tex_only_().Manual_("\\Uparrow"));
|
||||
Add(trie, Make("\\Uarr").Delimiter_().Tex_only_().Manual_("\\Uparrow"));
|
||||
Add(trie, Make("\\Bbb").Fun_ar1_().Manual_("\\mathbb"));
|
||||
Add(trie, Make("\\bold").Fun_ar1_().Manual_("\\mathbf"));
|
||||
Add(trie, Make("\\alef").Literal_().Tex_only_().Manual_("\\aleph"));
|
||||
Add(trie, Make("\\alefsym").Literal_().Tex_only_().Manual_("\\aleph"));
|
||||
Add(trie, Make("\\Alpha").Literal_().Tex_only_().Manual_("\\mathrm{A}"));
|
||||
Add(trie, Make("\\and").Literal_().Tex_only_().Manual_("\\land"));
|
||||
Add(trie, Make("\\ang").Literal_().Tex_only_().Manual_("\\angle"));
|
||||
Add(trie, Make("\\Beta").Literal_().Tex_only_().Manual_("\\mathrm{B}"));
|
||||
Add(trie, Make("\\bull").Literal_().Tex_only_().Manual_("\\bullet"));
|
||||
Add(trie, Make("\\Chi").Literal_().Tex_only_().Manual_("\\mathrm{X}"));
|
||||
Add(trie, Make("\\clubs").Literal_().Tex_only_().Manual_("\\clubsuit"));
|
||||
Add(trie, Make("\\cnums").Literal_().Tex_only_().Manual_("\\mathbb{C}"));
|
||||
Add(trie, Make("\\Complex").Literal_().Tex_only_().Manual_("\\mathbb{C}"));
|
||||
Add(trie, Make("\\Dagger").Literal_().Tex_only_().Manual_("\\ddagger"));
|
||||
Add(trie, Make("\\diamonds").Literal_().Tex_only_().Manual_("\\diamondsuit"));
|
||||
Add(trie, Make("\\Doteq").Literal_().Tex_only_().Manual_("\\doteqdot"));
|
||||
Add(trie, Make("\\doublecap").Literal_().Tex_only_().Manual_("\\Cap"));
|
||||
Add(trie, Make("\\doublecup").Literal_().Tex_only_().Manual_("\\Cup"));
|
||||
Add(trie, Make("\\empty").Literal_().Tex_only_().Manual_("\\emptyset"));
|
||||
Add(trie, Make("\\Epsilon").Literal_().Tex_only_().Manual_("\\mathrm{E}"));
|
||||
Add(trie, Make("\\Eta").Literal_().Tex_only_().Manual_("\\mathrm{H}"));
|
||||
Add(trie, Make("\\exist").Literal_().Tex_only_().Manual_("\\exists"));
|
||||
Add(trie, Make("\\ge").Literal_().Tex_only_().Manual_("\\geq"));
|
||||
Add(trie, Make("\\gggtr").Literal_().Tex_only_().Manual_("\\ggg"));
|
||||
Add(trie, Make("\\hAar").Literal_().Tex_only_().Manual_("\\Leftrightarrow"));
|
||||
Add(trie, Make("\\harr").Literal_().Tex_only_().Manual_("\\leftrightarrow"));
|
||||
Add(trie, Make("\\Harr").Literal_().Tex_only_().Manual_("\\Leftrightarrow"));
|
||||
Add(trie, Make("\\hearts").Literal_().Tex_only_().Manual_("\\heartsuit"));
|
||||
Add(trie, Make("\\image").Literal_().Tex_only_().Manual_("\\Im"));
|
||||
Add(trie, Make("\\infin").Literal_().Tex_only_().Manual_("\\infty"));
|
||||
Add(trie, Make("\\Iota").Literal_().Tex_only_().Manual_("\\mathrm{I}"));
|
||||
Add(trie, Make("\\isin").Literal_().Tex_only_().Manual_("\\in"));
|
||||
Add(trie, Make("\\Kappa").Literal_().Tex_only_().Manual_("\\mathrm{K}"));
|
||||
Add(trie, Make("\\larr").Literal_().Tex_only_().Manual_("\\leftarrow"));
|
||||
Add(trie, Make("\\Larr").Literal_().Tex_only_().Manual_("\\Leftarrow"));
|
||||
Add(trie, Make("\\lArr").Literal_().Tex_only_().Manual_("\\Leftarrow"));
|
||||
Add(trie, Make("\\le").Literal_().Tex_only_().Manual_("\\leq"));
|
||||
Add(trie, Make("\\lrarr").Literal_().Tex_only_().Manual_("\\leftrightarrow"));
|
||||
Add(trie, Make("\\Lrarr").Literal_().Tex_only_().Manual_("\\Leftrightarrow"));
|
||||
Add(trie, Make("\\lrArr").Literal_().Tex_only_().Manual_("\\Leftrightarrow"));
|
||||
Add(trie, Make("\\Mu").Literal_().Tex_only_().Manual_("\\mathrm{M}"));
|
||||
Add(trie, Make("\\natnums").Literal_().Tex_only_().Manual_("\\mathbb{N}"));
|
||||
Add(trie, Make("\\ne").Literal_().Tex_only_().Manual_("\\neq"));
|
||||
Add(trie, Make("\\Nu").Literal_().Tex_only_().Manual_("\\mathrm{N}"));
|
||||
Add(trie, Make("\\O").Literal_().Tex_only_().Manual_("\\emptyset"));
|
||||
Add(trie, Make("\\omicron").Literal_().Tex_only_().Manual_("\\mathrm{o}"));
|
||||
Add(trie, Make("\\Omicron").Literal_().Tex_only_().Manual_("\\mathrm{O}"));
|
||||
Add(trie, Make("\\or").Literal_().Tex_only_().Manual_("\\lor"));
|
||||
Add(trie, Make("\\part").Literal_().Tex_only_().Manual_("\\partial"));
|
||||
Add(trie, Make("\\plusmn").Literal_().Tex_only_().Manual_("\\pm"));
|
||||
Add(trie, Make("\\rarr").Literal_().Tex_only_().Manual_("\\rightarrow"));
|
||||
Add(trie, Make("\\Rarr").Literal_().Tex_only_().Manual_("\\Rightarrow"));
|
||||
Add(trie, Make("\\rArr").Literal_().Tex_only_().Manual_("\\Rightarrow"));
|
||||
Add(trie, Make("\\real").Literal_().Tex_only_().Manual_("\\Re"));
|
||||
Add(trie, Make("\\reals").Literal_().Tex_only_().Manual_("\\mathbb{R}"));
|
||||
Add(trie, Make("\\Reals").Literal_().Tex_only_().Manual_("\\mathbb{R}"));
|
||||
Add(trie, Make("\\restriction").Literal_().Tex_only_().Manual_("\\upharpoonright"));
|
||||
Add(trie, Make("\\Rho").Literal_().Tex_only_().Manual_("\\mathrm{P}"));
|
||||
Add(trie, Make("\\sdot").Literal_().Tex_only_().Manual_("\\cdot"));
|
||||
Add(trie, Make("\\sect").Literal_().Tex_only_().Manual_("\\S"));
|
||||
Add(trie, Make("\\spades").Literal_().Tex_only_().Manual_("\\spadesuit"));
|
||||
Add(trie, Make("\\sub").Literal_().Tex_only_().Manual_("\\subset"));
|
||||
Add(trie, Make("\\sube").Literal_().Tex_only_().Manual_("\\subseteq"));
|
||||
Add(trie, Make("\\supe").Literal_().Tex_only_().Manual_("\\supseteq"));
|
||||
Add(trie, Make("\\Tau").Literal_().Tex_only_().Manual_("\\mathrm{T}"));
|
||||
Add(trie, Make("\\thetasym").Literal_().Tex_only_().Manual_("\\vartheta"));
|
||||
Add(trie, Make("\\varcoppa").Literal_().Tex_only_().Manual_("\\mbox{coppa}"));
|
||||
Add(trie, Make("\\weierp").Literal_().Tex_only_().Manual_("\\wp"));
|
||||
Add(trie, Make("\\Zeta").Literal_().Tex_only_().Manual_("\\mathrm{Z}"));
|
||||
Add(trie, Make("\\rm").Declh_().Fontforce_rm_());
|
||||
Add(trie, Make("\\it").Declh_().Fontforce_rm_());
|
||||
Add(trie, Make("\\cal").Declh_().Fontforce_rm_());
|
||||
Add(trie, Make("\\bf").Declh_().Fontforce_rm_());
|
||||
Add(trie, Make("\\sideset").Fun_ar2nb_().Manual_("\\sideset "));
|
||||
Add(trie, Make("\\left").Left_());
|
||||
Add(trie, Make("\\right").Right_());
|
||||
Add(trie, Make("\\text").Fail_());
|
||||
Add(trie, Make("\\mbox").Fail_());
|
||||
Add(trie, Make("\\vbox").Fail_());
|
||||
Add(trie, Make("\\hbox").Fail_());
|
||||
Add(trie, Make("\\arccos").Type_latex_());
|
||||
Add(trie, Make("\\arcsin").Type_latex_());
|
||||
Add(trie, Make("\\arctan").Type_latex_());
|
||||
Add(trie, Make("\\arg").Type_latex_());
|
||||
Add(trie, Make("\\cos").Type_latex_());
|
||||
Add(trie, Make("\\cosh").Type_latex_());
|
||||
Add(trie, Make("\\cot").Type_latex_());
|
||||
Add(trie, Make("\\coth").Type_latex_());
|
||||
Add(trie, Make("\\csc").Type_latex_());
|
||||
Add(trie, Make("\\deg").Type_latex_());
|
||||
Add(trie, Make("\\det").Type_latex_());
|
||||
Add(trie, Make("\\dim").Type_latex_());
|
||||
Add(trie, Make("\\exp").Type_latex_());
|
||||
Add(trie, Make("\\gcd").Type_latex_());
|
||||
Add(trie, Make("\\hom").Type_latex_());
|
||||
Add(trie, Make("\\inf").Type_latex_());
|
||||
Add(trie, Make("\\ker").Type_latex_());
|
||||
Add(trie, Make("\\lg").Type_latex_());
|
||||
Add(trie, Make("\\lim").Type_latex_());
|
||||
Add(trie, Make("\\liminf").Type_latex_());
|
||||
Add(trie, Make("\\limsup").Type_latex_());
|
||||
Add(trie, Make("\\ln").Type_latex_());
|
||||
Add(trie, Make("\\log").Type_latex_());
|
||||
Add(trie, Make("\\max").Type_latex_());
|
||||
Add(trie, Make("\\min").Type_latex_());
|
||||
Add(trie, Make("\\Pr").Type_latex_());
|
||||
Add(trie, Make("\\sec").Type_latex_());
|
||||
Add(trie, Make("\\sin").Type_latex_());
|
||||
Add(trie, Make("\\sinh").Type_latex_());
|
||||
Add(trie, Make("\\sup").Type_latex_());
|
||||
Add(trie, Make("\\tan").Type_latex_());
|
||||
Add(trie, Make("\\tanh").Type_latex_());
|
||||
Add(trie, Make("\\arccot").Type_mw_());
|
||||
Add(trie, Make("\\arcsec").Type_mw_());
|
||||
Add(trie, Make("\\arccsc").Type_mw_());
|
||||
Add(trie, Make("\\sgn").Type_mw_());
|
||||
Add(trie, Make("\\sen").Type_mw_());
|
||||
return trie;
|
||||
}
|
||||
private Mwm_tkn__func Make(String key) {return new Mwm_tkn__func(Bry_.new_a7(key));} // NOTE: TEX func names are ASCII
|
||||
private void Add(Btrie_slim_mgr trie, Mwm_tkn__func tkn) {trie.Add_obj(tkn.Key(), tkn);}
|
||||
}
|
@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
class Mwm_tkn__leaf implements Mwm_tkn {
|
||||
class Mwm_tkn__leaf_raw implements Mwm_tkn {
|
||||
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {
|
||||
this.root = root;
|
||||
this.tid = tid;
|
||||
@ -26,7 +26,7 @@ class Mwm_tkn__leaf implements Mwm_tkn {
|
||||
return this;
|
||||
}
|
||||
public Mwm_tkn__root Root() {return root;} private Mwm_tkn__root root;
|
||||
public int Tid() {return tid;} private int tid;
|
||||
@gplx.Virtual public int Tid() {return tid;} private int tid;
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
class Mwm_tkn__leaf_repl implements Mwm_tkn {
|
||||
private final byte[] repl;
|
||||
public Mwm_tkn__leaf_repl(int tid, byte[] repl) {
|
||||
this.tid = tid;
|
||||
this.repl = repl;
|
||||
}
|
||||
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {
|
||||
this.root = root;
|
||||
this.uid = uid;
|
||||
this.src_bgn = src_bgn;
|
||||
this.src_end = src_end;
|
||||
return this;
|
||||
}
|
||||
public Mwm_tkn__root Root() {return root;} private Mwm_tkn__root root;
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Src_end_(int v) {this.src_end = v;}
|
||||
public int Subs__len() {return 0;}
|
||||
public Mwm_tkn Subs__get_at(int i) {throw Err_.new_unsupported();}
|
||||
public void To_bry(Bry_bfr bfr, int indent) {
|
||||
Mwm_tkn_.Tkn_to_bry__bgn(bfr, indent, this);
|
||||
Mwm_tkn_.Tkn_to_bry__end_head(bfr);
|
||||
}
|
||||
}
|
@ -20,19 +20,19 @@ class Mwm_tkn__root implements Mwm_tkn {
|
||||
private final Mwm_root_reg root_reg;
|
||||
private final Mwm_root_ary root_ary = new Mwm_root_ary();
|
||||
private final Mwm_root_sub root_sub = new Mwm_root_sub();
|
||||
public Mwm_tkn__root(Mwm_tkn_mkr tkn_mkr) {
|
||||
this.tkn_mkr = tkn_mkr;
|
||||
private Mwm_tkn_mkr tkn_mkr;
|
||||
public Mwm_tkn__root() {
|
||||
this.root_reg = new Mwm_root_reg(this);
|
||||
}
|
||||
public Mwm_tkn__root Root() {return this;}
|
||||
public Mwm_tkn_mkr Tkn_mkr() {return tkn_mkr;} private final Mwm_tkn_mkr tkn_mkr;
|
||||
public int Tid() {return Mwm_tkn_.Tid__root;}
|
||||
public int Uid() {return Mwm_tkn_.Uid__root;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Src_end_(int v) {this.src_end = v;}
|
||||
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {throw Err_.new_unsupported();}
|
||||
public Mwm_tkn Init_as_root(int src_bgn, int src_end) {
|
||||
public Mwm_tkn Init_as_root(Mwm_tkn_mkr tkn_mkr, int src_bgn, int src_end) {
|
||||
this.tkn_mkr = tkn_mkr;
|
||||
this.src_bgn = src_bgn; this.src_end = src_end;
|
||||
int expd_len = (src_end - src_bgn) / 5;
|
||||
root_reg.Init(expd_len);
|
||||
|
@ -17,16 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
|
||||
class Mwm_tkn_mkr {
|
||||
private final Mwm_tkn__leaf tmp_leaf = new Mwm_tkn__leaf();
|
||||
private final Mwm_tkn[] leaf_protos = new Mwm_tkn[Mwm_tkn_.Tid_len];
|
||||
public void Reg_leaf(int tid, Mwm_tkn tkn) {
|
||||
leaf_protos[tid] = tkn;
|
||||
}
|
||||
public Mwm_tkn Make_leaf(Mwm_tkn__root root, int tid, int uid, int bgn, int end) {
|
||||
synchronized (tmp_leaf) {
|
||||
tmp_leaf.Init(root, tid, uid, bgn, end);
|
||||
return tmp_leaf;
|
||||
}
|
||||
Mwm_tkn proto = leaf_protos[tid];
|
||||
return proto == null ? null : proto.Init(root, tid, uid, bgn, end);
|
||||
}
|
||||
public Mwm_tkn Make_func(Mwm_tkn__root root, int uid, int bgn, int end) {
|
||||
Mwm_tkn__node rv = new Mwm_tkn__node();
|
||||
rv.Init(root, Mwm_tkn_.Tid__func, uid, bgn, end);
|
||||
rv.Init(root, Mwm_tkn_.Tid__fnc, uid, bgn, end);
|
||||
return rv;
|
||||
}
|
||||
public Mwm_tkn Make_curly(Mwm_tkn__root root, int uid, int bgn, int end) {
|
||||
|
@ -164,6 +164,10 @@ public class Scrib_invoke_func_fxt {
|
||||
KeyVal[] actl = Test_scrib_proc_rv(lib, proc_name, Scrib_kv_utl_.base1_many_(args));
|
||||
return (KeyVal[])actl[0].Val();
|
||||
}
|
||||
public Object Test_scrib_proc_rv_as_obj(Scrib_lib lib, String proc_name, Object[] args) {
|
||||
KeyVal[] actl = Test_scrib_proc_rv(lib, proc_name, Scrib_kv_utl_.base1_many_(args));
|
||||
return actl[0].Val();
|
||||
}
|
||||
private KeyVal[] Test_scrib_proc_rv(Scrib_lib lib, String proc_name, KeyVal[] args) {
|
||||
Scrib_proc proc = lib.Procs().Get_by_key(proc_name);
|
||||
Scrib_proc_rslt proc_rslt = new Scrib_proc_rslt();
|
||||
|
@ -21,9 +21,10 @@ public class Scrib_proc_args {
|
||||
public Scrib_proc_args(KeyVal[] v) {Init(v);}
|
||||
public int Len() {return ary_len;}
|
||||
public KeyVal[] Ary() {return ary;}
|
||||
public boolean Pull_bool(int i) {Object rv = Get_or_fail(i); return Bool_.cast(rv);}
|
||||
public String Pull_str(int i) {Object rv = Get_or_fail(i); return String_.cast(rv);}
|
||||
public byte[] Pull_bry(int i) {Object rv = Get_or_fail(i); return Bry_.new_u8(String_.cast(rv));}
|
||||
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 KeyVal[] Pull_kv_ary(int i) {return (KeyVal[])Get_or_fail(i);}
|
||||
public int Pull_int(int i) {Object rv = Get_or_fail(i);
|
||||
try {return Int_.coerce_(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
|
||||
catch (Exception e) {
|
||||
@ -43,6 +44,7 @@ public class Scrib_proc_args {
|
||||
}
|
||||
}
|
||||
}
|
||||
public Object Pull_obj(int i) {return Get_or_fail(i);}
|
||||
public String Cast_str_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : String_.cast (rv);}
|
||||
public byte[] Cast_bry_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Bry_.new_u8(String_.cast (rv));} // NOTE: cast is deliberate; Scrib call checkType whi
|
||||
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));}
|
||||
@ -54,10 +56,6 @@ public class Scrib_proc_args {
|
||||
public String Xstr_str_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Object_.Xto_str_loose_or(rv, null);} // NOTE: Modules can throw exceptions in which return value is nothing; do not fail; return ""; EX: -logy; DATE:2013-10-14
|
||||
public byte[] Xstr_bry_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Bry_.new_u8(Object_.Xto_str_loose_or(rv, null));}
|
||||
public KeyVal[] Cast_kv_ary_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : (KeyVal[])rv;}
|
||||
public KeyVal[] Pull_kv_ary(int i) {
|
||||
Object rv = Get_or_fail(i);
|
||||
return (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));
|
||||
if (params_idx < 0 || params_idx >= ary_len) return Bry_.Ary_empty;
|
||||
Object o = ary[params_idx].Val();
|
||||
|
@ -59,7 +59,7 @@ class Gfo_fld_crt implements Criteria {
|
||||
}
|
||||
public void Val_from_args(Hash_adp args) {throw Err_.new_unimplemented();}
|
||||
public void Val_as_obj_(Object v) {throw Err_.new_unimplemented();}
|
||||
public String To_str() {return String_.Concat(Byte_.Xto_str(fld_idx), " ", crt.To_str());}
|
||||
public String To_str() {return String_.Concat(Byte_.To_str(fld_idx), " ", crt.To_str());}
|
||||
public static Gfo_fld_crt new_(byte fld_idx, Criteria crt) {
|
||||
Gfo_fld_crt rv = new Gfo_fld_crt();
|
||||
rv.fld_idx = fld_idx; rv.crt = crt;
|
||||
|
@ -27,8 +27,9 @@ class Kv_ary_utl {
|
||||
}
|
||||
public static KeyVal[] new_kvs(KeyVal... vals) {return vals;}
|
||||
public static String Ary_to_str(Json_wtr wtr, KeyVal[] ary) {
|
||||
wtr.Doc_nde_bgn();
|
||||
Ary_to_str(wtr, 0, ary);
|
||||
return wtr.To_str_and_clear();
|
||||
return wtr.Doc_nde_end().To_str_and_clear();
|
||||
}
|
||||
private static void Ary_to_str(Json_wtr wtr, int indent, KeyVal[] ary) {
|
||||
int len = ary.length;
|
||||
@ -44,7 +45,7 @@ class Kv_ary_utl {
|
||||
if (Type_adp_.Eq(val_type, KeyVal[].class))
|
||||
Ary_to_str__nde(wtr, indent, itm.Key(), (KeyVal[])itm.Val());
|
||||
else if (Type_adp_.Is_array(val_type))
|
||||
Ary_to_str__ary(wtr, indent, itm.Key(), Array_.cast(itm.Val()));
|
||||
Ary_to_str__ary(wtr, indent, itm.Key(), Array_.cast(val));
|
||||
else
|
||||
throw Err_.new_unhandled(type_tid);
|
||||
}
|
||||
@ -70,7 +71,7 @@ class Kv_ary_utl {
|
||||
if (itm_type_tid == Type_adp_.Tid__obj) {
|
||||
if (Type_adp_.Eq(itm_type, KeyVal.class))
|
||||
Ary_to_str__itm(wtr, indent + 1, (KeyVal)itm);
|
||||
if (Type_adp_.Is_array(itm_type))
|
||||
else if (Type_adp_.Is_array(itm_type))
|
||||
Ary_to_str__ary_itms(wtr, indent + 1, Array_.cast(itm));
|
||||
else
|
||||
throw Err_.new_unhandled(itm_type);
|
||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
public class Scrib_lib_text implements Scrib_lib {
|
||||
private final Scrib_lib_text__json_util json_util = new Scrib_lib_text__json_util();
|
||||
private final Scrib_lib_text__reindex_data reindex_data = new Scrib_lib_text__reindex_data();
|
||||
public Scrib_lib_text(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
public Scrib_lib Init() {procs.Init_by_lib(this, Proc_names); return this;}
|
||||
@ -27,7 +28,7 @@ public class Scrib_lib_text implements Scrib_lib {
|
||||
notify_wiki_changed_fnc = mod.Fncs_get_by_key("notify_wiki_changed");
|
||||
return mod;
|
||||
} private Scrib_lua_proc notify_wiki_changed_fnc;
|
||||
public Scrib_proc_mgr Procs() {return procs;} private Scrib_proc_mgr procs = new Scrib_proc_mgr();
|
||||
public Scrib_proc_mgr Procs() {return procs;} private final Scrib_proc_mgr procs = new Scrib_proc_mgr();
|
||||
public boolean Procs_exec(int key, Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
switch (key) {
|
||||
case Proc_unstrip: return Unstrip(args, rslt);
|
||||
@ -51,14 +52,55 @@ public class Scrib_lib_text implements Scrib_lib {
|
||||
if (Html_entity_ == null) Html_entity_ = Scrib_lib_text_html_entities.new_();
|
||||
return rslt.Init_obj(Html_entity_);
|
||||
} private static KeyVal[] Html_entity_;
|
||||
// public boolean JsonEncode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
// Object itm = args.Pull_obj(0);
|
||||
// Class<?> itm_type = itm.getClass();
|
||||
// KeyVal[] itm_as_kvy = null;
|
||||
// Object itm_as_ary = null;
|
||||
// if (Type_adp_.Eq(itm_type, typeof(KeyVal[]))) itm_as_kvy = (KeyVal[])itm;
|
||||
// else if (Type_adp_.Is_array(itm_type)) itm_as_ary = Array_.cast(itm);
|
||||
// int flags = args.Cast_int_or(1, 0);
|
||||
// if (itm_as_kvy != null && !Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys))
|
||||
// itm_as_kvy = json_util.Reindex_arrays(itm_as_kvy, true);
|
||||
// byte[] rv = null;
|
||||
// if (itm_as_kvy != null)
|
||||
// rv = json_util.Encode_as_nde(itm_as_kvy, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
|
||||
// else if (itm_as_ary != null)
|
||||
// rv = json_util.Encode_as_ary(itm_as_ary, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);;
|
||||
// if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to encode value");
|
||||
// return rslt.Init_obj(rv);
|
||||
// }
|
||||
public boolean JsonEncode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
KeyVal[] kv_ary = args.Pull_kv_ary(0);
|
||||
Object itm = args.Pull_obj(0);
|
||||
Class<?> itm_type = itm.getClass();
|
||||
KeyVal[] itm_as_kvy = null;
|
||||
Object itm_as_ary = null;
|
||||
if (Type_adp_.Eq(itm_type, KeyVal[].class)) itm_as_kvy = (KeyVal[])itm;
|
||||
else if (Type_adp_.Is_array(itm_type)) itm_as_ary = Array_.cast(itm);
|
||||
int flags = args.Cast_int_or(1, 0);
|
||||
if (!Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys))
|
||||
kv_ary = json_util.Reindex_arrays(kv_ary, true);
|
||||
byte[] rv = json_util.Encode(kv_ary, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
|
||||
if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to encode value");
|
||||
return rslt.Init_obj(rv);
|
||||
synchronized (reindex_data) {
|
||||
if ( itm_as_kvy != null
|
||||
&& itm_as_kvy.length > 0
|
||||
&& !Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys)
|
||||
) {
|
||||
json_util.Reindex_arrays(reindex_data, itm_as_kvy, true);
|
||||
if (reindex_data.Rv_is_kvy()) {
|
||||
itm_as_kvy = reindex_data.Rv_as_kvy();
|
||||
itm_as_ary = null;
|
||||
}
|
||||
else {
|
||||
itm_as_ary = reindex_data.Rv_as_ary();
|
||||
itm_as_kvy = null;
|
||||
}
|
||||
}
|
||||
byte[] rv = null;
|
||||
if (itm_as_kvy != null)
|
||||
rv = json_util.Encode_as_nde(itm_as_kvy, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
|
||||
else
|
||||
rv = json_util.Encode_as_ary(itm_as_ary, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
|
||||
if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to encode value");
|
||||
return rslt.Init_obj(rv);
|
||||
}
|
||||
}
|
||||
public boolean JsonDecode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] json = args.Pull_bry(0);
|
||||
@ -66,11 +108,19 @@ public class Scrib_lib_text implements Scrib_lib {
|
||||
int opts = Scrib_lib_text__json_util.Opt__force_assoc;
|
||||
if (Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__try_fixing))
|
||||
opts = Enm_.Add_int(opts, Scrib_lib_text__json_util.Flag__try_fixing);
|
||||
KeyVal[] rv = json_util.Decode(core.App().Utl__json_parser(), json, opts);
|
||||
if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to decode String " + String_.new_u8(json));
|
||||
if (!(Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys)))
|
||||
rv = json_util.Reindex_arrays(rv, false);
|
||||
return rslt.Init_obj(rv);
|
||||
synchronized (procs) {
|
||||
byte rv_tid = json_util.Decode(core.App().Utl__json_parser(), json, opts);
|
||||
if (rv_tid == Bool_.__byte) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to decode String " + String_.new_u8(json));
|
||||
if (rv_tid == Bool_.Y_byte && !(Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys))) {
|
||||
KeyVal[] rv_as_kvy = (KeyVal[])json_util.Decode_rslt_as_nde();
|
||||
synchronized (reindex_data) {
|
||||
json_util.Reindex_arrays(reindex_data, rv_as_kvy, false);
|
||||
return rslt.Init_obj(reindex_data.Rv_is_kvy() ? reindex_data.Rv_as_kvy() : reindex_data.Rv_as_ary());
|
||||
}
|
||||
}
|
||||
else
|
||||
return rslt.Init_obj(json_util.Decode_rslt_as_ary());
|
||||
}
|
||||
}
|
||||
public void Notify_wiki_changed() {if (notify_wiki_changed_fnc != null) core.Interpreter().CallFunction(notify_wiki_changed_fnc.Id(), KeyVal_.Ary_empty);}
|
||||
public boolean Init_text_for_wiki(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
@ -82,7 +132,6 @@ public class Scrib_lib_text implements Scrib_lib {
|
||||
rv[3] = KeyVal_.new_("nowiki_protocols", KeyVal_.Ary_empty); // NOTE: code implemented, but waiting for it to be used; DATE:2014-03-20
|
||||
return rslt.Init_obj(rv);
|
||||
}
|
||||
public void Init_for_tests() {json_util.Init_for_tests();}
|
||||
private String Init_lib_text_get_msg(Xow_msg_mgr msg_mgr, String msg_key) {
|
||||
return String_.new_u8(msg_mgr.Val_by_key_obj(Bry_.new_u8(msg_key)));
|
||||
}
|
||||
|
@ -19,11 +19,10 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.core.json.*;
|
||||
class Scrib_lib_text__json_util {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
public void Init_for_tests() {wtr.Opt_quote_byte_(Byte_ascii.Apos);}
|
||||
public KeyVal[] Reindex_arrays(KeyVal[] kv_ary, boolean is_encoding) {
|
||||
public void Reindex_arrays(Scrib_lib_text__reindex_data rv, KeyVal[] kv_ary, boolean is_encoding) {
|
||||
int next = 0;
|
||||
if (is_encoding) {
|
||||
// ksort( $arr, SORT_NUMERIC );
|
||||
Array_.Sort(kv_ary, KeyVal__sorter__key_is_numeric.I);
|
||||
next = 1;
|
||||
}
|
||||
boolean is_sequence = true;
|
||||
@ -31,56 +30,91 @@ class Scrib_lib_text__json_util {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
KeyVal kv = kv_ary[i];
|
||||
Object kv_val = kv.Val();
|
||||
if (kv_val != null && Type_adp_.Eq(kv_val.getClass(), KeyVal[].class))
|
||||
kv_val = Reindex_arrays((KeyVal[])kv_val, is_encoding);
|
||||
if (kv_val != null && Type_adp_.Eq(kv_val.getClass(), KeyVal[].class)) {
|
||||
Reindex_arrays(rv, (KeyVal[])kv_val, is_encoding);
|
||||
if (!rv.Rv_is_kvy())
|
||||
kv.Val_(rv.Rv_as_ary());
|
||||
}
|
||||
if (is_sequence) {
|
||||
if (kv.Key_tid() == Type_adp_.Tid__int) {
|
||||
int kv_key_as_int = Int_.cast(kv.Key_as_obj());
|
||||
is_sequence = next++ == kv_key_as_int;
|
||||
// } elseif ( $isEncoding && ctype_digit( $k ) ) {
|
||||
// // json_decode currently doesn't return integer keys for {}
|
||||
// $isSequence = $next++ === (int)$k;
|
||||
} else {
|
||||
is_sequence = false;
|
||||
}
|
||||
else {
|
||||
int kv_key_to_int = Bry_.To_int_or__strict(Bry_.new_a7(kv.Key()), -1); // NOTE: a7 b/c proc is only checking for digits; none a7 bytes will be replaced by ?
|
||||
if (is_encoding && kv_key_to_int != -1) {
|
||||
is_sequence = next == kv_key_to_int;
|
||||
++next;
|
||||
}
|
||||
else
|
||||
is_sequence = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_sequence) {
|
||||
if (is_encoding) {
|
||||
// return array_values( $arr );
|
||||
Object rv_as_ary = To_array_values(kv_ary);
|
||||
rv.Init(Bool_.N, null, rv_as_ary);
|
||||
return;
|
||||
} else {
|
||||
// return $arr ? array_combine( range( 1, count( $arr ) ), $arr ) : $arr;
|
||||
Convert_to_base1(kv_ary); // PHP: return $arr ? array_combine( range( 1, count( $arr ) ), $arr ) : $arr;
|
||||
}
|
||||
}
|
||||
return kv_ary;
|
||||
rv.Init(Bool_.Y, kv_ary, null);
|
||||
}
|
||||
public KeyVal[] Decode(Json_parser parser, byte[] src, int flag) {
|
||||
Json_doc jdoc = parser.Parse(src);
|
||||
Json_nde root = jdoc.Root_nde();
|
||||
int len = root.Len();
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
private static Object[] To_array_values(KeyVal[] ary) {
|
||||
int len = ary.length;
|
||||
Object[] rv = new Object[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_kv json_kv = root.Get_at_as_kv(i);
|
||||
String kv_str = json_kv.Key_as_str();
|
||||
Object kv_val = Decode_obj(json_kv.Val());
|
||||
rv[i] = KeyVal_.new_(kv_str, kv_val);
|
||||
KeyVal itm = ary[i];
|
||||
rv[i] = itm.Val();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static void Convert_to_base1(KeyVal[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
KeyVal itm = ary[i];
|
||||
itm.Key_(i + 1);
|
||||
}
|
||||
}
|
||||
public KeyVal[] Decode_rslt_as_nde() {return decode_rslt_as_nde;} private KeyVal[] decode_rslt_as_nde;
|
||||
public Object Decode_rslt_as_ary() {return decode_rslt_as_ary;} private Object decode_rslt_as_ary;
|
||||
public byte Decode(Json_parser parser, byte[] src, int flag) {
|
||||
synchronized (wtr) {
|
||||
Json_doc jdoc = parser.Parse(src);
|
||||
if (jdoc.Root_grp().Tid() == Json_itm_.Tid__ary) {
|
||||
this.decode_rslt_as_ary = Decode_ary(jdoc.Root_ary());
|
||||
return Bool_.N_byte;
|
||||
}
|
||||
else {
|
||||
Json_nde root = (Json_nde)jdoc.Root_grp();
|
||||
int len = root.Len();
|
||||
this.decode_rslt_as_nde = new KeyVal[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_kv json_kv = root.Get_at_as_kv(i);
|
||||
String kv_str = json_kv.Key_as_str();
|
||||
Object kv_val = Decode_obj(json_kv.Val());
|
||||
decode_rslt_as_nde[i] = KeyVal_.new_(kv_str, kv_val);
|
||||
}
|
||||
return Bool_.Y_byte;
|
||||
}
|
||||
}
|
||||
}
|
||||
private Object Decode_obj(Json_itm itm) {
|
||||
int itm_tid = itm.Tid();
|
||||
switch (itm_tid) {
|
||||
case Json_itm_.Tid__ary: return Decode_ary(Json_ary.cast(itm));
|
||||
case Json_itm_.Tid__nde: return Decode_nde(Json_nde.cast(itm));
|
||||
case Json_itm_.Tid__nde: return Decode_nde(Json_nde.cast(itm));
|
||||
default: return itm.Data();
|
||||
}
|
||||
}
|
||||
private Object Decode_ary(Json_ary ary) {
|
||||
int len = ary.Len();
|
||||
Object rv = Array_.Create(int.class, len);
|
||||
Object rv = Array_.Create(Object.class, len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm itm = ary.Get_at(i);
|
||||
Array_.Set(rv, i, Decode_obj(itm));
|
||||
Array_.Set_at(rv, i, Decode_obj(itm));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -93,11 +127,18 @@ class Scrib_lib_text__json_util {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public byte[] Encode(KeyVal[] kv_ary, int flag, int skip) {
|
||||
public byte[] Encode_as_nde(KeyVal[] itm, int flag, int skip) {
|
||||
synchronized (wtr ) {
|
||||
wtr.Clear().Doc_bgn();
|
||||
Encode_kv_ary(kv_ary);
|
||||
return wtr.Doc_end().To_bry_and_clear();
|
||||
wtr.Clear().Doc_nde_bgn();
|
||||
Encode_kv_ary(itm);
|
||||
return wtr.Doc_nde_end().To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Encode_as_ary(Object ary, int flag, int skip) {
|
||||
synchronized (wtr ) {
|
||||
wtr.Clear().Doc_ary_bgn();
|
||||
Encode_ary(ary);
|
||||
return wtr.Doc_ary_end().To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
private void Encode_kv_ary(KeyVal[] kv_ary) {
|
||||
@ -117,10 +158,7 @@ class Scrib_lib_text__json_util {
|
||||
}
|
||||
else if (Type_adp_.Is_array(type)) { // encode as array
|
||||
wtr.Ary_bgn(kv.Key());
|
||||
Object ary = Array_.cast(kv_val);
|
||||
int ary_len = Array_.Len(ary);
|
||||
for (int j = 0; j < ary_len; ++j)
|
||||
wtr.Ary_itm_obj(Array_.Get_at(ary, j));
|
||||
Encode_ary(kv_val);
|
||||
wtr.Ary_end();
|
||||
}
|
||||
else if (Type_adp_.Eq(type, Int_.Cls_ref_type)) wtr.Kv_int(kv.Key(), Int_.cast(kv_val));
|
||||
@ -129,9 +167,15 @@ class Scrib_lib_text__json_util {
|
||||
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 wtr.Kv_str(kv.Key(), Object_.Xto_str_strict_or_null(kv_val));
|
||||
}
|
||||
}
|
||||
private void Encode_ary(Object ary) {
|
||||
int ary_len = Array_.Len(ary);
|
||||
for (int j = 0; j < ary_len; ++j)
|
||||
wtr.Ary_itm_obj(Array_.Get_at(ary, j));
|
||||
}
|
||||
public static final int
|
||||
Flag__preserve_keys = 1
|
||||
Flag__none = 0
|
||||
, Flag__preserve_keys = 1
|
||||
, Flag__try_fixing = 2
|
||||
, Flag__pretty = 4
|
||||
;
|
||||
@ -144,3 +188,23 @@ class Scrib_lib_text__json_util {
|
||||
Opt__force_assoc = 1
|
||||
;
|
||||
}
|
||||
class KeyVal__sorter__key_is_numeric implements gplx.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
KeyVal lhs_itm = (KeyVal)lhsObj;
|
||||
KeyVal rhs_itm = (KeyVal)rhsObj;
|
||||
int lhs_int = Int_.parse_or(lhs_itm.Key(), Int_.Min_value);
|
||||
int rhs_int = Int_.parse_or(rhs_itm.Key(), Int_.Min_value);
|
||||
return CompareAble_.Compare(lhs_int, rhs_int);
|
||||
}
|
||||
public static final KeyVal__sorter__key_is_numeric I = new KeyVal__sorter__key_is_numeric(); KeyVal__sorter__key_is_numeric() {}
|
||||
}
|
||||
class Scrib_lib_text__reindex_data {
|
||||
public boolean Rv_is_kvy() {return rv_is_kvy;} private boolean rv_is_kvy;
|
||||
public KeyVal[] Rv_as_kvy() {return rv_as_kvy;} private KeyVal[] rv_as_kvy;
|
||||
public Object Rv_as_ary() {return rv_as_ary;} private Object rv_as_ary;
|
||||
public void Init(boolean rv_is_kvy, KeyVal[] rv_as_kvy, Object rv_as_ary) {
|
||||
this.rv_is_kvy = rv_is_kvy;
|
||||
this.rv_as_kvy = rv_as_kvy;
|
||||
this.rv_as_ary = rv_as_ary;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,239 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import org.junit.*; import gplx.core.json.*;
|
||||
public class Scrib_lib_text_json_tst {
|
||||
private Scrib_invoke_func_fxt fxt = new Scrib_invoke_func_fxt(); private Scrib_lib_text lib;
|
||||
private Scrib_lib_json_fxt json_fxt = new Scrib_lib_json_fxt();
|
||||
@Before public void init() {
|
||||
fxt.Clear_for_lib();
|
||||
lib = fxt.Core().Lib_text();
|
||||
lib.Init();
|
||||
}
|
||||
@Test public void Nde__empty() { // NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{"
|
||||
, "}"
|
||||
)
|
||||
, KeyVal_.Ary_empty
|
||||
);
|
||||
}
|
||||
@Test public void Nde__key_obj__primitives() { // NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{ 'int':1"
|
||||
, ", 'String':'abc'"
|
||||
, ", 'true':true"
|
||||
, ", 'array':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , 3"
|
||||
, " ]"
|
||||
, ", 'node':"
|
||||
, " { 'key':'val'"
|
||||
, " }"
|
||||
, "}"
|
||||
)
|
||||
, KeyVal_.Ary
|
||||
( KeyVal_.new_("int", 1)
|
||||
, KeyVal_.new_("String", "abc")
|
||||
, KeyVal_.new_("true", true)
|
||||
, KeyVal_.new_("array", new int[] {1, 2, 3})
|
||||
, KeyVal_.new_("node", KeyVal_.Ary(KeyVal_.new_("key", "val")))
|
||||
));
|
||||
}
|
||||
@Test public void Nde__obj_in_obj() {
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{ 'x':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , { 'y':'x'"
|
||||
, " }"
|
||||
, " ]"
|
||||
, "}"
|
||||
)
|
||||
, KeyVal_.Ary
|
||||
( KeyVal_.new_("x", new Object[]
|
||||
{ 1, 2, KeyVal_.Ary
|
||||
( KeyVal_.new_("y", "x")
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Nde__ary_in_obj() { // NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{ 'x':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , { 'y':"
|
||||
, " [ 3"
|
||||
, " , 4"
|
||||
, " ]"
|
||||
, " }"
|
||||
, " ]"
|
||||
, "}"
|
||||
)
|
||||
, KeyVal_.Ary
|
||||
( KeyVal_.new_("x"
|
||||
, new Object[] {1, 2, KeyVal_.Ary
|
||||
( KeyVal_.new_("y"
|
||||
, new Object[] {3, 4}
|
||||
))}))
|
||||
);
|
||||
}
|
||||
@Test public void Nde__key_int__mixed() {// NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{ 'x':'x'"
|
||||
, ", '1':1"
|
||||
, ", '2':2"
|
||||
, "}"
|
||||
)
|
||||
, KeyVal_.Ary
|
||||
( KeyVal_.new_("x", "x")
|
||||
, KeyVal_.new_("1", 1)
|
||||
, KeyVal_.new_("2", 2)
|
||||
));
|
||||
}
|
||||
@Test public void Nde__key_int__auto() {// NOTE: based on MW
|
||||
json_fxt.Test_json_encode(fxt, lib
|
||||
, Scrib_lib_text__json_util.Flag__preserve_keys
|
||||
, Kv_ary_utl.new_(Bool_.Y, new Object[]
|
||||
{ 1
|
||||
, "abc"
|
||||
, true
|
||||
, false
|
||||
})
|
||||
, Json_doc.Make_str_by_apos // NOTE: numbering is done by Kv_ary_utl, not Reindex_arrays
|
||||
( "{ '1':1"
|
||||
, ", '2':'abc'"
|
||||
, ", '3':true"
|
||||
, ", '4':false"
|
||||
, "}"
|
||||
)
|
||||
);
|
||||
json_fxt.Test_json_decode(fxt, lib
|
||||
, Scrib_lib_text__json_util.Flag__preserve_keys
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "[ 1"
|
||||
, ", 'abc'"
|
||||
, ", true"
|
||||
, ", false"
|
||||
, "]"
|
||||
)
|
||||
, new Object[]
|
||||
{ 1
|
||||
, "abc"
|
||||
, true
|
||||
, false
|
||||
}
|
||||
);
|
||||
}
|
||||
@Test public void Ary__empty() { // NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "["
|
||||
, "]"
|
||||
)
|
||||
, Object_.Ary_empty
|
||||
);
|
||||
}
|
||||
@Test public void Ary__obj() { // NOTE: based on MW
|
||||
json_fxt.Test_json_encode(fxt, lib, Scrib_lib_text__json_util.Flag__none
|
||||
, Kv_ary_utl.new_(Bool_.Y, 1, "abc", true)
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "[ 1"
|
||||
, ", 'abc'"
|
||||
, ", true"
|
||||
, "]"
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Ary__nested() { // NOTE: based on MW
|
||||
json_fxt.Test_json_roundtrip(fxt, lib
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "[ 1"
|
||||
, ", 2"
|
||||
, ", 3"
|
||||
, ", "
|
||||
, " [ 4"
|
||||
, " , 5"
|
||||
, " , "
|
||||
, " [ 6"
|
||||
, " , 7"
|
||||
, " , 8"
|
||||
, " ]"
|
||||
, " , 9"
|
||||
, " ]"
|
||||
, "]"
|
||||
)
|
||||
, new Object[] {1, 2, 3, new Object[] {4, 5, new Object[] {6, 7, 8}, 9}}
|
||||
);
|
||||
}
|
||||
@Test public void Nde__smoke() {
|
||||
json_fxt.Test_json_encode(fxt, lib
|
||||
, Scrib_lib_text__json_util.Flag__none
|
||||
, KeyVal_.Ary
|
||||
( KeyVal_.new_("axes", KeyVal_.Ary
|
||||
( KeyVal_.int_(1, KeyVal_.Ary
|
||||
( KeyVal_.new_("type", "x")
|
||||
))
|
||||
, KeyVal_.int_(2, KeyVal_.Ary
|
||||
( KeyVal_.new_("type", "y")
|
||||
))
|
||||
))
|
||||
)
|
||||
, Json_doc.Make_str_by_apos
|
||||
( "{ 'axes':"
|
||||
, " ["
|
||||
, " { 'type':'x'"
|
||||
, " }"
|
||||
, " , { 'type':'y'"
|
||||
, " }"
|
||||
, " ]"
|
||||
, "}"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
class Scrib_lib_json_fxt {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
public void Test_json_roundtrip(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, String json, Object obj) {
|
||||
Test_json_decode(fxt, lib, Scrib_lib_text__json_util.Flag__none, json, obj);
|
||||
Test_json_encode(fxt, lib, Scrib_lib_text__json_util.Flag__none, obj, json);
|
||||
}
|
||||
public void Test_json_decode(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, int flag, String raw, Object expd) {
|
||||
Object actl = fxt.Test_scrib_proc_rv_as_obj(lib, Scrib_lib_text.Invk_jsonDecode, Object_.Ary(raw, flag));
|
||||
Tfds.Eq_str_lines(To_str(expd), To_str(actl), raw);
|
||||
}
|
||||
public void Test_json_encode(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, int flag, Object raw, String expd) {
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_text.Invk_jsonEncode, Object_.Ary(raw, flag), "1=" + String_.Replace(expd, "'", "\""));
|
||||
}
|
||||
private String To_str(Object o) {
|
||||
if (o == null) return "<< NULL >>";
|
||||
Class<?> type = o.getClass();
|
||||
if (Type_adp_.Eq(type, KeyVal[].class)) return Kv_ary_utl.Ary_to_str(wtr, (KeyVal[])o);
|
||||
else if (Type_adp_.Is_array(type)) return Array_.To_str_nested_obj(o);
|
||||
else return Object_.Xto_str_strict_or_null(o);
|
||||
}
|
||||
}
|
@ -19,12 +19,10 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import org.junit.*; import gplx.core.json.*;
|
||||
public class Scrib_lib_text_tst {
|
||||
private Scrib_invoke_func_fxt fxt = new Scrib_invoke_func_fxt(); private Scrib_lib_text lib;
|
||||
private Scrib_lib_json_fxt json_fxt = new Scrib_lib_json_fxt();
|
||||
@Before public void init() {
|
||||
fxt.Clear_for_lib();
|
||||
lib = fxt.Core().Lib_text();
|
||||
lib.Init();
|
||||
lib.Init_for_tests();
|
||||
}
|
||||
@Test public void Unstrip() {
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_text.Invk_unstrip, Object_.Ary("a"), "a");
|
||||
@ -33,106 +31,4 @@ public class Scrib_lib_text_tst {
|
||||
KeyVal[] actl = fxt.Test_scrib_proc_rv_as_kv_ary(lib, Scrib_lib_text.Invk_getEntityTable, Object_.Ary());
|
||||
Tfds.Eq(1510, actl.length); // large result; only test # of entries
|
||||
}
|
||||
@Test public void JsonEncode() {
|
||||
json_fxt.Test_json_encode(fxt, lib, Kv_ary_utl.new_
|
||||
( true
|
||||
, true
|
||||
, 1
|
||||
, "a"
|
||||
, new int[] {1, 2, 3}
|
||||
, Kv_ary_utl.new_(true, "b")
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "1="
|
||||
+ "{ '1':true"
|
||||
, ", '2':1"
|
||||
, ", '3':'a'"
|
||||
, ", '4':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , 3"
|
||||
, " ]"
|
||||
, ", '5':"
|
||||
, " { '1':'b'"
|
||||
, " }"
|
||||
, "}"
|
||||
));
|
||||
}
|
||||
@Test public void JsonDecode() {
|
||||
json_fxt.Test_json_decode(fxt, lib
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "{ '1':true"
|
||||
, ", '2':1"
|
||||
, ", '3':'a'"
|
||||
, ", '4':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , 3"
|
||||
, " ]"
|
||||
, ", '5':"
|
||||
, " { '1':'b'"
|
||||
, " }"
|
||||
, "}"
|
||||
)
|
||||
, Kv_ary_utl.new_
|
||||
( true
|
||||
, true
|
||||
, 1
|
||||
, "a"
|
||||
, new int[] {1, 2, 3}
|
||||
, Kv_ary_utl.new_(true, "b")
|
||||
));
|
||||
}
|
||||
@Test public void JsonDecode__primitives() {
|
||||
json_fxt.Test_json_decode(fxt, lib
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "{ 'int':1"
|
||||
, ", 'String':'abc'"
|
||||
, ", 'true':true"
|
||||
, "}"
|
||||
)
|
||||
, Kv_ary_utl.new_kvs
|
||||
( KeyVal_.new_("int", 1)
|
||||
, KeyVal_.new_("String", "abc")
|
||||
, KeyVal_.new_("true", true)
|
||||
));
|
||||
}
|
||||
@Test public void JsonDecode__numeric_keys() {
|
||||
json_fxt.Test_json_decode(fxt, lib
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "{ 'x':'x'"
|
||||
, ", '1':1"
|
||||
, ", '2':2"
|
||||
, "}"
|
||||
)
|
||||
, Kv_ary_utl.new_kvs
|
||||
( KeyVal_.new_("x", "x")
|
||||
, KeyVal_.new_("1", 1)
|
||||
, KeyVal_.new_("2", 2)
|
||||
));
|
||||
}
|
||||
// @Test public void JsonDecode__array() {
|
||||
// json_fxt.Test_json_decode(fxt, lib
|
||||
// , String_.Concat_lines_nl_skip_last
|
||||
// ( "[ 1"
|
||||
// , ", 2"
|
||||
// , ", 3"
|
||||
// , "]"
|
||||
// )
|
||||
// , Kv_ary_utl.new_kvs
|
||||
// ( KeyVal_.new_("int", 1)
|
||||
// , KeyVal_.new_("String", "abc")
|
||||
// , KeyVal_.new_("true", true)
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Scrib_lib_json_fxt {
|
||||
private final Json_wtr wtr = new Json_wtr().Opt_quote_byte_(Byte_ascii.Apos);
|
||||
public void Test_json_decode(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, String raw, KeyVal[] expd) {
|
||||
raw = String_.Replace(raw, "'", "\"");
|
||||
KeyVal[] actl = fxt.Test_scrib_proc_rv_as_kv_ary(lib, Scrib_lib_text.Invk_jsonDecode, Object_.Ary(raw));
|
||||
Tfds.Eq_str_lines(Kv_ary_utl.Ary_to_str(wtr, expd), Kv_ary_utl.Ary_to_str(wtr, actl), raw);
|
||||
}
|
||||
public void Test_json_encode(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, KeyVal[] raw, String expd) {
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_text.Invk_jsonEncode, Object_.Ary((Object)raw), expd);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class Io_line_rdr {
|
||||
// ++url_idx;
|
||||
// bfr_state = Bfr_state_end;
|
||||
}
|
||||
if (old_bfr_len > 0) Array_.CopyTo(bfr, bfr_last_read, load_ary, 0, old_bfr_len); // copy old_bfr over
|
||||
if (old_bfr_len > 0) Array_.Copy_to(bfr, bfr_last_read, load_ary, 0, old_bfr_len); // copy old_bfr over
|
||||
file_pos += read_len;
|
||||
bfr = load_ary;
|
||||
bfr_last_read = 0;
|
||||
|
@ -65,7 +65,7 @@ public class Xol_lang_srl {
|
||||
switch (cs_byte) {
|
||||
case Byte_ascii.Num_0: cur_cs = false; break;
|
||||
case Byte_ascii.Num_1: cur_cs = true; break;
|
||||
default: throw Err_.new_wo_type("case sensitive should be 0 or 1", "cs", Byte_.Xto_str(cs_byte));
|
||||
default: throw Err_.new_wo_type("case sensitive should be 0 or 1", "cs", Byte_.To_str(cs_byte));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ public class Xoi_dump_mgr implements GfoInvkAble {
|
||||
else throw Err_.new_unhandled(v);
|
||||
}
|
||||
private static final KeyVal[] Options_search_version_list = KeyVal_.Ary(KeyVal_.new_("1"), KeyVal_.new_("2"));
|
||||
public static String Options_search_version_str(byte v) {return Byte_.Xto_str(v);}
|
||||
public static String Options_search_version_str(byte v) {return Byte_.To_str(v);}
|
||||
public static byte Options_search_version_parse(String v) {return Byte_.parse(v);}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
|
||||
int subs_pos_ary_len = subs_pos_ary.length;
|
||||
if (pos_idx + 1 > subs_pos_ary_len) {
|
||||
int[] new_subs_pos_ary = new int[(pos_idx + 1) * 2];
|
||||
Array_.CopyTo(subs_pos_ary, 0, new_subs_pos_ary, 0, subs_pos_ary.length);
|
||||
Array_.Copy_to(subs_pos_ary, 0, new_subs_pos_ary, 0, subs_pos_ary.length);
|
||||
subs_pos_ary = new_subs_pos_ary;
|
||||
}
|
||||
subs_pos_ary[pos_idx] = bgn;
|
||||
@ -56,7 +56,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
|
||||
if (new_len > subs_max) { // ary too small >>> expand
|
||||
subs_max = new_len * 2;
|
||||
Xop_tkn_itm[] new_subs = new Xop_tkn_itm[subs_max];
|
||||
Array_.CopyTo(subs, 0, new_subs, 0, subs_len);
|
||||
Array_.Copy_to(subs, 0, new_subs, 0, subs_len);
|
||||
subs = new_subs;
|
||||
}
|
||||
subs[subs_len] = sub;
|
||||
|
@ -71,6 +71,7 @@ public class Xop_tkn_mkr {
|
||||
public gplx.xowa.xtns.gallery.Gallery_xnde Xnde_gallery() {return new gplx.xowa.xtns.gallery.Gallery_xnde();}
|
||||
public gplx.xowa.xtns.imaps.Imap_xnde Xnde_imageMap() {return new gplx.xowa.xtns.imaps.Imap_xnde();}
|
||||
public gplx.xowa.xtns.hieros.Hiero_xnde Xnde_hiero() {return new gplx.xowa.xtns.hieros.Hiero_xnde();}
|
||||
public gplx.xowa.xtns.graphs.Graph_xnde Xnde_graph() {return new gplx.xowa.xtns.graphs.Graph_xnde();}
|
||||
public gplx.xowa.xtns.proofreadPage.Pp_pages_nde Xnde_pages() {return new gplx.xowa.xtns.proofreadPage.Pp_pages_nde();}
|
||||
public gplx.xowa.xtns.proofreadPage.Pp_pagelist_nde Xnde_pagelist() {return new gplx.xowa.xtns.proofreadPage.Pp_pagelist_nde();}
|
||||
public gplx.xowa.xtns.proofreadPage.Pp_pagequality_nde Xnde_pagequality() {return new gplx.xowa.xtns.proofreadPage.Pp_pagequality_nde();}
|
||||
|
@ -137,8 +137,9 @@ public class Xop_xnde_tag_ {
|
||||
, Tid_quiz = 111
|
||||
, Tid_indicator = 112
|
||||
, Tid_q = 113
|
||||
, Tid_graph = 114
|
||||
;
|
||||
public static final int _MaxLen = 114;
|
||||
public static final int _MaxLen = 115;
|
||||
public static final Xop_xnde_tag[] Ary = new Xop_xnde_tag[_MaxLen];
|
||||
private static Xop_xnde_tag new_(int id, String name) {
|
||||
Xop_xnde_tag rv = new Xop_xnde_tag(id, name);
|
||||
@ -260,5 +261,6 @@ public class Xop_xnde_tag_ {
|
||||
, Tag_quiz = new_(Tid_quiz, "quiz").Xtn_()
|
||||
, Tag_indicator = new_(Tid_indicator, "indicator").Xtn_()
|
||||
, Tag_q = new_(Tid_q, "q")
|
||||
, Tag_graph = new_(Tid_graph, "graph").Xtn_()
|
||||
;
|
||||
}
|
||||
|
@ -658,6 +658,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
case Xop_xnde_tag_.Tid_quiz: xnde_xtn = tkn_mkr.Xnde_quiz(); break;
|
||||
case Xop_xnde_tag_.Tid_indicator: xnde_xtn = tkn_mkr.Xnde_indicator(); break;
|
||||
case Xop_xnde_tag_.Tid_xowa_html: xnde_xtn = tkn_mkr.Xnde_xowa_html(); break;
|
||||
case Xop_xnde_tag_.Tid_graph: xnde_xtn = tkn_mkr.Xnde_graph(); break;
|
||||
case Xop_xnde_tag_.Tid_listing_buy:
|
||||
case Xop_xnde_tag_.Tid_listing_do:
|
||||
case Xop_xnde_tag_.Tid_listing_drink:
|
||||
|
@ -447,7 +447,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
} Arg_nde_tkn[] args = Arg_nde_tkn.Ary_empty; int args_max;
|
||||
Arg_nde_tkn[] Resize(Arg_nde_tkn[] src, int cur_len, int new_len) {
|
||||
Arg_nde_tkn[] rv = new Arg_nde_tkn[new_len];
|
||||
Array_.CopyTo(src, 0, rv, 0, cur_len);
|
||||
Array_.Copy_to(src, 0, rv, 0, cur_len);
|
||||
return rv;
|
||||
}
|
||||
public Xot_invk_tkn(int bgn, int end) {this.Tkn_ini_pos(false, bgn, end);}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user