2003/11/13 07:46:41
[org.ibex.core.git] / src / org / xwt / js / JSScope.java
index bdf8233..8327ea1 100644 (file)
@@ -44,18 +44,22 @@ public class JSScope extends JSCallable {
             return super.get(key);
         }
 
+        public Object call(Object method, JSArray args) {
+            if (method.equals("stringFromCharCode")) return stringFromCharCode(args);
+            else throw new JS.Exn("method not found");
+        }
+
         public Object call1(Object method, Object arg0) {
             //#switch(method)
-            case "parseInt": return parseInt(arg0, 0);
+            case "parseInt": return parseInt(arg0, N(0));
             case "isNaN": { double d = toDouble(arg0); return d == d ? F : T; }
-            case "isFinite": { double d = toDouble(arg0); return (d == d && !Double.isFinite(d)) ? T : F; }
+            case "isFinite": { double d = toDouble(arg0); return (d == d && !Double.isInfinite(d)) ? T : F; }
             case "decodeURI": throw new JS.Exn("unimplemented");
             case "decodeURIComponent": throw new JS.Exn("unimplemented");
             case "encodeURI": throw new JS.Exn("unimplemented");
             case "encodeURIComponent": throw new JS.Exn("unimplemented");
             case "escape": throw new JS.Exn("unimplemented");
             case "unescape": throw new JS.Exn("unimplemented");
-            case "stringFromCharCode": return stringFromCharCode(arg0);
             //#end
             return null;
         }
@@ -65,13 +69,14 @@ public class JSScope extends JSCallable {
             return null;
         }
 
-        private Object stringFromCharCode(Object arg) {
+        private Object stringFromCharCode(JSArray args) {
             char buf[] = new char[args.length()];
-            for(int i=0;i<args.length();i++) buf[i] = (char)(JS.toInt(arg) & 0xffff);
+            for(int i=0;i<args.length();i++) buf[i] = (char)(JS.toInt(args.elementAt(i)) & 0xffff);
             return new String(buf);
         }
 
-        private Object parseInt(Object arg, int radix) {
+        private Object parseInt(Object arg, Object r) {
+            int radix = JS.toInt(r);
             String s = (String)arg;
             int start = 0;
             int length = s.length();