Mercurial > projects > dwt2
diff java/src/java/lang/Integer.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 | 712ffca654f3 |
children |
line wrap: on
line diff
--- a/java/src/java/lang/Integer.d Wed Mar 18 12:10:17 2009 +0100 +++ b/java/src/java/lang/Integer.d Thu Mar 19 20:38:55 2009 +0100 @@ -3,6 +3,15 @@ import java.lang.util; import java.lang.exceptions; +version(Tango){ +} else { // Phobos +} + +version(Tango){ +} else { // Phobos +} + + class Integer : ValueWrapperT!(int) { public static const int MIN_VALUE = 0x80000000; @@ -19,57 +28,72 @@ public static String toString( int i, int radix ){ switch( radix ){ - case 2: - return toBinaryString(i); - case 8: - return toOctalString(i); - case 10: - return toString(i); - case 16: - return toHexString(i); - default: - implMissing( __FILE__, __LINE__ ); - return null; + case 2: + return toBinaryString(i); + case 8: + return toOctalString(i); + case 10: + return toString(i); + case 16: + return toHexString(i); + default: + implMissing( __FILE__, __LINE__ ); + return null; } } public static String toHexString( int i ){ - return tango.text.convert.Integer.toString(i, "x" ); + version(Tango){ + return tango.text.convert.Integer.toString(i, "x" ); + } else { // Phobos + return std.string.toString( cast(long)i, 16u ); + } } public static String toOctalString( int i ){ - return tango.text.convert.Integer.toString(i, "o" ); + version(Tango){ + return tango.text.convert.Integer.toString(i, "o" ); + } else { // Phobos + return std.string.toString( cast(long)i, 8u ); + } } public static String toBinaryString( int i ){ - return tango.text.convert.Integer.toString(i, "b" ); + version(Tango){ + return tango.text.convert.Integer.toString(i, "b" ); + } else { // Phobos + return std.string.toString( cast(long)i, 2u ); + } } public static String toString( int i ){ - return tango.text.convert.Integer.toString(i); + version(Tango){ + return tango.text.convert.Integer.toString(i); + } else { // Phobos + return std.string.toString( i ); + } } public static int parseInt( String s, int radix ){ - try{ - return tango.text.convert.Integer.toLong( s, radix ); - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); + version(Tango){ + try{ + return tango.text.convert.Integer.toLong( s, radix ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + return 0; } } public static int parseInt( String s ){ - try{ - return tango.text.convert.Integer.toLong( s ); - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); - } + return parseInt( s, 10 ); } public static Integer valueOf( String s, int radix ){ - implMissing( __FILE__, __LINE__ ); - return null; + return new Integer( parseInt( s, radix )); } public static Integer valueOf( String s ){ @@ -109,7 +133,11 @@ } public override String toString(){ - return tango.text.convert.Integer.toString( value ); + version(Tango){ + return tango.text.convert.Integer.toString( value ); + } else { // Phobos + return std.string.toString(value); + } } } alias Integer ValueWrapperInt;