Mercurial > hg > tema
changeset 25:665309ccd5e6
Merge.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Mon, 11 May 2009 20:19:02 +0400 |
parents | d3a8871e6e73 (current diff) 55fe63bb7858 (diff) |
children | 2b5306159761 |
files | doc/manual/manual.tema |
diffstat | 7 files changed, 30 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/manual/manual.tema Mon May 11 20:18:35 2009 +0400 +++ b/doc/manual/manual.tema Mon May 11 20:19:02 2009 +0400 @@ -58,8 +58,8 @@ <%par:Every function returns integer value. The general convention is to return non-zero for successful operation. The value of the macro substitution is the return value of the first function in the function list. The value of -any Tema text is the sum value of all macro in the text, except the value of -the text without any macro equals -1.%> +any Tema text is the sum of the absolute values of all macro in the text, +except the value of the text without any macro equals -1.%> <%par:Internally, Tema function could be represented by any Java object. Instances of kryshen.tema.Function and kryshen.tema.Context are handled
--- a/src/kryshen/tema/FunctionDataParser.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/FunctionDataParser.java Mon May 11 20:19:02 2009 +0400 @@ -205,7 +205,11 @@ if (file.isAbsolute()) return file; - - return new File(tp.getContext().getBaseDirectory(), path); + + File base = tp.getContext().getBaseDirectory(); + + return base.getPath().isEmpty() + ? new File(path) + : new File(base, path); } }
--- a/src/kryshen/tema/GlobalContext.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/GlobalContext.java Mon May 11 20:19:02 2009 +0400 @@ -37,7 +37,7 @@ class GlobalContext extends Context { GlobalContext() { - super(new File(System.getProperty("user.dir"))); + super(new File("")); // Register all standard functions. // TODO: arithmetics
--- a/src/kryshen/tema/Tema.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/Tema.java Mon May 11 20:19:02 2009 +0400 @@ -74,11 +74,7 @@ throws IOException, SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException { - - boolean demo = false; - boolean version = false; - boolean help = false; - + Options options = new Options(); options.addOption(null, "demo", false, "demo mode");
--- a/src/kryshen/tema/TemplateParser.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/TemplateParser.java Mon May 11 20:19:02 2009 +0400 @@ -184,9 +184,9 @@ int tb = termBracket; termBracket = openBracket; - int returnCode = Math.abs(parseFunction(in, out, format)); + int returnCode = parseFunction(in, out, format); lastReturnCode = returnCode; - result.retCode += returnCode; + result.retCode += Math.abs(returnCode); result.empty = false; termBracket = tb; @@ -419,24 +419,28 @@ } public int invoke(String name, FunctionDataParser fdp, Writer out) - throws IOException, TemplateException { + throws IOException, TemplateException { + Object value = context.get(name); - + if (value instanceof Function) { return ((Function) value).invoke(fdp, out); } - + if (value instanceof Context) { String code = fdp.getData(); - - if (fdp.getLastReturnCode() == 0) + + if (fdp.getLastReturnCode() == 0) { return 0; - + } + TemplateParser parser = new TemplateParser((Context) value); return parser.parse( - new TemplateReader(new StringReader(code)), out); + new TemplateReader(new StringReader(code), + fdp.getTemplateReader()), + out); } - + return parseValue(value, out); }
--- a/src/kryshen/tema/functions/Control.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/functions/Control.java Mon May 11 20:19:02 2009 +0400 @@ -179,7 +179,10 @@ while (true) { StringWriter sw = new StringWriter(); - e = parser.parse(new TemplateReader(dataReader), sw); + e = parser.parse( + new TemplateReader(dataReader, + fdp.getTemplateReader()), + sw); if (e == 0) break;
--- a/src/kryshen/tema/functions/IO.java Mon May 11 20:18:35 2009 +0400 +++ b/src/kryshen/tema/functions/IO.java Mon May 11 20:19:02 2009 +0400 @@ -103,14 +103,14 @@ throws IOException, TemplateException { String filename = fdp.getData(); - String file; try { readFile(fdp.createFile(filename), out); } catch (IOException e) { fdp.warning(e.getMessage()); //System.err.println(e); - //throw new TemplateException(e.getMessage(), e, in); + //throw new TemplateException(e.getMessage(), e, + // fdp.getTemplateReader()); return 0; }