1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-19 23:16:49 -04:00
parent 794b5a232f
commit 8e041d6e06
834 changed files with 4749 additions and 4461 deletions

View File

@@ -21,13 +21,13 @@ public class Scrib_engine_type {
switch (v) {
case Type_lua: return "lua";
case Type_luaj: return "luaj";
default: throw Exc_.new_unimplemented();
default: throw Err_.new_unimplemented();
}
}
public static byte Xto_byte(String s) {
if (String_.Eq(s, "lua")) return Type_lua;
else if (String_.Eq(s, "luaj")) return Type_luaj;
else throw Exc_.new_unimplemented();
else throw Err_.new_unimplemented();
}
public static final byte Type_lua = 0, Type_luaj = 1;
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_("luaj"), KeyVal_.new_("lua"));

View File

@@ -25,7 +25,7 @@ public class Luaj_server_func_recv extends OneArgFunction {
public LuaValue call(LuaValue tbl_val) {
LuaTable tbl = (LuaTable)tbl_val;
String op = Luaj_value_.Get_val_as_str(tbl, "op");
if (!String_.Eq(op, "call")) throw Exc_.new_("luaj_recvr only processes op calls");
if (!String_.Eq(op, "call")) throw Err_.new_wo_type("luaj_recvr only processes op calls");
return engine.Server_recv_call(tbl);
}
public static Luaj_server_func_recv _ = new Luaj_server_func_recv();

View File

@@ -57,7 +57,7 @@ class Luaj_value_ {
kv = KeyVal_.new_(((LuaString)itm_key).tojstring(), itm_val_obj);
break;
default:
throw Exc_.new_unhandled(itm_key.type());
throw Err_.new_unhandled(itm_key.type());
}
}
temp.Add(kv);
@@ -80,7 +80,7 @@ class Luaj_value_ {
return v_num.todouble();
case LuaValue.TTABLE: return X_tbl_to_kv_ary(server, (LuaTable)v);
case LuaValue.TFUNCTION: return server.Get_id_by_closure(v);
default: throw Exc_.new_unhandled(v.type());
default: throw Err_.new_unhandled(v.type());
}
}
public static LuaValue X_obj_to_val(Luaj_server server, Object o) {

View File

@@ -87,7 +87,7 @@ public class Process_engine implements Scrib_engine {
}
} private static final byte[] Dispatch_hdr = Bry_.new_a7("0000000000000000"); // itm_len + itm_chk in 8-len HexDec
private void Dispatch_bld_send(Bry_bfr bfr, Object[] ary) {
int len = ary.length; if (len % 2 != 0) throw Exc_.new_("arguments must be factor of 2", "len", len);
int len = ary.length; if (len % 2 != 0) throw Err_.new_wo_type("arguments must be factor of 2", "len", len);
bfr.Add(Dispatch_hdr);
bfr.Add_byte(Byte_ascii.Curly_bgn);
for (int i = 0; i < len; i++) {

View File

@@ -53,7 +53,7 @@ public class Process_recv_msg {
return op;
}
catch (Exception e) {
throw Scrib_xtn_mgr.err_(e, "failed to extract data: {0} {1}", Err_.Message_gplx_brief(e), String_.new_u8(rsp));
throw Scrib_xtn_mgr.err_(e, "failed to extract data", "rsp", rsp);
}
}
}

View File

@@ -40,7 +40,7 @@ public class Process_send_wtr {
case Byte_ascii.Quote: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(b); break;
case Byte_ascii.Nl: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(Byte_ascii.Ltr_n); break;
case Byte_ascii.Cr: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(Byte_ascii.Ltr_r); break;
case Byte_ascii.Nil: bfr.Add(CONST_escape_000); break;
case Byte_ascii.Null: bfr.Add(CONST_escape_000); break;
case Byte_ascii.Backslash: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(Byte_ascii.Backslash); break;
default: bfr.Add_byte(b); break;
}

View File

@@ -35,7 +35,7 @@ public class Process_server implements Scrib_server {
ProcessBuilder pb = new ProcessBuilder(process_args);
pb.redirectErrorStream(false);
try {process = pb.start();}
catch (Exception e) {throw Exc_.new_exc(e, "core", "process init failed", "args", String_.AryXtoStr(process_args));}
catch (Exception e) {throw Err_.new_exc(e, "core", "process init failed", "args", String_.AryXtoStr(process_args));}
stream_write = process.getOutputStream();
error_reader = new Process_server_gobbler_error(process.getErrorStream(), bry_error);
error_reader.Start();
@@ -45,7 +45,7 @@ public class Process_server implements Scrib_server {
return Server_recv();
}
public void Server_send(byte[] cmd, Object[] cmd_objs) {
if (process == null) throw Exc_.new_("process not started");
if (process == null) throw Err_.new_wo_type("process not started");
cmd_last = cmd;
// stream_read.Data_reset();
stream_read = new Process_server_gobbler_recv(process.getInputStream(), process_rdr).Start();
@@ -53,7 +53,7 @@ public class Process_server implements Scrib_server {
stream_write.write(cmd);
stream_write.flush();
}
catch (Exception e) {throw Exc_.new_exc(e, "core", "failed to write to output");}
catch (Exception e) {throw Err_.new_exc(e, "core", "failed to write to output");}
} private byte[] cmd_last;
public byte[] Server_recv() {
long time_bgn = System.currentTimeMillis();
@@ -96,7 +96,7 @@ class Process_server_gobbler_error extends Thread {
if (terminating)
return;
else
throw Exc_.new_exc(e, "core", "failed to write to output");
throw Err_.new_exc(e, "core", "failed to write to output");
}
}
public void Term() {

View File

@@ -67,7 +67,7 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
KeyVal kv = ary[i];
Object kv_val = kv.Val();
if (kv_val == null) {
bfr.Add(gplx.json.Json_itm_.Const_null);
bfr.Add(gplx.core.json.Json_itm_.Const_null);
continue;
}
Class<?> kv_val_type = kv_val.getClass();
@@ -75,7 +75,7 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
if (print_key && !kv_val_is_array)
bfr.Add_str(kv.Key()).Add_byte(Byte_ascii.Colon);
if (ClassAdp_.Eq(kv_val_type, Bool_.Cls_ref_type))
bfr.Add(Bool_.cast_(kv_val) ? gplx.json.Json_itm_.Const_true : gplx.json.Json_itm_.Const_false);
bfr.Add(Bool_.cast_(kv_val) ? gplx.core.json.Json_itm_.Const_true : gplx.core.json.Json_itm_.Const_false);
else if (kv_val_is_array) {
KeyVal[] sub = (KeyVal[])kv_val;
if (sub.length == 0) {bfr.Add_byte(Byte_ascii.Curly_bgn).Add_byte(Byte_ascii.Curly_end);}

View File

@@ -24,10 +24,10 @@ public class Process_stream_rdr {
int bytes_read = rdr.Read(bry_header, 0, 16);
if (bytes_read < 16) {
if (bytes_read == -1) return null; // stream closed; should only occur when shutting down
else throw Exc_.new_("failed to read header");
else throw Err_.new_wo_type("failed to read header");
}
int body_len = HexDecUtl.parse_or_(bry_header, 0,8, -1); if (body_len == -1) throw Exc_.new_("failed to read body_len");
int chk_len= HexDecUtl.parse_or_(bry_header, 9, 16, -1); if (chk_len == -1 || chk_len != (body_len * 2) - 1) throw Exc_.new_("failed to read chk_len");
int body_len = HexDecUtl.parse_or_(bry_header, 0,8, -1); if (body_len == -1) throw Err_.new_wo_type("failed to read body_len");
int chk_len= HexDecUtl.parse_or_(bry_header, 9, 16, -1); if (chk_len == -1 || chk_len != (body_len * 2) - 1) throw Err_.new_wo_type("failed to read chk_len");
byte[] trg_bry = (body_len > bry_body.length) ? new byte[body_len] : bry_body;
return Read_body(trg_bry, body_len, rdr);
}
@@ -46,7 +46,7 @@ public class Process_stream_rdr {
case Byte_ascii.Ltr_n: b = Byte_ascii.Nl; break;
case Byte_ascii.Ltr_r: b = Byte_ascii.Cr; break;
case Byte_ascii.Backslash: b = Byte_ascii.Backslash; break;
default: throw Exc_.new_unhandled(b);
default: throw Err_.new_unhandled(b);
}
}
else { // regular mode

View File

@@ -57,7 +57,7 @@ class Process_stream_rdr_fxt {
case Byte_ascii.Backslash: bfr.Add_byte(Byte_ascii.Backslash); break;
case Byte_ascii.Ltr_n: bfr.Add_byte(Byte_ascii.Nl); break;
case Byte_ascii.Ltr_r: bfr.Add_byte(Byte_ascii.Cr); break;
default: throw Exc_.new_unhandled(b);
default: throw Err_.new_unhandled(b);
}
break;
default: