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

'v3.4.3.1'

This commit is contained in:
gnosygnu
2016-04-17 23:47:45 -04:00
parent 14471ca656
commit ad140a93fe
102 changed files with 1278 additions and 382 deletions

View File

@@ -0,0 +1,21 @@
/*
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.brys; import gplx.*; import gplx.core.*;
public interface Bry_bfr_able {
void To_bfr(Bry_bfr bfr);
}

View File

@@ -0,0 +1,37 @@
/*
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.brys; import gplx.*; import gplx.core.*;
public class Bry_bfr_able_ {
public static byte[][] To_bry_ary(Bry_bfr tmp_bfr, Bry_bfr_able[] ary) {
int len = ary.length;
byte[][] rv = new byte[len][];
for (int i = 0; i < len; ++i) {
Bry_bfr_able itm = ary[i];
if (itm != null) {
itm.To_bfr(tmp_bfr);
rv[i] = tmp_bfr.To_bry_and_clear();
}
}
return rv;
}
public static byte[] To_bry_or_null(Bry_bfr tmp_bfr, Bry_bfr_able itm) {
if (itm == null) return null;
itm.To_bfr(tmp_bfr);
return tmp_bfr.To_bry_and_clear();
}
}

View File

@@ -0,0 +1,102 @@
/*
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.tests; import gplx.*; import gplx.core.*;
import gplx.core.brys.*;
public class Gftest {
private static Bry_bfr bfr = Bry_bfr.new_();
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary) {Eq__ary(expd_ary, actl_ary, null);}
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary, String msg_fmt, Object... msg_args) {
byte[][] expd_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, expd_ary);
byte[][] actl_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, actl_ary);
boolean[] failures = Calc__failures(Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
if (failures != null) {
bfr.Add(Bry__line_bgn);
if (msg_fmt != null) {
bfr.Add_str_u8(String_.Format(msg_fmt, msg_args));
bfr.Add(Bry__line_mid);
}
Write__failures(bfr, failures, Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
throw Err_.new_wo_type(bfr.To_str_and_clear());
}
}
private static void Write__failures(Bry_bfr bfr, boolean[] failures, int type_id, Object expd_ary, Object actl_ary) {
int len = failures.length;
int expd_len = Array_.Len(expd_ary);
int actl_len = Array_.Len(actl_ary);
for (int i = 0; i < len; ++i) {
boolean failure = failures[i];
bfr.Add_int_pad_bgn(Byte_ascii.Num_0, 5 - Int_.DigitCount(i), i).Add_byte_colon().Add_byte_space();
Write__itm(bfr, type_id, expd_ary, expd_len, i);
if (failure) {
bfr.Add(Bry__item__eq_n).Add_byte_repeat(Byte_ascii.Space, 3);
Write__itm(bfr, type_id, actl_ary, actl_len, i);
}
}
bfr.Add(Bry__line_end);
}
private static void Write__itm(Bry_bfr bfr, int type_id, Object ary, int len, int idx) {
if (idx < len) {
switch (type_id) {
case Type_adp_.Tid__bry: bfr.Add((byte[])Array_.Get_at(ary, idx)); break;
default: throw Err_.new_unhandled_default(type_id);
}
}
else
bfr.Add(Bry__null);
bfr.Add_byte_nl();
}
private static boolean[] Calc__failures(int tid, Object expd_ary, Object actl_ary) {
int expd_len = Array_.Len(expd_ary);
int actl_len = Array_.Len(actl_ary);
int max_len = expd_len > actl_len ? expd_len : actl_len; if (max_len == 0) return null;
boolean[] rv = null;
for (int i = 0; i < max_len; ++i) {
Object expd_obj = i < expd_len ? Array_.Get_at(expd_ary, i) : null;
Object actl_obj = i < actl_len ? Array_.Get_at(actl_ary, i) : null;
boolean eq = false;
switch (tid) {
case Type_adp_.Tid__bry: eq = Bry_.Eq((byte[])expd_obj, (byte[])actl_obj); break;
}
if (!eq) {
if (rv == null) {
rv = new boolean[max_len];
}
rv[i] = true;
}
}
return rv;
}
private static final byte[] Bry__item__eq_n = Bry_.new_a7("!= ") // Bry__item__eq_y = Bry_.new_a7("== "),
, Bry__null = Bry_.new_a7("<<NULL>>")
, Bry__line_bgn = Bry_.new_a7("\n************************************************************************************************\n")
, Bry__line_mid = Bry_.new_a7("\n------------------------------------------------------------------------------------------------\n")
, Bry__line_end = Bry_.new_a7( "________________________________________________________________________________________________")
;
}
/*
package ns;
import org.junit.*; import gplx.core.tests.*;
public class Cls1_tst {
private final Cls1_fxt fxt = new Cls1_fxt();
@Test public void Basic() {}
}
class Cls1_fxt {
private final Cls1 mgr = new Cls1();
public Cls1_fxt Test() {return this;}
}
*/