public override CmdResult ExecuteRequest(CmdRequest pargs) { string verb = pargs.CmdName; int argsUsed; string text = pargs.str; try { pse = pse ?? new PrologScriptInterpreter(this); Nullable<PlTerm> cmd = null; object o = null; ManualResetEvent mre = new ManualResetEvent(false); Client.InvokeGUI(true, () => { o = PrologCLR.InvokeFromC(() => { cmd = pse.prologClient.Read(text, null) as Nullable<PlTerm>; o = pse.prologClient.Eval(cmd); mre.Set(); return o; }, false); }); PrologCLR.RegisterCurrentThread(); mre.WaitOne(); if (o == null) return Success("swip: " + cmd.Value); return Success("swip: " + cmd.Value + " " + o); } catch (Exception e) { string f = e.Message + " " + e.StackTrace; Client.WriteLine(f); return Failure(f); } }
static public void Main(string[] args) { _reachAllTypes = 2; PrologScriptInterpreter pscript = new PrologScriptInterpreter(null); pscript.Init(pscript); pscript.Intern("pscript", pscript); PrologCLR.Main0(args); }
} // method: Str /// <summary> /// /// </summary> /// <returns></returns> public override ScriptInterpreter newInterpreter(object thiz) { PrologScriptInterpreter si; if (prologClient == null || prologClient == thiz) { si = this; } else { si = new PrologScriptInterpreter(thiz); } //si.prologClient = thiz as PrologClient; return(si); } // method: newInterpreter
public override CmdResult ExecuteRequest(CmdRequest pargs) { string verb = pargs.CmdName; int argsUsed; string text = pargs.str; try { pse = pse ?? new PrologScriptInterpreter(this); Nullable <PlTerm> cmd = null; object o = null; ManualResetEvent mre = new ManualResetEvent(false); Client.InvokeGUI(true, () => { o = PrologCLR.InvokeFromC(() => { cmd = pse.prologClient.Read(text, null) as Nullable <PlTerm>; o = pse.prologClient.Eval(cmd); mre.Set(); return(o); }, false); }); PrologCLR.RegisterCurrentThread(); mre.WaitOne(); if (o == null) { return(Success("swip: " + cmd.Value)); } return(Success("swip: " + cmd.Value + " " + o)); } catch (Exception e) { string f = e.Message + " " + e.StackTrace; Client.WriteLine(f); return(Failure(f)); } }
} // method: Str /// <summary> /// /// </summary> /// <returns></returns> public override ScriptInterpreter newInterpreter(object thiz) { PrologScriptInterpreter si; if (prologClient == null || prologClient == thiz) si = this; else si = new PrologScriptInterpreter(thiz); //si.prologClient = thiz as PrologClient; return si; } // method: newInterpreter
///<summary> ///</summary> ///<param name="parent"></param> public SwiPrologModule(BotClient parent) : base(parent) { PLScriptInterpreter = new PrologScriptInterpreter(parent); parent.RegisterCommand(new SwipCommand(parent)); }