Mercurial > projects > qtd
comparison d2/qtd/MOC.d @ 402:e67ce7c21758
gdc & 64 bit changes
author | Eldar Insafutdinov |
---|---|
date | Thu, 17 Mar 2011 19:45:42 +0000 |
parents | a032df77b6ab |
children |
comparison
equal
deleted
inserted
replaced
395:d757b8b1ca75 | 402:e67ce7c21758 |
---|---|
18 private: | 18 private: |
19 | 19 |
20 /** | 20 /** |
21 Utils. | 21 Utils. |
22 */ | 22 */ |
23 int lastIndexOf(T)(T[] haystack, T[] needle, int from = -1) | 23 sizediff_t lastIndexOf(T)(T[] haystack, T[] needle, sizediff_t from = -1) |
24 { | 24 { |
25 auto l = haystack.length; | 25 auto l = haystack.length; |
26 auto ol = needle.length; | 26 auto ol = needle.length; |
27 int delta = l - ol; | 27 auto delta = l - ol; |
28 if (from < 0) | 28 if (from < 0) |
29 from = delta; | 29 from = delta; |
30 if (from < 0 || from > l) | 30 if (from < 0 || from > l) |
31 return -1; | 31 return -1; |
32 if (from > delta) | 32 if (from > delta) |
39 from--; | 39 from--; |
40 } | 40 } |
41 return -1; | 41 return -1; |
42 } | 42 } |
43 | 43 |
44 string replicate(int n, char value) | 44 string replicate(size_t n, char value) |
45 { | 45 { |
46 char[] ret = "".dup; | 46 char[] ret = "".dup; |
47 if (n > 0) | 47 if (n > 0) |
48 { | 48 { |
49 // ret = newArray!char(n); | 49 // ret = newArray!char(n); |
142 ClassDef cdef; | 142 ClassDef cdef; |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 | 146 |
147 int lengthOfEscapeSequence(string s, uint i) | 147 int lengthOfEscapeSequence(string s, size_t i) |
148 { | 148 { |
149 if (s[i] != '\\' || i >= s.length - 1) | 149 if (s[i] != '\\' || i >= s.length - 1) |
150 return 1; | 150 return 1; |
151 const int startPos = i; | 151 const startPos = i; |
152 ++i; | 152 ++i; |
153 auto ch = s[i]; | 153 auto ch = s[i]; |
154 if (ch == 'x') { | 154 if (ch == 'x') { |
155 ++i; | 155 ++i; |
156 while (i < s.length && isHexChar(s[i])) | 156 while (i < s.length && isHexChar(s[i])) |
162 ++i; | 162 ++i; |
163 } | 163 } |
164 } else { // single character escape sequence | 164 } else { // single character escape sequence |
165 i = qMin(i + 1, s.length); | 165 i = qMin(i + 1, s.length); |
166 } | 166 } |
167 return i - startPos; | 167 return cast(int)(i - startPos); |
168 } | 168 } |
169 | 169 |
170 int strreg(ref Generator gen, string s) | 170 int strreg(ref Generator gen, string s) |
171 { | 171 { |
172 int idx = 0; | 172 int idx = 0; |
272 gen.output ~= format_ctfe(" ${}, // revision\n", 2); | 272 gen.output ~= format_ctfe(" ${}, // revision\n", 2); |
273 gen.output ~= format_ctfe(" ${}, // classname\n", strreg(gen, gen.cdef.classname)); | 273 gen.output ~= format_ctfe(" ${}, // classname\n", strreg(gen, gen.cdef.classname)); |
274 gen.output ~= format_ctfe(" ${}, ${}, // classinfo\n", gen.cdef.classInfoList.length, gen.cdef.classInfoList.length ? index : 0); | 274 gen.output ~= format_ctfe(" ${}, ${}, // classinfo\n", gen.cdef.classInfoList.length, gen.cdef.classInfoList.length ? index : 0); |
275 index += gen.cdef.classInfoList.length * 2; | 275 index += gen.cdef.classInfoList.length * 2; |
276 | 276 |
277 int methodCount = gen.cdef.signalList.length + gen.cdef.slotList.length;// + cdef->methodList.count(); | 277 auto methodCount = gen.cdef.signalList.length + gen.cdef.slotList.length;// + cdef->methodList.count(); |
278 gen.output ~= format_ctfe(" ${}, ${}, // methods\n", methodCount, methodCount ? index : 0); | 278 gen.output ~= format_ctfe(" ${}, ${}, // methods\n", methodCount, methodCount ? index : 0); |
279 index += methodCount * 5; | 279 index += methodCount * 5; |
280 gen.output ~= format_ctfe(" ${}, ${}, // properties\n", propertyList.length, propertyList.length ? index : 0); | 280 gen.output ~= format_ctfe(" ${}, ${}, // properties\n", propertyList.length, propertyList.length ? index : 0); |
281 index += propertyList.length * 3; | 281 index += propertyList.length * 3; |
282 // if(cdef->notifyableProperties) | 282 // if(cdef->notifyableProperties) |
335 // Build stringdata array | 335 // Build stringdata array |
336 // | 336 // |
337 gen.output ~= "private static immutable char[] qt_meta_stringdata = \n"; | 337 gen.output ~= "private static immutable char[] qt_meta_stringdata = \n"; |
338 gen.output ~= format_ctfe(" \""); | 338 gen.output ~= format_ctfe(" \""); |
339 int col = 0; | 339 int col = 0; |
340 int len = 0; | 340 sizediff_t len = 0; |
341 foreach (i, s; gen.strings) { | 341 foreach (i, s; gen.strings) { |
342 len = s.length; | 342 len = s.length; |
343 if (col && col + len >= 72) { | 343 if (col && col + len >= 72) { |
344 gen.output ~= format_ctfe("\"\n \""); | 344 gen.output ~= format_ctfe("\"\n \""); |
345 col = 0; | 345 col = 0; |
351 while (idx < s.length) { | 351 while (idx < s.length) { |
352 if (idx > 0) { | 352 if (idx > 0) { |
353 col = 0; | 353 col = 0; |
354 gen.output ~= format_ctfe("\"\n \""); | 354 gen.output ~= format_ctfe("\"\n \""); |
355 } | 355 } |
356 int spanLen = qMin(cast(uint)70, s.length - idx); | 356 sizediff_t spanLen = qMin(cast(size_t)70, s.length - idx); |
357 // don't cut escape sequences at the end of a line | 357 // don't cut escape sequences at the end of a line |
358 int backSlashPos = s.lastIndexOf("\\", idx + spanLen - 1); | 358 auto backSlashPos = s.lastIndexOf("\\", idx + spanLen - 1); |
359 if (backSlashPos >= idx) { | 359 if (backSlashPos >= idx) { |
360 int escapeLen = lengthOfEscapeSequence(s, backSlashPos); | 360 auto escapeLen = lengthOfEscapeSequence(s, backSlashPos); |
361 spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, cast(int)(s.length - idx)); | 361 spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, cast(sizediff_t)(s.length - idx)); |
362 } | 362 } |
363 gen.output ~= s[idx..idx+spanLen]; | 363 gen.output ~= s[idx..idx+spanLen]; |
364 idx += spanLen; | 364 idx += spanLen; |
365 col += spanLen; | 365 col += spanLen; |
366 } | 366 } |