// FIXME: SHouldn't need this (just trap [""])
if (JS.isString(name) && JS.toString(name).length() == 0) return rr;
// FEATURE: Preprocessor hack to generate specialized JS instances (avoid all this string concatenation)
- //#jswitch(name)
+ //#switch(JS.toString(name))
case "math": return ibexMath;
case "string": return ibexString;
case "date": return METHOD;
}
public void put(JS name, JS value) throws JSExn {
- //#jswitch(name)
+ //#switch(JS.toString(name))
case "thread": Scheduler.add((Task)value); return;
case "ui.clipboard": Platform.setClipBoard(JS.toString(value)); return;
case "ui.frame": Platform.createSurface((Box)value, true, true); return;
public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
try {
- //#jswitch(name)
+ //#switch(JS.toString(name))
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
switch (nargs) {
case 0:
- //#jswitch(name)
+ //#switch(JS.toString(name))
case "thread.yield": sleep(0); return null;
//#end
break;
case 1:
- //#jswitch(name)
+ //#switch(JS.toString(name))
case "clone":
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(JS.toString(a)); return null;
- case "stream.unzip": return a == null ? null : new Stream.Zip(a);
- case "stream.uncab": return a == null ? null : new Stream.Cab(a);
+ 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 a == null ? null : new Stream.CachedStream(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 = JS.toString(a);
//#end
break;
case 2:
- //#jswitch(name)
- case "stream.watch": return new Stream.ProgressWatcher(a, b);
+ //#switch(JS.toString(name))
+ case "stream.watch": return new Stream.ProgressWatcher((Stream)a, b);
case "regexp": return new JSRegexp(a, b);
//#end
case 3:
- //#jswitch(name)
+ //#switch(JS.toString(name))
case "ui.font.height": return N(Font.getFont(a, JS.toInt(b)).textheight(JS.toString(c)));
case "ui.font.wait": throw new Error("FIXME: ibex.ui.font.wait not implemented");
case "ui.font.width": return N(Font.getFont(a, JS.toInt(b)).textwidth(JS.toString(c)));
// 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 {
- //#jswitch(key)
+ //#switch(JS.toString(key))
case "isNaN": return METHOD;
case "isFinite": return METHOD;
case "NaN": return METHOD;
return MATH.get(key);
}
public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
- //#jswitch(name)
+ //#switch(JS.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);
public static final JS ibexString = new JS() {
private JS gs = /*new JSScope.Global();*/ null; // FIXME: Global scope
public JS get(JS key) throws JSExn {
- //#jswitch(key)
+ //#switch(JS.toString(key))
case "parseInt": return METHOD;
case "parseFloat": return METHOD;
case "decodeURI": return METHOD;
return super.get(key);
}
public JS callMethod(JS name, JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
- //#jswitch(name)
+ //#switch(JS.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);