2003/12/29 03:51:28
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:43:39 +0000 (07:43 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:43:39 +0000 (07:43 +0000)
darcs-hash:20040130074339-2ba56-c10a9528c2df15f61bfee6e67a4204a9a361b0fe.gz

src/org/xwt/Res.java
src/org/xwt/Template.java

index 35f3b51..b529a4e 100644 (file)
@@ -40,7 +40,7 @@ public abstract class Res extends JS {
         if ("".equals(key)) {
             try {
                 Template t = Template.getTemplate(addExtension(".xwt"));
-                return t == null ? null : t.getStatic();
+                return t == null ? null : t.getStatic(null);  /** FIXME VERY BAD! */
             } catch (Exception e) {
                 Log.info(this, e);
                 return null;
index df20ee9..b1aa9ad 100644 (file)
@@ -40,7 +40,7 @@ public class Template {
 
     // Instance Members that are only meaningful on root Template //////////////////////////////////////
 
-    private JSScope staticJSScope = null;   ///< the scope in which the static block is executed
+    private JSScope staticScope = null;   ///< the scope in which the static block is executed
     private JSFunction staticscript = null;  ///< the script on the static node of this template, null already performed
 
 
@@ -94,13 +94,13 @@ public class Template {
     }
 
     /** called before this template is applied or its static object can be externally referenced */
-    JSScope getStatic() throws JSExn {
-        if (staticJSScope == null) staticJSScope = new JSScope(null);
-        if (staticscript == null) return staticJSScope;
+    JSScope getStatic(XWT xwt) throws JSExn {
+        if (staticScope == null) staticScope = new PerInstantiationJSScope(null, xwt, null, null);
+        if (staticscript == null) return staticScope;
         JSFunction temp = staticscript;
         staticscript = null;
-        temp.cloneWithNewParentScope(staticJSScope).call(null, null, null, null, 0);
-        return staticJSScope;
+        temp.cloneWithNewParentScope(staticScope).call(null, null, null, null, 0);
+        return staticScope;
     }
     
     /** Applies the template to Box b
@@ -121,7 +121,7 @@ public class Template {
 
 
     private void apply(Box b, XWT xwt, PerInstantiationJSScope parentPis) throws JSExn {
-        getStatic();
+        getStatic(xwt);
 
         if (id != null) parentPis.putDollar(id, b);
         for(int i=0; i<preapply.size(); i++) {
@@ -130,7 +130,7 @@ public class Template {
             t.apply(b, xwt);
         }
 
-        PerInstantiationJSScope pis = new PerInstantiationJSScope(b, xwt, parentPis, staticJSScope);
+        PerInstantiationJSScope pis = new PerInstantiationJSScope(b, xwt, parentPis, staticScope);
         for (int i=0; children != null && i<children.size(); i++) {
             Box kid = new Box();
             ((Template)children.elementAt(i)).apply(kid, xwt, pis);