Browse Source

Lua: Add clamp logic to Boot

Justin Donaldson 9 years ago
parent
commit
815319cdd0
2 changed files with 12 additions and 2 deletions
  1. 2 2
      std/lua/Boot.hx
  2. 10 0
      std/lua/Global.hx

+ 2 - 2
std/lua/Boot.hx

@@ -242,8 +242,8 @@ class Boot {
 			+":"+(if( s < 10 ) "0"+s else ""+s);
 			+":"+(if( s < 10 ) "0"+s else ""+s);
 	}
 	}
 
 
-	public static inline function i32 (i : Float) : Int {
-		return untyped _i32(i);
+	public static function clamp(x:Int){
+		return (x & 2147483647) - (x & cast 2147483648);
 	}
 	}
 
 
 	public static function strDate( s : String ) : std.Date {
 	public static function strDate( s : String ) : std.Date {

+ 10 - 0
std/lua/Global.hx

@@ -0,0 +1,10 @@
+package lua;
+@:keep
+class Global {
+	public static function hxClamp(x:Int){
+		return (x & 2147483647) - (x & cast 2147483648);
+	}
+	public static function hxBnot(x:Int){
+		return hxClamp(Bit.bnot(x));
+	}
+}