changeset 25:665309ccd5e6

Merge.
author Mikhail Kryshen <mikhail@kryshen.net>
date Mon, 11 May 2009 20:19:02 +0400
parents d3a8871e6e73 55fe63bb7858
children 2b5306159761
files doc/manual/manual.tema
diffstat 7 files changed, 30 insertions(+), 23 deletions(-) [+]
line diff
     1.1 --- a/doc/manual/manual.tema	Mon May 11 20:18:35 2009 +0400
     1.2 +++ b/doc/manual/manual.tema	Mon May 11 20:19:02 2009 +0400
     1.3 @@ -58,8 +58,8 @@
     1.4  <%par:Every function returns integer value. The general convention is to 
     1.5  return non-zero for successful operation. The value of the macro substitution 
     1.6  is the return value of the first function in the function list. The value of
     1.7 -any Tema text is the sum value of all macro in the text, except the value of
     1.8 -the text without any macro equals -1.%>
     1.9 +any Tema text is the sum of the absolute values of all macro in the text,
    1.10 +except the value of the text without any macro equals -1.%>
    1.11  
    1.12  <%par:Internally, Tema function could be represented by any Java object.
    1.13  Instances of kryshen.tema.Function and kryshen.tema.Context are handled
     2.1 --- a/src/kryshen/tema/FunctionDataParser.java	Mon May 11 20:18:35 2009 +0400
     2.2 +++ b/src/kryshen/tema/FunctionDataParser.java	Mon May 11 20:19:02 2009 +0400
     2.3 @@ -205,7 +205,11 @@
     2.4          
     2.5          if (file.isAbsolute())
     2.6              return file;
     2.7 -        
     2.8 -        return new File(tp.getContext().getBaseDirectory(), path);
     2.9 +
    2.10 +        File base = tp.getContext().getBaseDirectory();
    2.11 +
    2.12 +        return base.getPath().isEmpty()
    2.13 +                ? new File(path)
    2.14 +                : new File(base, path);
    2.15      }
    2.16  }
     3.1 --- a/src/kryshen/tema/GlobalContext.java	Mon May 11 20:18:35 2009 +0400
     3.2 +++ b/src/kryshen/tema/GlobalContext.java	Mon May 11 20:19:02 2009 +0400
     3.3 @@ -37,7 +37,7 @@
     3.4  class GlobalContext extends Context {    
     3.5      
     3.6      GlobalContext() {
     3.7 -        super(new File(System.getProperty("user.dir")));
     3.8 +        super(new File(""));
     3.9          
    3.10          // Register all standard functions.
    3.11          // TODO: arithmetics
     4.1 --- a/src/kryshen/tema/Tema.java	Mon May 11 20:18:35 2009 +0400
     4.2 +++ b/src/kryshen/tema/Tema.java	Mon May 11 20:19:02 2009 +0400
     4.3 @@ -74,11 +74,7 @@
     4.4      throws IOException, SQLException,
     4.5              ClassNotFoundException, InstantiationException,
     4.6              IllegalAccessException, InvocationTargetException {
     4.7 -        
     4.8 -        boolean demo = false;
     4.9 -        boolean version = false;
    4.10 -        boolean help = false;
    4.11 -        
    4.12 +              
    4.13          Options options = new Options();
    4.14          
    4.15          options.addOption(null, "demo", false, "demo mode");
     5.1 --- a/src/kryshen/tema/TemplateParser.java	Mon May 11 20:18:35 2009 +0400
     5.2 +++ b/src/kryshen/tema/TemplateParser.java	Mon May 11 20:19:02 2009 +0400
     5.3 @@ -184,9 +184,9 @@
     5.4                      
     5.5                      int tb = termBracket;
     5.6                      termBracket = openBracket;
     5.7 -                    int returnCode = Math.abs(parseFunction(in, out, format));
     5.8 +                    int returnCode = parseFunction(in, out, format);
     5.9                      lastReturnCode = returnCode;
    5.10 -                    result.retCode += returnCode;
    5.11 +                    result.retCode += Math.abs(returnCode);
    5.12                      result.empty = false;
    5.13                      termBracket = tb;
    5.14                      
    5.15 @@ -419,24 +419,28 @@
    5.16      }
    5.17      
    5.18      public int invoke(String name, FunctionDataParser fdp, Writer out)
    5.19 -    throws IOException, TemplateException {
    5.20 +            throws IOException, TemplateException {
    5.21 +
    5.22          Object value = context.get(name);
    5.23 -        
    5.24 +
    5.25          if (value instanceof Function) {
    5.26              return ((Function) value).invoke(fdp, out);
    5.27          }
    5.28 -        
    5.29 +
    5.30          if (value instanceof Context) {
    5.31              String code = fdp.getData();
    5.32 -            
    5.33 -            if (fdp.getLastReturnCode() == 0)
    5.34 +
    5.35 +            if (fdp.getLastReturnCode() == 0) {
    5.36                  return 0;
    5.37 -            
    5.38 +            }
    5.39 +
    5.40              TemplateParser parser = new TemplateParser((Context) value);
    5.41              return parser.parse(
    5.42 -                    new TemplateReader(new StringReader(code)), out);
    5.43 +                    new TemplateReader(new StringReader(code),
    5.44 +                    fdp.getTemplateReader()),
    5.45 +                    out);
    5.46          }
    5.47 -        
    5.48 +
    5.49          return parseValue(value, out);
    5.50      }
    5.51  
     6.1 --- a/src/kryshen/tema/functions/Control.java	Mon May 11 20:18:35 2009 +0400
     6.2 +++ b/src/kryshen/tema/functions/Control.java	Mon May 11 20:19:02 2009 +0400
     6.3 @@ -179,7 +179,10 @@
     6.4              while (true) {
     6.5                  StringWriter sw = new StringWriter();
     6.6                  
     6.7 -                e = parser.parse(new TemplateReader(dataReader), sw);
     6.8 +                e = parser.parse(
     6.9 +                        new TemplateReader(dataReader,
    6.10 +                        fdp.getTemplateReader()),
    6.11 +                        sw);
    6.12                  
    6.13                  if (e == 0)
    6.14                      break;
     7.1 --- a/src/kryshen/tema/functions/IO.java	Mon May 11 20:18:35 2009 +0400
     7.2 +++ b/src/kryshen/tema/functions/IO.java	Mon May 11 20:19:02 2009 +0400
     7.3 @@ -103,14 +103,14 @@
     7.4          throws IOException, TemplateException {
     7.5              
     7.6              String filename = fdp.getData();
     7.7 -            String file;
     7.8              
     7.9              try {
    7.10                  readFile(fdp.createFile(filename), out);
    7.11              } catch (IOException e) {
    7.12                  fdp.warning(e.getMessage());
    7.13                  //System.err.println(e);
    7.14 -                //throw new TemplateException(e.getMessage(), e, in);
    7.15 +                //throw new TemplateException(e.getMessage(), e,
    7.16 +                //        fdp.getTemplateReader());
    7.17                  return 0;
    7.18              }
    7.19