cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler CommandLineCompiler.java

2002-06-02 Thread remm

remm2002/06/02 14:40:22

  Modified:jasper2/src/share/org/apache/jasper CommandLineContext.java
JspC.java
  Removed: jasper2/src/share/org/apache/jasper/compiler
CommandLineCompiler.java
  Log:
  - Last part of the compiler refactoring.
  - Make JspC work with the Ant compiler.
  - Remove the CommandLineCompiler class (partially refactored into the
CommandLineContext class).
  - Only tested with the JspC -webapp option. I don't really know what all the other
options are supposed to do. Please test it.
  
  Revision  ChangesPath
  1.3   +239 -49   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java
  
  Index: CommandLineContext.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CommandLineContext.java   24 Apr 2002 02:21:04 -  1.2
  +++ CommandLineContext.java   2 Jun 2002 21:40:22 -   1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
 1.2 2002/04/24 02:21:04 kinman Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/24 02:21:04 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/CommandLineContext.java,v
 1.3 2002/06/02 21:40:22 remm Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/06/02 21:40:22 $
*
* 
* 
  @@ -66,10 +66,10 @@
   package org.apache.jasper;
   
   import java.io.*;
  +import java.util.StringTokenizer;
   
   import org.apache.jasper.compiler.JspReader;
   import org.apache.jasper.compiler.ServletWriter;
  -import org.apache.jasper.compiler.CommandLineCompiler;
   import org.apache.jasper.compiler.Compiler;
   
   import java.net.URL;
  @@ -83,9 +83,14 @@
*
* @author Danno Ferrin
* @author Pierre Delisle
  + * @author Remy Maucherat
*/
   public class CommandLineContext implements JspCompilationContext {
   
  +
  +// - Instance Variables
  +
  +
   String classPath;
   JspReader reader;
   ServletWriter writer;
  @@ -93,23 +98,24 @@
   boolean errPage;
   String jspFile;
   String servletClassName;
  -String servletPackageName;
  +String servletPackageName = Constants.JSP_PACKAGE_NAME;;
   String servletJavaFileName;
   String contentType;
   Options options;
  +private String classFileName;
  +private String jspPath;
  +private String outputDir;
   
   String uriBase;
   File uriRoot;
   
   boolean outputInDirs;
   
  -public CommandLineContext(String newClassPath,
  -  String newJspFile, String newUriBase,
  +public CommandLineContext(String newJspFile, String newUriBase,
 String newUriRoot, boolean newErrPage,
 Options newOptions)
  -throws JasperException
  -{
  -classPath = newClassPath;
  +throws JasperException {
  +
   uriBase = newUriBase;
   String tUriRoot = newUriRoot;
   jspFile = newJspFile;
  @@ -138,8 +144,33 @@
   Constants.getString(jsp.error.jspc.uriroot_not_dir));
   }
   }
  +
   }
   
  +
  +/**
  + * Resolve relative path, and create output directories.
  + */
  +public void setupContext() {
  +
  +outputDir = options.getScratchDir().toString();
  +
  +if (isOutputInDirs()) {
  +int indexOfSlash = getJspFile().lastIndexOf('/');
  +String pathName = ;
  +if (indexOfSlash != -1) {
  +pathName = getJspFile().substring(0, indexOfSlash);
  +}
  +String tmpDir = outputDir + File.separatorChar + pathName;
  +File f = new File(tmpDir);
  +if (!f.exists()) {
  +f.mkdirs();
  +}
  +}
  +
  +}
  +
  +
   /**
* The classpath that is passed off to the Java compiler. 
*/
  @@ -148,6 +179,13 @@
   }
   
   /**
  + * The classpath that is passed off to the Java compiler. 
  + */
  +public void setClassPath(String classPath) {
  +this.classPath = classPath;
  +}
  +
  +/**
* Get the input reader for the JSP text. 
*/
   public JspReader getReader() {
  @@ -179,25 +217,13 @@
   
   /**
* The scratch directory to generate code into.
  - *
  - * FIXME: In some places this is called scratchDir and in some
  - * other places it is called outputDir.
*/
   public String getOutputDir() {
  -return options.getScratchDir().toString();
  +   

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler CommandLineCompiler.java JspReader.java Parser.java

2002-04-03 Thread kinman

kinman  02/04/03 18:34:01

  Modified:jasper2/src/share/org/apache/jasper/compiler
CommandLineCompiler.java JspReader.java Parser.java
  Log:
  - Handle quoted string %\ in scripting elements.
  
  Revision  ChangesPath
  1.2   +4 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java
  
  Index: CommandLineCompiler.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandLineCompiler.java  28 Mar 2002 18:46:15 -  1.1
  +++ CommandLineCompiler.java  4 Apr 2002 02:34:01 -   1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
 1.1 2002/03/28 18:46:15 kinman Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/28 18:46:15 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
 1.2 2002/04/04 02:34:01 kinman Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/04 02:34:01 $
*
* The Apache Software License, Version 1.1
*
  @@ -189,7 +189,7 @@
return modifiedClassName.toString();
   }
   
  -private static final String mangleChar(char ch) {
  +public static final String mangleChar(char ch) {

   if(ch == File.separatorChar) {
ch = '/';
  
  
  
  1.2   +37 -0 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JspReader.java28 Mar 2002 18:46:16 -  1.1
  +++ JspReader.java4 Apr 2002 02:34:01 -   1.2
  @@ -280,6 +280,43 @@
return caw.toCharArray();
   }
   
  +/**
  + * Get the text for a scripting element from the stream.  It handles
  + * the escape string %\.
  + *
  + * @param start The starting postion to read
  + * @param stop The ending (exclusive) postion to read
  + * @return The resultant text
  + */
  +char[] getScriptingText(Mark start, Mark stop) throws JasperException {
  + Mark oldstart = mark();
  + reset(start);
  + CharArrayWriter caw = new CharArrayWriter();
  + while (!stop.equals(mark())) {
  + int c = nextChar();
  + caw.write(c);
  + if (c == '%') {
  + if (stop.equals(mark()))
  + break;
  + int c2 = nextChar();
  + if (stop.equals(mark())) {
  + caw.write(c2);
  + break;
  + }
  + int c3 = nextChar();
  + if (c2 == '\\'  c3 == '') {
  + caw.write('');
  + } else {
  + caw.write(c2);
  + caw.write(c3);
  + }
  + }
  + }
  + caw.close();
  + reset(oldstart);
  + return caw.toCharArray();
  +}
  +
   public int peekChar() {
return current.stream[current.cursor];
   }
  
  
  
  1.2   +6 -6  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Parser.java   28 Mar 2002 18:46:16 -  1.1
  +++ Parser.java   4 Apr 2002 02:34:01 -   1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
 1.1 2002/03/28 18:46:16 kinman Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/28 18:46:16 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
 1.2 2002/04/04 02:34:01 kinman Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/04 02:34:01 $
*
* 
* 
  @@ -246,7 +246,7 @@
err.jspError(start, jsp.error.unterminated, %!);
}
   
  - new Node.Declaration(reader.getText(start, stop), start, parent);
  + new Node.Declaration(reader.getScriptingText(start, stop), start, parent);
   }
   
   /*
  @@ -259,7 +259,7 @@
err.jspError(start, jsp.error.unterminated, %=);
}
   
  - new Node.Expression(reader.getText(start, stop), start, parent);
  + new Node.Expression(reader.getScriptingText(start, stop), start, parent);
   }