private final JS rr;
private static final JS.Method METHOD = new JS.Method();
- public Ibex(Stream rr) { try { this.rr = bless(rr);} catch(JSExn e) { throw new Error("should never happen: " + e); } }
+ public Ibex(Fountain 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) {
public void put(JS name, JS value) throws JSExn {
//#switch(JSU.toString(name))
- case "thread": Scheduler.add((Callable)value); return;
+ case "thread": Platform.Scheduler.add((Callable)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;
return new JS.Clone((JS)args[0]);
case "bless": return bless((JS)args[0]);
case "ui.browser": Platform.newBrowserWindow(JSU.toString(args[0])); return null;
- case "stream.unzip": return args[0] == null ? null : new Stream.Zip((Stream)args[0]);
+ case "stream.unzip": return args[0] == null ? null : new Fountain.Zip((Fountain)args[0]);
//case "stream.uncab": return a == null ? null : new Stream.Cab(a);
case "stream.cache":
- try { return args[0] == null ? null : new Stream.CachedStream((Stream)args[0], "resources", true); }
- catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); }
+ //try { return args[0] == null ? null : new Fountain.CachedStream((Stream)args[0], "resources", true); }
+ //catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); }
case "stream.url": {
String url = JSU.toString(args[0]);
- 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(Encode.fromBase64(url.substring(5)), null);
- else if (url.startsWith("utf8:")) return new Stream.ByteArray(url.substring(5).getBytes(), null);
+ if (url.startsWith("http://")) return new Fountain.HTTP(url);
+ else if (url.startsWith("https://")) return new Fountain.HTTP(url);
+ else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5)), null);
+ else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes(), null);
else if (url.startsWith("file:")) {
// FIXME
Platform.fileDialog(url.substring(5), false);
break;
case 2:
//#switch(JSU.toString(method))
- case "stream.watch": return new Stream.ProgressWatcher((Stream)args[0], args[1]);
+ case "stream.watch":
+ final JS func = args[1];
+ return new Fountain.ProgressWatcher((Fountain)args[0],
+ new Callable() {
+ public Object run(Object o) throws Exception {
+ JS[] args = (JS[])o;
+ return func.call(null, args);
+ }
+ });
case "regexp": return new JSRegexp(args[0], args[1]);
//#end
case 3:
}
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(Encode.fromBase64(url.substring(5)), null);
- else if (url.startsWith("utf8:")) return new Stream.ByteArray(url.substring(5).getBytes(), null);
+ if (url.startsWith("http://")) return new Fountain.HTTP(url);
+ else if (url.startsWith("https://")) return new Fountain.HTTP(url);
+ else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5)), null);
+ else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes(), null);
else throw new JSExn("invalid resource specifier " + url);
// FIXME support file:// via dialog boxes
}
// FEATURE use a single sleeper thread
new Thread() { public void run() {
try { Thread.sleep(i); } catch (InterruptedException e) { }
- Scheduler.add(callback);
+ Platform.Scheduler.add(callback);
} }.start();
} catch (Pausable.NotPausableException npe) {
throw new JSExn("you cannot sleep or yield in the foreground thread");
public JS parentkey = null;
public Blessing parent = null;
public JS clonee;
- private Basket.Map cache = new Basket.HashMap();
+ private Basket.Map cache = new Basket.Hash();
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 {
}
// FEATURE: This is a gross hack
public InputStream getImage() throws JSExn {
- //try {
+ try {
InputStream in = JSU.getInputStream(this);
if (in != null) return in;
- //} catch (IOException e) { /* DELIBERATE */ }
+ } catch (IOException e) { /* DELIBERATE */ }
String[] exts = new String[] { ".png", ".jpeg", ".gif" };
for (int i=0; i < exts.length; i++) {
- //try {
- in = JSU.getInputStream(parent.get(JSU.S(JSU.toString(parentkey) + exts[i])));
+ try {
+ InputStream in = JSU.getInputStream(parent.get(JSU.S(JSU.toString(parentkey) + exts[i])));
if (in != null) return in;
- //} catch (IOException f) { /* DELIBERATE */ }
+ } catch (IOException f) { /* DELIBERATE */ }
}
return null;
}