ソースを参照

move Tools content to StringImpl

Simon Krajewski 11 年 前
コミット
9474beb48a
2 ファイル変更27 行追加44 行削除
  1. 0 36
      std/python/Tools.hx
  2. 27 8
      std/python/internal/StringImpl.hx

+ 0 - 36
std/python/Tools.hx

@@ -1,36 +0,0 @@
-
-package python;
-
-class Tools {
-
-	
-
-	public static function substring( s:String, startIndex : Int, ?endIndex : Int ) : String {
-		if (startIndex < 0) startIndex = 0;
-		if (endIndex == null) {
-			return untyped __python__("s[startIndex:]");		
-		} else {
-			if (endIndex < 0) endIndex = 0;
-			if (endIndex < startIndex) {
-				
-				return untyped __python__("s[endIndex:startIndex]");
-			} else {
-				
-				return untyped __python__("s[startIndex:endIndex]");
-			}
-			
-		}
-	}	
-
-	public static function substr( s:String, startIndex : Int, ?len : Int ) : String {
-		if (len == null) {
-			return untyped __python__("s[startIndex:]");
-		} else {
-			if (len == 0) return "";
-			return untyped __python__("s[startIndex:startIndex+len]");
-		}
-		
-	}
-
-
-}

+ 27 - 8
std/python/internal/StringImpl.hx

@@ -46,9 +46,7 @@ class StringImpl {
 		else
 			return Macros.callField(s, "find", str, startIndex);
 	}
-	public static function substr (s:String, pos:Int, ?len:Int) {
-		return python.Tools.substr(s, pos, len);
-	}
+
 	public static function toString (s:String) {
 		return s;
 	}
@@ -57,11 +55,6 @@ class StringImpl {
 		return python.lib.Builtin.len(s);
 	}
 
-	public static function substring (s:String, startIndex:Int, ?endIndex:Int) {
-		return python.Tools.substring(s, startIndex, endIndex);
-
-	}
-
 	public static inline function fromCharCode( code : Int ) : String {
 		#if doc_gen
 		return "";
@@ -71,4 +64,30 @@ class StringImpl {
 		#end
 	}
 
+	public static function substring( s:String, startIndex : Int, ?endIndex : Int ) : String {
+		if (startIndex < 0) startIndex = 0;
+		if (endIndex == null) {
+			return untyped __python__("s[startIndex:]");
+		} else {
+			if (endIndex < 0) endIndex = 0;
+			if (endIndex < startIndex) {
+
+				return untyped __python__("s[endIndex:startIndex]");
+			} else {
+
+				return untyped __python__("s[startIndex:endIndex]");
+			}
+
+		}
+	}
+
+	public static function substr( s:String, startIndex : Int, ?len : Int ) : String {
+		if (len == null) {
+			return untyped __python__("s[startIndex:]");
+		} else {
+			if (len == 0) return "";
+			return untyped __python__("s[startIndex:startIndex+len]");
+		}
+
+	}
 }