فهرست منبع

Lua : update new utility methods in _std classes

Justin Donaldson 9 سال پیش
والد
کامیت
bf01febbf2
4فایلهای تغییر یافته به همراه57 افزوده شده و 19 حذف شده
  1. 1 1
      std/lua/_std/Array.hx
  2. 3 3
      std/lua/_std/EReg.hx
  3. 25 15
      std/lua/_std/Sys.hx
  4. 28 0
      std/lua/_std/sys/FileSystem.hx

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

@@ -25,7 +25,7 @@ class Array<T> {
 	public var length(default,null) : Int;
 
 	public function new() : Void  {
-		lua.Boot.defArray(this,0);
+		lua.Lib.defArray(cast this,0);
 	}
 	public function concat( a : Array<T> ) : Array<T> {
 		var ret = this.copy();

+ 3 - 3
std/lua/_std/EReg.hx

@@ -21,7 +21,7 @@
  */
 import lua.lib.lrexlib.Rex;
 import lua.Table;
-import lua.Boot;
+import lua.Lib;
 
 @:coreApi
 class EReg {
@@ -105,11 +105,11 @@ class EReg {
 
 	public function split( s : String ) : Array<String> {
 		if (global){
-			return Boot.luaIteratorToArray(Rex.split(s, r));
+			return Lib.fillArray(Rex.split(s, r));
 		} else {
 			// we can't use directly Rex.split because it's ignoring the 'g' flag
 			var d = "#__delim__#";
-			return Boot.luaIteratorToArray(Rex.split(replace(s,d), d));
+			return Lib.fillArray(Rex.split(replace(s,d), d));
 		}
 	}
 

+ 25 - 15
std/lua/_std/Sys.hx

@@ -34,7 +34,7 @@ class Sys {
 		return lua.Lib.println(v);
 	}
 	public inline static function args() : Array<String> {
-		return lua.Boot.tableToArray(lua.Lua.arg);
+		return lua.Lib.tableToArray(lua.Lua.arg);
 	}
 	public inline static function command( cmd : String, ?args : Array<String> ) : Int  {
 		return lua.Os.execute('$cmd ${args.join(" ")}');
@@ -69,24 +69,36 @@ class Sys {
 		}
 	}
 
-	// TODO
-	public inline static function environment() : Map<String,String>  return new Map();
+	public inline static function environment() : Map<String,String>  {
+		throw "not supported";
+		return new Map();
+	}
 
-	// TODO
-	public inline static function executablePath() : String return null;
+	public inline static function executablePath() : String {
+		return Lua.arg[0];
+	}
 
-	// TODO
-	public static function getCwd() : String return null;
-	// TODO
-	public static function setCwd(s : String) : Void null;
+	public inline static function getCwd() : String {
+		return lua.lib.lfs.Lfs.currentdir();
+	}
 
-	public static function getEnv(s : String) : String return lua.Os.getenv(s);
-	// TODO
-	public static function putEnv(s : String, v : String ) : Void null;
+	public inline static function setCwd(s : String) : Void {
+		lua.lib.lfs.Lfs.chdir(s);
+	}
+
+	public inline static function getEnv(s : String) : String {
+		return lua.Os.getenv(s);
+	}
+	public inline static function putEnv(s : String, v : String ) : Void {
+		// TODO
+		return null;
+	}
 
 
 	// TODO verify
-	public static function setTimeLocale(loc : String) : Bool  return lua.Os.setlocale(loc) != null;
+	public inline static function setTimeLocale(loc : String) : Bool  {
+		return lua.Os.setlocale(loc) != null;
+	}
 
 	// TODO
 	public static function sleep(seconds : Float) : Void null;
@@ -98,6 +110,4 @@ class Sys {
 
 	// TODO
 	public static function time() : Float return lua.Os.time();
-
-
 }

+ 28 - 0
std/lua/_std/sys/FileSystem.hx

@@ -0,0 +1,28 @@
+/*
+ * Copyright (C)2005-2016 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 sys;
+
+class FileSystem {
+	public static function exists( path : String ) : Bool {
+
+	}
+}