X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FJSScope.java;h=44bfec1462a54341da05dad53cf3cd613c4b0de6;hb=8c1756ef3fd42cc2f324baf47e13a83f51045efe;hp=54dc44650dc232d32f30ed6f4fb95373e6f46a39;hpb=2b1b2ef9bb8b8a34efb6329c552eea4f773d9466;p=org.ibex.core.git diff --git a/src/org/xwt/js/JSScope.java b/src/org/xwt/js/JSScope.java index 54dc446..44bfec1 100644 --- a/src/org/xwt/js/JSScope.java +++ b/src/org/xwt/js/JSScope.java @@ -34,39 +34,61 @@ public class JSScope extends JSCallable { private final static Double NaN = new Double(Double.NaN); private final static Double POSITIVE_INFINITY = new Double(Double.POSITIVE_INFINITY); - public Global(JSScope parent) { - super(parent); - } - public Object get(Object key) { - if(key.equals("NaN")) return NaN; - if(key.equals("Infinity")) return POSITIVE_INFINITY; - if(key.equals("undefined")) return null; - return super.get(key); - } - - public Object call(Object method, JSArray args) { - if (method.equals("stringFromCharCode")) return stringFromCharCode(args); - return super.call(method, args); - } + public Global(JSScope parent) { super(parent); } - public Object call1(Object method, Object arg0) { - //#switch(method) - 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.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"); + public Object get(Object key) { + //#switch(key) + case "NaN": return NaN; + case "Infinity": return POSITIVE_INFINITY; + case "undefined": return null; + case "stringFromCharCode": return METHOD; + case "parseInt": return METHOD; + case "isNaN": return METHOD; + case "isFinite": 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 "parseInt": return METHOD; //#end - return super.call1(method, arg0); + return super.get(key); } - public Object call2(Object method, Object arg1, Object arg2) { - if (method.equals("parseInt")) return parseInt(arg1, arg2); - return super.call2(method, arg1, arg2); + public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) { + switch(nargs) { + case 0: { + //#switch(method) + case "stringFromCharCode": + JSArray args = new JSArray(); + for(int i=0; i