mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.5.4.1
This commit is contained in:
@@ -23,7 +23,7 @@ public class GfmlAtr implements GfmlItm {
|
||||
public GfmlType Type() {return type;} GfmlType type;
|
||||
public boolean KeyedSubObj() {return true;}
|
||||
public int SubObjs_Count() {return subObjs.Count();}
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.FetchAt(i);} GfmlObjList subObjs = GfmlObjList.new_(); // PERF?: make capacity 3 instead of 8
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.Get_at(i);} GfmlObjList subObjs = GfmlObjList.new_(); // PERF?: make capacity 3 instead of 8
|
||||
public void SubObjs_Add(GfmlObj o) {subObjs.Add(o);}
|
||||
public String XtoStr() {return String_.Concat(this.Key(), "=", this.DatTkn().Val());}
|
||||
@gplx.Internal protected void Key_set(String v) {keyTkn = GfmlTkn_.val_(v);} // used for 1 test
|
||||
@@ -43,14 +43,14 @@ public class GfmlAtr implements GfmlItm {
|
||||
int idx = GetTknIdx(oldTkn);
|
||||
GfmlTkn tkn = MakeTkn(oldTkn, s);
|
||||
if (idx != -1)
|
||||
subObjs.DelAt(idx);
|
||||
subObjs.Del_at(idx);
|
||||
if (idx == -1) idx = 0;
|
||||
subObjs.AddAt(tkn, idx);
|
||||
subObjs.Add_at(tkn, idx);
|
||||
return tkn;
|
||||
}
|
||||
int GetTknIdx(GfmlTkn t) {
|
||||
for (int i = 0; i < subObjs.Count(); i++) {
|
||||
GfmlObj obj = (GfmlObj)subObjs.FetchAt(i);
|
||||
GfmlObj obj = (GfmlObj)subObjs.Get_at(i);
|
||||
if (obj == t) return i;
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.gfml; import gplx.*;
|
||||
public class GfmlDoc {
|
||||
public GfmlNde RootNde() {return rootNde;} GfmlNde rootNde;
|
||||
@gplx.Internal protected ListAdp UsrMsgs() {return usrMsgs;} ListAdp usrMsgs = ListAdp_.new_();
|
||||
@gplx.Internal protected List_adp UsrMsgs() {return usrMsgs;} List_adp usrMsgs = List_adp_.new_();
|
||||
@gplx.Internal protected GfmlLxrRegy LxrRegy() {return lxrRegy;} GfmlLxrRegy lxrRegy = new GfmlLxrRegy();
|
||||
@gplx.Internal protected GfmlBldrCmdRegy CmdRegy() {return cmdRegy;} GfmlBldrCmdRegy cmdRegy = GfmlBldrCmdRegy.new_();
|
||||
@gplx.Internal protected GfmlPragmaMgr PragmaMgr() {return pragmaMgr;} GfmlPragmaMgr pragmaMgr = GfmlPragmaMgr.new_();
|
||||
|
||||
@@ -38,7 +38,7 @@ class GfmlUsrMsgs {
|
||||
public static Err gfmlParseError(GfmlBldr bldr) {
|
||||
Err rv = Err_.new_("gfml parse error");
|
||||
for (int i = 0; i < bldr.Doc().UsrMsgs().Count(); i++) {
|
||||
UsrMsg um = (UsrMsg)bldr.Doc().UsrMsgs().FetchAt(i);
|
||||
UsrMsg um = (UsrMsg)bldr.Doc().UsrMsgs().Get_at(i);
|
||||
rv.Add("err" + Int_.Xto_str(i), um.XtoStr());
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
public class GfmlItmHnds {
|
||||
public int Count() {return list.Count();} ListAdp list = ListAdp_.new_();
|
||||
public GfmlNde FetchAt(int idx) {return (GfmlNde)list.FetchAt(idx);}
|
||||
public int Count() {return list.Count();} List_adp list = List_adp_.new_();
|
||||
public GfmlNde Get_at(int idx) {return (GfmlNde)list.Get_at(idx);}
|
||||
public void Add(GfmlNde nde) {list.Add(nde);}
|
||||
public static GfmlItmHnds new_() {return new GfmlItmHnds();} GfmlItmHnds() {}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.gfml; import gplx.*;
|
||||
public class GfmlItmKeys {
|
||||
public int Count() {return list.Count();}
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public GfmlItm FetchAt(int i) {return (GfmlItm)list.FetchAt(i);}
|
||||
public GfmlItm Fetch(String key) {return (GfmlItm)hash.Fetch(key);}
|
||||
public GfmlItm Get_at(int i) {return (GfmlItm)list.Get_at(i);}
|
||||
public GfmlItm Get_by(String key) {return (GfmlItm)hash.Get_by(key);}
|
||||
public String FetchDataOr(String key, String or) {
|
||||
GfmlAtr atr = FetchAtr(key);
|
||||
return (atr == null) ? or : atr.DatTkn().Val();
|
||||
@@ -54,8 +54,8 @@ public class GfmlItmKeys {
|
||||
}
|
||||
if (toDel != null) list.Del(toDel);
|
||||
}
|
||||
GfmlAtr FetchAtr(String key) {return GfmlAtr.as_(hash.Fetch(key));}
|
||||
ListAdp list = ListAdp_.new_(); HashAdp hash = HashAdp_.new_();
|
||||
GfmlAtr FetchAtr(String key) {return GfmlAtr.as_(hash.Get_by(key));}
|
||||
List_adp list = List_adp_.new_(); Hash_adp hash = Hash_adp_.new_();
|
||||
public static GfmlItmKeys new_() {return new GfmlItmKeys();} GfmlItmKeys() {}
|
||||
@gplx.Internal protected static final String NullKey = "";
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GfmlNde implements GfmlItm {
|
||||
public boolean KeyedSubObj() {return keyedSubObj;} public GfmlNde KeyedSubObj_(boolean v) {keyedSubObj = v; return this;} private boolean keyedSubObj;
|
||||
public int ChainId() {return chainId;} public GfmlNde ChainId_(int v) {chainId = v; return this;} int chainId; // can use boolean chainHead, but this is easier for debugging
|
||||
public int SubObjs_Count() {return subObjs.Count();} GfmlObjList subObjs = GfmlObjList.new_();
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.FetchAt(i);}
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.Get_at(i);}
|
||||
public void SubObjs_Add(GfmlObj gobj) {
|
||||
subObjs.Add(gobj);
|
||||
GfmlItm subItm = GfmlItm_.as_(gobj);
|
||||
@@ -43,7 +43,7 @@ public class GfmlNde implements GfmlItm {
|
||||
public String XtoStr() {return GfmlDocWtr_.xtoStr_(this);}
|
||||
public void UpdateNde(String hnd) {
|
||||
for (int i = 0; i < subHnds.Count(); i++) {
|
||||
GfmlNde nde = (GfmlNde)subHnds.FetchAt(i);
|
||||
GfmlNde nde = (GfmlNde)subHnds.Get_at(i);
|
||||
if (String_.Eq(nde.hndTkn.Raw(), hnd)) return;
|
||||
}
|
||||
int endAtrPos = PosOf(false, ";", "}");
|
||||
@@ -58,7 +58,7 @@ public class GfmlNde implements GfmlItm {
|
||||
subNde.SubObjs_Add(endParen);
|
||||
subNde.SubObjs_Add(bgnBrace);
|
||||
subNde.SubObjs_Add(endBrace);
|
||||
subObjs.AddAt(subNde, endAtrPos);
|
||||
subObjs.Add_at(subNde, endAtrPos);
|
||||
// a(){b(){}}
|
||||
// a:{} -> a:{b:{}}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class GfmlNde implements GfmlItm {
|
||||
int end = fwd ? subObjs.Count() : 0;
|
||||
int dif = fwd ? 1 : -1;
|
||||
for (int i = bgn; i != end; i+=dif) {
|
||||
GfmlObj subObj = (GfmlObj)subObjs.FetchAt(i);
|
||||
GfmlObj subObj = (GfmlObj)subObjs.Get_at(i);
|
||||
GfmlTkn subTkn = GfmlTkn_.as_(subObj);
|
||||
if (subTkn == null) continue;
|
||||
if (String_.In(subTkn.Raw(), find)) {
|
||||
@@ -77,7 +77,7 @@ public class GfmlNde implements GfmlItm {
|
||||
return -1;
|
||||
}
|
||||
public void UpdateAtr(String key, String val) {
|
||||
GfmlAtr atr = (GfmlAtr)subKeys.Fetch(key);
|
||||
GfmlAtr atr = (GfmlAtr)subKeys.Get_by(key);
|
||||
if (atr != null) {atr.UpdateAtr(key, val); return;}
|
||||
val = String_.Replace(val, "'", "''");
|
||||
GfmlTkn quote = GfmlTkn_.new_("'", "");
|
||||
@@ -90,10 +90,10 @@ public class GfmlNde implements GfmlItm {
|
||||
atr.SubObjs_Add(valTkn);
|
||||
int endAtrPos = PosOf(true, ";", "{");
|
||||
if (subKeys.Count() != 0) {
|
||||
subObjs.AddAt(GfmlTkn_.new_(" ", ""), endAtrPos);
|
||||
subObjs.Add_at(GfmlTkn_.new_(" ", ""), endAtrPos);
|
||||
endAtrPos++;
|
||||
}
|
||||
subObjs.AddAt(atr, endAtrPos);
|
||||
subObjs.Add_at(atr, endAtrPos);
|
||||
}
|
||||
|
||||
@gplx.Internal protected void ObjType_set_pragma() {objType = GfmlObj_.Type_prg;}
|
||||
|
||||
@@ -22,7 +22,7 @@ interface GfmlScopeItm {
|
||||
}
|
||||
class GfmlScopeRegy {
|
||||
public boolean Has(String key) {
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Fetch(key); if (list == null) return false;
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Get_by(key); if (list == null) return false;
|
||||
return list.Count() > 0;
|
||||
}
|
||||
public void Add(GfmlScopeItm itm) {
|
||||
@@ -30,23 +30,23 @@ class GfmlScopeRegy {
|
||||
list.Add(itm);
|
||||
}
|
||||
public void Del(GfmlScopeItm itm) {
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Fetch(itm.Key()); if (list == null) return;
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Get_by(itm.Key()); if (list == null) return;
|
||||
list.Del(itm);
|
||||
if (list.Count() == 0) hash.Del(itm.Key());
|
||||
}
|
||||
public GfmlScopeItm Fetch(String key, GfmlDocPos pos) {
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Fetch(key); if (list == null) return null;
|
||||
return list.Fetch(pos);
|
||||
public GfmlScopeItm Get_by(String key, GfmlDocPos pos) {
|
||||
GfmlScopeList list = (GfmlScopeList)hash.Get_by(key); if (list == null) return null;
|
||||
return list.Get_by(pos);
|
||||
}
|
||||
GfmlScopeList ItmOrNew(String key) {
|
||||
GfmlScopeList rv = (GfmlScopeList)hash.Fetch(key);
|
||||
GfmlScopeList rv = (GfmlScopeList)hash.Get_by(key);
|
||||
if (rv == null) {
|
||||
rv = GfmlScopeList.new_(key);
|
||||
hash.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
HashAdp hash = HashAdp_.new_();
|
||||
Hash_adp hash = Hash_adp_.new_();
|
||||
public static GfmlScopeRegy new_() {return new GfmlScopeRegy();}
|
||||
}
|
||||
class GfmlScopeList {
|
||||
@@ -54,7 +54,7 @@ class GfmlScopeList {
|
||||
public int Count() {return list.Count();}
|
||||
public void Add(GfmlScopeItm itm) {list.Add(itm);}
|
||||
public void Del(GfmlScopeItm itm) {list.Del(itm);}
|
||||
public GfmlScopeItm Fetch(GfmlDocPos pos) {
|
||||
public GfmlScopeItm Get_by(GfmlDocPos pos) {
|
||||
if (list.Count() == 0) return null;
|
||||
GfmlScopeItm rv = null;
|
||||
for (Object itemObj : list) {
|
||||
@@ -66,7 +66,7 @@ class GfmlScopeList {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
ListAdp list = ListAdp_.new_();
|
||||
List_adp list = List_adp_.new_();
|
||||
public static GfmlScopeList new_(String key) {
|
||||
GfmlScopeList rv = new GfmlScopeList(); rv.key = key; return rv;
|
||||
} GfmlScopeList() {}
|
||||
|
||||
Reference in New Issue
Block a user