diff java/src/java/lang/Math.d @ 21:9b96950f2c3c

the 'java' tree compiles on both D1-Tango and D2-Phobos
author Frank Benoit <benoit@tionex.de>
date Thu, 19 Mar 2009 20:38:55 +0100
parents dbfb303e8fb0
children f713da8bc051
line wrap: on
line diff
--- a/java/src/java/lang/Math.d	Wed Mar 18 12:10:17 2009 +0100
+++ b/java/src/java/lang/Math.d	Thu Mar 19 20:38:55 2009 +0100
@@ -1,10 +1,16 @@
 module java.lang.Math;
 
-static import tango.math.Math;
+version(Tango){
+    static import tango.math.Math;
+    alias tango.math.Math MathLib;
+} else {
+    static import std.math;
+    alias std.math MathLib;
+}
 
 class Math {
 
-    public const double PI = tango.math.Math.PI;
+    public const double PI = MathLib.PI;
 
     static double abs(double a){ return a > 0 ? a : -a; }
     static float  abs(float  a){ return a > 0 ? a : -a; }
@@ -38,18 +44,21 @@
     static long   max(long   a, int    b){ return a > b ? a : b; }
 
 
-    static double sin(double a)  { return tango.math.Math.sin(a); }
-    static double cos(double a)  { return tango.math.Math.cos(a); }
+    static double sin(double a)  { return MathLib.sin(a); }
+    static double cos(double a)  { return MathLib.cos(a); }
 
-    static long   round(double a) { return cast(long)tango.math.Math.round(a); }
-    static int    round(float a)  { return cast(int)tango.math.Math.round(a); }
+    static long   round(double a) { return cast(long)MathLib.round(a); }
+    static int    round(float a)  { return cast(int)MathLib.round(a); }
     static int    round(int a)  { return a; }
-    static double rint(double a) { return tango.math.Math.rndint(a); }
-    static double ceil(double a) { return tango.math.Math.ceil(a); }
-    static double floor(double a) { return tango.math.Math.floor(a); }
-    static double sqrt(double a) { return tango.math.Math.sqrt(a); }
-    static double atan2(double a, double b) { return tango.math.Math.atan2(a,b); }
-    static double pow(double a, double b) { return tango.math.Math.pow(a, b); }
+    static double rint(double a) {
+        version(Tango) return MathLib.rndint(a);
+        else           return MathLib.rint(a);
+    }
+    static double ceil(double a) { return MathLib.ceil(a); }
+    static double floor(double a) { return MathLib.floor(a); }
+    static double sqrt(double a) { return MathLib.sqrt(a); }
+    static double atan2(double a, double b) { return MathLib.atan2(a,b); }
+    static double pow(double a, double b) { return MathLib.pow(a, b); }
 }