浏览代码

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 12 年之前
父节点
当前提交
6e6b64426f
共有 1 个文件被更改,包括 4 次插入0 次删除
  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();
 	}