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 a0, Object a1, Object a2, Object[] rest, int nargs) {
+ public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
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) {
+ public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
return XWT.this.callMethod(this.key + "." + method, a0, a1, a2, rest, nargs);
}
}
//#switch(name)
case "thread":
Scheduler.add(new Scheduler.Task() {
- public void perform() {
+ public void perform() throws JSExn {
try {
JS.invokePauseable((JSFunction)value);
} catch (JS.PausedException pe) {
return null;
}
- public static void sleep(final int i) {
+ public static void sleep(final int i) throws JSExn {
try {
final JS.UnpauseCallback callback = JS.pause();
final long currentTime = System.currentTimeMillis();
public void run() {
try { Thread.sleep(i); } catch (InterruptedException e) { }
Scheduler.add(new Scheduler.Task() {
- public void perform() {
+ public void perform() throws JSExn {
try {
callback.unpause(null);
} catch (JS.PausedException pe) {
public static final JSMath xwtMath = new JSMath() {
private JS gs = new JSScope.Global();
public String toString() { return "XWTMATH"; }
- public Object get(Object key) {
+ public Object get(Object key) throws JSExn {
//#switch(key)
case "isNaN": return gs.get("isNaN");
case "isFinite": return gs.get("isFinite");
public static final JS xwtString = new JS() {
private JS gs = new JSScope.Global();
public void put(Object key, Object val) { }
- public Object get(Object key) {
+ public Object get(Object key) throws JSExn {
//#switch(key)
case "parseInt": return gs.get("parseInt");
case "parseFloat": return gs.get("parseFloat");
Vector obStack = new Vector();
public XMLHelper() { super(BUFFER_SIZE); }
public void startElement(XML.Element c) throws XML.SchemaException {
- JS o = new JS();
- o.put("$name", c.localName);
- for(int i=0; i<c.len; i++) o.put(c.keys[i], c.vals[i]);
- o.put("$numchildren", new Integer(0));
- obStack.addElement(o);
+ try {
+ JS o = new JS();
+ o.put("$name", c.localName);
+ for(int i=0; i<c.len; i++) o.put(c.keys[i], c.vals[i]);
+ o.put("$numchildren", new Integer(0));
+ obStack.addElement(o);
+ } catch (JSExn jse) {
+ throw new Error("this should never happen");
+ }
}
public void endElement(XML.Element c) throws XML.SchemaException {
- if (obStack.size() == 1) return;
- JS me = (JS)obStack.lastElement();
- obStack.setSize(obStack.size() - 1);
- JS parent = (JS)obStack.lastElement();
- int numchildren = ((Integer)parent.get("$numchildren")).intValue();
- parent.put("$numchildren", new Integer(numchildren + 1));
- parent.put(new Integer(numchildren), me);
+ try {
+ if (obStack.size() == 1) return;
+ JS me = (JS)obStack.lastElement();
+ obStack.setSize(obStack.size() - 1);
+ JS parent = (JS)obStack.lastElement();
+ int numchildren = ((Integer)parent.get("$numchildren")).intValue();
+ parent.put("$numchildren", new Integer(numchildren + 1));
+ parent.put(new Integer(numchildren), me);
+ } catch (JSExn jse) {
+ throw new Error("this should never happen");
+ }
}
public void characters(char[] ch, int start, int length) throws XML.SchemaException {
- String s = new String(ch, start, length);
- JS parent = (JS)obStack.lastElement();
- int numchildren = ((Integer)parent.get("$numchildren")).intValue();
- Object lastChild = parent.get(new Integer(numchildren - 1));
- if (lastChild instanceof String) {
- parent.put(new Integer(numchildren - 1), lastChild + s);
- } else {
- parent.put("$numchildren", new Integer(numchildren + 1));
- parent.put(new Integer(numchildren), s);
+ try {
+ String s = new String(ch, start, length);
+ JS parent = (JS)obStack.lastElement();
+ int numchildren = ((Integer)parent.get("$numchildren")).intValue();
+ Object lastChild = parent.get(new Integer(numchildren - 1));
+ if (lastChild instanceof String) {
+ parent.put(new Integer(numchildren - 1), lastChild + s);
+ } else {
+ parent.put("$numchildren", new Integer(numchildren + 1));
+ parent.put(new Integer(numchildren), s);
+ }
+ } catch (JSExn jse) {
+ throw new Error("this should never happen");
}
}
public void whitespace(char[] ch, int start, int length) {}