-// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the GNU General Public License version 2 ("the License").
+// You may not use this file except in compliance with the License.
+
package org.ibex.core;
import java.io.*;
import org.ibex.crypto.*;
/** Singleton class that provides all functionality in the ibex.* namespace */
-public final class Ibex extends JS.Cloneable {
+public final class Ibex extends JS.Obj implements JS.Cloneable {
// FIXME remove this
private final JS rr;
+ private static final JS.Method METHOD = new JS.Method();
- public Ibex(Stream rr) { this.rr = bless(rr); }
+ public Ibex(Stream rr) { try { this.rr = bless(rr);} catch(JSExn e) { throw new Error("should never happen: " + e); } }
public JS resolveString(String str, boolean permitAbsolute) throws JSExn {
if (str.indexOf("://") != -1) {
- if (permitAbsolute) return (Stream)url2res(str);
+ if (permitAbsolute) return url2res(str);
throw new JSExn("absolute URL " + str + " not permitted here");
}
// root-relative
while(str.indexOf('.') != -1) {
String path = str.substring(0, str.indexOf('.'));
str = str.substring(str.indexOf('.') + 1);
- ret = (JS)ret.get(path);
+ ret = ret.get(JSU.S(path));
}
- if (!"".equals(str)) ret = (JS)ret.get(str);
+ if (!"".equals(str)) ret = ret.get(JSU.S(str));
return ret;
}
/** lets us put multi-level get/put/call keys all in the same method */
- private class Sub extends JS {
- String key;
- Sub(String key) { this.key = key; }
- public void put(Object key, Object val) throws JSExn { Ibex.this.put(this.key + "." + key, val); }
- public Object get(Object key) throws JSExn { return Ibex.this.get(this.key + "." + key); }
- public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
+ private class Sub extends JS.Obj {
+ JS key;
+ Sub(JS key) { this.key = key; }
+ public void put(JS key, JS val) throws JSExn { Ibex.this.put(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key)), val); }
+ public JS get(JS key) throws JSExn { return Ibex.this.get(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key))); }
+ public JS call(JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
return Ibex.this.callMethod(this.key, a0, a1, a2, rest, nargs);
}
- public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
- return Ibex.this.callMethod(this.key + "." + method, a0, a1, a2, rest, nargs);
+ public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
+ return Ibex.this.callMethod(JSU.S(JSU.toString(this.key) + "." + JSU.toString(method)), a0, a1, a2, rest, nargs);
}
}
private Cache subCache = new Cache(20);
- private Sub getSub(String s) {
- Sub ret = (Sub)subCache.get(s);
- if (ret == null) subCache.put(s, ret = new Sub(s));
+ private Sub getSub(JS key) {
+ Sub ret = (Sub)subCache.get(key);
+ if (ret == null) subCache.put(key, ret = new Sub(key));
return ret;
}
- public Object get(Object name) throws JSExn {
- if (name instanceof String && ((String)name).length() == 0) return rr;
- //#switch(name)
+ public JS get(JS name) throws JSExn {
+ // FIXME: SHouldn't need this (just trap [""])
+ if (JS.isString(name) && JSU.toString(name).length() == 0) return rr;
+ // FEATURE: Preprocessor hack to generate specialized JS instances (avoid all this string concatenation)
+ //#switch(JSU.toString(name))
case "math": return ibexMath;
case "string": return ibexString;
case "date": return METHOD;
case "clone": return METHOD;
case "bless": return METHOD;
case "regexp": return METHOD;
- case "ui": return getSub("ui");
- case "ui.font": return getSub("ui.font");
+ case "ui": return getSub(name);
+ case "ui.font": return getSub(name);
case "ui.font.wait": return METHOD;
case "ui.font.width": return METHOD;
case "ui.font.height": return METHOD;
- case "ui.font.sansserif": return Main.builtin.get("fonts/vera/Vera.ttf");
- case "ui.font.monospace": return Main.builtin.get("fonts/vera/VeraMono.ttf");
- case "ui.font.serif": return Main.builtin.get("fonts/vera/VeraSe.ttf");
+ case "ui.font.sansserif": return Main.builtin.get(JSU.S("fonts/vera/Vera.ttf"));
+ case "ui.font.monospace": return Main.builtin.get(JSU.S("fonts/vera/VeraMono.ttf"));
+ case "ui.font.serif": return Main.builtin.get(JSU.S("fonts/vera/VeraSe.ttf"));
case "ui.browser": return METHOD;
- case "ui.mouse": return getSub("ui.mouse");
+ case "ui.mouse": return getSub(name);
case "ui.mouse.button":
if (Surface.button1 && !Surface.button2 && !Surface.button3) return N(1);
else if (!Surface.button1 && Surface.button2 && !Surface.button3) return N(2);
else if (!Surface.button1 && !Surface.button2 && Surface.button3) return N(3);
else return ZERO;
- case "ui.key": return getSub("ui.key");
- case "ui.key.name": return getSub("ui.key.name");
- case "ui.key.name.alt": return Platform.altKeyName();
- case "ui.key.alt": return Surface.alt ? T : F;
- case "ui.key.control": return Surface.control ? T : F;
- case "ui.key.shift": return Surface.shift ? T : F;
- case "ui.clipboard": return Platform.getClipBoard();
+ case "ui.key": return getSub(name);
+ case "ui.key.name": return getSub(name);
+ case "ui.key.name.alt": return JSU.S(Platform.altKeyName());
+ case "ui.key.alt": return Surface.alt ? JSU.T : JSU.F;
+ case "ui.key.control": return Surface.control ? JSU.T : JSU.F;
+ case "ui.key.shift": return Surface.shift ? JSU.T : JSU.F;
+ case "ui.clipboard": return JSU.S((String)Platform.getClipBoard());
case "ui.maxdim": return N(Short.MAX_VALUE);
- case "ui.screen": return getSub("ui.screen");
+ case "ui.screen": return getSub(name);
case "ui.screen.width": return N(Platform.getScreenWidth());
case "ui.screen.height": return N(Platform.getScreenHeight());
- case "undocumented": return getSub("undocumented");
- case "undocumented.initialOrigin": return Main.origin;
- case "undocumented.initialTemplate": return Main.initialTemplate;
- case "thread": return getSub("thread");
+ case "undocumented": return getSub(name);
+ case "undocumented.initialOrigin": return JSU.S(Main.origin);
+ case "undocumented.initialTemplate": return JSU.S(Main.initialTemplate);
+ case "thread": return getSub(name);
case "thread.yield": return METHOD;
case "thread.sleep": return METHOD;
- case "stream": return getSub("stream");
+ case "stream": return getSub(name);
case "stream.homedir": return url2res("file:" + System.getProperty("user.home"));
case "stream.tempdir": return url2res("file:" + System.getProperty("java.io.tempdir"));
case "stream.watch": return METHOD;
case "stream.parse.html": return METHOD;
case "stream.parse.xml": return METHOD;
case "stream.parse.utf8": return METHOD;
- case "net": return getSub("net");
- case "net.rpc": return getSub("net.rpc");
+ case "net": return getSub(name);
+ case "net.rpc": return getSub(name);
case "net.rpc.xml": return METHOD;
case "net.rpc.soap": return METHOD;
- case "log": return getSub("log");
+ case "log": return getSub(name);
case "log.debug": return METHOD;
case "log.info": return METHOD;
case "log.warn": return METHOD;
case "log.error": return METHOD;
- case "crypto": return getSub("crypto");
+ case "crypto": return getSub(name);
case "crypto.rsa": return METHOD;
case "crypto.md5": return METHOD;
case "crypto.sha1": return METHOD;
case "crypto.rc4": return METHOD;
//#end
- return super.get(name);
+ return null;
}
- public void put(Object name, final Object value) throws JSExn {
- //#switch(name)
+ public void put(JS name, JS value) throws JSExn {
+ //#switch(JSU.toString(name))
case "thread": Scheduler.add((Task)value); return;
- case "ui.clipboard": Platform.setClipBoard((String)value); return;
+ case "ui.clipboard": Platform.setClipBoard(JSU.toString(value)); return;
case "ui.frame": Platform.createSurface((Box)value, true, true); return;
case "ui.window": Platform.createSurface((Box)value, false, true); return;
case "undocumented.proxyAuthorization":
throw new JSExn("attempted to put unknown property: ibex."+name);
}
- public Object callMethod(Object name, Object a, Object b, Object c, Object[] rest, int nargs) throws JSExn {
+ public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
try {
- //#switch(name)
+ //#switch(JSU.toString(name))
case "date": return new JSDate(a, b, c, rest, nargs);
- case "net.rpc.soap": return new SOAP((String)a, "", (String)b, (String)c);
+ case "net.rpc.soap": return new SOAP(JSU.toString(a), "", JSU.toString(b), JSU.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) {
case 0:
- //#switch(name)
+ //#switch(JSU.toString(name))
case "thread.yield": sleep(0); return null;
//#end
break;
case 1:
- //#switch(name)
+ //#switch(JSU.toString(name))
case "clone":
- if (!(a instanceof JS.Cloneable)) throw new JSExn("cannot clone a " + a.getClass().getName());
- return ((JS.Cloneable)a).jsclone();
+ if(a == null) throw new JSExn("can't clone the null value");
+ return ((JS)a).jsclone();
case "bless": return bless((JS)a);
- case "ui.browser": Platform.newBrowserWindow((String)a); return null;
- case "stream.unzip": return new Stream.Zip((Stream)a);
- case "stream.uncab": return new Stream.Cab((Stream)a);
+ case "ui.browser": Platform.newBrowserWindow(JSU.toString(a)); return null;
+ case "stream.unzip": return a == null ? null : new Stream.Zip((Stream)a);
+ //case "stream.uncab": return a == null ? null : new Stream.Cab(a);
case "stream.cache":
- try { return new Stream.CachedStream((Stream)a, "resources", true); }
+ try { return a == null ? null : new Stream.CachedStream((Stream)a, "resources", true); }
catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); }
case "stream.url": {
- String url = (String)a;
+ String url = JSU.toString(a);
if (url.startsWith("http://")) return new Stream.HTTP(url);
else if (url.startsWith("https://")) return new Stream.HTTP(url);
else if (url.startsWith("data:")) return new Stream.ByteArray(Base64.decode(url.substring(5)), null);
}
case "thread.sleep": sleep(JS.toInt(a)); return null;
case "regexp": return new JSRegexp(a, null);
- case "net.rpc.xml": return new XMLRPC((String)a, "");
+ case "net.rpc.xml": return new XMLRPC(JSU.toString(a), "");
case "crypto.rsa": /* FEATURE */ return null;
case "crypto.md5": /* FEATURE */ return null;
case "crypto.sha1": /* FEATURE */ return null;
case "crypto.rc4": /* FEATURE */ return null;
case "stream.parse.html": throw new JSExn("not implemented yet"); //return null;
- case "stream.parse.xml": new XMLHelper((JS)b).doParse((JS)a); return null;
+ case "stream.parse.xml": if(a == null) return null; new XMLHelper(b).doParse(a); return null;
// FIXME backgrounding
- case "stream.parse.utf8": try { return new String(InputStreamToByteArray.convert(Stream.getInputStream(a))); }
+ case "stream.parse.utf8": if(a == null) return null;
+ try { return JSU.S(new String(InputStreamToByteArray.convert(a.getInputStream()))); }
catch (Exception e) { Log.warn(this, e); }
//#end
break;
case 2:
- //#switch(name)
- case "stream.watch": return new Stream.ProgressWatcher((Stream)a, (JS)b);
+ //#switch(JSU.toString(name))
+ case "stream.watch": return new Stream.ProgressWatcher((Stream)a, b);
case "regexp": return new JSRegexp(a, b);
//#end
case 3:
- //#switch(name)
- case "ui.font.height": return N(Font.getFont((Stream)a, JS.toInt(b)).textheight((String)c));
+ //#switch(JSU.toString(name))
+ case "ui.font.height": return N(Font.getFont(a, JS.toInt(b)).textheight(JSU.toString(c)));
case "ui.font.wait": throw new Error("FIXME: ibex.ui.font.wait not implemented");
- case "ui.font.width": return N(Font.getFont((Stream)a, JS.toInt(b)).textwidth((String)c));
+ case "ui.font.width": return N(Font.getFont(a, JS.toInt(b)).textwidth(JSU.toString(c)));
//#end
break;
}
throw new JSExn("invalid number of arguments ("+nargs+") for ibex object method "+name+"()");
}
- public Stream url2res(String url) throws JSExn {
+ public JS url2res(String url) throws JSExn {
if (url.startsWith("http://")) return new Stream.HTTP(url);
else if (url.startsWith("https://")) return new Stream.HTTP(url);
else if (url.startsWith("data:")) return new Stream.ByteArray(Base64.decode(url.substring(5)), null);
try { Thread.sleep(i); } catch (InterruptedException e) { }
Scheduler.add(callback);
} }.start();
- } catch (JS.NotPauseableException npe) {
+ } catch (JSU.NotPauseableException npe) {
throw new JSExn("you cannot sleep or yield in the foreground thread");
}
}
- public static final JSMath ibexMath = new JSMath() {
- private JS gs = new JSScope.Global();
- public Object get(Object key) throws JSExn {
- //#switch(key)
- case "isNaN": return gs.get("isNaN");
- case "isFinite": return gs.get("isFinite");
- case "NaN": return gs.get("NaN");
- case "Infinity": return gs.get("Infinity");
+ public static final JS ibexMath = new JS.Obj() {
+ // FEATURE: find a cleaner way to do this
+ private JS gs = /*new JSScope.Global();*/ null; // FIXME: Global scope
+ public JS get(JS key) throws JSExn {
+ //#switch(JSU.toString(key))
+ case "isNaN": return METHOD;
+ case "isFinite": return METHOD;
+ case "NaN": return METHOD;
+ case "Infinity": return METHOD;
//#end
- return super.get(key);
+ return MATH.get(key);
+ }
+ public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
+ //#switch(JSU.toString(name))
+ case "isNaN": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "isFinite": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "NaN": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "Infinity": return gs.callMethod(name,a,b,c,rest,nargs);
+ //#end
+ return MATH.callMethod(name,a,b,c,rest,nargs);
}
- };
+ };
- public static final JS ibexString = new JS() {
- private JS gs = new JSScope.Global();
- public void put(Object key, Object val) { }
- public Object get(Object key) throws JSExn {
- //#switch(key)
- case "parseInt": return gs.get("parseInt");
- case "parseFloat": return gs.get("parseFloat");
- case "decodeURI": return gs.get("decodeURI");
- case "decodeURIComponent": return gs.get("decodeURIComponent");
- case "encodeURI": return gs.get("encodeURI");
- case "encodeURIComponent": return gs.get("encodeURIComponent");
- case "escape": return gs.get("escape");
- case "unescape": return gs.get("unescape");
- case "fromCharCode": return gs.get("stringFromCharCode");
+ public static final JS ibexString = new JS.Obj() {
+ private JS gs = /*new JSScope.Global();*/ null; // FIXME: Global scope
+ public JS get(JS key) throws JSExn {
+ //#switch(JSU.toString(key))
+ case "parseInt": return METHOD;
+ case "parseFloat": return METHOD;
+ case "decodeURI": return METHOD;
+ case "decodeURIComponent": return METHOD;
+ case "encodeURI": return METHOD;
+ case "encodeURIComponent": return METHOD;
+ case "escape": return METHOD;
+ case "unescape": return METHOD;
+ case "fromCharCode": return METHOD;
//#end
- return null;
+ return super.get(key);
}
- };
+ public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
+ //#switch(JSU.toString(name))
+ case "parseInt": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "parseFloat": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "decodeURI": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "decodeURIComponent": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "encodeURI": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "encodeURIComponent": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "escape": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "unescape": return gs.callMethod(name,a,b,c,rest,nargs);
+ case "fromCharCode": return gs.callMethod(name,a,b,c,rest,nargs);
+ //#end
+ return super.callMethod(name,a,b,c,rest,nargs);
+ }
+ };
private class XMLHelper extends XML {
private class Wrapper extends XML.Exn { public JSExn wrapee; public Wrapper(JSExn jse) { super(""); wrapee = jse; } }
private JS characters, whitespace, endElement, startElement;
public XMLHelper(JS b) throws JSExn {
super(BUFFER_SIZE);
- startElement = (JS)b.getAndTriggerTraps("startElement");
- endElement = (JS)b.getAndTriggerTraps("endElement");
- characters = (JS)b.getAndTriggerTraps("characters");
- whitespace = (JS)b.getAndTriggerTraps("whitespace");
+ startElement = b.getAndTriggerTraps(JSU.S("startElement"));
+ endElement = b.getAndTriggerTraps(JSU.S("endElement"));
+ characters = b.getAndTriggerTraps(JSU.S("characters"));
+ whitespace = b.getAndTriggerTraps(JSU.S("whitespace"));
}
public void startElement(XML.Element c) throws XML.Exn { try {
- JS attrs = new JS();
+ JS attrs = new JS.O();
// FIXME attribute URIs? add an additional hash?
- for(int i=0; i<c.getAttrLen(); i++) attrs.put(c.getAttrKey(i), c.getAttrVal(i));
- startElement.call(c.getLocalName(), attrs, c.getUri(), null, 3);
+ for(int i=0; i<c.getAttrLen(); i++) attrs.put(JSU.S(c.getAttrKey(i)), JSU.S(c.getAttrVal(i)));
+ startElement.call(JSU.S(c.getLocalName()), attrs, JSU.S(c.getUri()), null, 3);
} catch (JSExn jse) { throw new Wrapper(jse); } }
public void endElement(XML.Element c) throws XML.Exn { try {
- endElement.call(c.getLocalName(), c.getUri(), null, null, 2);
+ endElement.call(JSU.S(c.getLocalName()), JSU.S(c.getUri()), null, null, 2);
} catch (JSExn jse) { throw new Wrapper(jse); } }
public void characters(char[] ch, int start, int length) throws XML.Exn { try {
- characters.call(new String(ch, start, length), null, null, null, 1);
+ characters.call(JSU.S(new String(ch, start, length)), null, null, null, 1);
} catch (JSExn jse) { throw new Wrapper(jse); } }
public void whitespace(char[] ch, int start, int length) throws XML.Exn { try {
- whitespace.call(new String(ch, start, length), null, null, null, 1);
+ whitespace.call(JSU.S(new String(ch, start, length)), null, null, null, 1);
} catch (JSExn jse) { throw new Wrapper(jse); } }
public void doParse(JS s) throws JSExn {
try {
- parse(new BufferedReader(new InputStreamReader(Stream.getInputStream(s))));
+ parse(new BufferedReader(new InputStreamReader(s.getInputStream())));
} catch (Wrapper e) {
throw e.wrapee;
} catch (XML.Exn e) {
}
// FEATURE: move this into builtin.xwar
- public Blessing bless(JS b) { return new Ibex.Blessing((JS.Cloneable)b, this, null, null); }
- public static class Blessing extends JS.Clone {
+ public Blessing bless(JS b) throws JSExn { return new Ibex.Blessing(b, this, null, null); }
+ // JS:FIXME: This doesn't properly handle traps
+ public static class Blessing extends JS.Obj {
private Ibex ibex;
private Template t = null;
- public Object parentkey = null;
+ public JS parentkey = null;
public Blessing parent = null;
+ public JS clonee;
private Hash cache = new Hash();
- public Blessing(JS.Cloneable clonee, Ibex ibex, Blessing parent, Object parentkey) {
- super(clonee); this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
- public Object get(Object key) throws JSExn {
- if (key.equals("")) return ((Object)getStatic());
- if (cache.get(key) != null) return cache.get(key);
- Object ret = new Blessing((JS.Cloneable)clonee.get(key), ibex, this, key);
+ public Blessing(JS clonee, Ibex ibex, Blessing parent, JS parentkey) throws JSExn {
+ this.clonee = clonee; this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
+ public JS get(JS key) throws JSExn {
+ if (JS.isString(key) && JSU.toString(key).equals("")) return getStatic();
+ if (cache.get(key) != null) return (JS)cache.get(key);
+ JS ret = new Blessing(clonee.get(key), ibex, this, key);
cache.put(key, ret);
return ret;
}
- public static Blessing getBlessing(Object o) {
- if (!(o instanceof JS)) return null;
- JS js = (JS)o;
+ public static Blessing getBlessing(JS js) {
while (js instanceof JS.Clone && !(js instanceof Blessing)) js = ((JS.Clone)js).getClonee();
if (!(js instanceof Blessing)) return null;
return (Blessing)js;
}
+ // FEATURE: This is a gross hack
public InputStream getImage() throws JSExn {
try {
- InputStream in = Stream.getInputStream(this);
+ InputStream in = getInputStream();
if (in != null) return in;
} catch (IOException e) { /* DELIBERATE */ }
String[] exts = new String[] { ".png", ".jpeg", ".gif" };
for (int i=0; i < exts.length; i++)
try {
- InputStream in = Stream.getInputStream(parent.get(parentkey + exts[i]));
+ InputStream in = parent.get(JSU.S(JSU.toString(parentkey) + exts[i])).getInputStream();
if (in != null) return in;
} catch (IOException f) { /* DELIBERATE */ }
return null;
}
- public JSScope getStatic() {
+ public JS getStatic() throws JSExn {
try {
if (t == null) {
- JS res = (JS) parent.get(parentkey + ".t");
- t = Template.buildTemplate(res.unclone().toString(), res, ibex);
+ // FEATURE: Might want to handle the ".t" part better
+ JS res = parent.get(JSU.S(JSU.toString(parentkey) + ".t"));
+ t = Template.buildTemplate(description(), res, ibex);
}
- return t.staticScope;
+ return t != null ? t.staticObject : null;
} catch (Exception e) {
Log.error(this, e);
return null;
}
}
- public Object call(Object a, Object b, Object c, Object[] rest, int nargs) throws JSExn {
- // GROSS hack
- if (nargs != 1 && nargs != 9999) throw new JSExn("FIXME can only call with one arg");
+ private String description() {
+ String s = JS.debugToString(parentkey);
+ for(Blessing b = parent; b.parentkey != null; b = b.parent) s = JS.debugToString(b.parentkey) + "." + s;
+ return s;
+ }
+ public JS call(JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
+ 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;
+ if (t == null) throw new JSExn("No such template " + JS.debugToString(parentkey));
+ 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;
+ }
+ // JS:FIXME: Blessing shouldn't need to roll its own JS.Clone implementation
+ public InputStream getInputStream() throws IOException { return clonee.getInputStream(); }
}
}