Browse Source

split haxe.Log implementation into target-specific files (#6223)

Dan Korostelev 8 years ago
parent
commit
27ff0a2a30

+ 35 - 0
std/cpp/_std/haxe/Log.hx

@@ -0,0 +1,35 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		if (infos!=null && infos.customParams!=null) {
+			var extra:String = "";
+			for( v in infos.customParams )
+				extra += "," + v;
+			untyped __trace(v + extra,infos);
+		}
+		else
+			untyped __trace(v,infos);
+	}
+}

+ 38 - 0
std/cs/_std/haxe/Log.hx

@@ -0,0 +1,38 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var str:String = null;
+		if (infos != null) {
+			str = infos.fileName + ":" + infos.lineNumber + ": " + v;
+			if (infos.customParams != null)
+			{
+				str += "," + infos.customParams.join(",");
+			}
+		} else {
+			str = v;
+		}
+		cs.system.Console.WriteLine(str);
+	}
+}

+ 51 - 0
std/flash/_std/haxe/Log.hx

@@ -0,0 +1,51 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		#if (fdb || native_trace)
+			var pstr = infos == null ? "(null)" : infos.fileName + ":" + infos.lineNumber;
+			var str = flash.Boot.__string_rec(v, "");
+			if( infos != null && infos.customParams != null ) for( v in infos.customParams ) str += "," + flash.Boot.__string_rec(v, "");
+			untyped __global__["trace"](pstr+": "+str);
+		#else
+			flash.Boot.__trace(v,infos);
+		#end
+	}
+
+	/**
+		Clears the trace output.
+	**/
+	@:hack
+	public static dynamic function clear() : Void {
+		flash.Boot.__clear_trace();
+	}
+
+	/**
+		Sets the color of the trace output to `rgb`.
+	**/
+	@:hack
+	public static dynamic function setColor( rgb : Int ) : Void {
+		flash.Boot.__set_trace_color(rgb);
+	}
+}

+ 2 - 91
std/haxe/Log.hx

@@ -25,7 +25,7 @@ package haxe;
 	Log primarily provides the `trace()` method, which is invoked upon a call to
 	`trace()` in Haxe code.
 **/
-class Log {
+extern class Log {
 
 	/**
 		Outputs `v` in a platform-dependent way.
@@ -44,94 +44,5 @@ class Log {
 		If it is bound to null, subsequent calls to `trace()` will cause an
 		exception.
 	**/
-	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
-		#if flash
-			#if (fdb || native_trace)
-				var pstr = infos == null ? "(null)" : infos.fileName + ":" + infos.lineNumber;
-				var str = flash.Boot.__string_rec(v, "");
-				if( infos != null && infos.customParams != null ) for( v in infos.customParams ) str += "," + flash.Boot.__string_rec(v, "");
-				untyped __global__["trace"](pstr+": "+str);
-			#else
-				untyped flash.Boot.__trace(v,infos);
-			#end
-		#elseif neko
-			untyped {
-				$print(infos.fileName + ":" + infos.lineNumber + ": ", v);
-				if( infos.customParams != null ) for( v in infos.customParams ) $print(",", v);
-				$print("\n");
-			}
-		#elseif (php && php7)
-			php.Boot.trace(v, infos);
-		#elseif php
-			if (infos!=null && infos.customParams!=null) {
-				var extra:String = "";
-				for( v in infos.customParams )
-					extra += "," + v;
-				untyped __call__('_hx_trace', v + extra, infos);
-			}
-			else
-				untyped __call__('_hx_trace', v, infos);
-		#elseif cpp
-			if (infos!=null && infos.customParams!=null) {
-				var extra:String = "";
-				for( v in infos.customParams )
-					extra += "," + v;
-				untyped __trace(v + extra,infos);
-			}
-			else
-				untyped __trace(v,infos);
-		#elseif (cs || java || lua)
-			var str:String = null;
-			if (infos != null) {
-				str = infos.fileName + ":" + infos.lineNumber + ": " + v;
-				if (infos.customParams != null)
-				{
-					str += "," + infos.customParams.join(",");
-				}
-			} else {
-				str = v;
-			}
-			#if cs
-			cs.system.Console.WriteLine(str);
-			#elseif java
-			Sys.println(str);
-			#elseif lua
-			if (str == null) str = "null";
-			untyped __define_feature__("use._hx_print",_hx_print(str));
-			#end
-		#elseif (python)
-			var str:String = null;
-			if (infos != null) {
-				str = infos.fileName + ":" + Std.string(infos.lineNumber) + ": " + v;
-				if (infos.customParams != null) {
-					str += "," + infos.customParams.join(",");
-				}
-			} else {
-				str = v;
-			}
-			python.Lib.println(str);
-		#elseif hl
-			var pstr = infos == null ? "(null)" : infos.fileName + ":" + infos.lineNumber;
-			var str = Std.string(v);
-			if( infos != null && infos.customParams != null ) for( v in infos.customParams ) str += "," + Std.string(v);
-			Sys.println(pstr+": "+str);
-		#end
-	}
-
-	#if flash
-	/**
-		Clears the trace output.
-	**/
-	public static dynamic function clear() : Void {
-		flash.Boot.__clear_trace();
-	}
-
-	/**
-		Sets the color of the trace output to `rgb`.
-	**/
-	public static dynamic function setColor( rgb : Int ) {
-		untyped flash.Boot.__set_trace_color(rgb);
-	}
-	#end
-
+	static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void;
 }

+ 31 - 0
std/hl/_std/haxe/Log.hx

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var pstr = infos == null ? "(null)" : infos.fileName + ":" + infos.lineNumber;
+		var str = Std.string(v);
+		if( infos != null && infos.customParams != null ) for( v in infos.customParams ) str += "," + Std.string(v);
+		Sys.println(pstr+": "+str);
+	}
+}

+ 38 - 0
std/java/_std/haxe/Log.hx

@@ -0,0 +1,38 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var str:String = null;
+		if (infos != null) {
+			str = infos.fileName + ":" + infos.lineNumber + ": " + v;
+			if (infos.customParams != null)
+			{
+				str += "," + infos.customParams.join(",");
+			}
+		} else {
+			str = v;
+		}
+		Sys.println(str);
+	}
+}

+ 39 - 0
std/lua/_std/haxe/Log.hx

@@ -0,0 +1,39 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var str:String = null;
+		if (infos != null) {
+			str = infos.fileName + ":" + infos.lineNumber + ": " + v;
+			if (infos.customParams != null)
+			{
+				str += "," + infos.customParams.join(",");
+			}
+		} else {
+			str = v;
+		}
+		if (str == null) str = "null";
+		untyped __define_feature__("use._hx_print",_hx_print(str));
+	}
+}

+ 32 - 0
std/neko/_std/haxe/Log.hx

@@ -0,0 +1,32 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		untyped {
+			$print(infos.fileName + ":" + infos.lineNumber + ": ", v);
+			if( infos.customParams != null ) for( v in infos.customParams ) $print(",", v);
+			$print("\n");
+		}
+	}
+}

+ 35 - 0
std/php/_std/haxe/Log.hx

@@ -0,0 +1,35 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		if (infos!=null && infos.customParams!=null) {
+			var extra:String = "";
+			for( v in infos.customParams )
+				extra += "," + v;
+			untyped __call__('_hx_trace', v + extra, infos);
+		}
+		else
+			untyped __call__('_hx_trace', v, infos);
+	}
+}

+ 28 - 0
std/php7/_std/haxe/Log.hx

@@ -0,0 +1,28 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		php.Boot.trace(v, infos);
+	}
+}

+ 37 - 0
std/python/_std/haxe/Log.hx

@@ -0,0 +1,37 @@
+/*
+ * Copyright (C)2005-2017 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+@:coreApi class Log {
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var str:String = null;
+		if (infos != null) {
+			str = infos.fileName + ":" + Std.string(infos.lineNumber) + ": " + v;
+			if (infos.customParams != null) {
+				str += "," + infos.customParams.join(",");
+			}
+		} else {
+			str = v;
+		}
+		python.Lib.println(str);
+	}
+}