Revision: 1772
          http://svn.sourceforge.net/vexi/?rev=1772&view=rev
Author:   mkpg2
Date:     2007-03-30 11:37:43 -0700 (Fri, 30 Mar 2007)

Log Message:
-----------
Fix. Make sure that 'default default namespace' object is vexi[""]

Modified Paths:
--------------
    core/trunk/org.vexi.core/src/org/vexi/core/Template.java

Modified: core/trunk/org.vexi.core/src/org/vexi/core/Template.java
===================================================================
--- core/trunk/org.vexi.core/src/org/vexi/core/Template.java    2007-03-30 
18:19:35 UTC (rev 1771)
+++ core/trunk/org.vexi.core/src/org/vexi/core/Template.java    2007-03-30 
18:37:43 UTC (rev 1772)
@@ -153,9 +153,10 @@
         // FIXME this dollar stuff is all wrong
         if (id != null && parentPis!=null) parentPis.putDollar(id, b);
 
-        JS staticObj = parentPis==null?getStatic():parentPis.myStatic;
-        // FEATURE only if necessary
-        PerInstantiationScope pis = new PerInstantiationScope(b, parentPis, 
staticObj);
+        // Propagate the static part (and access to the static object
+        if(parentPis!=null)    staticPart = parentPis.getStaticPart();
+        // FEATURE only if necessary (i.e. if there is JS code)
+        PerInstantiationScope pis = new PerInstantiationScope(b, parentPis);
 
         // FIXME needs to obey the new application-ordering rules
         for (int i=0; children != null && i<children.size(); i++) {
@@ -272,10 +273,17 @@
     
     
     ///////////
-    // NAMESPACE PREFIX HANDLING
+    // GLOBAL SCOPES
     ///
-    
-    
+    private JS commonGlobals(String s) throws JSExn{
+        // FEATURE preprocess
+        if (s.equals("vexi")) return vexi;
+        if (s.equals("static")) return staticPart.staticObject;
+        // The 'default (default namespace)' object
+        if (s.equals("")) return vexi.getAndTriggerTraps(SC_);
+        return null;
+    }
+
     /** 
      * The StaticScope is the global scope for the static javascript code 
      *  @author mike
@@ -290,8 +298,8 @@
                 if (super.get(key) != null) return super.get(key);
                 r=(JS) staticPart.uriPrefixes.get(key, true);
                 if(r!=null)    return r;
-                if (s.equals("vexi")) return vexi;
-                if (s.equals("static")) return staticPart.staticObject;
+                r=commonGlobals(s);
+                if(r!=null)    return r;
             }
             // FIXME: This won't work with traps that do blocking operations
             return staticPart.staticObject.getAndTriggerTraps(key);
@@ -330,18 +338,19 @@
      */
     class PerInstantiationScope extends JS.Obj {
         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 = JSU.S("$" + key);
             sput(jskey, target);
         }
+        // REMARK - giving access to outerclass variable (
+        // as no way to do it otherwise in java?)
+        Static getStaticPart(){        return staticPart; }
         // JS:FIXME: ugly
         void sput(JS key, JS val) throws JSExn { super.put(key,val); }
-        public PerInstantiationScope(JS box, PerInstantiationScope 
parentBoxPis, JS myStatic) {
+        public PerInstantiationScope(JS box, PerInstantiationScope 
parentBoxPis) {
             this.parentBoxPis = parentBoxPis;
-            this.myStatic = myStatic;
             this.box = box;
         }
         public JS get(JS key) throws JSExn {
@@ -356,8 +365,8 @@
                 //  2.return prefix
                 r= (JS) uriPrefixes.get(key, true);
                 if(r!=null)    return r;
-                if (s.equals("vexi")) return vexi;
-                if (s.equals("static")) return myStatic;
+                r=commonGlobals(s);
+                if(r!=null)    return r;
             }
             // FIXME: This won't work with traps that do blocking operations
             return box.getAndTriggerTraps(key);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to