|
@@ -25,6 +25,9 @@
|
|
|
|
|
|
class Std {
|
|
|
|
|
|
+ public static var infinity = 1.0 / 0.0;
|
|
|
+ public static var nan = 0.0 / 0.0;
|
|
|
+
|
|
|
public static function instanceof( obj : Dynamic, vclass : Dynamic ) : Bool {
|
|
|
return untyped
|
|
|
#if flash
|
|
@@ -45,4 +48,95 @@ class Std {
|
|
|
#end
|
|
|
}
|
|
|
|
|
|
+ public static function int( x : Float ) : Int {
|
|
|
+ return Math.floor(x);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function bool( x : Dynamic ) : Bool {
|
|
|
+ return x != 0 && x != null && x != false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function parseInt( x : String ) : Int {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ _global.parseInt(x);
|
|
|
+ #else neko
|
|
|
+ __dollar__int(x.__s);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function parseFloat( x : String ) : Float {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ _global.parseFloat(x);
|
|
|
+ #else neko
|
|
|
+ __dollar__float(x.__s);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function chr( x : Int ) : String {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ String.fromCharCode(x);
|
|
|
+ #else neko
|
|
|
+ {
|
|
|
+ var s = __dollar__smake(1);
|
|
|
+ __dollar__sset(s,0,x);
|
|
|
+ new String(s);
|
|
|
+ }
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function ord( x : String ) : Int {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ if( x == "" )
|
|
|
+ null;
|
|
|
+ else
|
|
|
+ x.charCodeAt(0);
|
|
|
+ #else neko
|
|
|
+ {
|
|
|
+ var s = __dollar__ssize(x.__s);
|
|
|
+ if( s == 0 )
|
|
|
+ null;
|
|
|
+ else
|
|
|
+ __dollar__sget(s,0);
|
|
|
+ }
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function isFinite(i : Float) : Bool {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ _global.isFinite(i);
|
|
|
+ #else neko
|
|
|
+ !__dollar__isinfinite(i);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function isNaN(i : Float) : Bool {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ _global.isNaN(i);
|
|
|
+ #else neko
|
|
|
+ __dollar__isnan(i);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function random( x : Int ) : Int {
|
|
|
+ return untyped
|
|
|
+ #if flash
|
|
|
+ __random__(x);
|
|
|
+ #else neko
|
|
|
+ Math._rand_int(Math._rnd,x);
|
|
|
+ #else error
|
|
|
+ #end
|
|
|
+ }
|
|
|
+
|
|
|
}
|