mirror of https://github.com/gnosygnu/xowa
parent
d9f45cec19
commit
8a5d58a973
@ -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.*;
|
||||
import gplx.core.brys.args.*; import gplx.core.brys.fmtrs.*;
|
||||
public class Bfr_arg_ {
|
||||
public static Bfr_arg__int New_int(int v) {return new Bfr_arg__int(v);}
|
||||
public static Bfr_arg__byte New_byte(byte v) {return new Bfr_arg__byte(v);}
|
||||
public static Bfr_arg__bry New_bry(String v) {return new Bfr_arg__bry(Bry_.new_u8(v));}
|
||||
public static Bfr_arg__bry New_bry(byte[] v) {return new Bfr_arg__bry(v);}
|
||||
public static Bfr_arg__bry_fmtr New_bry_fmtr__null() {return new Bfr_arg__bry_fmtr(null, null);}
|
||||
public static Bfr_arg__bry_fmtr New_bry_fmtr(Bry_fmtr v, Bfr_arg... arg_ary) {return new Bfr_arg__bry_fmtr(v, arg_ary);}
|
||||
public static final Bfr_arg Noop = new Bfr_arg___noop();
|
||||
public static void Clear(Bfr_arg... ary) {
|
||||
for (Bfr_arg arg : ary)
|
||||
arg.Bfr_arg__clear();
|
||||
}
|
||||
}
|
||||
class Bfr_arg___noop implements gplx.core.brys.Bfr_arg {
|
||||
public void Bfr_arg__clear() {}
|
||||
public boolean Bfr_arg__exists() {return false;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
public class Bfr_arg__bry extends gplx.core.brys.Bfr_arg_base {
|
||||
private final byte[] bry;
|
||||
public Bfr_arg__bry(byte[] v) {this.bry = v;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {bfr.Add(bry);}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
public class Bfr_arg__bry_ary extends gplx.core.brys.Bfr_arg_base {
|
||||
private byte[][] bry_ary;
|
||||
public Bfr_arg__bry_ary Set(byte[][] v) {this.bry_ary = v; return this;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
for (byte[] bry : bry_ary)
|
||||
bfr.Add(bry);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
public class Bfr_arg__bry_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private Bry_fmtr fmtr; private Object[] arg_ary;
|
||||
public Bfr_arg__bry_fmtr(Bry_fmtr fmtr, Object[] arg_ary) {Set(fmtr, arg_ary);}
|
||||
public Bfr_arg__bry_fmtr Set(Bry_fmtr fmtr, Object... arg_ary) {
|
||||
this.fmtr = fmtr; this.arg_ary = arg_ary;
|
||||
return this;
|
||||
}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {fmtr.Bld_bfr_many(bfr, arg_ary);}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
public class Bfr_arg__byte extends gplx.core.brys.Bfr_arg_base {
|
||||
private final byte byt;
|
||||
public Bfr_arg__byte(byte byt) {this.byt = byt;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {bfr.Add_byte(byt);}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
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.langs.gfs; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.gfo_regys.*;
|
||||
public class GfsCore implements GfoInvkAble {
|
||||
public GfoInvkAble Root() {return root;}
|
||||
@gplx.Internal protected GfsRegy Root_as_regy() {return root;} GfsRegy root = GfsRegy.new_();
|
||||
public void Clear() {root.Clear();}
|
||||
public GfoMsgParser MsgParser() {return msgParser;} public GfsCore MsgParser_(GfoMsgParser v) {msgParser = v; return this;} GfoMsgParser msgParser;
|
||||
public void Del(String key) {root.Del(key);}
|
||||
public void AddLib(GfsLibIni... ary) {for (GfsLibIni itm : ary) itm.Ini(this);}
|
||||
public void AddCmd(GfoInvkAble invk, String key) {root.AddCmd(invk, key);}
|
||||
public void AddObj(GfoInvkAble invk, String key) {root.AddObj(invk, key);}
|
||||
public void AddDeep(GfoInvkAble invk, String... ary) {
|
||||
GfoInvkCmdMgrOwner cur = (GfoInvkCmdMgrOwner)((GfsRegyItm)root.Get_by(ary[0])).InvkAble();
|
||||
for (int i = 1; i < ary.length - 1; i++)
|
||||
cur = (GfoInvkCmdMgrOwner)cur.InvkMgr().Invk(GfsCtx.Instance, 0, ary[i], GfoMsg_.Null, cur);
|
||||
cur.InvkMgr().Add_cmd(ary[ary.length - 1], invk);
|
||||
}
|
||||
public String FetchKey(GfoInvkAble invk) {return root.FetchByType(invk).Key();}
|
||||
public Object ExecOne(GfsCtx ctx, GfoMsg msg) {return GfsCore_.Exec(ctx, root, msg, null, 0);}
|
||||
public Object ExecOne_to(GfsCtx ctx, GfoInvkAble invk, GfoMsg msg) {return GfsCore_.Exec(ctx, invk, msg, null, 0);}
|
||||
public Object ExecMany(GfsCtx ctx, GfoMsg rootMsg) {
|
||||
Object rv = null;
|
||||
for (int i = 0; i < rootMsg.Subs_count(); i++) {
|
||||
GfoMsg subMsg = (GfoMsg)rootMsg.Subs_getAt(i);
|
||||
rv = GfsCore_.Exec(ctx, root, subMsg, null, 0);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void ExecRegy(String key) {
|
||||
GfoRegyItm itm = GfoRegy.Instance.FetchOrNull(key);
|
||||
if (itm == null) {UsrDlg_.Instance.Warn(UsrMsg.new_("could not find script for key").Add("key", key)); return;}
|
||||
Io_url url = itm.Url();
|
||||
if (!Io_mgr.Instance.ExistsFil(url)) {
|
||||
UsrDlg_.Instance.Warn(UsrMsg.new_("script url does not exist").Add("key", key).Add("url", url));
|
||||
return;
|
||||
}
|
||||
this.ExecText(Io_mgr.Instance.LoadFilStr(url));
|
||||
}
|
||||
public Object ExecFile_ignoreMissing(Io_url url) {if (!Io_mgr.Instance.ExistsFil(url)) return null; return ExecText(Io_mgr.Instance.LoadFilStr(url));}
|
||||
public Object ExecFile(Io_url url) {return ExecText(Io_mgr.Instance.LoadFilStr(url));}
|
||||
public Object ExecFile_ignoreMissing(GfoInvkAble root, Io_url url) {
|
||||
if (!Io_mgr.Instance.ExistsFil(url)) return null;
|
||||
if (msgParser == null) throw Err_.new_wo_type("msgParser is null");
|
||||
return Exec_bry(Io_mgr.Instance.LoadFilBry(url), root);
|
||||
}
|
||||
public Object Exec_bry(byte[] bry) {return Exec_bry(bry, root);}
|
||||
public Object Exec_bry(byte[] bry, GfoInvkAble root) {
|
||||
GfoMsg rootMsg = msgParser.ParseToMsg(String_.new_u8(bry));
|
||||
Object rv = null;
|
||||
GfsCtx ctx = GfsCtx.new_();
|
||||
for (int i = 0; i < rootMsg.Subs_count(); i++) {
|
||||
GfoMsg subMsg = (GfoMsg)rootMsg.Subs_getAt(i);
|
||||
rv = GfsCore_.Exec(ctx, root, subMsg, null, 0);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Object ExecText(String text) {
|
||||
if (msgParser == null) throw Err_.new_wo_type("msgParser is null");
|
||||
GfsCtx ctx = GfsCtx.new_();
|
||||
return ExecMany(ctx, msgParser.ParseToMsg(text));
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_ExecFil)) {
|
||||
Io_url url = m.ReadIoUrl("url");
|
||||
if (ctx.Deny()) return this;
|
||||
return ExecFile(url);
|
||||
}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
// return this;
|
||||
} public static final String Invk_ExecFil = "ExecFil";
|
||||
public static final GfsCore Instance = new GfsCore();
|
||||
@gplx.Internal protected static GfsCore new_() {return new GfsCore();}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
import gplx.brys.*;
|
||||
public class Bry_fmtr_arg_ {
|
||||
public static Bry_fmtr_arg_bry bry_(String v) {return new Bry_fmtr_arg_bry(Bry_.new_u8(v));}
|
||||
public static Bry_fmtr_arg_bry bry_(byte[] v) {return new Bry_fmtr_arg_bry(v);}
|
||||
public static Bry_fmtr_arg_byt byt_(byte v) {return new Bry_fmtr_arg_byt(v);}
|
||||
public static Bry_fmtr_arg_int int_(int v) {return new Bry_fmtr_arg_int(v);}
|
||||
public static Bry_fmtr_arg_bfr bfr_(Bry_bfr v) {return new Bry_fmtr_arg_bfr(v);}
|
||||
public static Bry_fmtr_arg_bfr_preserve bfr_retain_(Bry_bfr v) {return new Bry_fmtr_arg_bfr_preserve(v);}
|
||||
public static Bry_fmtr_arg fmtr_(Bry_fmtr v, Bry_fmtr_arg... arg_ary) {return new Bry_fmtr_arg_fmtr(v, arg_ary);}
|
||||
public static Bry_fmtr_arg_fmtr_objs fmtr_null_() {return new Bry_fmtr_arg_fmtr_objs(null, null);}
|
||||
public static final Bry_fmtr_arg Noop = new Bry_fmtr_arg__noop();
|
||||
}
|
||||
class Bry_fmtr_arg__noop implements Bry_fmtr_arg {
|
||||
public void Fmt__do(Bry_bfr bfr) {}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
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.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_fmtr implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_fmtr Data_(Bry_fmtr v) {fmtr = v; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {fmtr.Bld_bfr(bfr, arg_ary);}
|
||||
public Bry_fmtr_arg_fmtr(Bry_fmtr fmtr, Bry_fmtr_arg... arg_ary) {this.fmtr = fmtr; this.arg_ary = arg_ary;} Bry_fmtr fmtr; Bry_fmtr_arg[] arg_ary;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
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.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_int implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_int Data_(int v) {val = Int_.cast(v); val_digits = Int_.DigitCount(val); return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {bfr.Add_int_fixed(val, val_digits);}
|
||||
public Bry_fmtr_arg_int(int v) {this.val = v; this.val_digits = Int_.DigitCount(v);} int val, val_digits;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue