Browse Source

[lua] featurize _hx_print

Justin Donaldson 9 years ago
parent
commit
5e37452221
4 changed files with 5 additions and 7 deletions
  1. 4 1
      src/generators/genlua.ml
  2. 1 1
      std/haxe/Log.hx
  3. 0 4
      std/lua/Lua.hx
  4. 0 1
      std/lua/_lua/_hx_print.lua

+ 4 - 1
src/generators/genlua.ml

@@ -1811,7 +1811,7 @@ let generate com =
 	List.iter (generate_type_forward ctx) com.types; newline ctx;
 
 	(* Generate some dummy placeholders for utility libs that may be required*)
-	println ctx "local _hx_bind, _hx_bit, _hx_staticToInstance, _hx_funcToField, _hx_maxn";
+	println ctx "local _hx_bind, _hx_bit, _hx_staticToInstance, _hx_funcToField, _hx_maxn, _hx_print";
 
 	if has_feature ctx "use._bitop" || has_feature ctx "lua.Boot.clamp" then begin
 	    println ctx "pcall(require, 'bit32') pcall(require, 'bit')";
@@ -1931,6 +1931,9 @@ let generate com =
 	    println ctx "end;";
 	end;
 
+	if has_feature ctx "use._hx_print" then
+	    println ctx "_hx_print = print or (function() end)";
+
 
 	List.iter (generate_enumMeta_fields ctx) com.types;
 

+ 1 - 1
std/haxe/Log.hx

@@ -96,7 +96,7 @@ class Log {
 			#elseif java
 			untyped __java__("java.lang.System.out.println(str)");
 			#elseif lua
-			untyped __lua__("_hx_print({0})", lua.Boot.__string_rec(str));
+			untyped __define_feature__("use._hx_print",_hx_print(Std.string(str)));
 			#end
 		#elseif (python)
 			var str:String = null;

+ 0 - 4
std/lua/Lua.hx

@@ -173,10 +173,6 @@ extern class Lua {
 	**/
 	public static function loadstring(code:String) : Void;
 
-	private static function __init__() : Void {
-		// print polyfill
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_print.lua");
-	}
 }
 
 /**

+ 0 - 1
std/lua/_lua/_hx_print.lua

@@ -1 +0,0 @@
-local _hx_print = print or (function()end)