Changeset 446

Show
Ignore:
Timestamp:
10/14/08 04:27:51 (1 month ago)
Author:
FeepingCreature
Message:
  • Stuff.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/tools/base.d

    r435 r446  
    11module tools.base; 
    22 
    3 version(Tango) public import std.compat; 
     3// version(Tango) public import std.compat; 
    44 
    55public import tools.smart_import; 
     
    510510    " 
    511511  )~"} 
    512   const _"~NAME~" "~NAME~"; "; 
     512  /*const .. not needed*/_"~NAME~" "~NAME~"; "; 
    513513} 
    514514 
     
    13371337} 
    13381338 
     1339int 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 
    13391346string SwitchCaseFn(string code) { 
    13401347  int arrowpos = ctFind(code, "->"); 
  • trunk/tools/tools/fixed_socket.d

    r405 r446  
    11module tools.fixed_socket; 
    22 
    3 version(Tango) import std.compat; 
     3// version(Tango) import std.compat; 
    44 
    55public import std.socket; 
  • trunk/tools/tools/ini.d

    r405 r446  
    11module tools.ini; 
    2 import std.file, std.string
     2import std.string, std.file: file_read = read, file_write = write
    33 
    44/* 
     
    5656  private { 
    5757    void read() { 
    58       auto _lines=(cast(string).read(name)).split("\n"); 
     58      auto _lines=(cast(string)name.file_read()).split("\n"); 
    5959      foreach (line; _lines) if (line.length) lines~=line; 
    6060    } 
    6161    void save() { 
    6262      string res; foreach (line; lines) res~=line~"\n"; 
    63       write(name, res); 
     63      name.file_write(res); 
    6464    } 
    6565    size_t findEntry(string section, string label) { 
  • trunk/tools/tools/mersenne.d

    r417 r446  
    44const MATRIX_A=0x9908b0dfUL, UPPER_MASK=0x80000000UL, LOWER_MASK=0x7fffffffUL; 
    55 
    6 import tools.downloader, tools.base
     6import tools.downloader, tools.base, tools.log
    77ubyte[] get_hotbits(int count) { 
    88  ubyte[] res; 
  • trunk/tools/tools/rd.d

    r436 r446  
    5050    CLOSE_LITERAL = ") && ((s = scratch), true); }"; 
    5151  res = OPEN_LITERAL; 
     52  bool escape_mode; 
    5253  for (int i = 0; i < expr.length; ++i) { 
    5354    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    } 
    5464    // if it's the last character, as well as a normal text character: closing tokens don't count 
    5565    // in this case, we're just using the flush. 
    5666    // 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) { 
    5969      // flush 
    6070      tokenBuf = ctStrip(tokenBuf); 
     
    6373        tokenBuf = ""; 
    6474      } 
    65       if (ctFind("[{", ""~expr[i]) != -1) stack ~= expr[i]; 
     75      if (ctFind("[{", expr[i]) != -1) stack ~= expr[i]; 
    6676    } 
    6777    if (expr[i] == '[') { 
     
    114124  return 
    115125"{ 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()); 
    117127}"; 
    118128} 
     
    122132    Params!(typeof(got"~name~"))[1] res; 
    123133    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()); 
    125135    return res; 
    126136  }"; 
  • trunk/tools/tools/tests.d

    r244 r446  
    11module tools.tests; 
    2 import tools.base, tools.log; 
     2import tools.base; 
     3public import tools.log; 
    34 
    45size_t passed, failed; 
     
    2021} 
    2122 
    22 struct Δ(T) { T ÎŽ; } struct delta { static Δ!(T) opAssign(T)(T ÎŽ) { return Δ!(T)(ÎŽ); } } 
     23struct DeltaHolder(T) { T sigma; } 
     24struct delta { static DeltaHolder!(T) opAssign(T)(T s) { return DeltaHolder!(T)(s); } } 
    2325 
    2426string formatTuple(T...)(T stufs) { 
     
    4850void mustEqual(T...)(char[] name, T stuffs) { 
    4951  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; 
    5254    foreach (thingie; stuffs[1..$-1]) { 
    5355      if (thingie<lower) lower=thingie; 
    5456      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)); 
    5759    } 
    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))); 
    5961  } else { 
    6062    foreach (thing; stuffs[0..$-1]) if (unequal(thing, stuffs[$-1])) 
  • trunk/tools/tools/threads.d

    r435 r446  
    298298} 
    299299 
     300import tools.log; 
    300301class MessageMultiChannel(T, bool SingleGet, bool SinglePut) { 
    301302  private {