public
Fork of hns/helma-ng
Description: Next generation of Helma Javascript on Java web app framework
Homepage: http://dev.helma.org/ng/
Clone URL: git://github.com/zumbrunn/helma-ng.git
Merge commit 'hns/master'
zumbrunn (author)
Fri Sep 05 09:47:14 -0700 2008
commit  02126dc362270def8389c988c2e3e6cfd17865d6
tree    1176bc257573c9ccd978062367cdf2191cffa05d
parent  38e8e9cafb5edf9038c01757a8d71a5a89dd1cd5
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
146
147
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
150
151
0
@@ -146,23 +146,6 @@ var log = logging.getLogger(__name__);
0
                 });
0
             }
0
             return '"' + x + '"';
0
-        },
0
-
0
-        /*
0
-         * TODO this is a preliminary hack to support JSAdapter properties for the
0
-         * storable module. JSAdapters identify as functions with the typeof operator,
0
-         * and we use this to generate proxies in the DB representation of persistent
0
-         * object references. We need to find out how to implement this without
0
-         * messing with the main JSON module.
0
-         */
0
-        'function': function(x) {
0
-            if (x instanceof JSAdapter && x._type && typeof x.save == 'function') {
0
-                if (!x._id) {
0
-                    throw Error("Trying to save non-persistent property");
0
-                }
0
-                return '{"_id": "' + x._id + '", "_type": "' + x._type + '"}'
0
-            }
0
-            return null;
0
         }
0
     };
0
 
...
51
52
53
 
54
55
56
...
182
183
184
185
186
 
 
187
188
189
...
250
251
252
253
 
 
254
255
256
...
51
52
53
54
55
56
57
...
183
184
185
 
 
186
187
188
189
190
...
251
252
253
 
254
255
256
257
258
0
@@ -51,6 +51,7 @@ public class RhinoEngine {
0
     AppClassLoader                     loader             = new AppClassLoader();
0
     HelmaWrapFactory                   wrapFactory        = new HelmaWrapFactory();
0
     HelmaContextFactory                contextFactory     = new HelmaContextFactory(this);
0
+    ModuleScope                        mainScope          = null;
0
 
0
     public static final Object[]       EMPTY_ARGS         = new Object[0];
0
     protected boolean                  isInitialized      = false;
0
@@ -182,8 +183,8 @@ public class RhinoEngine {
0
             }
0
             ReloadableScript script = new ReloadableScript(resource, this);
0
             scripts.put(resource, script);
0
-            Scriptable scope = new ModuleScope("__main__", resource, topLevelScope);
0
-            retval = script.evaluate(scope, cx);
0
+            mainScope = new ModuleScope("__main__", resource, topLevelScope);
0
+            retval = script.evaluate(mainScope, cx);
0
           if (retval instanceof Wrapper) {
0
             return ((Wrapper) retval).unwrap();
0
           }
0
@@ -250,7 +251,8 @@ public class RhinoEngine {
0
         try {
0
             Repository repository = repositories.get(0);
0
             Resource resource = repository.getResource("<shell>");
0
-            ModuleScope scope = new ModuleScope("<shell>", resource, topLevelScope);
0
+            Scriptable parentScope = mainScope != null ? mainScope : topLevelScope;
0
+            ModuleScope scope = new ModuleScope("<shell>", resource, parentScope);
0
             try {
0
                 getScript("helma.shell").evaluate(scope, cx);
0
             } catch (Exception x) {
...
25
26
27
28
29
30
31
...
25
26
27
 
28
29
30
0
@@ -25,7 +25,6 @@ import org.mozilla.javascript.tools.ToolErrorReporter;
0
 
0
 import java.io.IOException;
0
 import java.io.PrintWriter;
0
-import java.io.FileNotFoundException;
0
 import java.util.Collections;
0
 import java.util.List;
0
 import java.util.regex.Matcher;

Comments