velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From by...@apache.org
Subject svn commit: r740591 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Date Wed, 04 Feb 2009 03:29:30 GMT
Author: byron
Date: Wed Feb  4 03:29:30 2009
New Revision: 740591

URL: http://svn.apache.org/viewvc?rev=740591&view=rev
Log:
Fixed number of arguments reported in macro mis-match argument exception

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=740591&r1=740590&r2=740591&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Wed Feb  4 03:29:30 2009
@@ -57,6 +57,12 @@
     private boolean localContextScope = false;
     private int maxCallDepth;
     private String bodyReference;
+    
+    /**
+     * Set to true when the configuration indicates we are following pass by value
+     * Symentics for macro parameter passing.
+     */
+    private boolean passByValue = false;
 
     /**
      * Return name of this Velocimacro.
@@ -171,7 +177,15 @@
                  * This makes VMReferenceMungeVisitor obsolete and it would not work anyway

                  * when the macro AST is shared
                  */
-                vmc.addVMProxyArg(context, argArray[i], literalArgArray[i], node.jjtGetChild(i
- 1));
+                if (passByValue)
+                {
+                    vmc.addVMProxyArg(context, argArray[i], node.jjtGetChild(i - 1));
+                }
+                else
+                {
+                    vmc.addVMProxyArg(context, argArray[i], 
+                        literalArgArray[i], node.jjtGetChild(i - 1));
+                }
             }
         }
         
@@ -253,6 +267,9 @@
 
         // get name of the reference that refers to AST block passed to block macro call
         bodyReference = rsvc.getString(RuntimeConstants.VM_BODY_REFERENCE, "bodyContent");
+
+        // Are we configured for pass by value semantics when passing parameters
+        passByValue = rs.getBoolean(RuntimeConstants.VM_ARGUMENTS_PASSBYVALUE, false); 
     }
     
 
@@ -261,7 +278,7 @@
      */
     private String buildErrorMsg(Node node)
     {
-      int i = node.jjtGetNumChildren();  // the number of arguments this call provided
+      int i = node.jjtGetNumChildren() - 1;  // the number of arguments this call provided
       String msg = "VM #" + macroName + ": too "
         + ((getNumArgs() > i) ? "few" : "many") + " arguments to macro. Wanted "
         + getNumArgs() + " got " + i;      



Mime
View raw message