From 01df2f60bed66fd28d488e03bf4193a856cb1a3e Mon Sep 17 00:00:00 2001 From: k-hara Date: Fri, 23 Nov 2012 14:45:51 +0900 Subject: [PATCH] Remove redundant parenthesis for getters, and use assignment syntax for setters --- std/algorithm.d | 10 ++--- std/bitmanip.d | 2 +- std/container.d | 10 ++--- std/conv.d | 2 +- std/cpuid.d | 6 +-- std/cstream.d | 12 +++--- std/csv.d | 2 +- std/datetime.d | 20 +++++----- std/exception.d | 2 +- std/file.d | 2 +- std/format.d | 18 ++++----- std/internal/uni.d | 2 +- std/json.d | 10 ++--- std/math.d | 8 ++-- std/net/curl.d | 64 +++++++++++++++--------------- std/parallelism.d | 44 ++++++++++----------- std/path.d | 2 +- std/process.d | 2 +- std/random.d | 4 +- std/range.d | 23 ++++++----- std/regex.d | 4 +- std/socket.d | 6 +-- std/stdio.d | 2 +- std/stream.d | 98 +++++++++++++++++++++++----------------------- std/typecons.d | 2 +- std/uuid.d | 4 +- std/variant.d | 12 +++--- unittest.d | 4 +- 28 files changed, 188 insertions(+), 189 deletions(-) diff --git a/std/algorithm.d b/std/algorithm.d index 619eb5016..be5847f77 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -1275,11 +1275,11 @@ unittest auto under10 = filter!("a < 10")(a); assert(equal(under10, [1, 3, 5][])); static assert(isForwardRange!(typeof(under10))); - under10.front() = 4; + under10.front = 4; assert(equal(under10, [4, 3, 5][])); - under10.front() = 40; + under10.front = 40; assert(equal(under10, [40, 3, 5][])); - under10.front() = 1; + under10.front = 1; auto infinite = filter!"a > 2"(repeat(3)); static assert(isInfinite!(typeof(infinite))); @@ -2747,7 +2747,7 @@ unittest // joiner allows in-place mutation! auto a = [ [1, 2, 3], [42, 43] ]; auto j = joiner(a); - j.front() = 44; + j.front = 44; assert(a == [ [44, 2, 3], [42, 43] ]); // bugzilla 8240 @@ -7737,7 +7737,7 @@ void schwartzSort(alias transform, alias less = "a < b", xform[i] = transform(e); } auto z = zip(xform, r); - alias typeof(z.front()) ProxyType; + alias typeof(z.front) ProxyType; bool myLess(ProxyType a, ProxyType b) { return binaryFun!less(a[0], b[0]); diff --git a/std/bitmanip.d b/std/bitmanip.d index 2d7775587..6f1ef5764 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -1385,7 +1385,7 @@ struct BitArray { BitArray r; - r = this.dup(); + r = this.dup; r ~= b; return r; } diff --git a/std/container.d b/std/container.d index 43725d0c0..6edb55848 100644 --- a/std/container.d +++ b/std/container.d @@ -3796,8 +3796,8 @@ the heap work incorrectly. void acquire(Store s, size_t initialSize = size_t.max) { _payload.refCountedStore.ensureInitialized(); - _store() = move(s); - _length() = min(_store.length, initialSize); + _store = move(s); + _length = min(_store.length, initialSize); if (_length < 2) return; for (auto i = (_length - 2) / 2; ; ) { @@ -3814,8 +3814,8 @@ heap. void assume(Store s, size_t initialSize = size_t.max) { _payload.refCountedStore.ensureInitialized(); - _store() = s; - _length() = min(_store.length, initialSize); + _store = s; + _length = min(_store.length, initialSize); assertValid(); } @@ -4557,7 +4557,7 @@ struct Array(T) if (is(T == bool)) */ T removeAny() { - auto result = back(); + auto result = back; removeBack(); return result; } diff --git a/std/conv.d b/std/conv.d index 4a194962f..0415db2c3 100644 --- a/std/conv.d +++ b/std/conv.d @@ -3065,7 +3065,7 @@ Target parseElement(Target, Source)(ref Source s) result.put(parseEscape(s)); break; default: - result.put(s.front()); + result.put(s.front); s.popFront(); break; } diff --git a/std/cpuid.d b/std/cpuid.d index c006ff700..5db98931d 100644 --- a/std/cpuid.d +++ b/std/cpuid.d @@ -79,8 +79,8 @@ version(D_InlineAsm_X86) "Signature: Family=%d Model=%d Stepping=%d\n"~ "Features: %s\n"~ "Multithreading: %d threads / %d cores\n", - vendor(), - processor(), + vendor, + processor, family, model, stepping, feats, threadsPerCPU, coresPerCPU); @@ -141,7 +141,7 @@ version(D_InlineAsm_X86) shared static this() { - switch (vendor()) + switch (vendor) { case "GenuineIntel": manufac = INTEL; diff --git a/std/cstream.d b/std/cstream.d index 5209d1e81..923272478 100644 --- a/std/cstream.d +++ b/std/cstream.d @@ -160,9 +160,9 @@ class CFile : Stream { file.write(i); // string#1 + string#2 + int should give exacly that version (Windows) - assert(file.position() == 19 + 13 + 4); + assert(file.position == 19 + 13 + 4); version (Posix) - assert(file.position() == 18 + 13 + 4); + assert(file.position == 18 + 13 + 4); file.close(); // no operations are allowed when file is closed assert(!file.readable && !file.writeable && !file.seekable); @@ -178,17 +178,17 @@ class CFile : Stream { // jump over "Hello, " file.seek(7, SeekPos.Current); version (Windows) - assert(file.position() == 19 + 7); + assert(file.position == 19 + 7); version (Posix) - assert(file.position() == 18 + 7); + assert(file.position == 18 + 7); assert(!std.algorithm.cmp(file.readString(6), "world!")); i = 0; file.read(i); assert(i == 666); // string#1 + string#2 + int should give exacly that version (Windows) - assert(file.position() == 19 + 13 + 4); + assert(file.position == 19 + 13 + 4); version (Posix) - assert(file.position() == 18 + 13 + 4); + assert(file.position == 18 + 13 + 4); // we must be at the end of file file.close(); f = fopen("stream.txt","w+"); diff --git a/std/csv.d b/std/csv.d index 9d4363ecb..3ad2ec4b7 100644 --- a/std/csv.d +++ b/std/csv.d @@ -687,7 +687,7 @@ unittest @property auto empty() { - return text.empty(); + return text.empty; } auto popFront() diff --git a/std/datetime.d b/std/datetime.d index c8493a5fa..1d72754f5 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -485,7 +485,7 @@ public: @safe static @property TickDuration currSystemTick() { - return TickDuration.currSystemTick(); + return TickDuration.currSystemTick; } version(testStdDateTime) unittest @@ -29275,7 +29275,7 @@ assert(tz.dstName == "PDT"); foreach(ref inUTC; transitionInUTC) inUTC = readVal!bool(tzFile); - _enforceValidTZFile(!tzFile.eof()); + _enforceValidTZFile(!tzFile.eof); //If version 2, the information is duplicated in 64-bit. if(tzFileVersion == '2') @@ -29365,12 +29365,12 @@ assert(tz.dstName == "PDT"); inUTC = readVal!bool(tzFile); } - _enforceValidTZFile(tzFile.readln().strip().empty()); + _enforceValidTZFile(tzFile.readln().strip().empty); auto posixEnvStr = tzFile.readln().strip(); - _enforceValidTZFile(tzFile.readln().strip().empty()); - _enforceValidTZFile(tzFile.eof()); + _enforceValidTZFile(tzFile.readln().strip().empty); + _enforceValidTZFile(tzFile.eof); auto transitionTypes = new TransitionType*[](tempTTInfos.length); @@ -29505,7 +29505,7 @@ assert(tz.dstName == "PDT"); { auto tzName = dentry.name[tzDatabaseDir.length .. $]; - if(!tzName.extension().empty() || + if(!tzName.extension().empty || !tzName.startsWith(subName) || tzName == "+VERSION") { @@ -29684,7 +29684,7 @@ private: import std.bitmanip; T[1] buff; - _enforceValidTZFile(!tzFile.eof()); + _enforceValidTZFile(!tzFile.eof); tzFile.rawRead(buff); return bigEndianToNative!T(cast(ubyte[T.sizeof])buff); @@ -29698,7 +29698,7 @@ private: { auto buff = new T(length); - _enforceValidTZFile(!tzFile.eof()); + _enforceValidTZFile(!tzFile.eof); tzFile.rawRead(buff); return buff; @@ -30093,7 +30093,7 @@ else version(Windows) otherTime.wMinute, otherTime.wSecond); immutable diff = utcDateTime - otherDateTime; - immutable minutes = diff.total!"minutes"() - tzInfo.Bias; + immutable minutes = diff.total!"minutes" - tzInfo.Bias; if(minutes == tzInfo.DaylightBias) return true; @@ -30185,7 +30185,7 @@ else version(Windows) utcTime.wSecond); immutable diff = localDateTime - utcDateTime; - immutable minutes = -tzInfo.Bias - diff.total!"minutes"(); + immutable minutes = -tzInfo.Bias - diff.total!"minutes"; if(minutes == tzInfo.DaylightBias) return true; diff --git a/std/exception.d b/std/exception.d index 06147916c..6d6759c8f 100644 --- a/std/exception.d +++ b/std/exception.d @@ -999,7 +999,7 @@ class ErrnoException : Exception uint errno; // operating system error code this(string msg, string file = null, size_t line = 0) { - errno = .errno(); + errno = .errno; version (linux) { char[1024] buf = void; diff --git a/std/file.d b/std/file.d index 4d6bc5e9f..336f51aae 100644 --- a/std/file.d +++ b/std/file.d @@ -2182,7 +2182,7 @@ void rmdirRecurse(ref DirEntry de) if(!de.isDir) throw new FileException(text("File ", de.name, " is not a directory")); - if(de.isSymlink()) + if(de.isSymlink) remove(de.name); else { diff --git a/std/format.d b/std/format.d index 7ac9be2cc..cfdc180f2 100644 --- a/std/format.d +++ b/std/format.d @@ -1811,7 +1811,7 @@ unittest { string value; const @property bool empty(){ return !value.length; } - const @property dchar front(){ return value.front(); } + const @property dchar front(){ return value.front; } void popFront(){ value.popFront(); } const @property size_t length(){ return value.length; } @@ -2103,7 +2103,7 @@ if (isSomeString!T && !is(T == enum)) formatChar(app, c, '"'); } put(app, '\"'); - put(w, app.data()); + put(w, app.data); return; } catch (UTFException) @@ -4645,10 +4645,10 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) */ void putArray(void* p, size_t len, TypeInfo valti) { - //printf("\nputArray(len = %u), tsize = %u\n", len, valti.tsize()); + //printf("\nputArray(len = %u), tsize = %u\n", len, valti.tsize); putc('['); valti = skipCI(valti); - size_t tsize = valti.tsize(); + size_t tsize = valti.tsize; auto argptrSave = argptr; auto tiSave = ti; auto mSave = m; @@ -4753,7 +4753,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) else version (Win64) { void* q2 = void; - auto valuesize = valti.tsize(); + auto valuesize = valti.tsize; if (valuesize > 8 && m != Mangle.Tsarray) { q2 = pvalue; argptr = &q2; @@ -5012,12 +5012,12 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) version(X86) { s = tis.xtoString(argptr); - argptr += (tis.tsize() + 3) & ~3; + argptr += (tis.tsize + 3) & ~3; } else version(Win64) { void* p = argptr; - if (tis.tsize() > 8) + if (tis.tsize > 8) p = *cast(void**)p; s = tis.xtoString(p); argptr += size_t.sizeof; @@ -5026,7 +5026,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) { void[32] parmn = void; // place to copy struct if passed in regs void* p; - auto tsize = tis.tsize(); + auto tsize = tis.tsize; TypeInfo arg1, arg2; if (!tis.argTypes(arg1, arg2)) // if could be passed in regs { assert(tsize <= parmn.length); @@ -5038,7 +5038,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) * it always being passed in memory */ // The arg may have more strict alignment than the stack - auto talign = tis.talign(); + auto talign = tis.talign; __va_list* ap = cast(__va_list*)argptr; p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1)); ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); diff --git a/std/internal/uni.d b/std/internal/uni.d index 19c494e6c..42fd35378 100644 --- a/std/internal/uni.d +++ b/std/internal/uni.d @@ -633,7 +633,7 @@ unittest @system unittest { import std.conv, std.random, std.range; - immutable seed = unpredictableSeed(); + immutable seed = unpredictableSeed; auto rnd = Random(seed); auto testCases = randomSample(unicodeProperties, 10, rnd); diff --git a/std/json.d b/std/json.d index e452c9ef6..fc0014223 100644 --- a/std/json.d +++ b/std/json.d @@ -89,7 +89,7 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) { JSONValue root = void; root.type = JSON_TYPE.NULL; - if(json.empty()) return root; + if(json.empty) return root; int depth = -1; dchar next = 0; @@ -101,8 +101,8 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) { dchar peekChar() { if(!next) { - if(json.empty()) return '\0'; - next = json.front(); + if(json.empty) return '\0'; + next = json.front; json.popFront(); } return next; @@ -121,8 +121,8 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) { next = 0; } else { - if(json.empty()) error("Unexpected end of data."); - c = json.front(); + if(json.empty) error("Unexpected end of data."); + c = json.front; json.popFront(); } diff --git a/std/math.d b/std/math.d index cc19ba0db..a8a14c641 100644 --- a/std/math.d +++ b/std/math.d @@ -1512,9 +1512,9 @@ unittest f = ieeeFlags; assert(x == exptestpoints[i][1]); // Check the overflow bit - assert(f.overflow() == (fabs(x) == real.infinity)); + assert(f.overflow == (fabs(x) == real.infinity)); // Check the underflow bit - assert(f.underflow() == (fabs(x) < real.min_normal)); + assert(f.underflow == (fabs(x) < real.min_normal)); // Invalid and div by zero shouldn't be affected. assert(!f.invalid); assert(!f.divByZero); @@ -2827,7 +2827,7 @@ unittest FloatingPointControl ctrl; ctrl.enableExceptions(FloatingPointControl.divByZeroException | FloatingPointControl.overflowException); - assert(ctrl.enabledExceptions() == + assert(ctrl.enabledExceptions == (FloatingPointControl.divByZeroException | FloatingPointControl.overflowException)); @@ -2836,7 +2836,7 @@ unittest } assert(FloatingPointControl.rounding == FloatingPointControl.roundToNearest); - assert(FloatingPointControl.enabledExceptions() ==0); + assert(FloatingPointControl.enabledExceptions ==0); } diff --git a/std/net/curl.d b/std/net/curl.d index e6ad899b1..3ab3d53f8 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -977,12 +977,12 @@ unittest { if (!netAllowed()) return; auto res = byLine(testUrl1); - auto line = res.front(); + auto line = res.front; assert(line == "Hello world", "byLine!HTTP() returns unexpected content: " ~ line); auto res2 = byLine(testUrl1, KeepTerminator.no, '\n', HTTP()); - line = res2.front(); + line = res2.front; assert(line == "Hello world", "byLine!HTTP() returns unexpected content: " ~ line); } @@ -1052,12 +1052,12 @@ unittest if (!netAllowed()) return; auto res = byChunk(testUrl1); - auto line = res.front(); + auto line = res.front; assert(line == cast(ubyte[])"Hello world\n", "byLineAsync!HTTP() returns unexpected content " ~ to!string(line)); auto res2 = byChunk(testUrl1, 1024, HTTP()); - line = res2.front(); + line = res2.front; assert(line == cast(ubyte[])"Hello world\n", "byLineAsync!HTTP() returns unexpected content: " ~ to!string(line)); } @@ -1346,11 +1346,11 @@ unittest { if (!netAllowed()) return; auto res = byLineAsync(testUrl2, "Hello world"); - auto line = res.front(); + auto line = res.front; assert(line == "Hello world", "byLineAsync!HTTP() returns unexpected content " ~ line); res = byLineAsync(testUrl1); - line = res.front(); + line = res.front; assert(line == "Hello world", "byLineAsync!HTTP() returns unexpected content: " ~ line); } @@ -1497,11 +1497,11 @@ unittest { if (!netAllowed()) return; auto res = byChunkAsync(testUrl2, "Hello world"); - auto line = res.front(); + auto line = res.front; assert(line == cast(ubyte[])"Hello world", "byLineAsync!HTTP() returns unexpected content " ~ to!string(line)); res = byChunkAsync(testUrl1); - line = res.front(); + line = res.front; assert(line == cast(ubyte[])"Hello world\n", "byLineAsync!HTTP() returns unexpected content: " ~ to!string(line)); } @@ -1607,7 +1607,7 @@ private mixin template Protocol() @property void dataTimeout(Duration d) { p.curl.set(CurlOption.low_speed_limit, 1); - p.curl.set(CurlOption.low_speed_time, d.total!"seconds"()); + p.curl.set(CurlOption.low_speed_time, d.total!"seconds"); } /** Set maximum time an operation is allowed to take. @@ -1615,13 +1615,13 @@ private mixin template Protocol() */ @property void operationTimeout(Duration d) { - p.curl.set(CurlOption.timeout_ms, d.total!"msecs"()); + p.curl.set(CurlOption.timeout_ms, d.total!"msecs"); } /// Set timeout for connecting. @property void connectTimeout(Duration d) { - p.curl.set(CurlOption.connecttimeout_ms, d.total!"msecs"()); + p.curl.set(CurlOption.connecttimeout_ms, d.total!"msecs"); } // Network settings @@ -1656,7 +1656,7 @@ private mixin template Protocol() /// DNS lookup timeout. @property void dnsTimeout(Duration d) { - p.curl.set(CurlOption.dns_cache_timeout, d.total!"msecs"()); + p.curl.set(CurlOption.dns_cache_timeout, d.total!"msecs"); } /** @@ -1679,13 +1679,13 @@ private mixin template Protocol() @property void netInterface(const(ubyte)[4] i) { auto str = format("%d.%d.%d.%d", i[0], i[1], i[2], i[3]); - netInterface(str); + netInterface = str; } /// ditto @property void netInterface(InternetAddress i) { - netInterface(i.toAddrString()); + netInterface = i.toAddrString(); } /** @@ -1786,7 +1786,7 @@ private mixin template Protocol() @property void onSend(size_t delegate(void[]) callback) { p.curl.clear(CurlOption.postfields); // cannot specify data when using callback - p.curl.onSend(callback); + p.curl.onSend = callback; } /** @@ -1814,7 +1814,7 @@ private mixin template Protocol() */ @property void onReceive(size_t delegate(ubyte[]) callback) { - p.curl.onReceive(callback); + p.curl.onReceive = callback; } /** @@ -1845,7 +1845,7 @@ private mixin template Protocol() @property void onProgress(int delegate(size_t dlTotal, size_t dlNow, size_t ulTotal, size_t ulNow) callback) { - p.curl.onProgress(callback); + p.curl.onProgress = callback; } } @@ -2062,7 +2062,7 @@ struct HTTP copy.p.curl.set(CurlOption.httpheader, copy.p.headersOut); copy.p.curl = p.curl.dup(); copy.dataTimeout = _defaultDataTimeout; - copy.onReceiveHeader(null); + copy.onReceiveHeader = null; return copy; } @@ -2073,8 +2073,8 @@ struct HTTP p.charset = "ISO-8859-1"; // Default charset defined in HTTP RFC p.method = Method.undefined; dataTimeout = _defaultDataTimeout; - onReceiveHeader(null); - version (unittest) verbose(true); + onReceiveHeader = null; + version (unittest) verbose = true; } /** @@ -2576,7 +2576,7 @@ struct HTTP callback(fieldName, m.captures[2]); p.headersIn[fieldName] = m.captures[2].idup; }; - p.curl.onReceiveHeader(dg); + p.curl.onReceiveHeader = dg; } /** @@ -2763,7 +2763,7 @@ struct FTP p.curl.initialize(); p.encoding = "ISO-8859-1"; dataTimeout = _defaultDataTimeout; - version (unittest) verbose(true); + version (unittest) verbose = true; } /** @@ -3949,7 +3949,7 @@ private static size_t _receiveAsyncChunks(ubyte[] data, ref ubyte[] outdata, data = data[copyBytes..$]; if (outdata.empty) - fromTid.send(thisTid(), curlMessage(cast(immutable(ubyte)[])buffer)); + fromTid.send(thisTid, curlMessage(cast(immutable(ubyte)[])buffer)); } return datalen; @@ -3963,7 +3963,7 @@ private static void _finalizeAsyncChunks(ubyte[] outdata, ref ubyte[] buffer, { // Resize the last buffer buffer.length = buffer.length - outdata.length; - fromTid.send(thisTid(), curlMessage(cast(immutable(ubyte)[])buffer)); + fromTid.send(thisTid, curlMessage(cast(immutable(ubyte)[])buffer)); } } @@ -4021,17 +4021,17 @@ private static size_t _receiveAsyncLines(Terminator, Unit) { if (keepTerminator) { - fromTid.send(thisTid(), + fromTid.send(thisTid, curlMessage(cast(immutable(Unit)[])buffer)); } else { static if (isArray!Terminator) - fromTid.send(thisTid(), + fromTid.send(thisTid, curlMessage(cast(immutable(Unit)[]) buffer[0..$-terminator.length])); else - fromTid.send(thisTid(), + fromTid.send(thisTid, curlMessage(cast(immutable(Unit)[]) buffer[0..$-1])); } @@ -4067,7 +4067,7 @@ private static void _finalizeAsyncLines(Unit)(bool bufferValid, Unit[] buffer, Tid fromTid) { if (bufferValid && buffer.length != 0) - fromTid.send(thisTid(), curlMessage(cast(immutable(Unit)[])buffer[0..$])); + fromTid.send(thisTid, curlMessage(cast(immutable(Unit)[])buffer[0..$])); } @@ -4150,7 +4150,7 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)() catch (Exception ex) { prioritySend(fromTid, cast(immutable(Exception)) ex); - fromTid.send(thisTid(), curlMessage(true)); // signal done + fromTid.send(thisTid, curlMessage(true)); // signal done return; } @@ -4159,13 +4159,13 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)() if (aborted && (code == CurlError.aborted_by_callback || code == CurlError.write_error)) { - fromTid.send(thisTid(), curlMessage(true)); // signal done + fromTid.send(thisTid, curlMessage(true)); // signal done return; } prioritySend(fromTid, cast(immutable(CurlException)) new CurlException(client.p.curl.errorString(code))); - fromTid.send(thisTid(), curlMessage(true)); // signal done + fromTid.send(thisTid, curlMessage(true)); // signal done return; } @@ -4175,7 +4175,7 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)() else _finalizeAsyncLines(bufferValid, buffer, fromTid); - fromTid.send(thisTid(), curlMessage(true)); // signal done + fromTid.send(thisTid, curlMessage(true)); // signal done } version (unittest) private auto netAllowed() diff --git a/std/parallelism.d b/std/parallelism.d index a9025286c..482ab3d69 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -721,7 +721,7 @@ AbstractTask base = {runTask : stderr.writeln("Yield from workForce."); } - return yieldForce(); + return yieldForce; } } } @@ -761,7 +761,7 @@ AbstractTask base = {runTask : { if(isScoped && pool !is null && taskStatus != TaskStatus.done) { - yieldForce(); + yieldForce; } } @@ -802,7 +802,7 @@ void main() auto file2Data = read("bar.txt"); // Get the results of reading foo.txt. - auto file1Data = file1Task.yieldForce(); + auto file1Data = file1Task.yieldForce; } --- @@ -840,7 +840,7 @@ void parallelSort(T)(T[] data) auto recurseTask = task!(parallelSort)(greaterEqual); taskPool.put(recurseTask); parallelSort(less); - recurseTask.yieldForce(); + recurseTask.yieldForce; } --- */ @@ -871,7 +871,7 @@ void main() auto file2Data = read("bar.txt"); // Get the results of reading foo.txt. - auto file1Data = file1Task.yieldForce(); + auto file1Data = file1Task.yieldForce; } --- @@ -2042,7 +2042,7 @@ public: } buf2 = buf1; - buf1 = nextBufTask.yieldForce(); + buf1 = nextBufTask.yieldForce; bufPos = 0; if(source.empty) @@ -2222,7 +2222,7 @@ public: } buf2 = buf1; - buf1 = nextBufTask.yieldForce(); + buf1 = nextBufTask.yieldForce; bufPos = 0; if(source.empty) @@ -2714,7 +2714,7 @@ public: { try { - task.yieldForce(); + task.yieldForce; } catch(Throwable e) { @@ -3232,7 +3232,7 @@ public: { queueLock(); scope(exit) queueUnlock(); - return (size == 0) ? true : pool[0].isDaemon(); + return (size == 0) ? true : pool[0].isDaemon; } /// Ditto @@ -3258,7 +3258,7 @@ public: int priority() @property @trusted { return (size == 0) ? core.thread.Thread.PRIORITY_MIN : - pool[0].priority(); + pool[0].priority; } /// Ditto @@ -3268,7 +3268,7 @@ public: { foreach(t; pool) { - t.priority(newPriority); + t.priority = newPriority; } } } @@ -3466,7 +3466,7 @@ private void submitAndExecute( { try { - task.yieldForce(); + task.yieldForce; } catch(Throwable e) { @@ -3951,29 +3951,29 @@ unittest // Test task(). auto t = task!refFun(x); poolInstance.put(t); - t.yieldForce(); + t.yieldForce; assert(t.args[0] == 1); auto t2 = task(&refFun, x); poolInstance.put(t2); - t2.yieldForce(); + t2.yieldForce; assert(t2.args[0] == 1); // Test scopedTask(). auto st = scopedTask!refFun(x); poolInstance.put(st); - st.yieldForce(); + st.yieldForce; assert(st.args[0] == 1); auto st2 = scopedTask(&refFun, x); poolInstance.put(st2); - st2.yieldForce(); + st2.yieldForce; assert(st2.args[0] == 1); // Test executeInNewThread(). auto ct = scopedTask!refFun(x); ct.executeInNewThread(Thread.PRIORITY_MAX); - ct.yieldForce(); + ct.yieldForce; assert(ct.args[0] == 1); // Test ref return. @@ -3998,11 +3998,11 @@ unittest auto safePool = new TaskPool(0); auto t = task(&bump, 1); taskPool.put(t); - assert(t.yieldForce() == 2); + assert(t.yieldForce == 2); auto st = scopedTask(&bump, 1); taskPool.put(st); - assert(st.yieldForce() == 2); + assert(st.yieldForce == 2); safePool.stop(); } @@ -4032,8 +4032,8 @@ unittest auto addScopedTask = scopedTask(&add, addLhs, addRhs); poolInstance.put(addTask); poolInstance.put(addScopedTask); - assert(addTask.yieldForce() == 3); - assert(addScopedTask.yieldForce() == 3); + assert(addTask.yieldForce == 3); + assert(addScopedTask.yieldForce == 3); // Test parallel foreach with non-random access range. auto range = filter!"a != 666"([0, 1, 2, 3, 4]); @@ -4117,7 +4117,7 @@ unittest pool1.put(tSlow); pool1.finish(); assert(!tSlow.done); - tSlow.yieldForce(); + tSlow.yieldForce; // Can't assert that pool1.status == PoolState.stopNow because status // doesn't change until after the "done" flag is set and the waiting // thread is woken up. diff --git a/std/path.d b/std/path.d index 60620371f..f99fcb7d1 100644 --- a/std/path.d +++ b/std/path.d @@ -1597,7 +1597,7 @@ unittest // save() auto ps1 = pathSplitter("foo/bar/baz"); - auto ps2 = ps1.save(); + auto ps2 = ps1.save; ps1.popFront(); assert (equal2(ps1, ["bar", "baz"])); assert (equal2(ps2, ["foo", "bar", "baz"])); diff --git a/std/process.d b/std/process.d index 01ca54ce2..a00749730 100644 --- a/std/process.d +++ b/std/process.d @@ -1076,7 +1076,7 @@ string escapeWindowsShellCommand(in char[] command) default: result.put(c); } - return result.data(); + return result.data; } private string escapeShellCommandString(string command) diff --git a/std/random.d b/std/random.d index 348cdcd17..57546691c 100644 --- a/std/random.d +++ b/std/random.d @@ -1030,11 +1030,11 @@ auto n = rnd.front; if (!seeded) { uint threadID = cast(uint) cast(void*) Thread.getThis(); - rand.seed((getpid() + threadID) ^ cast(uint) TickDuration.currSystemTick().length); + rand.seed((getpid() + threadID) ^ cast(uint) TickDuration.currSystemTick.length); seeded = true; } rand.popFront(); - return cast(uint) (TickDuration.currSystemTick().length ^ rand.front); + return cast(uint) (TickDuration.currSystemTick.length ^ rand.front); } unittest diff --git a/std/range.d b/std/range.d index 1aee7c06a..d39bd02c1 100644 --- a/std/range.d +++ b/std/range.d @@ -1004,7 +1004,7 @@ template ElementType(R) unittest { enum XYZ : string { a = "foo" } - auto x = front(XYZ.a); + auto x = XYZ.a.front; immutable char[3] a = "abc"; int[] i; void[] buf; @@ -1035,7 +1035,7 @@ template ElementEncodingType(R) unittest { enum XYZ : string { a = "foo" } - auto x = front(XYZ.a); + auto x = XYZ.a.front; immutable char[3] a = "abc"; int[] i; void[] buf; @@ -2487,7 +2487,7 @@ unittest { assert(rr.front == moveFront(rr)); } - r.front() = 5; + r.front = 5; assert(r.front == 5); // Test instantiation without lvalue elements. @@ -2528,7 +2528,6 @@ if (isInputRange!(Unqual!Range) public R source; private size_t _maxAvailable; - private enum bool byRef = is(typeof(&_input.front) == ElementType!(R)*); alias R Source; @@ -2631,7 +2630,7 @@ if (isInputRange!(Unqual!Range) auto back(ElementType!R v) { // This has to return auto instead of void because of Bug 4706. - assert(!empty, + assert(!empty, "Attempting to assign to the back of an empty " ~ Take.stringof); source[this.length - 1] = v; @@ -2650,7 +2649,7 @@ if (isInputRange!(Unqual!Range) { auto moveBack() { - assert(!empty, + assert(!empty, "Attempting to move the back of an empty " ~ Take.stringof); return .moveAt(source, this.length - 1); @@ -2824,7 +2823,7 @@ if (isInputRange!R && !hasSlicing!R) @property auto ref front() { assert(_n > 0, "front() on an empty " ~ Result.stringof); - return _input.front(); + return _input.front; } void popFront() { _input.popFront(); --_n; } @property size_t length() const { return _n; } @@ -5083,11 +5082,11 @@ unittest // unsigned reverse iota can be buggy if .length doesn't take them into // account (issue 7982). - assert(iota(10u, 0u, -1).length() == 10); - assert(iota(10u, 0u, -2).length() == 5); - assert(iota(uint.max, uint.max-10, -1).length() == 10); - assert(iota(uint.max, uint.max-10, -2).length() == 5); - assert(iota(uint.max, 0u, -1).length() == uint.max); + assert(iota(10u, 0u, -1).length == 10); + assert(iota(10u, 0u, -2).length == 5); + assert(iota(uint.max, uint.max-10, -1).length == 10); + assert(iota(uint.max, uint.max-10, -2).length == 5); + assert(iota(uint.max, 0u, -1).length == uint.max); } unittest diff --git a/std/regex.d b/std/regex.d index 26fb81384..fac990efe 100644 --- a/std/regex.d +++ b/std/regex.d @@ -1773,7 +1773,7 @@ struct Parser(R, bool CTFE=false) //try to generate optimal IR code for this CodepointSet @trusted void charsetToIr(in CodepointSet set) {//@@@BUG@@@ writeln is @system - uint chars = set.chars(); + uint chars = set.chars; if(chars < Bytecode.maxSequence) { switch(chars) @@ -6774,7 +6774,7 @@ private: public: auto ref opSlice() { - return this.save(); + return this.save; } ///Forward range primitives. diff --git a/std/socket.d b/std/socket.d index ff001e746..b52030461 100644 --- a/std/socket.d +++ b/std/socket.d @@ -1290,7 +1290,7 @@ abstract class Address /// Family of this address. @property AddressFamily addressFamily() const { - return cast(AddressFamily) name().sa_family; + return cast(AddressFamily) name.sa_family; } // Common code for toAddrString and toHostNameString @@ -2928,7 +2928,7 @@ public: version (Windows) { - auto msecs = to!int(value.total!"msecs"()); + auto msecs = to!int(value.total!"msecs"); if (msecs != 0 && option == SocketOption.RCVTIMEO) msecs = max(1, msecs - WINSOCK_TIMEOUT_SKEW); setOption(level, option, msecs); @@ -3013,7 +3013,7 @@ public: static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration timeout) { TimeVal tv; - tv.seconds = to!(tv.tv_sec_t )(timeout.total!"seconds"()); + tv.seconds = to!(tv.tv_sec_t )(timeout.total!"seconds"); tv.microseconds = to!(tv.tv_usec_t)(timeout.fracSec.usecs); return select(checkRead, checkWrite, checkError, &tv); } diff --git a/std/stdio.d b/std/stdio.d index 246614ffe..95ccf113d 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -851,7 +851,7 @@ with every line. */ size_t readln(C, R)(ref C[] buf, R terminator) if (isBidirectionalRange!R && is(typeof(terminator.front == buf[0]))) { - auto last = terminator.back(); + auto last = terminator.back; C[] buf2; swap(buf, buf2); for (;;) { diff --git a/std/stream.d b/std/stream.d index d5d9f6f01..55a9b8f8b 100644 --- a/std/stream.d +++ b/std/stream.d @@ -251,7 +251,7 @@ interface InputStream { * past the end. */ - bool eof(); + @property bool eof(); @property bool isOpen(); /// Return true if the stream is currently open. } @@ -560,7 +560,7 @@ class Stream : InputStream, OutputStream { int opApply(scope int delegate(ref char[] line) dg) { int res = 0; char[128] buf; - while (!eof()) { + while (!eof) { char[] line = readLine(buf); res = dg(line); if (res) break; @@ -573,7 +573,7 @@ class Stream : InputStream, OutputStream { int res = 0; ulong n = 1; char[128] buf; - while (!eof()) { + while (!eof) { auto line = readLine(buf); res = dg(n,line); if (res) break; @@ -586,7 +586,7 @@ class Stream : InputStream, OutputStream { int opApply(scope int delegate(ref wchar[] line) dg) { int res = 0; wchar[128] buf; - while (!eof()) { + while (!eof) { auto line = readLineW(buf); res = dg(line); if (res) break; @@ -599,7 +599,7 @@ class Stream : InputStream, OutputStream { int res = 0; ulong n = 1; wchar[128] buf; - while (!eof()) { + while (!eof) { auto line = readLineW(buf); res = dg(n,line); if (res) break; @@ -698,7 +698,7 @@ class Stream : InputStream, OutputStream { int j = 0; int count = 0, i = 0; char c = getc(); - while ((j < arguments.length || i < fmt.length) && !eof()) { + while ((j < arguments.length || i < fmt.length) && !eof) { if (fmt.length == 0 || i == fmt.length) { i = 0; if (arguments[j] is typeid(char[])) { @@ -994,7 +994,7 @@ class Stream : InputStream, OutputStream { c = getc(); count++; } - while (width-- && !eof()) { + while (width-- && !eof) { *(s++) = c; c = getc(); count++; @@ -1220,12 +1220,12 @@ class Stream : InputStream, OutputStream { void copyFrom(Stream s) { if (seekable) { ulong pos = s.position; - s.position(0); + s.position = 0; copyFrom(s, s.size); - s.position(pos); + s.position = pos; } else { ubyte[128] buf; - while (!s.eof()) { + while (!s.eof) { size_t m = s.readBlock(buf.ptr, buf.length); writeExact(buf.ptr, m); } @@ -1281,7 +1281,7 @@ class Stream : InputStream, OutputStream { @property ulong size() { assertSeekable(); ulong pos = position, result = seek(0, SeekPos.End); - position(pos); + position = pos; return result; } @@ -1328,8 +1328,8 @@ class Stream : InputStream, OutputStream { char[] result; if (seekable) { ulong orig_pos = position; - scope(exit) position(orig_pos); - position(0); + scope(exit) position = orig_pos; + position = 0; blockSize = cast(size_t)size; result = new char[blockSize]; while (blockSize > 0) { @@ -1364,10 +1364,10 @@ class Stream : InputStream, OutputStream { try { ulong pos = position; - scope(exit) position(pos); + scope(exit) position = pos; CRC32 crc; crc.start(); - position(0); + position = 0; ulong len = size; for (ulong i = 0; i < len; i++) { @@ -1772,9 +1772,9 @@ class BufferedStream : FilterStream { } // returns true if end of stream is reached, false otherwise - override bool eof() { + override @property bool eof() { if ((buffer.length == 0) || !readable) { - return super.eof(); + return super.eof; } // some simple tests to avoid flushing if (ungetAvailable() || bufferCurPos != bufferLen) @@ -2071,7 +2071,7 @@ class File: Stream { version (Posix) assert(file.position == 18 + 13 + 4); // we must be at the end of file - assert(file.eof()); + assert(file.eof); file.close(); // no operations are allowed when file is closed assert(!file.readable && !file.writeable && !file.seekable); @@ -2099,7 +2099,7 @@ class File: Stream { version (Posix) assert(file.position == 18 + 13 + 4); // we must be at the end of file - assert(file.eof()); + assert(file.eof); file.close(); file.open("stream.$$$",FileMode.OutNew | FileMode.In); file.writeLine("Testing stream.d:"); @@ -2188,7 +2188,7 @@ class BufferedFile: BufferedStream { version (Posix) assert(file.position == 18 + 13 + 4); // we must be at the end of file - assert(file.eof()); + assert(file.eof); long oldsize = cast(long)file.size; file.close(); // no operations are allowed when file is closed @@ -2216,7 +2216,7 @@ class BufferedFile: BufferedStream { version (Posix) assert(file.position == 18 + 13 + 4); // we must be at the end of file - assert(file.eof()); + assert(file.eof); file.close(); remove("stream.$$$"); } @@ -2294,7 +2294,7 @@ class EndianStream : FilterStream { immutable ubyte[] bom = ByteOrderMarks[i]; for (j=0; j < bom.length; ++j) { if (n <= j) { // have to read more - if (eof()) + if (eof) break; readExact(&BOM_buffer[n++],1); } @@ -2459,7 +2459,7 @@ class EndianStream : FilterStream { } } - override bool eof() { return s.eof() && !ungetAvailable(); } + override @property bool eof() { return s.eof && !ungetAvailable(); } override @property ulong size() { return s.size; } unittest { @@ -2472,12 +2472,12 @@ class EndianStream : FilterStream { assert( m.data[1] == 0x22 ); assert( m.data[2] == 0x33 ); assert( m.data[3] == 0x44 ); - em.position(0); + em.position = 0; ushort x2 = 0x5566; em.write(x2); assert( m.data[0] == 0x55 ); assert( m.data[1] == 0x66 ); - em.position(0); + em.position = 0; static ubyte[12] x3 = [1,2,3,4,5,6,7,8,9,10,11,12]; em.fixBO(x3.ptr,12); if (std.system.endian == Endian.littleEndian) { @@ -2498,11 +2498,11 @@ class EndianStream : FilterStream { assert( m.data[1] == 0x33 ); assert( m.data[2] == 0x22 ); assert( m.data[3] == 0x11 ); - em.position(0); + em.position = 0; em.write(x2); assert( m.data[0] == 0x66 ); assert( m.data[1] == 0x55 ); - em.position(0); + em.position = 0; em.fixBO(x3.ptr,12); if (std.system.endian == Endian.bigEndian) { assert( x3[0] == 12 ); @@ -2522,28 +2522,28 @@ class EndianStream : FilterStream { assert( m.data[1] == 0xBB ); assert( m.data[2] == 0xBF ); em.writeString ("Hello, world"); - em.position(0); + em.position = 0; assert( m.position == 0 ); assert( em.readBOM() == BOM.UTF8 ); assert( m.position == 3 ); assert( em.getc() == 'H' ); - em.position(0); + em.position = 0; em.writeBOM(BOM.UTF16BE); assert( m.data[0] == 0xFE ); assert( m.data[1] == 0xFF ); - em.position(0); + em.position = 0; em.writeBOM(BOM.UTF16LE); assert( m.data[0] == 0xFF ); assert( m.data[1] == 0xFE ); - em.position(0); + em.position = 0; em.writeString ("Hello, world"); - em.position(0); + em.position = 0; assert( em.readBOM() == -1 ); assert( em.getc() == 'H' ); assert( em.getc() == 'e' ); assert( em.getc() == 'l' ); assert( em.getc() == 'l' ); - em.position(0); + em.position = 0; } } @@ -2645,7 +2645,7 @@ unittest { m = new TArrayStream!(char[]) (buf); assert (m.isOpen); m.writeString ("Hello, world"); - assert (m.position () == 12); + assert (m.position == 12); assert (m.available == 88); assert (m.seekSet (0) == 0); assert (m.available == 100); @@ -2698,7 +2698,7 @@ class MemoryStream: TArrayStream!(ubyte[]) { m = new MemoryStream (); assert (m.isOpen); m.writeString ("Hello, world"); - assert (m.position () == 12); + assert (m.position == 12); assert (m.seekSet (0) == 0); assert (m.available == 12); assert (m.seekCur (4) == 4); @@ -2708,13 +2708,13 @@ class MemoryStream: TArrayStream!(ubyte[]) { assert (m.size == 12); assert (m.readString (4) == "o, w"); m.writeString ("ie"); - assert (cast(char[]) m.data () == "Hello, wield"); + assert (cast(char[]) m.data == "Hello, wield"); m.seekEnd (0); m.writeString ("Foo"); - assert (m.position () == 15); + assert (m.position == 15); assert (m.available == 0); m.writeString ("Foo foo foo foo foo foo foo"); - assert (m.position () == 42); + assert (m.position == 42); m.position = 0; assert (m.available == 42); m.writef("%d %d %s",100,345,"hello"); @@ -2774,7 +2774,7 @@ unittest { MmFileStream m; m = new MmFileStream (mf); m.writeString ("Hello, world"); - assert (m.position () == 12); + assert (m.position == 12); assert (m.seekSet (0) == 0); assert (m.seekCur (4) == 4); assert (m.seekEnd (-8) == 92); @@ -2782,13 +2782,13 @@ unittest { assert (m.seekSet (4)); assert (m.readString (4) == "o, w"); m.writeString ("ie"); - ubyte[] dd = m.data(); + ubyte[] dd = m.data; assert ((cast(char[]) dd)[0 .. 12] == "Hello, wield"); m.position = 12; m.writeString ("Foo"); - assert (m.position () == 15); + assert (m.position == 15); m.writeString ("Foo foo foo foo foo foo foo"); - assert (m.position () == 42); + assert (m.position == 42); m.close(); mf = new MmFile("testing.txt"); m = new MmFileStream (mf); @@ -2944,21 +2944,21 @@ class SliceStream : FilterStream { m = new MemoryStream ((cast(char[])"Hello, world").dup); s = new SliceStream (m, 4, 8); assert (s.size == 4); - assert (m.position () == 0); - assert (s.position () == 0); + assert (m.position == 0); + assert (s.position == 0); assert (m.available == 12); assert (s.available == 4); assert (s.writeBlock (cast(char *) "Vroom", 5) == 4); - assert (m.position () == 0); - assert (s.position () == 4); + assert (m.position == 0); + assert (s.position == 4); assert (m.available == 12); assert (s.available == 0); assert (s.seekEnd (-2) == 2); assert (s.available == 2); assert (s.seekEnd (2) == 4); assert (s.available == 0); - assert (m.position () == 0); + assert (m.position == 0); assert (m.available == 12); m.seekEnd(0); @@ -2975,10 +2975,10 @@ class SliceStream : FilterStream { assert (s.available == 0); s.writeString (", etcetera."); - assert (s.position () == 25); + assert (s.position == 25); assert (s.seekSet (0) == 0); assert (s.size == 25); - assert (m.position () == 18); + assert (m.position == 18); assert (m.size == 29); assert (m.toString() == "HellVrooorld\nBlaho, etcetera."); } diff --git a/std/typecons.d b/std/typecons.d index 9adcd4929..100dc1b9d 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2320,7 +2320,7 @@ private static: * Returns D code which declares function parameters. * "ref int a0, real a1, ..." */ - private string generateParameters(string myFuncInfo, func...)() @property + private string generateParameters(string myFuncInfo, func...)() { alias ParameterStorageClass STC; alias ParameterStorageClassTuple!(func) stcs; diff --git a/std/uuid.d b/std/uuid.d index 8ffc7ad96..3c4d1a033 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -1074,7 +1074,7 @@ unittest * //provide a custom RNG. Must be seeded manually. * Xorshift192 gen; * - * gen.seed(unpredictableSeed()); + * gen.seed(unpredictableSeed); * auto uuid3 = randomUUID(gen); * ------------------------------------------ */ @@ -1127,7 +1127,7 @@ unittest //provide a custom RNG. Must be seeded manually. Xorshift192 gen; - gen.seed(unpredictableSeed()); + gen.seed(unpredictableSeed); auto uuid3 = randomUUID(gen); auto u1 = randomUUID(); diff --git a/std/variant.d b/std/variant.d index cbdbaed8d..b559ef6e2 100644 --- a/std/variant.d +++ b/std/variant.d @@ -704,7 +704,7 @@ public: { static if (isNumeric!(T)) { - if (convertsTo!real()) + if (convertsTo!real) { // maybe optimize this fella; handle ints separately return to!T(get!real); @@ -725,7 +725,7 @@ public: else { - enforce(false, text("Type ", type(), " does not convert to ", + enforce(false, text("Type ", type, " does not convert to ", typeid(T))); assert(0); } @@ -1055,7 +1055,7 @@ public: int opApply(Delegate)(scope Delegate dg) if (is(Delegate == delegate)) { alias ParameterTypeTuple!(Delegate)[0] A; - if (type() == typeid(A[])) + if (type == typeid(A[])) { auto arr = get!(A[]); foreach (ref e; arr) @@ -1077,7 +1077,7 @@ public: } else { - enforce(false, text("Variant type ", type(), + enforce(false, text("Variant type ", type, " not iterable with values of type ", A.stringof)); } @@ -1497,7 +1497,7 @@ unittest unittest { const x = Variant(42); - auto y1 = x.get!(const int)(); + auto y1 = x.get!(const int); // @@@BUG@@@ //auto y2 = x.get!(immutable int)(); } @@ -1829,7 +1829,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant enum HandlerOverloadMap = visitGetOverloadMap(); - if (!variant.hasValue()) + if (!variant.hasValue) { // Call the exception function. The HandlerOverloadMap // will have its exceptionFuncIdx field set to value != -1 if an diff --git a/unittest.d b/unittest.d index 5a5467134..a1a757165 100644 --- a/unittest.d +++ b/unittest.d @@ -77,8 +77,8 @@ version (all) OutBuffer b = new OutBuffer(); // outbuffer std.ctype.tolower('A'); // ctype RegExp r = new RegExp(null, null); // regexp - uint ranseed = std.random.unpredictableSeed(); - thisTid(); + uint ranseed = std.random.unpredictableSeed; + thisTid; int a[]; a.reverse; // adi a.sort; // qsort