浏览代码

[js] provide @:coreApi haxe.Log implementation and move `__trace` from js.Boot into haxe.Log

Dan Korostelev 8 年之前
父节点
当前提交
07be740780
共有 3 个文件被更改,包括 35 次插入13 次删除
  1. 0 2
      std/haxe/Log.hx
  2. 0 11
      std/js/Boot.hx
  3. 35 0
      std/js/_std/haxe/Log.hx

+ 0 - 2
std/haxe/Log.hx

@@ -60,8 +60,6 @@ class Log {
 				if( infos.customParams != null ) for( v in infos.customParams ) $print(",", v);
 				$print("\n");
 			}
-		#elseif js
-			@:privateAccess js.Boot.__trace(v,infos);
 		#elseif (php && php7)
 			php.Boot.trace(v, infos);
 		#elseif php

+ 0 - 11
std/js/Boot.hx

@@ -40,17 +40,6 @@ private class HaxeError extends js.Error {
 @:dox(hide)
 class Boot {
 
-	private static function __trace(v,i : haxe.PosInfos) {
-		var msg = if (i != null) i.fileName + ":" + i.lineNumber + ": " else "";
-		msg += __string_rec(v, "");
-		if (i != null && i.customParams != null)
-			for (v in i.customParams)
-				msg += "," + __string_rec(v, "");
-		var d;
-		if( js.Lib.typeof(untyped console) != "undefined" && (untyped console).log != null )
-			(untyped console).log(msg);
-	}
-
 	static inline function isClass(o:Dynamic) : Bool {
 		return untyped __define_feature__("js.Boot.isClass", o.__name__);
 	}

+ 35 - 0
std/js/_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 {
+	@:access(js.Boot.__string_rec)
+	public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void {
+		var msg = if (infos != null) infos.fileName + ":" + infos.lineNumber + ": " else "";
+		msg += js.Boot.__string_rec(v, "");
+		if (infos != null && infos.customParams != null)
+			for (v in infos.customParams)
+				msg += "," + js.Boot.__string_rec(v, "");
+		if( js.Lib.typeof(untyped console) != "undefined" && (untyped console).log != null )
+			(untyped console).log(msg);
+	}
+}