X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fcore%2FIbex.java;fp=src%2Forg%2Fibex%2Fcore%2FIbex.java;h=58969ae063db17fb246a8278f0316ca7315bc90c;hp=6492ed204c939d82e5a7c972541dafd19bc560b2;hb=b0ec2e1d6c3bd35205dfffc6893f01157aef2ced;hpb=9bff7ae2a6824ac83fb1e0ccd455ac3b1277ef3c diff --git a/src/org/ibex/core/Ibex.java b/src/org/ibex/core/Ibex.java index 6492ed2..58969ae 100644 --- a/src/org/ibex/core/Ibex.java +++ b/src/org/ibex/core/Ibex.java @@ -152,10 +152,10 @@ public final class Ibex extends JS implements JS.Cloneable { case "date": return new JSDate(a, b, c, rest, nargs); case "net.rpc.soap": return new SOAP(JS.toString(a), "", JS.toString(b), JS.toString(c)); // FIXME support object dumping - case "log.debug": JS.debug(a== null ? "**null**" : a.toString()); return null; - case "log.info": JS.info(a== null ? "**null**" : a.toString()); return null; - case "log.warn": JS.warn(a== null ? "**null**" : a.toString()); return null; - case "log.error": JS.error(a== null ? "**null**" : a.toString()); return null; + case "log.debug": JS.debug(a== null ? "**null**" : JS.debugToString(a)); return null; + case "log.info": JS.info(a== null ? "**null**" : JS.debugToString(a)); return null; + case "log.warn": JS.warn(a== null ? "**null**" : JS.debugToString(a)); return null; + case "log.error": JS.error(a== null ? "**null**" : JS.debugToString(a)); return null; //#end switch (nargs) { @@ -349,6 +349,7 @@ public final class Ibex extends JS implements JS.Cloneable { // FEATURE: move this into builtin.xwar public Blessing bless(JS b) throws JSExn { return new Ibex.Blessing(b, this, null, null); } // FIXME: Does this really need to extends JS.Clone? + // FEATURE: Mandate that Blessings use only String keys? public static class Blessing extends JS.Clone { private Ibex ibex; private Template t = null; @@ -382,28 +383,34 @@ public final class Ibex extends JS implements JS.Cloneable { } catch (IOException f) { /* DELIBERATE */ } return null; } - public JSScope getStatic() { + public JSScope getStatic() throws JSExn { try { if (t == null) { + // FEATURE: Might want to handle the ".t" part better JS res = (JS) parent.get(JS.S(JS.toString(parentkey) + ".t")); - t = Template.buildTemplate(res.unclone().toString(), res, ibex); + // FIXME: need a better description (Stream.toString()) + t = Template.buildTemplate(JS.toString(parentkey), res, ibex); } - return t.staticScope; + return t != null ? t.staticScope : null; } catch (Exception e) { Log.error(this, e); return null; } } public JS call(JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn { - // GROSS hack - if (nargs != 1 && nargs != 9999) throw new JSExn("FIXME can only call with one arg"); + if (nargs != 1) throw new JSExn("can only call a template with one arg"); getStatic(); if (t == null) throw new JSExn("No such template " + parentkey); - if (nargs == 9999) /*return t;*/ throw new Error("FIXME"); // FIXME: 9999 stuff if(!(a instanceof Box)) throw new JSExn("can only apply templates to boxes"); t.apply((Box)a); return a; } + // FEATURE: This is a gross hack + Template getTemplate() throws JSExn { + getStatic(); + if (t == null) throw new JSExn("No such template " + JS.debugToString(parentkey)); + return t; + } } }