Procházet zdrojové kódy

[lua] fix failing test due to inlined vector constructor

Justin Donaldson před 9 roky
rodič
revize
ce3adc952a
2 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 1 2
      std/haxe/ds/Vector.hx
  2. 10 0
      std/lua/Boot.hx

+ 1 - 2
std/haxe/ds/Vector.hx

@@ -74,8 +74,7 @@ abstract Vector<T>(VectorData<T>) {
 		#elseif python
 			this = python.Syntax.pythonCode("[{0}]*{1}", null, length);
 		#elseif lua
-			this = lua.Boot.createTable();
-			untyped this.length = length;
+			this = lua.Boot.createVectorTable(length);
 		#else
 			this = [];
 			untyped this.length = length;

+ 10 - 0
std/lua/Boot.hx

@@ -341,6 +341,16 @@ class Boot {
 		return untyped __lua__("{}");
 	}
 
+	/*
+	   Create an empty table for vectors
+	*/
+	// TODO: provide a simpler anonymous table generator syntax in genlua
+	public static function createVectorTable<K,V>(length:Int) : Table<K,V> {
+		var table : Table<K,V> = untyped __lua__("{}");
+		untyped table.length = length;
+		return table;
+	}
+
 	/*
 		Returns a shell escaped version of "cmd" along with any args
 	*/