remm        2002/06/10 13:12:27

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
               jasper2/src/share/org/apache/jasper/runtime
                        BodyContentImpl.java PageContextImpl.java
  Log:
  - Code cleanup, based on ideas by Kin-Man. It still has a few issues with JSTL.
  
  Revision  Changes    Path
  1.22      +29 -13    
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Generator.java    10 Jun 2002 17:02:37 -0000      1.21
  +++ Generator.java    10 Jun 2002 20:12:26 -0000      1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
 1.21 2002/06/10 17:02:37 kinman Exp $
  - * $Revision: 1.21 $
  - * $Date: 2002/06/10 17:02:37 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
 1.22 2002/06/10 20:12:26 remm Exp $
  + * $Revision: 1.22 $
  + * $Date: 2002/06/10 20:12:26 $
    *
    * ====================================================================
    * 
  @@ -402,7 +402,7 @@
            out.printil("session = pageContext.getSession();");
        out.printil("out = pageContext.getOut();");
           if (maxTagNesting > 0) {
  -            out.printil("_jspxState.outs[0] = out;");
  +            out.printil("_jspxState.out = out;");
           }
        out.println();
       }
  @@ -434,13 +434,15 @@
        out.println();
        out.printil("public int tagDepth;");
        out.println();
  -     out.printil("public JspWriter[] outs;");
  +     out.printil("public javax.servlet.jsp.tagext.BodyContent[] outs;");
  +     out.println();
  +     out.printil("public JspWriter out;");
        out.println();
        out.printil("public JspxState() {");
        out.pushIndent();
        out.printil("tagCount = 0;");
  -     out.printil("tagDepth = 0;");
  -     out.printil("outs = new JspWriter[" + (maxTagNesting + 1) + "];");
  +     out.printil("tagDepth = -1;");
  +     out.printil("outs = new org.apache.jasper.runtime.BodyContentImpl[" + 
(maxTagNesting) + "];");
        out.popIndent();
        out.printil("}");
        out.popIndent();
  @@ -1048,7 +1050,16 @@
                out.pushIndent();
   
                // Initilaize local variables used in this method.
  -             out.printil("JspWriter out = _jspxState.outs[_jspxState.tagDepth];");
  +             out.printil("JspWriter out = null;");
  +                out.printil("if (_jspxState.tagDepth < 0) {");
  +             out.pushIndent();
  +                out.printil("out = _jspxState.out;");
  +             out.popIndent();
  +                out.printil("} else {");
  +             out.pushIndent();
  +                out.printil("out = _jspxState.outs[_jspxState.tagDepth];");
  +             out.popIndent();
  +                out.printil("}");
                if (n.isHasUsebean()) {
                    out.println("HttpSession session = pageContext.getSession();");
                    out.println("ServletContext application = 
pageContext.getServletContext();");
  @@ -1256,12 +1267,17 @@
                    }
                       out.printil("_jspxState.tagDepth++;");
   
  -                    out.printil("out = 
pageContext.allocateBody(_jspxState.outs[_jspxState.tagDepth], out);");
  -                    out.printil("_jspxState.outs[_jspxState.tagDepth] = out;");
  +                    out.printil("if (_jspxState.outs[_jspxState.tagDepth] == null) 
{");
  +                 out.pushIndent();
  +                    out.printil("_jspxState.outs[_jspxState.tagDepth] = new 
org.apache.jasper.runtime.BodyContentImpl(out);");
  +                 out.popIndent();
  +                 out.printil("}");
  +
  +                    out.printil("out = _jspxState.outs[_jspxState.tagDepth];");
                    out.printil("pageContext.setOut(out);");
   
                    out.printin(tagHandlerVar);
  -                 
out.println(".setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);");
  +                 
out.println(".setBodyContent(_jspxState.outs[_jspxState.tagDepth]);");
                    out.printin(tagHandlerVar);
                    out.println(".doInitBody();");
                    
  @@ -1320,8 +1336,8 @@
                       if (!implementsTryCatchFinally) {
                           out.printil("_jspxState.tagCount--;");
                    }
  +                    out.printil("out = 
_jspxState.outs[_jspxState.tagDepth].getEnclosingWriter();");
                       out.printil("_jspxState.tagDepth--;");
  -                 out.printil("out = _jspxState.outs[_jspxState.tagDepth];");
                       out.printil("pageContext.setOut(out);");
                    out.popIndent();
                }
  @@ -1578,7 +1594,7 @@
   
        // Cleanup the tags on the stack
           if (maxTagNesting > 0) {
  -            out.printil("out = _jspxState.outs[0];");
  +            out.printil("out = _jspxState.out;");
               out.printil("pageContext.setOut(out);");
           }
   
  
  
  
  1.4       +0 -10     
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java
  
  Index: BodyContentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BodyContentImpl.java      10 Jun 2002 01:29:45 -0000      1.3
  +++ BodyContentImpl.java      10 Jun 2002 20:12:27 -0000      1.4
  @@ -83,21 +83,11 @@
       private int nextChar;
       static String lineSeparator = System.getProperty("line.separator");
       private boolean closed = false;
  -    protected JspWriter writer = null;
   
       public BodyContentImpl (JspWriter writer) {
           super(writer);
  -        this.writer = writer;
        cb = new char[bufferSize];
        nextChar = 0;
  -    }
  -
  -    public JspWriter getEnclosingWriter() {
  -        return writer;
  -    }
  -
  -    public void setEnclosingWriter(JspWriter writer) {
  -        this.writer = writer;
       }
   
       private void ensureOpen() throws IOException {
  
  
  
  1.8       +3 -15     
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java
  
  Index: PageContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PageContextImpl.java      10 Jun 2002 01:32:57 -0000      1.7
  +++ PageContextImpl.java      10 Jun 2002 20:12:27 -0000      1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
 1.7 2002/06/10 01:32:57 remm Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/06/10 01:32:57 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
 1.8 2002/06/10 20:12:27 remm Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/06/10 20:12:27 $
    *
    * ====================================================================
    *
  @@ -426,18 +426,6 @@
                   request.setAttribute(Constants.INC_SERVLET_PATH, includeUri);
            request.setAttribute(Constants.FORWARD_SEEN, "true");
           }
  -    }
  -
  -    public BodyContent allocateBody(JspWriter bodyContent, 
  -                                    JspWriter previous) {
  -
  -        if (bodyContent == null) {
  -            return new BodyContentImpl(previous);
  -        } else {
  -            ((BodyContentImpl) bodyContent).setEnclosingWriter(previous);
  -            return (BodyContent) bodyContent;
  -        }
  -
       }
   
       public void setOut(JspWriter newOut) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to