package org.ibex.xt;
import java.io.*;
-import java.net.*;
import java.util.*;
import javax.servlet.ServletContext;
public static class JSTransaction implements Transaction {
public static final long serialVersionUid = 0xfb2aa281;
private JS js;
- JSScope newscope;
- List v;
- public JSTransaction(JS js) throws JSExn {
- newscope = new JSScope(null);
- this.js = JS.cloneWithNewParentScope(js, newscope);
- v = JS.getFormalArgs(this.js);
- for(int i=0; i<v.size(); i++) {
- if ("prevalent".equals(v.get(i))) continue;
- newscope.put(v.get(i), JS.getParentScope(js).get(v.get(i)));
- }
- }
+ public JSTransaction(JS js) throws JSExn { this.js = js; }
public void executeOn(Object o, Date now) {
try {
- newscope.put("prevalent", o);
- newscope.put("now", new JSDate(now.getTime()));
- Object a = v.size() <= 0 ? null : newscope.get(v.get(0));
- Object b = v.size() <= 1 ? null : newscope.get(v.get(1));
- Object c = v.size() <= 2 ? null : newscope.get(v.get(2));
- Object[] rest = v.size() <= 3 ? null : new Object[v.size() - 3];
- for(int i=3; i<v.size(); i++) rest[i-3] = v.get(i);
- js.call(a, b, c, rest, v.size());
+ JSScope scope = JS.getParentScope(js);
+ scope.put("prevalent", o);
+ scope.put("now", new JSDate(now.getTime()));
+ js.call(null, null, null, null, 0);
} catch (Exception e) { throw new RuntimeException(e); }
}
}
public static final long serialVersionUid = 0xfb2aa282;
private JS js;
private Object a;
- public JSQuery(JS js, Object a) { this.js = JS.cloneWithNewParentScope(js, null); this.a = a; }
+ public JSQuery(JS js, Object a) { this.js = js; this.a = a; }
public Object query(Object o, Date now) {
try {
return js.call(o, a, new JSDate(now.getTime()), null, 3);