mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Scribunto: Fix script error 'NullPointerException' on 1 en.w page
This commit is contained in:
parent
bee71c22fe
commit
ffe4c0d094
@ -43,6 +43,10 @@ public class Keyval_ {
|
|||||||
int len = ary.length;
|
int len = ary.length;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
Keyval itm = ary[i];
|
Keyval itm = ary[i];
|
||||||
|
if (itm == null) {
|
||||||
|
sb.Add("<<NULL>>");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sb.Add(itm.Key()).Add("=");
|
sb.Add(itm.Key()).Add("=");
|
||||||
Object itm_val = itm.Val();
|
Object itm_val = itm.Val();
|
||||||
if (Type_adp_.Eq_typeSafe(itm_val, Keyval[].class))
|
if (Type_adp_.Eq_typeSafe(itm_val, Keyval[].class))
|
||||||
|
@ -82,6 +82,10 @@ public class Scrib_proc_args {
|
|||||||
// loop itms and handle out-of-order; note that in most cases, itms should be in-order and proc will just return rv; DATE:2016-09-12
|
// loop itms and handle out-of-order; note that in most cases, itms should be in-order and proc will just return rv; DATE:2016-09-12
|
||||||
for (int i = 0; i < rv_len; ++i) {
|
for (int i = 0; i < rv_len; ++i) {
|
||||||
Keyval kv = rv[i];
|
Keyval kv = rv[i];
|
||||||
|
|
||||||
|
// ignore null arguments; PAGE:en.w:Huadu_District DATE:2017-05-11
|
||||||
|
if (kv == null) continue;
|
||||||
|
|
||||||
// get integer-key; needed to handle gaps
|
// get integer-key; needed to handle gaps
|
||||||
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|
||||||
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects
|
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects
|
||||||
|
@ -32,6 +32,10 @@ public class Scrib_proc_args__tst {
|
|||||||
, Keyval_.int_(6, null), Keyval_.int_(7, null), Keyval_.int_(8, "h")
|
, Keyval_.int_(6, null), Keyval_.int_(7, null), Keyval_.int_(8, "h")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Test public void Pull_kv_ary__null() { // PURPOSE: null arg shouldn't fail; PAGE:en.w:Huadu_District DATE:2017-05-11
|
||||||
|
fxt.Init(Keyval_.int_(1, Keyval_.Ary(Keyval_.int_(1, "a"), null, Keyval_.int_(2, "b"))));
|
||||||
|
fxt.Test__pull_kv_ary(0, Keyval_.int_(1, "a"), null, Keyval_.int_(2, "b"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class Scrib_proc_args__fxt {
|
class Scrib_proc_args__fxt {
|
||||||
private Scrib_proc_args args;
|
private Scrib_proc_args args;
|
||||||
|
@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.xtns.wbases.claims.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*;
|
package gplx.xowa.xtns.wbases.claims.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*;
|
||||||
public class Wbase_claim_type_ {
|
public class Wbase_claim_type_ {
|
||||||
public static final byte // SERIALIZED:wbase_prop|datatype
|
public static final byte // SERIALIZED:wbase_prop|datatype; REF:https://www.wikidata.org/wiki/Help:Data_type
|
||||||
Tid__unknown = 0
|
Tid__unknown = 0
|
||||||
, Tid__value = 1
|
, Tid__value = 1
|
||||||
, Tid__bad = 1
|
, Tid__bad = 1
|
||||||
@ -30,8 +30,9 @@ public class Wbase_claim_type_ {
|
|||||||
, Tid__url = 10
|
, Tid__url = 10
|
||||||
, Tid__externalid = 11
|
, Tid__externalid = 11
|
||||||
, Tid__commonsmedia = 12
|
, Tid__commonsmedia = 12
|
||||||
|
, Tid__geo_shape = 13
|
||||||
;
|
;
|
||||||
public static final Wbase_enum_hash Reg = new Wbase_enum_hash("claim.data_type", 13);
|
public static final Wbase_enum_hash Reg = new Wbase_enum_hash("claim.data_type", 14);
|
||||||
public static final Wbase_enum_itm
|
public static final Wbase_enum_itm
|
||||||
Itm__unknown = New(Tid__unknown , "unknown")
|
Itm__unknown = New(Tid__unknown , "unknown")
|
||||||
, Itm__bad = New(Tid__bad , "bad") // NOTE: wikidata identifies several entries as "bad"; Q1615351|'s-Graveland, Q107538|Baco; DATE:2013-10-20
|
, Itm__bad = New(Tid__bad , "bad") // NOTE: wikidata identifies several entries as "bad"; Q1615351|'s-Graveland, Q107538|Baco; DATE:2013-10-20
|
||||||
@ -46,6 +47,7 @@ public class Wbase_claim_type_ {
|
|||||||
, Itm__commonsmedia = New(Tid__commonsmedia , "commonsMedia") // EX:wd:Property:P14
|
, Itm__commonsmedia = New(Tid__commonsmedia , "commonsMedia") // EX:wd:Property:P14
|
||||||
, Itm__externalid = New(Tid__externalid , "external-id") // EX:wd:Property:P1003
|
, Itm__externalid = New(Tid__externalid , "external-id") // EX:wd:Property:P1003
|
||||||
, Itm__math = New(Tid__math , "math") // EX:wd:Property:P2534
|
, Itm__math = New(Tid__math , "math") // EX:wd:Property:P2534
|
||||||
|
, Itm__geo_shape = New(Tid__geo_shape , "geo-shape") // EX:wd:Property:P3896
|
||||||
;
|
;
|
||||||
private static Wbase_enum_itm New(byte tid, String key) {return New(tid, key, key);}
|
private static Wbase_enum_itm New(byte tid, String key) {return New(tid, key, key);}
|
||||||
private static Wbase_enum_itm New(byte tid, String key, String scrib) {return Reg.Add(new Wbase_claim_type(tid, key, scrib));}
|
private static Wbase_enum_itm New(byte tid, String key, String scrib) {return Reg.Add(new Wbase_claim_type(tid, key, scrib));}
|
||||||
|
Loading…
Reference in New Issue
Block a user