Forráskód Böngészése

Lua : normalize lua inline helpers, and add instance function helper

Justin Donaldson 9 éve
szülő
commit
ad9c685608

+ 4 - 2
std/lua/Boot.hx

@@ -291,7 +291,9 @@ class Boot {
 	}
 
 	public static function __init__(){
-		// static to instance method wrapper
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_static_to_instance.lua");
+		// anonymous to instance method wrapper
+		haxe.macro.Compiler.includeFile("lua/_lua/_hx_function_to_instance_function.lua");
+		// static to instance class wrapper
+		haxe.macro.Compiler.includeFile("lua/_lua/_hx_static_to_instance_function.lua");
 	}
 }

+ 10 - 0
std/lua/_lua/_hx_function_to_instance_function.lua

@@ -0,0 +1,10 @@
+local function _hx_functionToInstanceFunction(f)
+  if type(f) == "function" then 
+    return function(self,...) 
+      return f(...) 
+    end
+  else 
+    return f
+  end
+end
+    

+ 0 - 0
std/lua/_lua/_hx_static_to_instance.lua → std/lua/_lua/_hx_static_to_instance_function.lua


+ 0 - 0
std/lua/_lua/_hx_tabArray.lua → std/lua/_lua/_hx_tab_array.lua


+ 1 - 1
std/lua/_std/Array.hx

@@ -190,7 +190,7 @@ class Array<T> {
 	}
 	private static function __init__() : Void{
 		// table-to-array helper
-		haxe.macro.Compiler.includeFile("lua/_lua/_hx_tabArray.lua");
+		haxe.macro.Compiler.includeFile("lua/_lua/_hx_tab_array.lua");
 		// attach the prototype for Array to the metatable for 
 		// the tabToArray helper function
 		untyped __lua__("_hx_array_mt.__index = Array.prototype");