Mercurial > projects > dwt-linux
annotate dwt/dwthelper/System.d @ 354:59b54fea05d0
Fixes for XPCOM 1.9 and anonymous classes
author | john@andLinux |
---|---|
date | Sun, 14 Dec 2008 02:13:20 -0500 |
parents | 373b48b9eaf0 |
children | ee1dd551f5b1 |
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; |
350
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
13 import tango.stdc.locale; |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
14 import tango.stdc.string; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 template SimpleType(T) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 debug{ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 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
|
19 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
|
20 //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
|
21 assert(0); |
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 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 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
|
27 if(items.length == 0) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 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
|
31 throw new ArrayBoundsException(__FILE__, __LINE__); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 } |
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 T element = items[index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 int length = items.length; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 if(length == 1){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 items.length = 0; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 return;// element; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 if(index == 0) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 items = items[1 .. $]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 else if(index == length - 1) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 items = items[0 .. index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 else |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 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
|
48 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 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
|
51 if(index == -1) |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 index = items.length; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 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
|
55 throw new ArrayBoundsException(__FILE__, __LINE__); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 if(index == items.length){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 items ~= item; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 }else if(index == 0){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 T[] newVect; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 newVect ~= item; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 items = newVect ~ items; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 }else if(index < items.length ){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 T[] arr1 = items[0 .. index]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 T[] arr2 = items[index .. $]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 // 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
|
69 // you get wrong data |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 // 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
|
71 // T[] arr2 = items[index..$]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 // items = arr1 ~ item; // error, !!! |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 // 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
|
74 items = arr1 ~ item ~ arr2; |
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 } |
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 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
|
79 { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 if(len == 0) return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 assert(src); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 assert(dest); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 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
|
85 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 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
|
87 if( destPos < srcPos ){ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
88 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
|
89 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
|
90 } |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
91 } |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
92 else{ |
da992144273f
Fix bug in System.arraycopy when called for overlapping array ranges
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
93 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
|
94 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
|
95 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 }else{ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 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
|
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 |
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 class System { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 alias SimpleType!(int).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 alias SimpleType!(byte).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 alias SimpleType!(double).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 alias SimpleType!(float).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 alias SimpleType!(short).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 alias SimpleType!(long).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 alias SimpleType!(uint).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 alias SimpleType!(ushort).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 alias SimpleType!(ubyte).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 alias SimpleType!(ulong).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 alias SimpleType!(char).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
117 alias SimpleType!(wchar).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
118 alias SimpleType!(Object).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 alias SimpleType!(void*).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 alias SimpleType!(int[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 alias SimpleType!(byte[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
123 alias SimpleType!(double[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 alias SimpleType!(float[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 alias SimpleType!(short[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 alias SimpleType!(long[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 alias SimpleType!(uint[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 alias SimpleType!(ushort[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 alias SimpleType!(ubyte[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 alias SimpleType!(ulong[]).arraycopy arraycopy; |
238 | 131 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
|
132 alias SimpleType!(wchar[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 alias SimpleType!(Object[]).arraycopy arraycopy; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 alias SimpleType!(void*[]).arraycopy arraycopy; |
26 | 135 alias SimpleType!(void*[]).arraycopy arraycopy; |
92 | 136 |
137 static long currentTimeMillis(){ | |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
149
diff
changeset
|
138 return Clock.now().ticks() / 10000; |
92 | 139 } |
140 | |
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
|
141 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
|
142 .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
|
143 } |
219 | 144 public static int identityHashCode(Object x){ |
145 if( x is null ){ | |
146 return 0; | |
147 } | |
148 return (*cast(Object *)&x).toHash(); | |
149 } | |
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
|
150 |
311 | 151 public static String getProperty( String key, String defval ){ |
152 String res = getProperty(key); | |
153 if( res ){ | |
154 return res; | |
155 } | |
156 return defval; | |
157 } | |
238 | 158 public static String getProperty( String key ){ |
350
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
159 /* get values for global system keys (environment) */ |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
160 switch( key ) { |
354 | 161 // Ubuntu Gutsy:Environment.get for OSTYPE is not working |
162 // Force default to "linux" for now -JJR | |
163 case "os.name": return Environment.get("OSTYPE","linux"); | |
350
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
164 case "user.name": return Environment.get("USER"); |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
165 case "user.home": return Environment.get("HOME"); |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
166 case "user.dir" : return Environment.get("PWD"); |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
167 case "file.separator" : return FileConst.PathSeparatorString ; |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
168 case "file.encoding" : |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
169 char* encoding; |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
170 encoding = setlocale(LC_CTYPE, null); |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
171 if (encoding is null) |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
172 return "CP1252"; //default |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
173 else |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
174 return encoding[0..strlen(encoding)].dup; |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
175 default: return null; |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
176 } |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
177 |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
178 /* 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
|
179 String* p; |
350
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
180 return ((p = key in localProperties) != null) ? *p : null; |
219 | 181 } |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
182 |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
183 public static void setProperty ( String key, String value ) { |
350
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
184 /* set property for LOCAL dwt keys */ |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
185 if (key !is null && value !is null) |
373b48b9eaf0
Conclusion of long painful debugging: working Browser package :) (aplha)
John Reimer <terminal.node@gmail.com>
parents:
334
diff
changeset
|
186 localProperties[ key ] = value; |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
187 } |
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
188 |
311 | 189 static class Output { |
310
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
190 public void println( String str ){ |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
191 implMissing( __FILE__, __LINE__ ); |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
192 } |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
193 } |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
194 |
311 | 195 private static Output err__; |
196 public static Output err(){ | |
197 if( err__ is null ){ | |
198 err__ = new Output(); | |
199 } | |
200 return err__; | |
201 } | |
202 private static Output out__; | |
310
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
203 public static Output out_(){ |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
204 if( out__ is null ){ |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
205 out__ = new Output(); |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
206 } |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
207 return out__; |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
208 } |
7ca3f26319f1
System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents:
306
diff
changeset
|
209 |
305
c7c696cdfec2
Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents:
280
diff
changeset
|
210 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
|
211 } |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 |