Browse Source

[lua] featurize _hx_apply_self

Justin Donaldson 9 years ago
parent
commit
c53356019b
2 changed files with 7 additions and 6 deletions
  1. 7 1
      src/generators/genlua.ml
  2. 0 5
      std/lua/Boot.hx

+ 7 - 1
src/generators/genlua.ml

@@ -433,6 +433,7 @@ let rec gen_call ctx e el in_value =
 		if Hashtbl.mem kwds s || not (valid_lua_ident s) then begin
 		    match e.eexpr with
 		    |TNew _-> (
+			add_feature ctx "use._hx_apply_self";
 			spr ctx "_hx_apply_self(";
 			gen_value ctx e;
 			print ctx ",\"%s\"" (field_name ef);
@@ -1811,7 +1812,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, _hx_print";
+	println ctx "local _hx_bind, _hx_bit, _hx_staticToInstance, _hx_funcToField, _hx_maxn, _hx_print, _hx_apply_self";
 
 	if has_feature ctx "use._bitop" || has_feature ctx "lua.Boot.clamp" then begin
 	    println ctx "pcall(require, 'bit32') pcall(require, 'bit')";
@@ -1934,6 +1935,11 @@ let generate com =
 	if has_feature ctx "use._hx_print" then
 	    println ctx "_hx_print = print or (function() end)";
 
+	if has_feature ctx "use._hx_apply_self" then
+	    println ctx "_hx_apply_self = function(self, f, ...)";
+	    println ctx "  return self[f](self,...)";
+	    println ctx "end";
+
 
 	List.iter (generate_enumMeta_fields ctx) com.types;
 

+ 0 - 5
std/lua/Boot.hx

@@ -372,9 +372,4 @@ class Boot {
 			hasNext : function() return cur_val !=  null
 		}
 	}
-
-	public static function __init__(){
-		// simple apply method
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_apply.lua");
-	}
 }