Mercurial > projects > dwt2
comparison java/src/java/lang/System.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 | 6dd524f61e62 |
children |
comparison
equal
deleted
inserted
replaced
20:dccb717aa902 | 21:9b96950f2c3c |
---|---|
2 * Authors: Frank Benoit <keinfarbton@googlemail.com> | 2 * Authors: Frank Benoit <keinfarbton@googlemail.com> |
3 */ | 3 */ |
4 module java.lang.System; | 4 module java.lang.System; |
5 | 5 |
6 import java.lang.util; | 6 import java.lang.util; |
7 | 7 import java.lang.exceptions; |
8 import tango.sys.Environment; | 8 |
9 import tango.core.Exception; | 9 version(Tango){ |
10 import tango.io.model.IFile : FileConst; | 10 static import tango.sys.Environment; |
11 import tango.time.Clock; | 11 static import tango.core.Exception; |
12 import tango.stdc.stdlib : exit; | 12 static import tango.io.model.IFile; |
13 static import tango.time.Clock; | |
14 static import tango.stdc.stdlib; | |
15 } else { // Phobos | |
16 static import std.c.stdlib; | |
17 static import std.date; | |
18 static import std.path; | |
19 } | |
13 | 20 |
14 template SimpleType(T) { | 21 template SimpleType(T) { |
15 debug{ | 22 debug{ |
16 static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ | 23 static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ |
17 if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ | 24 if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ |
24 static void remove(inout T[] items, int index) { | 31 static void remove(inout T[] items, int index) { |
25 if(items.length == 0) | 32 if(items.length == 0) |
26 return; | 33 return; |
27 | 34 |
28 if(index < 0 || index >= items.length){ | 35 if(index < 0 || index >= items.length){ |
29 throw new ArrayBoundsException(__FILE__, __LINE__); | 36 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); |
30 } | 37 } |
31 | 38 |
32 T element = items[index]; | 39 T element = items[index]; |
33 | 40 |
34 int length = items.length; | 41 int length = items.length; |
48 static void insert(inout T[] items, T item, int index = -1) { | 55 static void insert(inout T[] items, T item, int index = -1) { |
49 if(index == -1) | 56 if(index == -1) |
50 index = items.length; | 57 index = items.length; |
51 | 58 |
52 if(index < 0 || index > items.length ){ | 59 if(index < 0 || index > items.length ){ |
53 throw new ArrayBoundsException(__FILE__, __LINE__); | 60 throw new ArrayIndexOutOfBoundsException(__FILE__, __LINE__); |
54 } | 61 } |
55 | 62 |
56 if(index == items.length){ | 63 if(index == items.length){ |
57 items ~= item; | 64 items ~= item; |
58 }else if(index == 0){ | 65 }else if(index == 0){ |
131 alias SimpleType!(Object[]).arraycopy arraycopy; | 138 alias SimpleType!(Object[]).arraycopy arraycopy; |
132 alias SimpleType!(void*[]).arraycopy arraycopy; | 139 alias SimpleType!(void*[]).arraycopy arraycopy; |
133 alias SimpleType!(void*[]).arraycopy arraycopy; | 140 alias SimpleType!(void*[]).arraycopy arraycopy; |
134 | 141 |
135 static long currentTimeMillis(){ | 142 static long currentTimeMillis(){ |
136 return Clock.now().ticks() / 10000; | 143 version(Tango) return tango.time.Clock.Clock.now().ticks() / 10000; |
144 else return std.date.getUTCtime() / (std.date.TicksPerSecond/1000); | |
137 } | 145 } |
138 | 146 |
139 static void exit( int code ){ | 147 static void exit( int code ){ |
140 .exit(code); | 148 version(Tango) tango.stdc.stdlib.exit(code); |
149 else std.c.stdlib.exit(code); | |
141 } | 150 } |
142 public static int identityHashCode(Object x){ | 151 public static int identityHashCode(Object x){ |
143 if( x is null ){ | 152 if( x is null ){ |
144 return 0; | 153 return 0; |
145 } | 154 } |
163 switch( key ){ | 172 switch( key ){ |
164 case "os.name": return "linux"; | 173 case "os.name": return "linux"; |
165 case "user.name": return ""; | 174 case "user.name": return ""; |
166 case "user.home": return ""; | 175 case "user.home": return ""; |
167 case "user.dir" : return ""; | 176 case "user.dir" : return ""; |
168 case "file.separator" : return FileConst.PathSeparatorString ; | 177 case "file.separator" : |
178 version(Tango) return tango.io.model.IFile.FileConst.PathSeparatorString ; | |
179 else return std.path.sep; | |
169 default: return null; | 180 default: return null; |
170 } | 181 } |
171 } | 182 } |
172 } | 183 } |
173 | 184 |