Browse Source

add MacroStringTools.toDotPath

Simon Krajewski 12 years ago
parent
commit
e051725ff0
1 changed files with 15 additions and 0 deletions
  1. 15 0
      std/haxe/macro/MacroStringTools.hx

+ 15 - 0
std/haxe/macro/MacroStringTools.hx

@@ -67,5 +67,20 @@ class MacroStringTools {
 		return Lambda.fold(sl, function(s, e) return e == null ? (macro $i{s}) : (macro $e.$s), null);
 		return Lambda.fold(sl, function(s, e) return e == null ? (macro $i{s}) : (macro $e.$s), null);
 	}
 	}
 	
 	
+	/**
+		Converts a path given by package `pack` and name `name` to a `String`
+		separated by dots.
+		
+		If `pack` has no elements, the result is `name`.
+		
+		If `pack` is null, the result is unspecified.
+		
+		Otherwise the elements of `pack` are joined with a separating dot, with
+		an appended dot separating the result from `name`.
+	**/
+	static public function toDotPath(pack:Array<String>, name:String):String {
+		return if (pack.length == 0) name else pack.join(".") + "." +name;
+	}
+	
 	#end
 	#end
 }
 }