+ }
+ }
+
+ public static void sleep(int i) {
+ java.lang.Thread thread = java.lang.Thread.currentThread();
+ if (!(thread instanceof ThreadMessage)) {
+ if (Log.on) Log.log(XWT.class, "cannot sleep() or yield() in the foreground thread");
+ } else {
+ ThreadMessage mythread = (ThreadMessage)thread;
+ mythread.done.release();
+ if (i > 0) try { java.lang.Thread.sleep(i); } catch (Exception e) { }
+ Message.Q.add(mythread);
+ mythread.go.block();
+ }
+ }
+
+ private static class XWTMath extends JS.Obj {
+ public XWTMath() {
+ JS gs = new JS.GlobalScope();
+ put("isNaN",gs.get("isNaN"));
+ put("isFinite",gs.get("isFinite"));
+ put("NaN",gs.get("NaN"));
+ put("Infinity",gs.get("Infinity"));
+ setSeal(true);
+ }
+ public Object get(Object key) {
+ Object ret = super.get(key);
+ if(ret == null) ret = JS.Math.get(key);
+ return ret;
+ }
+ }
+ private static class XWTString extends JS.Obj {
+ public XWTString() {
+ JS gs = new JS.GlobalScope();
+ put("parseInt",gs.get("parseInt"));
+ put("parseFloat",gs.get("parseFloat"));
+ put("decodeURI",gs.get("decodeURI"));
+ put("decodeURIComponent",gs.get("decodeURIComponent"));
+ put("encodeURI",gs.get("encodeURI"));
+ put("encodeURIComponent",gs.get("encodeURIComponent"));
+ put("escape",gs.get("escape"));
+ put("unescape",gs.get("unescape"));
+ put("fromCharCode",gs.get("stringFromCharCode"));
+ setSeal(true);
+ }
+ }
+}