Changeset 446
- Timestamp:
- 10/14/08 04:27:51 (1 month ago)
- Files:
-
- trunk/tools/tools/base.d (modified) (3 diffs)
- trunk/tools/tools/fixed_socket.d (modified) (1 diff)
- trunk/tools/tools/ini.d (modified) (2 diffs)
- trunk/tools/tools/mersenne.d (modified) (1 diff)
- trunk/tools/tools/rd.d (modified) (4 diffs)
- trunk/tools/tools/tests.d (modified) (3 diffs)
- trunk/tools/tools/threads.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tools/tools/base.d
r435 r446 1 1 module tools.base; 2 2 3 version(Tango) public import std.compat;3 // version(Tango) public import std.compat; 4 4 5 5 public import tools.smart_import; … … 510 510 " 511 511 )~"} 512 const_"~NAME~" "~NAME~"; ";512 /*const .. not needed*/_"~NAME~" "~NAME~"; "; 513 513 } 514 514 … … 1337 1337 } 1338 1338 1339 int ctFind(string text, char match) { 1340 for (int i = 0; i < text.length; ++i) { 1341 if (text[i] == match) return i; 1342 } 1343 return -1; 1344 } 1345 1339 1346 string SwitchCaseFn(string code) { 1340 1347 int arrowpos = ctFind(code, "->"); trunk/tools/tools/fixed_socket.d
r405 r446 1 1 module tools.fixed_socket; 2 2 3 version(Tango) import std.compat;3 // version(Tango) import std.compat; 4 4 5 5 public import std.socket; trunk/tools/tools/ini.d
r405 r446 1 1 module tools.ini; 2 import std. file, std.string;2 import std.string, std.file: file_read = read, file_write = write; 3 3 4 4 /* … … 56 56 private { 57 57 void read() { 58 auto _lines=(cast(string) .read(name)).split("\n");58 auto _lines=(cast(string)name.file_read()).split("\n"); 59 59 foreach (line; _lines) if (line.length) lines~=line; 60 60 } 61 61 void save() { 62 62 string res; foreach (line; lines) res~=line~"\n"; 63 write(name,res);63 name.file_write(res); 64 64 } 65 65 size_t findEntry(string section, string label) { trunk/tools/tools/mersenne.d
r417 r446 4 4 const MATRIX_A=0x9908b0dfUL, UPPER_MASK=0x80000000UL, LOWER_MASK=0x7fffffffUL; 5 5 6 import tools.downloader, tools.base ;6 import tools.downloader, tools.base, tools.log; 7 7 ubyte[] get_hotbits(int count) { 8 8 ubyte[] res; trunk/tools/tools/rd.d
r436 r446 50 50 CLOSE_LITERAL = ") && ((s = scratch), true); }"; 51 51 res = OPEN_LITERAL; 52 bool escape_mode; 52 53 for (int i = 0; i < expr.length; ++i) { 53 54 bool lastChar; 55 if (escape_mode) { 56 tokenBuf ~= expr[i]; 57 escape_mode = false; 58 continue; 59 } 60 if (expr[i] == '\\') { 61 escape_mode = true; 62 continue; 63 } 54 64 // if it's the last character, as well as a normal text character: closing tokens don't count 55 65 // in this case, we're just using the flush. 56 66 // evidently, if your last character is an opening token, you're Doing It Wrong. 57 if (i == expr.length - 1 && ctFind("$|]}", ""~expr[i]) == -1) { tokenBuf ~= expr[i]; lastChar = true; }58 if (ctFind("[{$|}]", ""~expr[i]) != -1 || lastChar) {67 if (i == expr.length - 1 && ctFind("$|]}", expr[i]) == -1) { tokenBuf ~= expr[i]; lastChar = true; } 68 if (ctFind("[{$|}]", expr[i]) != -1 || lastChar) { 59 69 // flush 60 70 tokenBuf = ctStrip(tokenBuf); … … 63 73 tokenBuf = ""; 64 74 } 65 if (ctFind("[{", ""~expr[i]) != -1) stack ~= expr[i];75 if (ctFind("[{", expr[i]) != -1) stack ~= expr[i]; 66 76 } 67 77 if (expr[i] == '[') { … … 114 124 return 115 125 "{ auto match = "~gotMatchExpr(expr)~"; 116 if (!match) throw new Exception( \"Expected `"~rest~"', got \"~"~var~".next_text());126 if (!match) throw new Exception(r\"Expected `"~rest~"', got \"~"~var~".next_text()); 117 127 }"; 118 128 } … … 122 132 Params!(typeof(got"~name~"))[1] res; 123 133 if (!got"~name~"(s, res)) 124 throw new ParseException( \"Expected \"~typeof(res).stringof~\", got \"~s.next_text());134 throw new ParseException(r\"Expected \"~typeof(res).stringof~\", got \"~s.next_text()); 125 135 return res; 126 136 }"; trunk/tools/tools/tests.d
r244 r446 1 1 module tools.tests; 2 import tools.base, tools.log; 2 import tools.base; 3 public import tools.log; 3 4 4 5 size_t passed, failed; … … 20 21 } 21 22 22 struct Î(T) { T ÎŽ; } struct delta { static Î!(T) opAssign(T)(T ÎŽ) { return Î!(T)(ÎŽ); } } 23 struct DeltaHolder(T) { T sigma; } 24 struct delta { static DeltaHolder!(T) opAssign(T)(T s) { return DeltaHolder!(T)(s); } } 23 25 24 26 string formatTuple(T...)(T stufs) { … … 48 50 void mustEqual(T...)(char[] name, T stuffs) { 49 51 static assert(T.length, "Cannot establish equality without things to compare"); 50 static if (is(typeof(T[$-1]. ÎŽ))) {51 typeof(T[$-1]. ÎŽ) lower=stuffs[0], upper=lower;52 static if (is(typeof(T[$-1].sigma))) { 53 typeof(T[$-1].sigma) lower=stuffs[0], upper=lower; 52 54 foreach (thingie; stuffs[1..$-1]) { 53 55 if (thingie<lower) lower=thingie; 54 56 if (thingie>upper) upper=thingie; 55 if (upper-lower>stuffs[$-1]. ÎŽ)56 throw new Exception(Format(name, ": fail, value ", thingie, " violated delta of ", stuffs[$-1]. ÎŽ));57 if (upper-lower>stuffs[$-1].sigma) 58 throw new Exception(Format(name, ": fail, value ", thingie, " violated delta of ", stuffs[$-1].sigma)); 57 59 } 58 logln(logResult(name, true, Format("Parameters ", formatTuple(stuffs[0..$-1]), " are equal within delta of ", stuffs[$-1]. ÎŽ)));60 logln(logResult(name, true, Format("Parameters ", formatTuple(stuffs[0..$-1]), " are equal within delta of ", stuffs[$-1].sigma))); 59 61 } else { 60 62 foreach (thing; stuffs[0..$-1]) if (unequal(thing, stuffs[$-1])) trunk/tools/tools/threads.d
r435 r446 298 298 } 299 299 300 import tools.log; 300 301 class MessageMultiChannel(T, bool SingleGet, bool SinglePut) { 301 302 private {
