X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FXWT.java;h=263120dc2ed35babe3a968c146d5e82d8f639348;hb=8c1756ef3fd42cc2f324baf47e13a83f51045efe;hp=811a64304345a427aba554d9853ba61416e06fb9;hpb=2b1b2ef9bb8b8a34efb6329c552eea4f773d9466;p=org.ibex.core.git diff --git a/src/org/xwt/XWT.java b/src/org/xwt/XWT.java index 811a643..263120d 100644 --- a/src/org/xwt/XWT.java +++ b/src/org/xwt/XWT.java @@ -22,15 +22,20 @@ public final class XWT extends JSCallable { Sub(String key) { this.key = key; } public String toString() { return "XWTSUB " + key; } public void put(Object key, Object val) { XWT.this.put(this.key + "." + key, val); } - public Object get(Object key) { return XWT.this._get(this.key + "." + key); } - public Object call(Object method, JSArray args) { return XWT.this.call(method == null ? key : this.key + "." + method, args); } + public Object get(Object key) { return XWT.this.get(this.key + "." + key); } + public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) { + return XWT.this.callMethod(this.key, a0, a1, a2, rest, nargs); + } + public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) { + return XWT.this.callMethod(this.key + "." + method, a0, a1, a2, rest, nargs); + } } - public Object _get(Object name) { + public Object get(Object name) { //#switch(name) case "math": return xwtMath; case "string": return xwtString; - case "date": return new JSDate(); + case "date": return METHOD; case "origin": return Main.origin; case "box": return new BoxTree(); case "log": return new Sub("log"); @@ -58,23 +63,38 @@ public final class XWT extends JSCallable { else return new Integer(0); case "undocumented": return new Sub("undocumented"); case "undocumented.internal": return new Sub("undocumented.internal"); + case "thread.yield": return METHOD; + case "thread.sleep": return METHOD; + case "res.watch": return METHOD; + case "soap": return METHOD; + case "apply": return METHOD; + case "graft": return METHOD; + case "ui.browser": return METHOD; + case "clone": return METHOD; + case "res.unzip": return METHOD; + case "res.uncab": return METHOD; + case "res.cache": return METHOD; + case "res.url": return METHOD; + case "log.println": return METHOD; + case "log.dump": return METHOD; + case "regexp": return METHOD; + case "rpc.xml": return METHOD; + case "rpc.soap": return METHOD; + case "crypto.rsa": return METHOD; + case "crypto.md5": return METHOD; + case "crypto.sha1": return METHOD; + case "crypto.rc4": return METHOD; + case "stream.parse.html": return METHOD; + case "stream.parse.xml": return METHOD; + case "stream.parse.utf8": return METHOD; //#end return null; } - public Object get(Object name) { - Object ret = _get(name); - if (ret != null) return ret; - return !name.equals("clone") && !name.equals("apply") ? rr.get(name) : null; - } - public void put(Object name, final Object value) { //#switch(name) case "thread": - System.out.println("new thread " + value); - Scheduler.add(new Scheduler.Task() { - public String toString() { return "thread task"; } - public void perform() { JSContext.invokePauseable((JSFunction)value); } }); + Scheduler.add(new Scheduler.Task() { public void perform() { JSContext.invokePauseable((JSFunction)value); } }); case "ui.clipboard": Platform.setClipBoard((String)value); case "ui.frame": Platform.createSurface((Box)value, true, true); case "ui.window": Platform.createSurface((Box)value, false, true); @@ -84,23 +104,24 @@ public final class XWT extends JSCallable { //#end } - public Object call(Object name, JSArray args) throws JS.Exn { - Object a = args.elementAt(0); - Object b = args.elementAt(1); - Object c = args.elementAt(2); - if (name.equals("date")) return new org.xwt.js.JSDate(args); - else if (args.length() == 0 && name.equals("thread.yield")) { sleep(0); return null; } - else if (args.length() == 2) { + public Object callMethod(Object name, Object a, Object b, Object c, Object[] rest, int nargs) throws JS.Exn { + if (name.equals("date")) { + JSArray args = new JSArray(); + for(int i=0; i