You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2009/03/12 00:35:04 UTC
svn commit: r752695 - in /velocity/engine/branches/2.0_Exp/src:
java/org/apache/velocity/context/ java/org/apache/velocity/runtime/
java/org/apache/velocity/runtime/defaults/
java/org/apache/velocity/runtime/directive/ test/org/apache/velocity/test/
te...
Author: nbubna
Date: Wed Mar 11 23:35:04 2009
New Revision: 752695
URL: http://svn.apache.org/viewvc?rev=752695&view=rev
Log:
remove velocimacro.context.localscope config (as local macro refs should be explicitly set on $macro now)
Removed:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/VMContextLocalscopeTestCase.java
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateContextTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/GlobalTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity62TestCase.java
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java Wed Mar 11 23:35:04 2009
@@ -38,7 +38,12 @@
boolean localscope = true;
private Context globalContext = null;
-
+
+ public ProxyVMContext(InternalContextAdapter context)
+ {
+ this(context, false);
+ }
+
/**
* @param context the parent context
* @param localScopeContext if true, all references are set to be local
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java Wed Mar 11 23:35:04 2009
@@ -222,9 +222,6 @@
/** Switch for VM blather : default true. */
String VM_MESSAGES_ON = "velocimacro.messages.on";
- /** switch for local context in VM : default false. */
- String VM_CONTEXT_LOCALSCOPE = "velocimacro.context.localscope";
-
/** if true, throw an exception for wrong number of arguments **/
String VM_ARGUMENTS_STRICT = "velocimacro.arguments.strict";
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties Wed Mar 11 23:35:04 2009
@@ -47,18 +47,12 @@
# ----------------------------------------------------------------------------
# F O R E A C H P R O P E R T I E S
# ----------------------------------------------------------------------------
-# These properties control how the counter is accessed in the #foreach
-# directive. By default the reference $velocityCount and $velocityHasNext
-# will be available in the body of the #foreach directive.
-# The default starting value for $velocityCount is 1.
+# This property controls how many loops #foreach can execute. The default
+# is -1, which means there is no limit.
# ----------------------------------------------------------------------------
-directive.foreach.counter.name = velocityCount
-directive.foreach.counter.initial.value = 1
directive.foreach.maxloops = -1
-directive.foreach.iterator.name = velocityHasNext
-
# ----------------------------------------------------------------------------
# S E T P R O P E R T I E S
# ----------------------------------------------------------------------------
@@ -112,8 +106,6 @@
velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = false
velocimacro.permissions.allow.inline.local.scope = false
-
-velocimacro.context.localscope = false
velocimacro.max.depth = 20
# ----------------------------------------------------------------------------
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java Wed Mar 11 23:35:04 2009
@@ -52,7 +52,6 @@
private SimpleNode nodeTree = null;
private int numMacroArgs = 0;
private boolean strictArguments;
- private boolean localContextScope = false;
private int maxCallDepth;
private String bodyReference;
@@ -151,7 +150,7 @@
// wrap the current context and add the macro arguments
// the creation of this context is a major bottleneck (incl 2x HashMap)
- final ProxyVMContext vmc = new ProxyVMContext(context, localContextScope);
+ final ProxyVMContext vmc = new ProxyVMContext(context);
int callArgNum = node.jjtGetNumChildren();
@@ -281,10 +280,6 @@
strictArguments = rs.getConfiguration().getBoolean(
RuntimeConstants.VM_ARGUMENTS_STRICT, false);
- // support for local context scope feature, where all references are local
- // we do not have to check this at every invocation of ProxyVMContext
- localContextScope = rsvc.getBoolean(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, false);
-
// get the macro call depth limit
maxCallDepth = rsvc.getInt(RuntimeConstants.VM_MAX_DEPTH);
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateContextTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateContextTestCase.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateContextTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateContextTestCase.java Wed Mar 11 23:35:04 2009
@@ -42,7 +42,6 @@
RuntimeInstance instance;
instance = new RuntimeInstance();
- instance.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
instance.init();
VelocityContext base = new VelocityContext();
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java Wed Mar 11 23:35:04 2009
@@ -117,11 +117,6 @@
{
Map properties = new HashMap();
properties.clear();
- properties.put(RuntimeConstants.VM_CONTEXT_LOCALSCOPE,"false");
- testFile("eval2", properties);
-
- properties.clear();
- properties.put(RuntimeConstants.VM_CONTEXT_LOCALSCOPE,"true");
testFile("eval2", properties);
properties.clear();
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/GlobalTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/GlobalTestCase.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/GlobalTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/GlobalTestCase.java Wed Mar 11 23:35:04 2009
@@ -35,14 +35,13 @@
public void setUp() throws Exception
{
super.setUp();
- engine.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, true);
engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, true);
}
public void testSimple()
{
// define a macro for testing
- assertEvalEquals("","#macro(foo)#set($bar = \"a\")#global($bar = \"b\")$bar#end");
+ assertEvalEquals("","#macro(foo)#set($macro.bar = \"a\")#global($bar = \"b\")$macro.bar#end");
assertEvalEquals("ab", "#foo()$bar");
assertEvalEquals("ab", "#set($bar=\"c\")#foo()$bar");
assertEvalEquals("ab", "#global($bar=\"c\")#foo()$bar");
@@ -51,9 +50,9 @@
public void testNested()
{
// define inner macro
- assertEvalEquals("","#macro(inner)#set($bar = \"x\")$bar#global($bar = \"y\")$bar#end");
+ assertEvalEquals("","#macro(inner)#set($macro.bar = \"x\")$macro.bar#global($bar = \"y\")$macro.bar#end");
// define outer macro
- assertEvalEquals("","#macro(outer)#set($bar = \"a\")$bar#inner()$bar#global($bar = \"b\")$bar#end");
+ assertEvalEquals("","#macro(outer)#set($macro.bar = \"a\")$macro.bar#inner()$macro.bar#global($bar = \"b\")$macro.bar#end");
assertEvalEquals("axxaab","#outer()$bar");
assertEvalEquals("axxaab","#set($bar = \"z\")#outer()$bar");
}
@@ -65,16 +64,16 @@
public void testExistance2()
{
- assertEvalEquals("no","#macro(foo)#set($bar = \"b\")#end#foo()#if($bar)yes#{else}no#end");
+ assertEvalEquals("no","#macro(foo)#set($macro.bar = \"b\")#end#foo()#if($bar)yes#{else}no#end");
}
public void testProperties()
{
- assertEvalEquals("1223", "#set($bar = {\"a\":1})$bar.a#macro(foo)#set($bar = {\"a\":2})$bar.a#global($bar.a = 3)$bar.a#end#foo()$bar.a");
+ assertEvalEquals("1223", "#set($bar = {\"a\":1})$bar.a#macro(foo)#set($macro.bar = {\"a\":2})$macro.bar.a#global($bar.a = 3)$macro.bar.a#end#foo()$bar.a");
}
public void testProperties2()
{
- assertEvalException("#macro(foo)#set($bar = {\"a\":2})$bar.a#global($bar.a = 3)$bar.a#end#foo()");
+ assertEvalException("#macro(foo)#set($macro.bar = {\"a\":2})$macro.bar.a#global($bar.a = 3)$macro.bar.a#end#foo()");
}
}
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity62TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity62TestCase.java?rev=752695&r1=752694&r2=752695&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity62TestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity62TestCase.java Wed Mar 11 23:35:04 2009
@@ -36,7 +36,6 @@
public void setUp() throws Exception
{
super.setUp();
- engine.setProperty(RuntimeConstants.VM_CONTEXT_LOCALSCOPE, Boolean.TRUE);
context.put("foo", "foo");
}
@@ -45,7 +44,7 @@
String template = "#macro( outer )#set( $foo = 'bar' )#inner()#end"+
"#macro( inner )$foo#end"+
"#inner()#outer()#inner()";
- assertEvalEquals("foobarfoo", template);
+ assertEvalEquals("foobarbar", template);
}
public void testRecursive()