[re]-merged in Brians stuff
[org.ibex.core.git] / src / org / ibex / core / Ibex.java
index 447ee1d..9427c20 100644 (file)
@@ -59,7 +59,7 @@ public final class Ibex extends JS implements JS.Cloneable {
         // 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;
@@ -129,7 +129,7 @@ public final class Ibex extends JS implements JS.Cloneable {
     }
 
     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;
@@ -144,7 +144,7 @@ public final class Ibex extends JS implements JS.Cloneable {
 
     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
@@ -156,21 +156,21 @@ public final class Ibex extends JS implements JS.Cloneable {
  
             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);
@@ -200,12 +200,12 @@ public final class Ibex extends JS implements JS.Cloneable {
                     //#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)));
@@ -247,7 +247,7 @@ public final class Ibex extends JS implements JS.Cloneable {
             // 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;
@@ -256,7 +256,7 @@ public final class Ibex extends JS implements JS.Cloneable {
                 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);
@@ -269,7 +269,7 @@ public final class Ibex extends JS implements JS.Cloneable {
     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;
@@ -283,7 +283,7 @@ public final class Ibex extends JS implements JS.Cloneable {
                 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);