* trigger a Surface.abort; if rendering were done in the same pass,
* rendering work done prior to the Surface.abort would be wasted.
*/
-public final class Box extends JSScope implements Task {
+public final class Box extends JS.O implements Task {
// Macros //////////////////////////////////////////////////////////////////////
//#define CHECKSET_BOOLEAN(prop) boolean nu = toBoolean(value); if (nu == prop) break; prop = nu;
//#define CHECKSET_STRING(prop) if ((value==null&&prop==null)||(value!=null&&JS.toString(value).equals(prop))) break; prop=JS.toString(value);
- public Box() { super(null); }
-
// FIXME memory leak
static Hash boxToCursor = new Hash(500, 3);
throw new JSExn("invalid resource specifier " + url);
}
case "thread.sleep": sleep(JS.toInt(a)); return null;
- case "regexp": return JS.newRegexp(a, null);
+ case "regexp": return new JSRegexp(a, null);
case "net.rpc.xml": return new XMLRPC(JS.toString(a), "");
case "crypto.rsa": /* FEATURE */ return null;
case "crypto.md5": /* FEATURE */ return null;
case 2:
//#jswitch(name)
case "stream.watch": return new Stream.ProgressWatcher(a, b);
- case "regexp": return JS.newRegexp(a, b);
+ case "regexp": return new JSRegexp(a, b);
//#end
case 3:
//#jswitch(name)
// FEATURE: move this into builtin.xwar
public Blessing bless(JS b) throws JSExn { return new Ibex.Blessing(b, this, null, null); }
- // FIXME: Does this really need to extends JS.Clone?
- // FEATURE: Mandate that Blessings use only String keys?
- public static class Blessing extends JS.Clone {
+ // JS:FIXME: This doesn't properly handle traps
+ public static class Blessing extends JS.O {
private Ibex ibex;
private Template t = null;
public JS parentkey = null;
public Blessing parent = null;
+ public JS clonee;
private Hash cache = new Hash();
public Blessing(JS clonee, Ibex ibex, Blessing parent, JS parentkey) throws JSExn {
- super(clonee); this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
+ this.clonee = clonee; this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
public JS get(JS key) throws JSExn {
if (JS.isString(key) && JS.toString(key).equals("")) return getStatic();
if (cache.get(key) != null) return (JS)cache.get(key);
} catch (IOException f) { /* DELIBERATE */ }
return null;
}
- public JSScope getStatic() throws JSExn {
+ public JS getStatic() throws JSExn {
try {
if (t == null) {
// FEATURE: Might want to handle the ".t" part better
JS res = parent.get(JS.S(JS.toString(parentkey) + ".t"));
t = Template.buildTemplate(description(), res, ibex);
}
- return t != null ? t.staticScope : null;
+ return t != null ? t.staticObject : null;
} catch (Exception e) {
Log.error(this, e);
return null;
}
private String description() {
String s = JS.debugToString(parentkey);
- for(Blessing b = parent; b != null; b = b.parent) s = JS.debugToString(parentkey) + "." + s;
+ for(Blessing b = parent; b.parentkey != null; b = b.parent) s = JS.debugToString(b.parentkey) + "." + s;
return s;
}
public JS call(JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
if (t == null) throw new JSExn("No such template " + JS.debugToString(parentkey));
return t;
}
+ // JS:FIXME: Blessing shouldn't need to roll its own JS.Clone implementation
+ public InputStream getInputStream() throws IOException { return clonee.getInputStream(); }
}
}
private JS script = null; ///< the script on this node
Template prev;
Template prev2;
- JSScope staticScope = null; ///< the scope in which the static block is executed
JS staticObject = null;
for(int i=0; i<urikeys.length; i++) {
if (urikeys[i] == null) continue;
// FEATURE: Cache urikeys and resolved resources
- pis.declare(JS.S(urikeys[i]));
- pis.put(JS.S(urikeys[i]), ibex.resolveString(urivals[i], true));
+ //pis.declare(JS.S(urikeys[i]));
+ // JS:FIXME: ugly
+ pis.sput(JS.S(urikeys[i]), ibex.resolveString(urivals[i], true));
}
// FIXME needs to obey the new application-ordering rules
b.putAndTriggerTraps(b.get(JS.S("numchildren")), kid);
}
- if (script != null) JS.cloneWithNewParentScope(script, pis).call(null, null, null, null, 0);
+ if (script != null) JS.cloneWithNewGlobalScope(script, pis).call(null, null, null, null, 0);
for(int i=0; keys != null && i < keys.length; i++) {
if (keys[i] == null) continue;
parse(new InputStreamReader(is));
JS staticScript = parseScript(static_content, static_content_start);
t.staticObject = new JS.O();
- t.staticScope = new PerInstantiationScope(null, ibex, null, t.staticObject);
- if (staticScript != null) JS.cloneWithNewParentScope(staticScript, t.staticScope).call(null, null, null, null, 0);
+ JS staticScope = new PerInstantiationScope(null, ibex, null, t.staticObject);
+ if (staticScript != null) JS.cloneWithNewGlobalScope(staticScript, staticScope).call(null, null, null, null, 0);
}
private JS parseScript(StringBuffer content, int content_start) throws IOException {
// t.prev2 = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999);
if(t.prev2 != null) throw new Error("FIXME: t.prev2 != null");
t.prev2 = ((Ibex.Blessing)t.ibex.resolveString(tagname, false)).getTemplate();
+ if(t.prev2 == null) throw new Exception("" + tagname + " not found");
} catch (Exception e) {
Log.error(Template.class, e);
}
public void whitespace(char[] ch, int start, int length) throws XML.Exn { }
}
- private static class PerInstantiationScope extends JSScope {
+ private static class PerInstantiationScope extends JS.O {
Ibex ibex = null;
PerInstantiationScope parentBoxPis = null;
JS myStatic = null;
+ JS box;
void putDollar(String key, Box target) throws JSExn {
if (parentBoxPis != null) parentBoxPis.putDollar(key, target);
JS jskey = JS.S("$" + key);
- declare(jskey);
- put(jskey, target);
+ //declare(jskey);
+ sput(jskey, target);
}
- public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JS myStatic) {
- super(parentScope);
+ // JS:FIXME: ugly
+ void sput(JS key, JS val) throws JSExn { super.put(key,val); }
+ public PerInstantiationScope(JS box, Ibex ibex, PerInstantiationScope parentBoxPis, JS myStatic) {
this.parentBoxPis = parentBoxPis;
this.ibex = ibex;
this.myStatic = myStatic;
+ this.box = box;
}
public JS get(JS key) throws JSExn {
- if (super.has(key)) return super.get(key);
if(JS.isString(key)) {
String s = JS.toString(key);
+ // JS:FIXME This is a hack
+ if (super.get(key) != null) return super.get(key);
if (s.equals("ibex")) return ibex;
if (s.equals("")) return ibex.get(key);
if (s.equals("static")) return myStatic;
}
- return super.get(key);
+ // JS:FIXME: This won't work with traps that do blocking operations
+ return box.getAndTriggerTraps(key);
}
+ // JS:FIXME: Everything below here should come from js.scope or something
+ public void put(JS key, JS val) throws JSExn { if(box != null) box.putAndTriggerTraps(key,val); else super.put(key,val); }
+ public void addTrap(JS key, JSFunction f) throws JSExn { box.addTrap(key,f); }
+ public void delTrap(JS key, JSFunction f) throws JSExn { box.delTrap(key,f); }
}
}
return ret;
}
- public static JSScope proxyAutoConfigRootScope = /*new ProxyAutoConfigRootScope();*/ null; // FIXME: New api
+ public static JS proxyAutoConfigRootScope = /*new ProxyAutoConfigRootScope();*/ null; // JS:FIXME: New api
public static JS getProxyAutoConfigFunction(String url) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new HTTP(url, true).GET()));
}
JS scr = JS.fromReader("PAC script at " + url, 0, new StringReader(script));
- JS.cloneWithNewParentScope(scr, proxyAutoConfigRootScope).call(null, null, null, null, 0);
+ JS.cloneWithNewGlobalScope(scr, proxyAutoConfigRootScope).call(null, null, null, null, 0);
return (JS)proxyAutoConfigRootScope.get(JS.S("FindProxyForURL"));
} catch (Exception e) {
if (Log.on) {
objects.addElement(null);
} else if (value.endsWith("arrayType") || value.endsWith("JSArray") || key.endsWith("arrayType")) {
objects.removeElementAt(objects.size() - 1);
- objects.addElement(JS.newArray());
+ objects.addElement(new JSArray());
}
}
}
/** Appends the SOAP representation of <code>o</code> to <code>sb</code> */
void appendObject(String name, JS o, StringBuffer sb) throws JSExn {
- // FIXME: Update for new api
+ // JS:FIXME: Update for new api
/*
if (o instanceof Number) {
if ((double)((Number)o).intValue() == ((Number)o).doubleValue()) {
case "data":
int i;
for(i=objects.size() - 1; objects.elementAt(i) != null; i--);
- JS arr = JS.newArray();
+ JS arr = new JSArray();
try {
for(int j = i + 1; j<objects.size(); j++) arr.put(JS.N(j - i - 1), (JS)objects.elementAt(j));
} catch (JSExn e) {
/** Appends the XML-RPC representation of <code>o</code> to <code>sb</code> */
void appendObject(JS o, StringBuffer sb) throws JSExn {
- // FIXME: Update for new api
+ // JS:FIXME: Update for new api
throw new Error("FIXME");
/*if (o == null) {
throw new JSExn("attempted to send a null value via XML-RPC");