Mercurial > projects > dwt-linux
annotate dwt/dwthelper/System.d @ 306:9764f08379f2
fix dwthelper after recent change
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Sat, 16 Aug 2008 23:12:10 -0700 |
parents | c7c696cdfec2 |
children | 7ca3f26319f1 |
rev | line source |
---|---|
149
2eb6d07425c9
Fix ticket #2: debug version doesn't compile
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
1 /** |
108 | 2 * Authors: Frank Benoit <keinfarbton@googlemail.com> |
3 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 module dwt.dwthelper.System; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 |
238 | 6 import dwt.dwthelper.utils; |
7 | |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
8 import tango.sys.Environment; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 import tango.core.Exception; |
306
9764f08379f2
fix dwthelper after recent change
John Reimer<terminal.node@gmail.com>
parents:
305
diff
changeset
|
10 import tango.io.model.IFile : FileConst; |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
149
diff
changeset
|
11 import tango.time.Clock; |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
150
diff
changeset
|
12 import tango.stdc.stdlib : exit; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 template SimpleType(T) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 debug{ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ |
149
2eb6d07425c9
Fix ticket #2: debug version doesn't compile
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
18 //Util.trace("Error : SimpleType.arraycopy(), out of bounds."); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 assert(0); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 static void remove(inout T[] items, int index) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 if(items.length == 0) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 if(index < 0 || index >= items.length){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 throw new ArrayBoundsException(__FILE__, __LINE__); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 T element = items[index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 int length = items.length; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 if(length == 1){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 items.length = 0; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 return;// element; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 if(index == 0) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 items = items[1 .. $]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 else if(index == length - 1) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 items = items[0 .. index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 else |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 items = items[0 .. index] ~ items[index + 1 .. $]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 static void insert(inout T[] items, T item, int index = -1) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 if(index == -1) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 index = items.length; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 if(index < 0 || index > items.length ){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 throw new ArrayBoundsException(__FILE__, __LINE__); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 if(index == items.length){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 items ~= item; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 }else if(index == 0){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 T[] newVect; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 newVect ~= item; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 items = newVect ~ items; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 }else if(index < items.length ){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 T[] arr1 = items[0 .. index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 T[] arr2 = items[index .. $]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 // Important : if you write like the following commented, |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 // you get wrong data |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 // code: T[] arr1 = items[0..index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 // T[] arr2 = items[index..$]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 // items = arr1 ~ item; // error, !!! |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 // items ~= arr2; // item replace the arrr2[0] here |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 items = arr1 ~ item ~ arr2; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 static void arraycopy(T[] src, uint srcPos, T[] dest, uint destPos, uint len) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 if(len == 0) return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 assert(src); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 assert(dest); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 debug{validCheck(src.length - srcPos, dest.length - destPos, len);} |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 if(src is dest){ |
247
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
85 if( destPos < srcPos ){ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
86 for(int i=0; i<len; ++i){ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
87 dest[destPos+i] = src[srcPos+i]; |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
88 } |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
89 } |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
90 else{ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
91 for(int i=len-1; i>=0; --i){ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
92 dest[destPos+i] = src[srcPos+i]; |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
93 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 }else{ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 dest[destPos..(len+destPos)] = src[srcPos..(len+srcPos)]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 class System { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 alias SimpleType!(int).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 alias SimpleType!(byte).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 alias SimpleType!(double).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 alias SimpleType!(float).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 alias SimpleType!(short).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 alias SimpleType!(long).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 alias SimpleType!(uint).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 alias SimpleType!(ushort).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 alias SimpleType!(ubyte).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 alias SimpleType!(ulong).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 alias SimpleType!(char).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 alias SimpleType!(wchar).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 alias SimpleType!(Object).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 alias SimpleType!(void*).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 alias SimpleType!(int[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 alias SimpleType!(byte[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 alias SimpleType!(double[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 alias SimpleType!(float[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 alias SimpleType!(short[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 alias SimpleType!(long[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 alias SimpleType!(uint[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 alias SimpleType!(ushort[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 alias SimpleType!(ubyte[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 alias SimpleType!(ulong[]).arraycopy arraycopy; |
238 | 129 alias SimpleType!(String).arraycopy arraycopy; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 alias SimpleType!(wchar[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 alias SimpleType!(Object[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 alias SimpleType!(void*[]).arraycopy arraycopy; |
26 | 133 alias SimpleType!(void*[]).arraycopy arraycopy; |
92 | 134 |
135 static long currentTimeMillis(){ | |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
149
diff
changeset
|
136 return Clock.now().ticks() / 10000; |
92 | 137 } |
138 | |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
150
diff
changeset
|
139 static void exit( int code ){ |
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
150
diff
changeset
|
140 .exit(code); |
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
150
diff
changeset
|
141 } |
219 | 142 public static int identityHashCode(Object x){ |
143 if( x is null ){ | |
144 return 0; | |
145 } | |
146 return (*cast(Object *)&x).toHash(); | |
147 } | |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
150
diff
changeset
|
148 |
238 | 149 public static String getProperty( String key ){ |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
150 /* Get values for local dwt specific keys */ |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
151 String* p; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
152 if (key[0..3] == "dwt") { |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
153 return ((p = key in localProperties) != null) ? *p : null; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
154 /* else get values for global system keys (environment) */ |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
155 } else { |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
156 switch( key ){ |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
157 case "os.name": return "linux"; |
306
9764f08379f2
fix dwthelper after recent change
John Reimer<terminal.node@gmail.com>
parents:
305
diff
changeset
|
158 case "user.name": return ""; |
9764f08379f2
fix dwthelper after recent change
John Reimer<terminal.node@gmail.com>
parents:
305
diff
changeset
|
159 case "user.home": return ""; |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
160 case "user.dir" : return ""; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
161 case "file.separator" : return FileConst.PathSeparatorString ; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
162 default: return null; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
163 } |
219 | 164 } |
165 } | |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
166 |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
167 public static void setProperty ( String key, String value ) { |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
168 /* set property for local dwt keys */ |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
169 if (key[0..3] == "dwt") { |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
170 if (key !is null && value !is null) |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
171 localProperties[ key ] = value; |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
172 /* else set properties for global system keys (environment) */ |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
173 } else { |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
174 |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
175 } |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
176 |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
177 } |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
178 |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
179 private static String[String] localProperties; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 |