Mercurial > projects > dwt2
annotate base/src/java/lang/Long.d @ 120:536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
===D2===
* added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements
used these templates to work with strict type storage rules of dmd-2.053
* com.ibm.icu now also compilable with D2, but not tested yet
* small fixes
Snippet288 - shared data is in TLS
===Phobos===
* fixed critical bugs in Phobos implemention
completely incorrect segfault prone fromStringz (Linux's port ruthless killer)
terrible, incorrect StringBuffer realization (StyledText killer)
* fixed small bugs as well
Snippet72 - misprint in the snippet
* implemented missed functionality for Phobos
ByteArrayOutputStream implemented (image loading available)
formatting correctly works for all DWT's cases
As a result, folowing snippets now works with Phobos (Snippet### - what is fixed):
Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting
Snippet48, 282 - crash on image loading
Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText
Snippet244 - hang-up
===Tango===
* few changes for the latest Tango trunc-r5661
* few small performance improvments
===General===
* implMissing-s for only one version changed to implMissingInTango/InPhobos
* incorrect calls to Format in toString-s fixed
* fixed loading \uXXXX characters in ResourceBundle
* added good UTF-8 support for StyledText, TextLayout (Win32) and friends
UTF functions revised and tested. It is now in java.nonstandard.*Utf modules
StyledText and TextLayout (Win32) modules revised for UTF-8 support
* removed small diferences in most identical files in *.swt.* folders
*.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32
now 179 of 576 (~31%) files in *.swt.* folders are fully identical
* Win32: snippets now have right subsystem, pretty icons and native system style controls
* small fixes in snippets
Snippet44 - it's not Snippet44
Snippet212 - functions work with different images and offsets arrays
Win32: Snippet282 - crash on close if the button has an image
Snippet293 - setGrayed is commented
and others
Win32: As a result, folowing snippets now works
Snippet68 - color doesn't change
Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above)
Snippet193 - no tabel headers
author | Denis Shelomovskij <verylonglogin.reg@gmail.com> |
---|---|
date | Sat, 09 Jul 2011 15:50:20 +0300 |
parents | 5d5bd660917f |
children |
rev | line source |
---|---|
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 module java.lang.Long; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 import java.lang.util; |
99
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
4 import java.lang.exceptions; |
84 | 5 import java.lang.Number; |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
6 import java.lang.Character; |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
7 import java.lang.Class; |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
8 import java.lang.String; |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
9 |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
10 version(Tango){ |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
11 static import tango.text.convert.Integer; |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
12 } else { // Phobos |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
13 static import std.conv; |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
14 static import std.string; |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
15 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 |
84 | 17 class Long : Number { |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 public static const long MIN_VALUE = long.min; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 public static const long MAX_VALUE = long.max; |
84 | 20 private long value; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 this( long value ){ |
84 | 22 super(); |
23 this.value = value; | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 this( String str ){ |
84 | 26 super(); |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
27 this.value = parseLong(str); |
84 | 28 } |
29 public byte byteValue(){ | |
30 return cast(byte)value; | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 } |
84 | 32 |
33 public short shortValue(){ | |
34 return cast(short)value; | |
35 } | |
36 | |
37 public int intValue(){ | |
38 return cast(int)value; | |
39 } | |
40 | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 public long longValue(){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 return value; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 } |
84 | 44 |
45 public float floatValue(){ | |
46 return cast(float)value; | |
47 } | |
48 | |
49 public double doubleValue(){ | |
50 return cast(double)value; | |
51 } | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 public static long parseLong(String s){ |
99
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
53 return parseLong( s, 10 ); |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
54 } |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
55 public static long parseLong(String s, int radix){ |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
56 if(radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
57 throw new NumberFormatException("The radix is out of range"); |
99
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
58 version(Tango){ |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
59 try{ |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
60 return tango.text.convert.Integer.toLong( s, radix ); |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
61 } |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
62 catch( IllegalArgumentException e ){ |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
63 throw new NumberFormatException( e ); |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
64 } |
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
65 } else { // Phobos |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
66 try{ |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
67 immutable res = std.conv.parse!(long)( s, radix ); |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
68 if(s.length) |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
69 throw new NumberFormatException("String has invalid characters: " ~ s); |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
70 return res; |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
71 } |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
72 catch( std.conv.ConvException e ){ |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
73 throw new NumberFormatException( e ); |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
74 } |
99
5d5bd660917f
build some databind snippets
Frank Benoit <benoit@tionex.de>
parents:
88
diff
changeset
|
75 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 } |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
77 public static String toString( long i ){ |
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
99
diff
changeset
|
78 return String_valueOf(i); |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 } |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
80 private static Class TYPE_; |
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
81 public static Class TYPE(){ |
84 | 82 if( TYPE_ is null ){ |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
83 TYPE_ = Class.fromType!(long); |
84 | 84 } |
85 return TYPE_; | |
86 } | |
87 | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 alias Long ValueWrapperLong; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 |