2
0
Laurent Bedubourg 19 жил өмнө
parent
commit
bc33a26ba4

+ 2 - 2
std/mtwin/templo/Loader.hx

@@ -29,7 +29,7 @@ import neko.Sys;
 import neko.File;
 import neko.FileSystem;
 
-class File {
+class Loader {
 
 	public static var BASE_DIR = "";
 	public static var TMP_DIR = "/tmp/";
@@ -69,7 +69,7 @@ class File {
 		else
 			result = Sys.command("temploc -m "+BASE_DIR+MACROS+" -o "+TMP_DIR+" -r "+BASE_DIR+" "+path+" 2> "+TMP_DIR+"temploc.out");
 		if( result != 0 )
-			throw "temploc compilation or "+path+" failed : "+neko.File.getContent(File.TMP_DIR+"temploc.out");
+			throw "temploc compilation or "+path+" failed : "+neko.File.getContent(Loader.TMP_DIR+"temploc.out");
 	}
 
 	static function loadTemplate( nPath:String ) : Dynamic -> String {

+ 5 - 5
std/mtwin/templo/Main.hx

@@ -45,7 +45,7 @@ class Main {
 					if (value.charAt(value.length-1) == "/"){
 						value = value.substr(0, value.length-1);
 					}
-					File.BASE_DIR = value;
+					Loader.BASE_DIR = value;
 					++i;
 
 				case "-o":
@@ -53,7 +53,7 @@ class Main {
 					if (value.charAt(value.length-1) != "/"){
 						value = value + "/";
 					}
-					File.TMP_DIR = value;
+					Loader.TMP_DIR = value;
 					++i;
 
 				case "-m":
@@ -73,7 +73,7 @@ class Main {
 			neko.Lib.print("temploc - v"+VERSION+"\n");
 			neko.Lib.print(USAGE);
 		}
-		else if (File.BASE_DIR == null){
+		else if (Loader.BASE_DIR == null){
 			var sampleFile = Lambda.array(files.iterator())[0];
 			var pslah = sampleFile.lastIndexOf("/",sampleFile.length);
 			var aslah = sampleFile.lastIndexOf("/",sampleFile.length);
@@ -82,7 +82,7 @@ class Main {
 				neko.Lib.print("missing template BASE_DIR\n");
 				throw USAGE;
 			}
-			File.BASE_DIR = sampleFile.substr(0,pos);
+			Loader.BASE_DIR = sampleFile.substr(0,pos);
 		}
 	}
 
@@ -93,7 +93,7 @@ class Main {
 	static function main(){
 		parseArgs();
 		for (file in files){
-			file = StringTools.replace(file, File.BASE_DIR+"/", "");
+			file = StringTools.replace(file, Loader.BASE_DIR+"/", "");
 			neko.Lib.print("* "+file+"...");
 			mtwin.templo.Template.fromFile(file);
 			neko.Lib.print(" done\n");

+ 2 - 2
std/mtwin/templo/Preprocessor.hx

@@ -48,8 +48,8 @@ class Preprocessor {
 	public static var macroFileStamp : Float;
 
 	public static function process( str:String ) : String {
-		if (macroFileStamp == null && File.MACROS != null)
-			registerMacroFile(File.BASE_DIR+File.MACROS);
+		if (macroFileStamp == null && Loader.MACROS != null)
+			registerMacroFile(Loader.BASE_DIR+Loader.MACROS);
 
 		var res = expandMacros(str);
 		res = escapeCdata1(res);

+ 11 - 11
std/mtwin/templo/Template.hx

@@ -30,7 +30,7 @@ class Template {
 	public var execute : Dynamic -> String;
 
 	public function new( file:String ){
-		execute = if (File.OPTIMIZED) loadTemplate(nekoBin(file)) else fromFile(file);
+		execute = if (Loader.OPTIMIZED) loadTemplate(nekoBin(file)) else fromFile(file);
 	}
 
 	static function nekoId( path:String ) : String {
@@ -45,28 +45,28 @@ class Template {
 	}
 
 	static function nekoBin( path:String ) : String {
-		return File.TMP_DIR + nekoId(path) + ".n";
+		return Loader.TMP_DIR + nekoId(path) + ".n";
 	}
 
 	static function nekoSrc( path:String ) : String {
-		return File.TMP_DIR + nekoId(path) + ".neko";
+		return Loader.TMP_DIR + nekoId(path) + ".neko";
 	}
 
 	public static function fromFile( path:String ) : Dynamic -> String {
-		if (File.OPTIMIZED)
+		if (Loader.OPTIMIZED)
 			return loadTemplate(nekoBin(path));
-		if (File.MACROS != null && mtwin.templo.Preprocessor.macroFileStamp == null)
-			mtwin.templo.Preprocessor.registerMacroFile(File.BASE_DIR+File.MACROS);
+		if (Loader.MACROS != null && mtwin.templo.Preprocessor.macroFileStamp == null)
+			mtwin.templo.Preprocessor.registerMacroFile(Loader.BASE_DIR+Loader.MACROS);
 		var binPath = nekoBin(path);
 		if (neko.FileSystem.exists(binPath)){
 			var macroStamp  = mtwin.templo.Preprocessor.macroFileStamp;
-			var sourceStamp = neko.FileSystem.stat(File.BASE_DIR+"/"+path).mtime.getTime();
+			var sourceStamp = neko.FileSystem.stat(Loader.BASE_DIR+"/"+path).mtime.getTime();
 			var stamp       = neko.FileSystem.stat(binPath).mtime.getTime();
 			if ((stamp >= sourceStamp) && (macroStamp == null || macroStamp < stamp)){
 				return loadTemplate(binPath);
 			}
 		}
-		var content = neko.File.getContent(File.BASE_DIR+"/"+path);
+		var content = neko.File.getContent(Loader.BASE_DIR+"/"+path);
 		return fromString(content, nekoId(path));
 	}
 
@@ -94,10 +94,10 @@ class Template {
 		f.write(s);
 		f.close();
 
-		var r = neko.Sys.command("nekoc -o "+File.TMP_DIR+" "+path+" 2> "+File.TMP_DIR+"/nekoc.out");
+		var r = neko.Sys.command("nekoc -o "+Loader.TMP_DIR+" "+path+" 2> "+Loader.TMP_DIR+"/nekoc.out");
 		if (r != 0){
-			if (neko.FileSystem.exists(File.TMP_DIR+"/nekoc.out")){
-				throw "nekoc compilation of "+path+" failed ("+r+") : "+neko.File.getContent(File.TMP_DIR+"/nekoc.out");
+			if (neko.FileSystem.exists(Loader.TMP_DIR+"/nekoc.out")){
+				throw "nekoc compilation of "+path+" failed ("+r+") : "+neko.File.getContent(Loader.TMP_DIR+"/nekoc.out");
 			}
 			else {
 				throw "nekoc compilation of "+path+" failed ("+r+") -- no nekoc.out available";