comparison dwt/dwthelper/utils.d @ 10:30a762abda2a

Revert automatic changes from dwt/internal and dwt/dwthelper. Excluded dwt/internal/image and theme.
author Frank Benoit <benoit@tionex.de>
date Thu, 28 Aug 2008 12:31:10 +0200
parents e831403a80a9
children 5b53d338c709
comparison
equal deleted inserted replaced
9:e76aa0b07480 10:30a762abda2a
23 static import tango.util.collection.model.Seq; 23 static import tango.util.collection.model.Seq;
24 24
25 alias bool boolean; 25 alias bool boolean;
26 alias char[] String; 26 alias char[] String;
27 alias char[] string; 27 alias char[] string;
28 alias tango.text.Text.Text!cast(wchar) StringBuffer; 28 alias tango.text.Text.Text!(char) StringBuffer;
29 alias opEquals equals; 29 alias opEquals equals;
30 30
31 alias PlatformException Error; 31 alias PlatformException Error;
32 alias Exception Throwable; 32 alias Exception Throwable;
33 alias Exception RuntimeException; 33 alias Exception RuntimeException;
57 } 57 }
58 public int opEquals( T other ){ 58 public int opEquals( T other ){
59 return value == other; 59 return value == other;
60 } 60 }
61 public int opEquals( Object other ){ 61 public int opEquals( Object other ){
62 if( auto o = cast(ValueWrapperT!cast(T))other ){ 62 if( auto o = cast(ValueWrapperT!(T))other ){
63 return value == o.value; 63 return value == o.value;
64 } 64 }
65 return false; 65 return false;
66 } 66 }
67 } 67 }
103 } 103 }
104 104
105 alias Boolean ValueWrapperBool; 105 alias Boolean ValueWrapperBool;
106 106
107 107
108 class Byte : ValueWrapperT!cast(byte) { 108 class Byte : ValueWrapperT!(byte) {
109 public static byte parseByte( String s ){ 109 public static byte parseByte( String s ){
110 try{ 110 try{
111 int res = tango.text.convert.Integer.parse( s ); 111 int res = tango.text.convert.Integer.parse( s );
112 if( res < byte.min || res > byte.max ){ 112 if( res < byte.min || res > byte.max ){
113 throw new NumberFormatException( "out of range" ); 113 throw new NumberFormatException( "out of range" );
123 } 123 }
124 } 124 }
125 alias Byte ValueWrapperByte; 125 alias Byte ValueWrapperByte;
126 126
127 127
128 class Integer : ValueWrapperT!cast(int) { 128 class Integer : ValueWrapperT!(int) {
129 129
130 public static const int MIN_VALUE = 0x80000000; 130 public static const int MIN_VALUE = 0x80000000;
131 public static const int MAX_VALUE = 0x7fffffff; 131 public static const int MAX_VALUE = 0x7fffffff;
132 public static const int SIZE = 32; 132 public static const int SIZE = 32;
133 133
234 return tango.text.convert.Integer.toString( value ); 234 return tango.text.convert.Integer.toString( value );
235 } 235 }
236 } 236 }
237 alias Integer ValueWrapperInt; 237 alias Integer ValueWrapperInt;
238 238
239 class Double : ValueWrapperT!cast(double) { 239 class Double : ValueWrapperT!(double) {
240 this( double value ){ 240 this( double value ){
241 super(value); 241 super(value);
242 } 242 }
243 this( String str ){ 243 this( String str ){
244 implMissing( __FILE__, __LINE__ ); 244 implMissing( __FILE__, __LINE__ );
251 implMissing( __FILE__, __LINE__ ); 251 implMissing( __FILE__, __LINE__ );
252 return null; 252 return null;
253 } 253 }
254 } 254 }
255 255
256 class Float : ValueWrapperT!cast(float) { 256 class Float : ValueWrapperT!(float) {
257 257
258 public static float POSITIVE_INFINITY = (1.0f / 0.0f); 258 public static float POSITIVE_INFINITY = (1.0f / 0.0f);
259 public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f); 259 public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f);
260 public static float NaN = (0.0f / 0.0f); 260 public static float NaN = (0.0f / 0.0f);
261 public static float MAX_VALUE = 3.4028235e+38f; 261 public static float MAX_VALUE = 3.4028235e+38f;
284 throw new NumberFormatException( e ); 284 throw new NumberFormatException( e );
285 } 285 }
286 } 286 }
287 287
288 } 288 }
289 class Long : ValueWrapperT!cast(long) { 289 class Long : ValueWrapperT!(long) {
290 this( long value ){ 290 this( long value ){
291 super(value); 291 super(value);
292 } 292 }
293 this( String str ){ 293 this( String str ){
294 implMissing( __FILE__, __LINE__ ); 294 implMissing( __FILE__, __LINE__ );
307 } 307 }
308 } 308 }
309 alias Long ValueWrapperLong; 309 alias Long ValueWrapperLong;
310 310
311 311
312 // alias ValueWrapperT!cast(int) ValueWrapperInt; 312 // alias ValueWrapperT!(int) ValueWrapperInt;
313 313
314 alias ArrayWrapperT!cast(byte) ArrayWrapperByte; 314 alias ArrayWrapperT!(byte) ArrayWrapperByte;
315 alias ArrayWrapperT!cast(int) ArrayWrapperInt; 315 alias ArrayWrapperT!(int) ArrayWrapperInt;
316 alias ArrayWrapperT!cast(Object) ArrayWrapperObject; 316 alias ArrayWrapperT!(Object) ArrayWrapperObject;
317 alias ArrayWrapperT!cast(wchar) ArrayWrapperString; 317 alias ArrayWrapperT!(char) ArrayWrapperString;
318 alias ArrayWrapperT!cast(String) ArrayWrapperString2; 318 alias ArrayWrapperT!(String) ArrayWrapperString2;
319 319
320 Object[] StringArrayToObjectArray( String[] strs ){ 320 Object[] StringArrayToObjectArray( String[] strs ){
321 Object[] res = new Object[strs.length]; 321 Object[] res = new Object[strs.length];
322 foreach( idx, str; strs ){ 322 foreach( idx, str; strs ){
323 res[idx] = new ArrayWrapperString(str); 323 res[idx] = new ArrayWrapperString(str);
784 String ExceptionGetLocalizedMessage( Exception e ){ 784 String ExceptionGetLocalizedMessage( Exception e ){
785 return e.msg; 785 return e.msg;
786 } 786 }
787 787
788 void ExceptionPrintStackTrace( Exception e ){ 788 void ExceptionPrintStackTrace( Exception e ){
789 this( e, Stderr ); 789 ExceptionPrintStackTrace( e, Stderr );
790 } 790 }
791 void ExceptionPrintStackTrace( Exception e, Print!cast(wchar) print ){ 791 void ExceptionPrintStackTrace( Exception e, Print!(char) print ){
792 Exception exception = e; 792 Exception exception = e;
793 while( exception !is null ){ 793 while( exception !is null ){
794 print.formatln( "Exception in {}({}): {}", exception.file, exception.line, exception.msg ); 794 print.formatln( "Exception in {}({}): {}", exception.file, exception.line, exception.msg );
795 if( exception.info !is null ){ 795 if( exception.info !is null ){
796 foreach( msg; exception.info ){ 796 foreach( msg; exception.info ){
912 } 912 }
913 return true; 913 return true;
914 } 914 }
915 } 915 }
916 916
917 int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!cast(T) s, T src ){ 917 int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){
918 int idx; 918 int idx;
919 foreach( e; s ){ 919 foreach( e; s ){
920 if( e == src ){ 920 if( e == src ){
921 return idx; 921 return idx;
922 } 922 }
935 idx++; 935 idx++;
936 } 936 }
937 return res; 937 return res;
938 } 938 }
939 939
940 int seqIndexOf( tango.util.collection.model.Seq.Seq!cast(Object) seq, Object v ){ 940 int seqIndexOf( tango.util.collection.model.Seq.Seq!(Object) seq, Object v ){
941 int res = -1; 941 int res = -1;
942 int idx = 0; 942 int idx = 0;
943 foreach( p; seq ){ 943 foreach( p; seq ){
944 if( p == v){ 944 if( p == v){
945 res = idx; 945 res = idx;