X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FTemplate.java;h=ee0bea5d38ad7950e39a5f83468bdfbb6d347cb5;hb=55c3195af733f3de6b7894f4c4a96f7b50f58c11;hp=a9ea9b91502a90352a6c92d33b17de5d7435181e;hpb=e58686eae8a823ed64ed0ec92c2274c41d90ec93;p=org.ibex.core.git diff --git a/src/org/xwt/Template.java b/src/org/xwt/Template.java index a9ea9b9..ee0bea5 100644 --- a/src/org/xwt/Template.java +++ b/src/org/xwt/Template.java @@ -1,4 +1,4 @@ -// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.io.*; @@ -73,10 +73,10 @@ public class Template { private boolean changed = false; /** the script on the static node of this template, null if it has already been executed */ - private JS.Script staticscript = null; + private JS.CompiledFunction staticscript = null; /** the script on this node */ - private JS.Script script = null; + private JS.CompiledFunction script = null; /** during XML parsing, this holds the list of currently-parsed children; null otherwise */ private Vec childvect = new Vec(); @@ -165,7 +165,7 @@ public class Template { * @param pboxes a vector of all box parents on which to put $-references * @param ptemplates a vector of the nodeNames to recieve private references on the pboxes */ - void apply(Box b, Vec pboxes, Vec ptemplates, JS.Function callback, int numerator, int denominator) { + void apply(Box b, Vec pboxes, Vec ptemplates, JS.Callable callback, int numerator, int denominator) { int original_numerator = numerator; @@ -197,7 +197,9 @@ public class Template { } for (int i=0; children != null && ichange as needed */ @@ -365,20 +371,18 @@ public class Template { if (staticscript != null) try { JS.Scope s = Static.createStatic(nodeName, false); if (staticscript != null) { - JS.Script temp = staticscript; + JS.CompiledFunction temp = staticscript; staticscript = null; - // we layer a transparent scope over the Static so that we can catch requests for the xwt object - // yet not screw up paths that include a package called xwt (ie xwt.static.org.xwt.foo) - JS.Scope varScope = new JS.Scope(s) { - public boolean isTransparent() { return true; } - public Object get(Object key) { - if ("xwt".equals(key)) return XWT.singleton; else return super.get(key); - } }; - - JS.Array args = new JS.Array(); - args.addElement(varScope); - temp.call(args); + // we layer a transparent scope over the Static so that we can catch requests for the xwt object + // yet not screw up paths that include a package called xwt (ie xwt.static.org.xwt.foo) + JS.Scope varScope = new JS.Scope(s) { + public boolean isTransparent() { return true; } + public Object get(Object key) { + if ("xwt".equals(key)) return XWT.singleton; else return super.get(key); + } }; + + temp.call(new JS.Array(), varScope); } } catch (JS.Exn e) { if (Log.on) Log.log(this, "WARNING: uncaught ecmascript exception: " + e.getMessage()); @@ -492,6 +496,7 @@ public class Template { if (t.redirect != null) throw new XML.SchemaException("the header element may not appear more than once"); t.redirect = c.vals[0].toString(); + if(t.redirect.equals("null")) t.redirect = null; return; } else if (c.localName.equals("preapply")) { @@ -654,10 +659,10 @@ public class Template { } } - private JS.Script genscript(boolean isstatic) { - JS.Script thisscript = null; + private JS.CompiledFunction genscript(boolean isstatic) { + JS.CompiledFunction thisscript = null; try { - thisscript = JS.Script.parse(new StringReader(t.content.toString()), t.nodeName + (isstatic ? "._" : ""), t.content_start); + thisscript = JS.parse(t.nodeName + (isstatic ? "._" : ""), t.content_start, new StringReader(t.content.toString())); } catch (JS.Exn ee) { if (Log.on) Log.log(this, " ERROR: " + ee.getMessage()); thisscript = null;