From: brian Date: Tue, 13 Jul 2004 04:29:24 +0000 (+0000) Subject: update core for recent js changes X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=a9e4fbe550f9618ebef864db11d4b249578db9dd update core for recent js changes darcs-hash:20040713042924-24bed-cc9d2ad4adbae140ea9b441aa9d0a836af8244f7.gz --- diff --git a/src/org/ibex/core/Box.java b/src/org/ibex/core/Box.java index a587a55..96aa0a0 100644 --- a/src/org/ibex/core/Box.java +++ b/src/org/ibex/core/Box.java @@ -38,7 +38,7 @@ import org.ibex.graphics.*; * 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 ////////////////////////////////////////////////////////////////////// @@ -52,8 +52,6 @@ public final class Box extends JSScope implements Task { //#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); diff --git a/src/org/ibex/core/Ibex.java b/src/org/ibex/core/Ibex.java index ccc6afb..447ee1d 100644 --- a/src/org/ibex/core/Ibex.java +++ b/src/org/ibex/core/Ibex.java @@ -185,7 +185,7 @@ public final class Ibex extends JS implements JS.Cloneable { 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; @@ -202,7 +202,7 @@ public final class Ibex extends JS implements JS.Cloneable { 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) @@ -345,16 +345,16 @@ public final class Ibex extends JS implements JS.Cloneable { // 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); @@ -381,14 +381,14 @@ public final class Ibex extends JS implements JS.Cloneable { } 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; @@ -396,7 +396,7 @@ public final class Ibex extends JS implements JS.Cloneable { } 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 { @@ -413,6 +413,8 @@ public final class Ibex extends JS implements JS.Cloneable { 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(); } } } diff --git a/src/org/ibex/core/Template.java b/src/org/ibex/core/Template.java index efa3bbb..a3d0e4e 100644 --- a/src/org/ibex/core/Template.java +++ b/src/org/ibex/core/Template.java @@ -33,7 +33,6 @@ public class Template { 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; @@ -86,8 +85,9 @@ public class Template { for(int i=0; io to sb */ 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()) { diff --git a/src/org/ibex/net/XMLRPC.java b/src/org/ibex/net/XMLRPC.java index e6a3f65..72a2c76 100644 --- a/src/org/ibex/net/XMLRPC.java +++ b/src/org/ibex/net/XMLRPC.java @@ -141,7 +141,7 @@ public class XMLRPC extends JS { 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; jo to sb */ 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");