mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Scribunto: Handle anypos flag [#337]
This commit is contained in:
@@ -54,6 +54,15 @@ public class Array_ {
|
||||
Copy_to(src, 0, trg, 0, copy_len);
|
||||
return trg;
|
||||
}
|
||||
public static Object Extract_by_pos(Object src, int src_bgn) {
|
||||
return Extract_by_pos(src, src_bgn, Array.getLength(src));
|
||||
}
|
||||
public static Object Extract_by_pos(Object src, int src_bgn, int src_end) {
|
||||
int trg_len = src_end - src_bgn;
|
||||
Object trg = Create(Component_type(src), trg_len);
|
||||
Copy_to(src, src_bgn, trg, 0, src_end - src_bgn);
|
||||
return trg;
|
||||
}
|
||||
public static List_adp To_list(Object ary) {
|
||||
int aryLen = Array_.Len(ary);
|
||||
List_adp rv = List_adp_.New();
|
||||
|
||||
@@ -70,6 +70,14 @@ public class Keyval_ {
|
||||
Ary__to_str__nest__ary(bfr, 0, true, ary);
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public static Object[] Ary__to_objary__val(Keyval[] ary) {
|
||||
int ary_len = ary.length;
|
||||
Object[] rv = new Object[ary_len];
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
rv[i] = ary[i].Val();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static void Ary__to_str__nest__ary(Bry_bfr bfr, int indent, boolean is_kv, Object[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package gplx.core.tests; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.*;
|
||||
public class Gftest {
|
||||
private static final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public static void Eq__ary(Object[] expd, Object[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__obj, expd, actl, msg_fmt, msg_args);}
|
||||
public static void Eq__ary(boolean[] expd, boolean[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bool, expd, actl, msg_fmt, msg_args);}
|
||||
public static void Eq__ary(int[] expd, int[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__int, expd, actl, msg_fmt, msg_args);}
|
||||
public static void Eq__ary(long[] expd, long[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__long, expd, actl, msg_fmt, msg_args);}
|
||||
@@ -151,12 +152,14 @@ public class Gftest {
|
||||
}
|
||||
private static void Write__itm(Bry_bfr bfr, int type_id, Object ary, int len, int idx) {
|
||||
if (idx < len) {
|
||||
Object val = Array_.Get_at(ary, idx);
|
||||
switch (type_id) {
|
||||
case Type_ids_.Id__bool: bfr.Add_yn(Bool_.Cast(Array_.Get_at(ary, idx))); break;
|
||||
case Type_ids_.Id__bry: bfr.Add_safe((byte[])Array_.Get_at(ary, idx)); break;
|
||||
case Type_ids_.Id__long: bfr.Add_long_variable(Long_.cast(Array_.Get_at(ary, idx))); break;
|
||||
case Type_ids_.Id__int: bfr.Add_int_variable(Int_.Cast(Array_.Get_at(ary, idx))); break;
|
||||
case Type_ids_.Id__byte: bfr.Add_int_variable((int)(Byte_.Cast(Array_.Get_at(ary, idx)))); break;
|
||||
case Type_ids_.Id__bool: bfr.Add_yn(Bool_.Cast(val)); break;
|
||||
case Type_ids_.Id__bry: bfr.Add_safe((byte[])val); break;
|
||||
case Type_ids_.Id__long: bfr.Add_long_variable(Long_.cast(val)); break;
|
||||
case Type_ids_.Id__int: bfr.Add_int_variable(Int_.Cast(val)); break;
|
||||
case Type_ids_.Id__byte: bfr.Add_int_variable((int)(Byte_.Cast(val))); break;
|
||||
case Type_ids_.Id__obj: bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(val)); break;
|
||||
default: throw Err_.new_unhandled_default(type_id);
|
||||
}
|
||||
}
|
||||
@@ -182,6 +185,7 @@ public class Gftest {
|
||||
case Type_ids_.Id__long: eq = Long_.cast(expd_obj) == Long_.cast(actl_obj); break;
|
||||
case Type_ids_.Id__int: eq = Int_.Cast(expd_obj) == Int_.Cast(actl_obj); break;
|
||||
case Type_ids_.Id__byte: eq = Byte_.Cast(expd_obj) == Byte_.Cast(actl_obj); break;
|
||||
case Type_ids_.Id__obj: eq = Object_.Eq(expd_obj, actl_obj); break;
|
||||
}
|
||||
}
|
||||
if (!eq) {
|
||||
|
||||
Reference in New Issue
Block a user