Ver Fonte

Add Std.instance for hxcpp.

Implemented as Std.is ? cast : null as per php, don't know if
there's something better that could be used.
Luca Deltodesco há 12 anos atrás
pai
commit
6e6b64426f
1 ficheiros alterados com 4 adições e 0 exclusões
  1. 4 0
      std/cpp/_std/Std.hx

+ 4 - 0
std/cpp/_std/Std.hx

@@ -24,6 +24,10 @@
 		return untyped __global__.__instanceof(v,t);
 	}
 
+	public static function instance<T>( v : { }, c : Class<T> ) : T {
+		return Std.is(v, c) ? cast v : null;
+	}
+
 	public static function string( s : Dynamic ) : String {
 		return untyped s==null ? "null" : s.toString();
 	}