annotate dwt/dwthelper/System.d @ 334:a4b331f75790

Quick fix
author John Reimer <terminal.node@gmail.com>
date Sun, 19 Oct 2008 21:41:55 -0700
parents 8235a17d9255
children 373b48b9eaf0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
149
2eb6d07425c9 Fix ticket #2: debug version doesn't compile
Frank Benoit <benoit@tionex.de>
parents: 108
diff changeset
1 /**
108
0f12f6bb9739 author notice
Frank Benoit <benoit@tionex.de>
parents: 92
diff changeset
2 * Authors: Frank Benoit <keinfarbton@googlemail.com>
0f12f6bb9739 author notice
Frank Benoit <benoit@tionex.de>
parents: 92
diff changeset
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
380bad9f6852 reverted char[] to String
Frank Benoit <benoit@tionex.de>
parents: 219
diff changeset
6 import dwt.dwthelper.utils;
380bad9f6852 reverted char[] to String
Frank Benoit <benoit@tionex.de>
parents: 219
diff changeset
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
380bad9f6852 reverted char[] to String
Frank Benoit <benoit@tionex.de>
parents: 219
diff changeset
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
09f5459a5014 Display in work
Frank Benoit <benoit@tionex.de>
parents: 25
diff changeset
133 alias SimpleType!(void*[]).arraycopy arraycopy;
92
ddb19cb18d2e package dnd
Frank Benoit <benoit@tionex.de>
parents: 26
diff changeset
134
ddb19cb18d2e package dnd
Frank Benoit <benoit@tionex.de>
parents: 26
diff changeset
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
ddb19cb18d2e package dnd
Frank Benoit <benoit@tionex.de>
parents: 26
diff changeset
137 }
ddb19cb18d2e package dnd
Frank Benoit <benoit@tionex.de>
parents: 26
diff changeset
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
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
142 public static int identityHashCode(Object x){
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
143 if( x is null ){
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
144 return 0;
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
145 }
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
146 return (*cast(Object *)&x).toHash();
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
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
311
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
149 public static String getProperty( String key, String defval ){
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
150 String res = getProperty(key);
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
151 if( res ){
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
152 return res;
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
153 }
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
154 return defval;
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
155 }
238
380bad9f6852 reverted char[] to String
Frank Benoit <benoit@tionex.de>
parents: 219
diff changeset
156 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
157 /* 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
158 String* p;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
159 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
160 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
161 /* 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
162 } else {
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
163 switch( key ){
334
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
164 case "os.name": return Environment.get("OSTYPE");
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
165 case "user.name": return Environment.get("USER");
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
166 case "user.home": return Environment.get("HOME");
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
167 case "user.dir" : return Environment.get("PWD");
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
168 case "file.separator" : return FileConst.PathSeparatorString ;
334
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
169 case "file.encoding" : implMissing( __FILE__, __LINE__);
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
170 case "network.proxy_host" : implMissing( __FILE__, __LINE__);
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
171 case "network.proxy_port" : implMissing( __FILE__, __LINE__);
a4b331f75790 Quick fix
John Reimer <terminal.node@gmail.com>
parents: 333
diff changeset
172
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
173 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
174 }
219
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
175 }
9b4e6fc63930 utils updates
Frank Benoit <benoit@tionex.de>
parents: 158
diff changeset
176 }
305
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 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
179 /* 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
180 if (key[0..3] == "dwt") {
310
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
181 if (key !is null && value !is null)
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
182 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
183 /* 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
184 } else {
310
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
185
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
186 }
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 }
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
189
311
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
190 static class Output {
310
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
191 public void println( String str ){
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
192 implMissing( __FILE__, __LINE__ );
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 }
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
195
311
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
196 private static Output err__;
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
197 public static Output err(){
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
198 if( err__ is null ){
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
199 err__ = new Output();
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
200 }
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
201 return err__;
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
202 }
77fa7f3ab37e Additions for jface.text
Frank Benoit <benoit@tionex.de>
parents: 310
diff changeset
203 private static Output out__;
310
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
204 public static Output out_(){
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
205 if( out__ is null ){
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
206 out__ = new Output();
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
207 }
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
208 return out__;
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
209 }
7ca3f26319f1 System.out.println and interface CharSequence
Frank Benoit <benoit@tionex.de>
parents: 306
diff changeset
210
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 280
diff changeset
211 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
212 }
fc2b263b8a3f Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213