瀏覽代碼

[cpp] Add cpp.NativeMath with some faster routines in it.

hughsando 9 年之前
父節點
當前提交
6c80e4c4d2
共有 1 個文件被更改,包括 26 次插入0 次删除
  1. 26 0
      std/cpp/NativeMath.hx

+ 26 - 0
std/cpp/NativeMath.hx

@@ -0,0 +1,26 @@
+package cpp;
+
+@:noPackageRestrict
+extern class NativeMath
+{
+#if (cpp && !cppia)
+   @:native("_hx_idiv")
+   public static function idiv(num:Int,denom:Int):Int return 0;
+   @:native("_hx_cast_int")
+   public static function castInt(f:Float):Int return 0;
+   @:native("_hx_fast_floor")
+   public static function fastInt(f:Float):Int return 0;
+
+#else
+
+   public static inline function idiv(num:Int,denom:Int):Int
+      return Std.int(num/denom);
+
+   public static inline function castInt(f:Float):Int
+      return Std.int(f);
+
+   public static inline function fastInt(f:Float):Int
+      return Std.int(f);
+
+#end
+}