cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: rev 56135 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom
Date Sun, 31 Oct 2004 09:41:06 GMT
Author: sylvain
Date: Sun Oct 31 01:41:06 2004
New Revision: 56135

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
Log:
allow declaring classes in the toplevel scope even when locked

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
Sun Oct 31 01:41:06 2004
@@ -421,7 +421,9 @@
         }
 
         public void put(String name, Scriptable start, Object value) {
-            if (!has(name, start) && this.locked) {
+            //Allow setting values to existing variables, or if this is a
+            //java class (used by importClass & importPackage)
+            if (this.locked && !has(name, start) && !(value instanceof NativeJavaClass))
{
                 // Need to wrap into a runtime exception as Scriptable.put has no throws
clause...
                 throw new WrappedException (new JavaScriptException("Implicit declaration
of global variable '" + name +
                   "' forbidden. Please ensure all variables are explicitely declared with
the 'var' keyword"));
@@ -432,7 +434,7 @@
 
         public void put(int index, Scriptable start, Object value) {
             // FIXME(SW): do indexed properties have a meaning on the global scope?
-            if (!has(index, start) && this.locked) {
+            if (this.locked && !has(index, start)) {
                 throw new WrappedException(new JavaScriptException("Global scope locked.
Cannot set value for index " + index));
             }
             this.useSession = true;

Mime
View raw message