tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java ScriptingVariabler.java
Date Mon, 09 Sep 2002 23:24:15 GMT
luehe       2002/09/09 16:24:15

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        ScriptingVariabler.java
  Log:
  Fixed 12432: Can't compile JSP with nested custom tags that have VariableInfo
  
  Revision  Changes    Path
  1.95      +32 -45    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- Generator.java	9 Sep 2002 18:12:50 -0000	1.94
  +++ Generator.java	9 Sep 2002 23:24:14 -0000	1.95
  @@ -1972,13 +1972,7 @@
   
   	    // Declare AT_BEGIN scripting variables
   	    declareScriptingVars(n, VariableInfo.AT_BEGIN);
  -
  -	    /*
  -	     * Save current values of scripting variables, so that the 
  -	     * scripting variables may be synchronized without affecting their
  -	     * original values
  -	     */
  -	    saveScriptingVars(n);
  +	    saveScriptingVars(n, VariableInfo.AT_BEGIN);
   
   	    out.printin(tagHandlerClass.getName());
   	    out.print(" ");
  @@ -2013,9 +2007,6 @@
   	    if (!n.implementsIterationTag()) {
   		// Synchronize AT_BEGIN scripting variables
   		syncScriptingVars(n, VariableInfo.AT_BEGIN);
  -		// Declare and synchronize NESTED scripting variables
  -		declareScriptingVars(n, VariableInfo.NESTED);
  -		syncScriptingVars(n, VariableInfo.NESTED);
   	    }
   
   	    if (n.getBody() != null) {
  @@ -2027,6 +2018,7 @@
   		if (n.implementsIterationTag()) {
   		    // Declare NESTED scripting variables
   		    declareScriptingVars(n, VariableInfo.NESTED);
  +		    saveScriptingVars(n, VariableInfo.NESTED);
   
   		    if (n.implementsBodyTag()) {
   			out.printin("if (");
  @@ -2065,25 +2057,26 @@
   	    VariableInfo[] varInfos = n.getVariableInfos();
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
   
  -	    if ((n.getBody() != null) && n.implementsIterationTag()) {
  -		out.printin("int evalDoAfterBody = ");
  -		out.print(tagHandlerVar);
  -		out.println(".doAfterBody();");
  -
  -		// Synchronize AT_BEGIN and NESTED scripting variables
  -		syncScriptingVars(n, VariableInfo.AT_BEGIN);
  -		syncScriptingVars(n, VariableInfo.NESTED);
  +	    if (n.getBody() != null) {
  +		if (n.implementsIterationTag()) {
  +		    out.printin("int evalDoAfterBody = ");
  +		    out.print(tagHandlerVar);
  +		    out.println(".doAfterBody();");
  +
  +		    // Synchronize AT_BEGIN and NESTED scripting variables
  +		    syncScriptingVars(n, VariableInfo.AT_BEGIN);
  +		    syncScriptingVars(n, VariableInfo.NESTED);
   
  -		out.printil("if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
  -		out.pushIndent();
  -		out.printil("break;");
  -		out.popIndent();
  +		    out.printil("if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
  +		    out.pushIndent();
  +		    out.printil("break;");
  +		    out.popIndent();
   
  -		out.popIndent();
  -		out.printil("} while (true);");
  -	    }
  +		    out.popIndent();
  +		    out.printil("} while (true);");
  +		    restoreScriptingVars(n, VariableInfo.NESTED);
  +		}
   
  -	    if (n.getBody() != null) {
   		if (n.implementsBodyTag()) {
   		    out.printin("if (");
   		    out.print(tagEvalVar);
  @@ -2141,7 +2134,7 @@
                   out.println("}");
   	    }
   
  -	    restoreScriptingVars(n);
  +	    restoreScriptingVars(n, VariableInfo.AT_BEGIN);
   
   	    n.setEndJavaLine(out.getJavaLine());
   	}
  @@ -2160,17 +2153,11 @@
               
               // Declare AT_BEGIN scripting variables
   	    declareScriptingVars(n, VariableInfo.AT_BEGIN);
  -            
  +	    saveScriptingVars(n, VariableInfo.AT_BEGIN);
  +
   	    out.printil("{");
   	    out.pushIndent();
   
  -	    /*
  -	     * Save current values of scripting variables, so that the 
  -	     * scripting variables may be synchronized without affecting their
  -	     * original values
  -	     */
  -	    saveScriptingVars(n);
  -
   	    out.printin(tagHandlerClass.getName());
   	    out.print(" ");
   	    out.print(tagHandlerVar);
  @@ -2210,7 +2197,7 @@
   	    out.printin(tagHandlerVar);
   	    out.println(".doTag();");
   
  -	    restoreScriptingVars(n);
  +	    restoreScriptingVars(n, VariableInfo.AT_BEGIN);
   	    out.popIndent();
   	    out.printil("}");
               
  @@ -2265,7 +2252,7 @@
   	 * end element. This way, the scripting variables may be synchronized
   	 * by the given tag without affecting their original values.
   	 */
  -	private void saveScriptingVars(Node.CustomTag n) {
  +	private void saveScriptingVars(Node.CustomTag n, int scope) {
   	    if (n.getCustomNestingLevel() == 0) {
   		return;
   	    }
  @@ -2278,7 +2265,7 @@
   
   	    if (varInfos != null) {
   		for (int i=0; i<varInfos.length; i++) {
  -		    if (varInfos[i].getScope() == VariableInfo.AT_END)
  +		    if (varInfos[i].getScope() != scope)
   			continue;
   		    String varName = varInfos[i].getVarName();
   		    String tmpVarName = "_jspx_" + varName + "_"
  @@ -2290,7 +2277,7 @@
   		}
   	    } else {
   		for (int i=0; i<tagVarInfos.length; i++) {
  -		    if (tagVarInfos[i].getScope() == VariableInfo.AT_END)
  +		    if (tagVarInfos[i].getScope() != scope)
   			continue;
   		    String varName = tagVarInfos[i].getNameGiven();
   		    if (varName == null) {
  @@ -2314,7 +2301,7 @@
   	 * restore its scripting variables to their original values that were
   	 * saved in the tag's start element.
   	 */
  -	private void restoreScriptingVars(Node.CustomTag n) {
  +	private void restoreScriptingVars(Node.CustomTag n, int scope) {
   	    if (n.getCustomNestingLevel() == 0) {
   		return;
   	    }
  @@ -2327,7 +2314,7 @@
   
   	    if (varInfos != null) {
   		for (int i=0; i<varInfos.length; i++) {
  -		    if (varInfos[i].getScope() == VariableInfo.AT_END)
  +		    if (varInfos[i].getScope() != scope)
   			continue;
   		    String varName = varInfos[i].getVarName();
   		    String tmpVarName = "_jspx_" + varName + "_"
  @@ -2339,7 +2326,7 @@
   		}
   	    } else {
   		for (int i=0; i<tagVarInfos.length; i++) {
  -		    if (tagVarInfos[i].getScope() == VariableInfo.AT_END)
  +		    if (tagVarInfos[i].getScope() != scope)
   			continue;
   		    String varName = tagVarInfos[i].getNameGiven();
   		    if (varName == null) {
  
  
  
  1.4       +24 -40    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ScriptingVariabler.java
  
  Index: ScriptingVariabler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ScriptingVariabler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScriptingVariabler.java	19 Aug 2002 20:29:12 -0000	1.3
  +++ ScriptingVariabler.java	9 Sep 2002 23:24:14 -0000	1.4
  @@ -124,11 +124,17 @@
   	    Vector vec = new Vector();
   
   	    Integer ownRange = null;
  -	    Node.CustomTag parent = n.getCustomTagParent();
  -	    if (parent == null)
  -		ownRange = MAX_SCOPE;
  -	    else
  -		ownRange = parent.getNumCount();
  +	    if (scope == VariableInfo.AT_BEGIN
  +		    || scope == VariableInfo.AT_END) {
  +		Node.CustomTag parent = n.getCustomTagParent();
  +		if (parent == null)
  +		    ownRange = MAX_SCOPE;
  +		else
  +		    ownRange = parent.getNumCount();
  +	    } else {
  +		// NESTED
  +		ownRange = n.getNumCount();
  +	    }
   
   	    if (varInfos != null) {
   		for (int i=0; i<varInfos.length; i++) {
  @@ -138,22 +144,11 @@
   		    }
   		    String varName = varInfos[i].getVarName();
   		    
  -		    if (scope == VariableInfo.AT_BEGIN 
  -			    || scope == VariableInfo.AT_END
  -			    || (scope == VariableInfo.NESTED
  -				&& !n.implementsBodyTag())) {
  -			Integer currentRange =
  -			    (Integer) scriptVars.get(varName);
  -			if (currentRange == null
  -			        || ownRange.compareTo(currentRange) > 0) {
  -			    scriptVars.put(varName, ownRange);
  -			    vec.add(varInfos[i]);
  -			}
  -		    } else {
  -			// scope equals NESTED AND node implements BodyTag
  -			if (n.getCustomNestingLevel() == 0) {
  -			    vec.add(varInfos[i]);
  -			}
  +		    Integer currentRange = (Integer) scriptVars.get(varName);
  +		    if (currentRange == null
  +			    || ownRange.compareTo(currentRange) > 0) {
  +			scriptVars.put(varName, ownRange);
  +			vec.add(varInfos[i]);
   		    }
   		}
   	    } else {
  @@ -169,22 +164,11 @@
   		                        tagVarInfos[i].getNameFromAttribute());
   		    }
   
  -		    if (scope == VariableInfo.AT_BEGIN 
  -			    || scope == VariableInfo.AT_END
  -			    || (scope == VariableInfo.NESTED
  -				&& !n.implementsBodyTag())) {
  -			Integer currentRange =
  -			    (Integer) scriptVars.get(varName);
  -			if (currentRange == null
  -			        || ownRange.compareTo(currentRange) > 0) {
  -			    scriptVars.put(varName, ownRange);
  -			    vec.add(tagVarInfos[i]);
  -			}
  -		    } else {
  -			// scope equals NESTED AND node implements BodyTag
  -			if (n.getCustomNestingLevel() == 0) {
  -			    vec.add(tagVarInfos[i]);
  -			}
  +		    Integer currentRange = (Integer) scriptVars.get(varName);
  +		    if (currentRange == null
  +			    || ownRange.compareTo(currentRange) > 0) {
  +			scriptVars.put(varName, ownRange);
  +			vec.add(tagVarInfos[i]);
   		    }
   		}
   	    }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message