Remove redundant parenthesis for getters, and use assignment syntax for setters

This commit is contained in:
k-hara 2012-11-23 14:45:51 +09:00
parent 245274b408
commit 01df2f60be
28 changed files with 188 additions and 189 deletions

View file

@ -1275,11 +1275,11 @@ unittest
auto under10 = filter!("a < 10")(a); auto under10 = filter!("a < 10")(a);
assert(equal(under10, [1, 3, 5][])); assert(equal(under10, [1, 3, 5][]));
static assert(isForwardRange!(typeof(under10))); static assert(isForwardRange!(typeof(under10)));
under10.front() = 4; under10.front = 4;
assert(equal(under10, [4, 3, 5][])); assert(equal(under10, [4, 3, 5][]));
under10.front() = 40; under10.front = 40;
assert(equal(under10, [40, 3, 5][])); assert(equal(under10, [40, 3, 5][]));
under10.front() = 1; under10.front = 1;
auto infinite = filter!"a > 2"(repeat(3)); auto infinite = filter!"a > 2"(repeat(3));
static assert(isInfinite!(typeof(infinite))); static assert(isInfinite!(typeof(infinite)));
@ -2747,7 +2747,7 @@ unittest
// joiner allows in-place mutation! // joiner allows in-place mutation!
auto a = [ [1, 2, 3], [42, 43] ]; auto a = [ [1, 2, 3], [42, 43] ];
auto j = joiner(a); auto j = joiner(a);
j.front() = 44; j.front = 44;
assert(a == [ [44, 2, 3], [42, 43] ]); assert(a == [ [44, 2, 3], [42, 43] ]);
// bugzilla 8240 // bugzilla 8240
@ -7737,7 +7737,7 @@ void schwartzSort(alias transform, alias less = "a < b",
xform[i] = transform(e); xform[i] = transform(e);
} }
auto z = zip(xform, r); auto z = zip(xform, r);
alias typeof(z.front()) ProxyType; alias typeof(z.front) ProxyType;
bool myLess(ProxyType a, ProxyType b) bool myLess(ProxyType a, ProxyType b)
{ {
return binaryFun!less(a[0], b[0]); return binaryFun!less(a[0], b[0]);

View file

@ -1385,7 +1385,7 @@ struct BitArray
{ {
BitArray r; BitArray r;
r = this.dup(); r = this.dup;
r ~= b; r ~= b;
return r; return r;
} }

View file

@ -3796,8 +3796,8 @@ the heap work incorrectly.
void acquire(Store s, size_t initialSize = size_t.max) void acquire(Store s, size_t initialSize = size_t.max)
{ {
_payload.refCountedStore.ensureInitialized(); _payload.refCountedStore.ensureInitialized();
_store() = move(s); _store = move(s);
_length() = min(_store.length, initialSize); _length = min(_store.length, initialSize);
if (_length < 2) return; if (_length < 2) return;
for (auto i = (_length - 2) / 2; ; ) for (auto i = (_length - 2) / 2; ; )
{ {
@ -3814,8 +3814,8 @@ heap.
void assume(Store s, size_t initialSize = size_t.max) void assume(Store s, size_t initialSize = size_t.max)
{ {
_payload.refCountedStore.ensureInitialized(); _payload.refCountedStore.ensureInitialized();
_store() = s; _store = s;
_length() = min(_store.length, initialSize); _length = min(_store.length, initialSize);
assertValid(); assertValid();
} }
@ -4557,7 +4557,7 @@ struct Array(T) if (is(T == bool))
*/ */
T removeAny() T removeAny()
{ {
auto result = back(); auto result = back;
removeBack(); removeBack();
return result; return result;
} }

View file

@ -3065,7 +3065,7 @@ Target parseElement(Target, Source)(ref Source s)
result.put(parseEscape(s)); result.put(parseEscape(s));
break; break;
default: default:
result.put(s.front()); result.put(s.front);
s.popFront(); s.popFront();
break; break;
} }

View file

@ -79,8 +79,8 @@ version(D_InlineAsm_X86)
"Signature: Family=%d Model=%d Stepping=%d\n"~ "Signature: Family=%d Model=%d Stepping=%d\n"~
"Features: %s\n"~ "Features: %s\n"~
"Multithreading: %d threads / %d cores\n", "Multithreading: %d threads / %d cores\n",
vendor(), vendor,
processor(), processor,
family, model, stepping, family, model, stepping,
feats, feats,
threadsPerCPU, coresPerCPU); threadsPerCPU, coresPerCPU);
@ -141,7 +141,7 @@ version(D_InlineAsm_X86)
shared static this() shared static this()
{ {
switch (vendor()) switch (vendor)
{ {
case "GenuineIntel": case "GenuineIntel":
manufac = INTEL; manufac = INTEL;

View file

@ -160,9 +160,9 @@ class CFile : Stream {
file.write(i); file.write(i);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Windows) version (Windows)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
file.close(); file.close();
// no operations are allowed when file is closed // no operations are allowed when file is closed
assert(!file.readable && !file.writeable && !file.seekable); assert(!file.readable && !file.writeable && !file.seekable);
@ -178,17 +178,17 @@ class CFile : Stream {
// jump over "Hello, " // jump over "Hello, "
file.seek(7, SeekPos.Current); file.seek(7, SeekPos.Current);
version (Windows) version (Windows)
assert(file.position() == 19 + 7); assert(file.position == 19 + 7);
version (Posix) version (Posix)
assert(file.position() == 18 + 7); assert(file.position == 18 + 7);
assert(!std.algorithm.cmp(file.readString(6), "world!")); assert(!std.algorithm.cmp(file.readString(6), "world!"));
i = 0; file.read(i); i = 0; file.read(i);
assert(i == 666); assert(i == 666);
// string#1 + string#2 + int should give exacly that // string#1 + string#2 + int should give exacly that
version (Windows) version (Windows)
assert(file.position() == 19 + 13 + 4); assert(file.position == 19 + 13 + 4);
version (Posix) version (Posix)
assert(file.position() == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
file.close(); file.close();
f = fopen("stream.txt","w+"); f = fopen("stream.txt","w+");

View file

@ -687,7 +687,7 @@ unittest
@property auto empty() @property auto empty()
{ {
return text.empty(); return text.empty;
} }
auto popFront() auto popFront()

View file

@ -485,7 +485,7 @@ public:
@safe @safe
static @property TickDuration currSystemTick() static @property TickDuration currSystemTick()
{ {
return TickDuration.currSystemTick(); return TickDuration.currSystemTick;
} }
version(testStdDateTime) unittest version(testStdDateTime) unittest
@ -29275,7 +29275,7 @@ assert(tz.dstName == "PDT");
foreach(ref inUTC; transitionInUTC) foreach(ref inUTC; transitionInUTC)
inUTC = readVal!bool(tzFile); inUTC = readVal!bool(tzFile);
_enforceValidTZFile(!tzFile.eof()); _enforceValidTZFile(!tzFile.eof);
//If version 2, the information is duplicated in 64-bit. //If version 2, the information is duplicated in 64-bit.
if(tzFileVersion == '2') if(tzFileVersion == '2')
@ -29365,12 +29365,12 @@ assert(tz.dstName == "PDT");
inUTC = readVal!bool(tzFile); inUTC = readVal!bool(tzFile);
} }
_enforceValidTZFile(tzFile.readln().strip().empty()); _enforceValidTZFile(tzFile.readln().strip().empty);
auto posixEnvStr = tzFile.readln().strip(); auto posixEnvStr = tzFile.readln().strip();
_enforceValidTZFile(tzFile.readln().strip().empty()); _enforceValidTZFile(tzFile.readln().strip().empty);
_enforceValidTZFile(tzFile.eof()); _enforceValidTZFile(tzFile.eof);
auto transitionTypes = new TransitionType*[](tempTTInfos.length); auto transitionTypes = new TransitionType*[](tempTTInfos.length);
@ -29505,7 +29505,7 @@ assert(tz.dstName == "PDT");
{ {
auto tzName = dentry.name[tzDatabaseDir.length .. $]; auto tzName = dentry.name[tzDatabaseDir.length .. $];
if(!tzName.extension().empty() || if(!tzName.extension().empty ||
!tzName.startsWith(subName) || !tzName.startsWith(subName) ||
tzName == "+VERSION") tzName == "+VERSION")
{ {
@ -29684,7 +29684,7 @@ private:
import std.bitmanip; import std.bitmanip;
T[1] buff; T[1] buff;
_enforceValidTZFile(!tzFile.eof()); _enforceValidTZFile(!tzFile.eof);
tzFile.rawRead(buff); tzFile.rawRead(buff);
return bigEndianToNative!T(cast(ubyte[T.sizeof])buff); return bigEndianToNative!T(cast(ubyte[T.sizeof])buff);
@ -29698,7 +29698,7 @@ private:
{ {
auto buff = new T(length); auto buff = new T(length);
_enforceValidTZFile(!tzFile.eof()); _enforceValidTZFile(!tzFile.eof);
tzFile.rawRead(buff); tzFile.rawRead(buff);
return buff; return buff;
@ -30093,7 +30093,7 @@ else version(Windows)
otherTime.wMinute, otherTime.wMinute,
otherTime.wSecond); otherTime.wSecond);
immutable diff = utcDateTime - otherDateTime; immutable diff = utcDateTime - otherDateTime;
immutable minutes = diff.total!"minutes"() - tzInfo.Bias; immutable minutes = diff.total!"minutes" - tzInfo.Bias;
if(minutes == tzInfo.DaylightBias) if(minutes == tzInfo.DaylightBias)
return true; return true;
@ -30185,7 +30185,7 @@ else version(Windows)
utcTime.wSecond); utcTime.wSecond);
immutable diff = localDateTime - utcDateTime; immutable diff = localDateTime - utcDateTime;
immutable minutes = -tzInfo.Bias - diff.total!"minutes"(); immutable minutes = -tzInfo.Bias - diff.total!"minutes";
if(minutes == tzInfo.DaylightBias) if(minutes == tzInfo.DaylightBias)
return true; return true;

View file

@ -999,7 +999,7 @@ class ErrnoException : Exception
uint errno; // operating system error code uint errno; // operating system error code
this(string msg, string file = null, size_t line = 0) this(string msg, string file = null, size_t line = 0)
{ {
errno = .errno(); errno = .errno;
version (linux) version (linux)
{ {
char[1024] buf = void; char[1024] buf = void;

View file

@ -2182,7 +2182,7 @@ void rmdirRecurse(ref DirEntry de)
if(!de.isDir) if(!de.isDir)
throw new FileException(text("File ", de.name, " is not a directory")); throw new FileException(text("File ", de.name, " is not a directory"));
if(de.isSymlink()) if(de.isSymlink)
remove(de.name); remove(de.name);
else else
{ {

View file

@ -1811,7 +1811,7 @@ unittest
{ {
string value; string value;
const @property bool empty(){ return !value.length; } 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(); } void popFront(){ value.popFront(); }
const @property size_t length(){ return value.length; } const @property size_t length(){ return value.length; }
@ -2103,7 +2103,7 @@ if (isSomeString!T && !is(T == enum))
formatChar(app, c, '"'); formatChar(app, c, '"');
} }
put(app, '\"'); put(app, '\"');
put(w, app.data()); put(w, app.data);
return; return;
} }
catch (UTFException) 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) 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('['); putc('[');
valti = skipCI(valti); valti = skipCI(valti);
size_t tsize = valti.tsize(); size_t tsize = valti.tsize;
auto argptrSave = argptr; auto argptrSave = argptr;
auto tiSave = ti; auto tiSave = ti;
auto mSave = m; auto mSave = m;
@ -4753,7 +4753,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
else version (Win64) else version (Win64)
{ {
void* q2 = void; void* q2 = void;
auto valuesize = valti.tsize(); auto valuesize = valti.tsize;
if (valuesize > 8 && m != Mangle.Tsarray) if (valuesize > 8 && m != Mangle.Tsarray)
{ q2 = pvalue; { q2 = pvalue;
argptr = &q2; argptr = &q2;
@ -5012,12 +5012,12 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
version(X86) version(X86)
{ {
s = tis.xtoString(argptr); s = tis.xtoString(argptr);
argptr += (tis.tsize() + 3) & ~3; argptr += (tis.tsize + 3) & ~3;
} }
else version(Win64) else version(Win64)
{ {
void* p = argptr; void* p = argptr;
if (tis.tsize() > 8) if (tis.tsize > 8)
p = *cast(void**)p; p = *cast(void**)p;
s = tis.xtoString(p); s = tis.xtoString(p);
argptr += size_t.sizeof; 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[32] parmn = void; // place to copy struct if passed in regs
void* p; void* p;
auto tsize = tis.tsize(); auto tsize = tis.tsize;
TypeInfo arg1, arg2; TypeInfo arg1, arg2;
if (!tis.argTypes(arg1, arg2)) // if could be passed in regs if (!tis.argTypes(arg1, arg2)) // if could be passed in regs
{ assert(tsize <= parmn.length); { 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 * it always being passed in memory
*/ */
// The arg may have more strict alignment than the stack // 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; __va_list* ap = cast(__va_list*)argptr;
p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1)); 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))); ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));

View file

@ -633,7 +633,7 @@ unittest
@system unittest @system unittest
{ {
import std.conv, std.random, std.range; import std.conv, std.random, std.range;
immutable seed = unpredictableSeed(); immutable seed = unpredictableSeed;
auto rnd = Random(seed); auto rnd = Random(seed);
auto testCases = randomSample(unicodeProperties, 10, rnd); auto testCases = randomSample(unicodeProperties, 10, rnd);

View file

@ -89,7 +89,7 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) {
JSONValue root = void; JSONValue root = void;
root.type = JSON_TYPE.NULL; root.type = JSON_TYPE.NULL;
if(json.empty()) return root; if(json.empty) return root;
int depth = -1; int depth = -1;
dchar next = 0; dchar next = 0;
@ -101,8 +101,8 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) {
dchar peekChar() { dchar peekChar() {
if(!next) { if(!next) {
if(json.empty()) return '\0'; if(json.empty) return '\0';
next = json.front(); next = json.front;
json.popFront(); json.popFront();
} }
return next; return next;
@ -121,8 +121,8 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) {
next = 0; next = 0;
} }
else { else {
if(json.empty()) error("Unexpected end of data."); if(json.empty) error("Unexpected end of data.");
c = json.front(); c = json.front;
json.popFront(); json.popFront();
} }

View file

@ -1512,9 +1512,9 @@ unittest
f = ieeeFlags; f = ieeeFlags;
assert(x == exptestpoints[i][1]); assert(x == exptestpoints[i][1]);
// Check the overflow bit // Check the overflow bit
assert(f.overflow() == (fabs(x) == real.infinity)); assert(f.overflow == (fabs(x) == real.infinity));
// Check the underflow bit // 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. // Invalid and div by zero shouldn't be affected.
assert(!f.invalid); assert(!f.invalid);
assert(!f.divByZero); assert(!f.divByZero);
@ -2827,7 +2827,7 @@ unittest
FloatingPointControl ctrl; FloatingPointControl ctrl;
ctrl.enableExceptions(FloatingPointControl.divByZeroException ctrl.enableExceptions(FloatingPointControl.divByZeroException
| FloatingPointControl.overflowException); | FloatingPointControl.overflowException);
assert(ctrl.enabledExceptions() == assert(ctrl.enabledExceptions ==
(FloatingPointControl.divByZeroException (FloatingPointControl.divByZeroException
| FloatingPointControl.overflowException)); | FloatingPointControl.overflowException));
@ -2836,7 +2836,7 @@ unittest
} }
assert(FloatingPointControl.rounding assert(FloatingPointControl.rounding
== FloatingPointControl.roundToNearest); == FloatingPointControl.roundToNearest);
assert(FloatingPointControl.enabledExceptions() ==0); assert(FloatingPointControl.enabledExceptions ==0);
} }

View file

@ -977,12 +977,12 @@ unittest
{ {
if (!netAllowed()) return; if (!netAllowed()) return;
auto res = byLine(testUrl1); auto res = byLine(testUrl1);
auto line = res.front(); auto line = res.front;
assert(line == "Hello world", assert(line == "Hello world",
"byLine!HTTP() returns unexpected content: " ~ line); "byLine!HTTP() returns unexpected content: " ~ line);
auto res2 = byLine(testUrl1, KeepTerminator.no, '\n', HTTP()); auto res2 = byLine(testUrl1, KeepTerminator.no, '\n', HTTP());
line = res2.front(); line = res2.front;
assert(line == "Hello world", assert(line == "Hello world",
"byLine!HTTP() returns unexpected content: " ~ line); "byLine!HTTP() returns unexpected content: " ~ line);
} }
@ -1052,12 +1052,12 @@ unittest
if (!netAllowed()) return; if (!netAllowed()) return;
auto res = byChunk(testUrl1); auto res = byChunk(testUrl1);
auto line = res.front(); auto line = res.front;
assert(line == cast(ubyte[])"Hello world\n", assert(line == cast(ubyte[])"Hello world\n",
"byLineAsync!HTTP() returns unexpected content " ~ to!string(line)); "byLineAsync!HTTP() returns unexpected content " ~ to!string(line));
auto res2 = byChunk(testUrl1, 1024, HTTP()); auto res2 = byChunk(testUrl1, 1024, HTTP());
line = res2.front(); line = res2.front;
assert(line == cast(ubyte[])"Hello world\n", assert(line == cast(ubyte[])"Hello world\n",
"byLineAsync!HTTP() returns unexpected content: " ~ to!string(line)); "byLineAsync!HTTP() returns unexpected content: " ~ to!string(line));
} }
@ -1346,11 +1346,11 @@ unittest
{ {
if (!netAllowed()) return; if (!netAllowed()) return;
auto res = byLineAsync(testUrl2, "Hello world"); auto res = byLineAsync(testUrl2, "Hello world");
auto line = res.front(); auto line = res.front;
assert(line == "Hello world", assert(line == "Hello world",
"byLineAsync!HTTP() returns unexpected content " ~ line); "byLineAsync!HTTP() returns unexpected content " ~ line);
res = byLineAsync(testUrl1); res = byLineAsync(testUrl1);
line = res.front(); line = res.front;
assert(line == "Hello world", assert(line == "Hello world",
"byLineAsync!HTTP() returns unexpected content: " ~ line); "byLineAsync!HTTP() returns unexpected content: " ~ line);
} }
@ -1497,11 +1497,11 @@ unittest
{ {
if (!netAllowed()) return; if (!netAllowed()) return;
auto res = byChunkAsync(testUrl2, "Hello world"); auto res = byChunkAsync(testUrl2, "Hello world");
auto line = res.front(); auto line = res.front;
assert(line == cast(ubyte[])"Hello world", assert(line == cast(ubyte[])"Hello world",
"byLineAsync!HTTP() returns unexpected content " ~ to!string(line)); "byLineAsync!HTTP() returns unexpected content " ~ to!string(line));
res = byChunkAsync(testUrl1); res = byChunkAsync(testUrl1);
line = res.front(); line = res.front;
assert(line == cast(ubyte[])"Hello world\n", assert(line == cast(ubyte[])"Hello world\n",
"byLineAsync!HTTP() returns unexpected content: " ~ to!string(line)); "byLineAsync!HTTP() returns unexpected content: " ~ to!string(line));
} }
@ -1607,7 +1607,7 @@ private mixin template Protocol()
@property void dataTimeout(Duration d) @property void dataTimeout(Duration d)
{ {
p.curl.set(CurlOption.low_speed_limit, 1); 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. /** Set maximum time an operation is allowed to take.
@ -1615,13 +1615,13 @@ private mixin template Protocol()
*/ */
@property void operationTimeout(Duration d) @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. /// Set timeout for connecting.
@property void connectTimeout(Duration d) @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 // Network settings
@ -1656,7 +1656,7 @@ private mixin template Protocol()
/// DNS lookup timeout. /// DNS lookup timeout.
@property void dnsTimeout(Duration d) @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) @property void netInterface(const(ubyte)[4] i)
{ {
auto str = format("%d.%d.%d.%d", i[0], i[1], i[2], i[3]); auto str = format("%d.%d.%d.%d", i[0], i[1], i[2], i[3]);
netInterface(str); netInterface = str;
} }
/// ditto /// ditto
@property void netInterface(InternetAddress i) @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) @property void onSend(size_t delegate(void[]) callback)
{ {
p.curl.clear(CurlOption.postfields); // cannot specify data when using 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) @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, @property void onProgress(int delegate(size_t dlTotal, size_t dlNow,
size_t ulTotal, size_t ulNow) callback) 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.set(CurlOption.httpheader, copy.p.headersOut);
copy.p.curl = p.curl.dup(); copy.p.curl = p.curl.dup();
copy.dataTimeout = _defaultDataTimeout; copy.dataTimeout = _defaultDataTimeout;
copy.onReceiveHeader(null); copy.onReceiveHeader = null;
return copy; return copy;
} }
@ -2073,8 +2073,8 @@ struct HTTP
p.charset = "ISO-8859-1"; // Default charset defined in HTTP RFC p.charset = "ISO-8859-1"; // Default charset defined in HTTP RFC
p.method = Method.undefined; p.method = Method.undefined;
dataTimeout = _defaultDataTimeout; dataTimeout = _defaultDataTimeout;
onReceiveHeader(null); onReceiveHeader = null;
version (unittest) verbose(true); version (unittest) verbose = true;
} }
/** /**
@ -2576,7 +2576,7 @@ struct HTTP
callback(fieldName, m.captures[2]); callback(fieldName, m.captures[2]);
p.headersIn[fieldName] = m.captures[2].idup; 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.curl.initialize();
p.encoding = "ISO-8859-1"; p.encoding = "ISO-8859-1";
dataTimeout = _defaultDataTimeout; 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..$]; data = data[copyBytes..$];
if (outdata.empty) if (outdata.empty)
fromTid.send(thisTid(), curlMessage(cast(immutable(ubyte)[])buffer)); fromTid.send(thisTid, curlMessage(cast(immutable(ubyte)[])buffer));
} }
return datalen; return datalen;
@ -3963,7 +3963,7 @@ private static void _finalizeAsyncChunks(ubyte[] outdata, ref ubyte[] buffer,
{ {
// Resize the last buffer // Resize the last buffer
buffer.length = buffer.length - outdata.length; 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) if (keepTerminator)
{ {
fromTid.send(thisTid(), fromTid.send(thisTid,
curlMessage(cast(immutable(Unit)[])buffer)); curlMessage(cast(immutable(Unit)[])buffer));
} }
else else
{ {
static if (isArray!Terminator) static if (isArray!Terminator)
fromTid.send(thisTid(), fromTid.send(thisTid,
curlMessage(cast(immutable(Unit)[]) curlMessage(cast(immutable(Unit)[])
buffer[0..$-terminator.length])); buffer[0..$-terminator.length]));
else else
fromTid.send(thisTid(), fromTid.send(thisTid,
curlMessage(cast(immutable(Unit)[]) curlMessage(cast(immutable(Unit)[])
buffer[0..$-1])); buffer[0..$-1]));
} }
@ -4067,7 +4067,7 @@ private static
void _finalizeAsyncLines(Unit)(bool bufferValid, Unit[] buffer, Tid fromTid) void _finalizeAsyncLines(Unit)(bool bufferValid, Unit[] buffer, Tid fromTid)
{ {
if (bufferValid && buffer.length != 0) 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) catch (Exception ex)
{ {
prioritySend(fromTid, cast(immutable(Exception)) ex); prioritySend(fromTid, cast(immutable(Exception)) ex);
fromTid.send(thisTid(), curlMessage(true)); // signal done fromTid.send(thisTid, curlMessage(true)); // signal done
return; return;
} }
@ -4159,13 +4159,13 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)()
if (aborted && (code == CurlError.aborted_by_callback || if (aborted && (code == CurlError.aborted_by_callback ||
code == CurlError.write_error)) code == CurlError.write_error))
{ {
fromTid.send(thisTid(), curlMessage(true)); // signal done fromTid.send(thisTid, curlMessage(true)); // signal done
return; return;
} }
prioritySend(fromTid, cast(immutable(CurlException)) prioritySend(fromTid, cast(immutable(CurlException))
new CurlException(client.p.curl.errorString(code))); new CurlException(client.p.curl.errorString(code)));
fromTid.send(thisTid(), curlMessage(true)); // signal done fromTid.send(thisTid, curlMessage(true)); // signal done
return; return;
} }
@ -4175,7 +4175,7 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)()
else else
_finalizeAsyncLines(bufferValid, buffer, fromTid); _finalizeAsyncLines(bufferValid, buffer, fromTid);
fromTid.send(thisTid(), curlMessage(true)); // signal done fromTid.send(thisTid, curlMessage(true)); // signal done
} }
version (unittest) private auto netAllowed() version (unittest) private auto netAllowed()

View file

@ -721,7 +721,7 @@ AbstractTask base = {runTask :
stderr.writeln("Yield from workForce."); stderr.writeln("Yield from workForce.");
} }
return yieldForce(); return yieldForce;
} }
} }
} }
@ -761,7 +761,7 @@ AbstractTask base = {runTask :
{ {
if(isScoped && pool !is null && taskStatus != TaskStatus.done) if(isScoped && pool !is null && taskStatus != TaskStatus.done)
{ {
yieldForce(); yieldForce;
} }
} }
@ -802,7 +802,7 @@ void main()
auto file2Data = read("bar.txt"); auto file2Data = read("bar.txt");
// Get the results of reading foo.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); auto recurseTask = task!(parallelSort)(greaterEqual);
taskPool.put(recurseTask); taskPool.put(recurseTask);
parallelSort(less); parallelSort(less);
recurseTask.yieldForce(); recurseTask.yieldForce;
} }
--- ---
*/ */
@ -871,7 +871,7 @@ void main()
auto file2Data = read("bar.txt"); auto file2Data = read("bar.txt");
// Get the results of reading foo.txt. // Get the results of reading foo.txt.
auto file1Data = file1Task.yieldForce(); auto file1Data = file1Task.yieldForce;
} }
--- ---
@ -2042,7 +2042,7 @@ public:
} }
buf2 = buf1; buf2 = buf1;
buf1 = nextBufTask.yieldForce(); buf1 = nextBufTask.yieldForce;
bufPos = 0; bufPos = 0;
if(source.empty) if(source.empty)
@ -2222,7 +2222,7 @@ public:
} }
buf2 = buf1; buf2 = buf1;
buf1 = nextBufTask.yieldForce(); buf1 = nextBufTask.yieldForce;
bufPos = 0; bufPos = 0;
if(source.empty) if(source.empty)
@ -2714,7 +2714,7 @@ public:
{ {
try try
{ {
task.yieldForce(); task.yieldForce;
} }
catch(Throwable e) catch(Throwable e)
{ {
@ -3232,7 +3232,7 @@ public:
{ {
queueLock(); queueLock();
scope(exit) queueUnlock(); scope(exit) queueUnlock();
return (size == 0) ? true : pool[0].isDaemon(); return (size == 0) ? true : pool[0].isDaemon;
} }
/// Ditto /// Ditto
@ -3258,7 +3258,7 @@ public:
int priority() @property @trusted int priority() @property @trusted
{ {
return (size == 0) ? core.thread.Thread.PRIORITY_MIN : return (size == 0) ? core.thread.Thread.PRIORITY_MIN :
pool[0].priority(); pool[0].priority;
} }
/// Ditto /// Ditto
@ -3268,7 +3268,7 @@ public:
{ {
foreach(t; pool) foreach(t; pool)
{ {
t.priority(newPriority); t.priority = newPriority;
} }
} }
} }
@ -3466,7 +3466,7 @@ private void submitAndExecute(
{ {
try try
{ {
task.yieldForce(); task.yieldForce;
} }
catch(Throwable e) catch(Throwable e)
{ {
@ -3951,29 +3951,29 @@ unittest
// Test task(). // Test task().
auto t = task!refFun(x); auto t = task!refFun(x);
poolInstance.put(t); poolInstance.put(t);
t.yieldForce(); t.yieldForce;
assert(t.args[0] == 1); assert(t.args[0] == 1);
auto t2 = task(&refFun, x); auto t2 = task(&refFun, x);
poolInstance.put(t2); poolInstance.put(t2);
t2.yieldForce(); t2.yieldForce;
assert(t2.args[0] == 1); assert(t2.args[0] == 1);
// Test scopedTask(). // Test scopedTask().
auto st = scopedTask!refFun(x); auto st = scopedTask!refFun(x);
poolInstance.put(st); poolInstance.put(st);
st.yieldForce(); st.yieldForce;
assert(st.args[0] == 1); assert(st.args[0] == 1);
auto st2 = scopedTask(&refFun, x); auto st2 = scopedTask(&refFun, x);
poolInstance.put(st2); poolInstance.put(st2);
st2.yieldForce(); st2.yieldForce;
assert(st2.args[0] == 1); assert(st2.args[0] == 1);
// Test executeInNewThread(). // Test executeInNewThread().
auto ct = scopedTask!refFun(x); auto ct = scopedTask!refFun(x);
ct.executeInNewThread(Thread.PRIORITY_MAX); ct.executeInNewThread(Thread.PRIORITY_MAX);
ct.yieldForce(); ct.yieldForce;
assert(ct.args[0] == 1); assert(ct.args[0] == 1);
// Test ref return. // Test ref return.
@ -3998,11 +3998,11 @@ unittest
auto safePool = new TaskPool(0); auto safePool = new TaskPool(0);
auto t = task(&bump, 1); auto t = task(&bump, 1);
taskPool.put(t); taskPool.put(t);
assert(t.yieldForce() == 2); assert(t.yieldForce == 2);
auto st = scopedTask(&bump, 1); auto st = scopedTask(&bump, 1);
taskPool.put(st); taskPool.put(st);
assert(st.yieldForce() == 2); assert(st.yieldForce == 2);
safePool.stop(); safePool.stop();
} }
@ -4032,8 +4032,8 @@ unittest
auto addScopedTask = scopedTask(&add, addLhs, addRhs); auto addScopedTask = scopedTask(&add, addLhs, addRhs);
poolInstance.put(addTask); poolInstance.put(addTask);
poolInstance.put(addScopedTask); poolInstance.put(addScopedTask);
assert(addTask.yieldForce() == 3); assert(addTask.yieldForce == 3);
assert(addScopedTask.yieldForce() == 3); assert(addScopedTask.yieldForce == 3);
// Test parallel foreach with non-random access range. // Test parallel foreach with non-random access range.
auto range = filter!"a != 666"([0, 1, 2, 3, 4]); auto range = filter!"a != 666"([0, 1, 2, 3, 4]);
@ -4117,7 +4117,7 @@ unittest
pool1.put(tSlow); pool1.put(tSlow);
pool1.finish(); pool1.finish();
assert(!tSlow.done); assert(!tSlow.done);
tSlow.yieldForce(); tSlow.yieldForce;
// Can't assert that pool1.status == PoolState.stopNow because status // Can't assert that pool1.status == PoolState.stopNow because status
// doesn't change until after the "done" flag is set and the waiting // doesn't change until after the "done" flag is set and the waiting
// thread is woken up. // thread is woken up.

View file

@ -1597,7 +1597,7 @@ unittest
// save() // save()
auto ps1 = pathSplitter("foo/bar/baz"); auto ps1 = pathSplitter("foo/bar/baz");
auto ps2 = ps1.save(); auto ps2 = ps1.save;
ps1.popFront(); ps1.popFront();
assert (equal2(ps1, ["bar", "baz"])); assert (equal2(ps1, ["bar", "baz"]));
assert (equal2(ps2, ["foo", "bar", "baz"])); assert (equal2(ps2, ["foo", "bar", "baz"]));

View file

@ -1076,7 +1076,7 @@ string escapeWindowsShellCommand(in char[] command)
default: default:
result.put(c); result.put(c);
} }
return result.data(); return result.data;
} }
private string escapeShellCommandString(string command) private string escapeShellCommandString(string command)

View file

@ -1030,11 +1030,11 @@ auto n = rnd.front;
if (!seeded) if (!seeded)
{ {
uint threadID = cast(uint) cast(void*) Thread.getThis(); 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; seeded = true;
} }
rand.popFront(); rand.popFront();
return cast(uint) (TickDuration.currSystemTick().length ^ rand.front); return cast(uint) (TickDuration.currSystemTick.length ^ rand.front);
} }
unittest unittest

View file

@ -1004,7 +1004,7 @@ template ElementType(R)
unittest unittest
{ {
enum XYZ : string { a = "foo" } enum XYZ : string { a = "foo" }
auto x = front(XYZ.a); auto x = XYZ.a.front;
immutable char[3] a = "abc"; immutable char[3] a = "abc";
int[] i; int[] i;
void[] buf; void[] buf;
@ -1035,7 +1035,7 @@ template ElementEncodingType(R)
unittest unittest
{ {
enum XYZ : string { a = "foo" } enum XYZ : string { a = "foo" }
auto x = front(XYZ.a); auto x = XYZ.a.front;
immutable char[3] a = "abc"; immutable char[3] a = "abc";
int[] i; int[] i;
void[] buf; void[] buf;
@ -2487,7 +2487,7 @@ unittest
{ {
assert(rr.front == moveFront(rr)); assert(rr.front == moveFront(rr));
} }
r.front() = 5; r.front = 5;
assert(r.front == 5); assert(r.front == 5);
// Test instantiation without lvalue elements. // Test instantiation without lvalue elements.
@ -2528,7 +2528,6 @@ if (isInputRange!(Unqual!Range)
public R source; public R source;
private size_t _maxAvailable; private size_t _maxAvailable;
private enum bool byRef = is(typeof(&_input.front) == ElementType!(R)*);
alias R Source; alias R Source;
@ -2824,7 +2823,7 @@ if (isInputRange!R && !hasSlicing!R)
@property auto ref front() @property auto ref front()
{ {
assert(_n > 0, "front() on an empty " ~ Result.stringof); assert(_n > 0, "front() on an empty " ~ Result.stringof);
return _input.front(); return _input.front;
} }
void popFront() { _input.popFront(); --_n; } void popFront() { _input.popFront(); --_n; }
@property size_t length() const { return _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 // unsigned reverse iota can be buggy if .length doesn't take them into
// account (issue 7982). // account (issue 7982).
assert(iota(10u, 0u, -1).length() == 10); assert(iota(10u, 0u, -1).length == 10);
assert(iota(10u, 0u, -2).length() == 5); assert(iota(10u, 0u, -2).length == 5);
assert(iota(uint.max, uint.max-10, -1).length() == 10); assert(iota(uint.max, uint.max-10, -1).length == 10);
assert(iota(uint.max, uint.max-10, -2).length() == 5); assert(iota(uint.max, uint.max-10, -2).length == 5);
assert(iota(uint.max, 0u, -1).length() == uint.max); assert(iota(uint.max, 0u, -1).length == uint.max);
} }
unittest unittest

View file

@ -1773,7 +1773,7 @@ struct Parser(R, bool CTFE=false)
//try to generate optimal IR code for this CodepointSet //try to generate optimal IR code for this CodepointSet
@trusted void charsetToIr(in CodepointSet set) @trusted void charsetToIr(in CodepointSet set)
{//@@@BUG@@@ writeln is @system {//@@@BUG@@@ writeln is @system
uint chars = set.chars(); uint chars = set.chars;
if(chars < Bytecode.maxSequence) if(chars < Bytecode.maxSequence)
{ {
switch(chars) switch(chars)
@ -6774,7 +6774,7 @@ private:
public: public:
auto ref opSlice() auto ref opSlice()
{ {
return this.save(); return this.save;
} }
///Forward range primitives. ///Forward range primitives.

View file

@ -1290,7 +1290,7 @@ abstract class Address
/// Family of this address. /// Family of this address.
@property AddressFamily addressFamily() const @property AddressFamily addressFamily() const
{ {
return cast(AddressFamily) name().sa_family; return cast(AddressFamily) name.sa_family;
} }
// Common code for toAddrString and toHostNameString // Common code for toAddrString and toHostNameString
@ -2928,7 +2928,7 @@ public:
version (Windows) version (Windows)
{ {
auto msecs = to!int(value.total!"msecs"()); auto msecs = to!int(value.total!"msecs");
if (msecs != 0 && option == SocketOption.RCVTIMEO) if (msecs != 0 && option == SocketOption.RCVTIMEO)
msecs = max(1, msecs - WINSOCK_TIMEOUT_SKEW); msecs = max(1, msecs - WINSOCK_TIMEOUT_SKEW);
setOption(level, option, msecs); setOption(level, option, msecs);
@ -3013,7 +3013,7 @@ public:
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration timeout) static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration timeout)
{ {
TimeVal tv; 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); tv.microseconds = to!(tv.tv_usec_t)(timeout.fracSec.usecs);
return select(checkRead, checkWrite, checkError, &tv); return select(checkRead, checkWrite, checkError, &tv);
} }

View file

@ -851,7 +851,7 @@ with every line. */
size_t readln(C, R)(ref C[] buf, R terminator) size_t readln(C, R)(ref C[] buf, R terminator)
if (isBidirectionalRange!R && is(typeof(terminator.front == buf[0]))) if (isBidirectionalRange!R && is(typeof(terminator.front == buf[0])))
{ {
auto last = terminator.back(); auto last = terminator.back;
C[] buf2; C[] buf2;
swap(buf, buf2); swap(buf, buf2);
for (;;) { for (;;) {

View file

@ -251,7 +251,7 @@ interface InputStream {
* past the end. * past the end.
*/ */
bool eof(); @property bool eof();
@property bool isOpen(); /// Return true if the stream is currently open. @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 opApply(scope int delegate(ref char[] line) dg) {
int res = 0; int res = 0;
char[128] buf; char[128] buf;
while (!eof()) { while (!eof) {
char[] line = readLine(buf); char[] line = readLine(buf);
res = dg(line); res = dg(line);
if (res) break; if (res) break;
@ -573,7 +573,7 @@ class Stream : InputStream, OutputStream {
int res = 0; int res = 0;
ulong n = 1; ulong n = 1;
char[128] buf; char[128] buf;
while (!eof()) { while (!eof) {
auto line = readLine(buf); auto line = readLine(buf);
res = dg(n,line); res = dg(n,line);
if (res) break; if (res) break;
@ -586,7 +586,7 @@ class Stream : InputStream, OutputStream {
int opApply(scope int delegate(ref wchar[] line) dg) { int opApply(scope int delegate(ref wchar[] line) dg) {
int res = 0; int res = 0;
wchar[128] buf; wchar[128] buf;
while (!eof()) { while (!eof) {
auto line = readLineW(buf); auto line = readLineW(buf);
res = dg(line); res = dg(line);
if (res) break; if (res) break;
@ -599,7 +599,7 @@ class Stream : InputStream, OutputStream {
int res = 0; int res = 0;
ulong n = 1; ulong n = 1;
wchar[128] buf; wchar[128] buf;
while (!eof()) { while (!eof) {
auto line = readLineW(buf); auto line = readLineW(buf);
res = dg(n,line); res = dg(n,line);
if (res) break; if (res) break;
@ -698,7 +698,7 @@ class Stream : InputStream, OutputStream {
int j = 0; int j = 0;
int count = 0, i = 0; int count = 0, i = 0;
char c = getc(); 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) { if (fmt.length == 0 || i == fmt.length) {
i = 0; i = 0;
if (arguments[j] is typeid(char[])) { if (arguments[j] is typeid(char[])) {
@ -994,7 +994,7 @@ class Stream : InputStream, OutputStream {
c = getc(); c = getc();
count++; count++;
} }
while (width-- && !eof()) { while (width-- && !eof) {
*(s++) = c; *(s++) = c;
c = getc(); c = getc();
count++; count++;
@ -1220,12 +1220,12 @@ class Stream : InputStream, OutputStream {
void copyFrom(Stream s) { void copyFrom(Stream s) {
if (seekable) { if (seekable) {
ulong pos = s.position; ulong pos = s.position;
s.position(0); s.position = 0;
copyFrom(s, s.size); copyFrom(s, s.size);
s.position(pos); s.position = pos;
} else { } else {
ubyte[128] buf; ubyte[128] buf;
while (!s.eof()) { while (!s.eof) {
size_t m = s.readBlock(buf.ptr, buf.length); size_t m = s.readBlock(buf.ptr, buf.length);
writeExact(buf.ptr, m); writeExact(buf.ptr, m);
} }
@ -1281,7 +1281,7 @@ class Stream : InputStream, OutputStream {
@property ulong size() { @property ulong size() {
assertSeekable(); assertSeekable();
ulong pos = position, result = seek(0, SeekPos.End); ulong pos = position, result = seek(0, SeekPos.End);
position(pos); position = pos;
return result; return result;
} }
@ -1328,8 +1328,8 @@ class Stream : InputStream, OutputStream {
char[] result; char[] result;
if (seekable) { if (seekable) {
ulong orig_pos = position; ulong orig_pos = position;
scope(exit) position(orig_pos); scope(exit) position = orig_pos;
position(0); position = 0;
blockSize = cast(size_t)size; blockSize = cast(size_t)size;
result = new char[blockSize]; result = new char[blockSize];
while (blockSize > 0) { while (blockSize > 0) {
@ -1364,10 +1364,10 @@ class Stream : InputStream, OutputStream {
try try
{ {
ulong pos = position; ulong pos = position;
scope(exit) position(pos); scope(exit) position = pos;
CRC32 crc; CRC32 crc;
crc.start(); crc.start();
position(0); position = 0;
ulong len = size; ulong len = size;
for (ulong i = 0; i < len; i++) for (ulong i = 0; i < len; i++)
{ {
@ -1772,9 +1772,9 @@ class BufferedStream : FilterStream {
} }
// returns true if end of stream is reached, false otherwise // returns true if end of stream is reached, false otherwise
override bool eof() { override @property bool eof() {
if ((buffer.length == 0) || !readable) { if ((buffer.length == 0) || !readable) {
return super.eof(); return super.eof;
} }
// some simple tests to avoid flushing // some simple tests to avoid flushing
if (ungetAvailable() || bufferCurPos != bufferLen) if (ungetAvailable() || bufferCurPos != bufferLen)
@ -2071,7 +2071,7 @@ class File: Stream {
version (Posix) version (Posix)
assert(file.position == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof);
file.close(); file.close();
// no operations are allowed when file is closed // no operations are allowed when file is closed
assert(!file.readable && !file.writeable && !file.seekable); assert(!file.readable && !file.writeable && !file.seekable);
@ -2099,7 +2099,7 @@ class File: Stream {
version (Posix) version (Posix)
assert(file.position == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof);
file.close(); file.close();
file.open("stream.$$$",FileMode.OutNew | FileMode.In); file.open("stream.$$$",FileMode.OutNew | FileMode.In);
file.writeLine("Testing stream.d:"); file.writeLine("Testing stream.d:");
@ -2188,7 +2188,7 @@ class BufferedFile: BufferedStream {
version (Posix) version (Posix)
assert(file.position == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof);
long oldsize = cast(long)file.size; long oldsize = cast(long)file.size;
file.close(); file.close();
// no operations are allowed when file is closed // no operations are allowed when file is closed
@ -2216,7 +2216,7 @@ class BufferedFile: BufferedStream {
version (Posix) version (Posix)
assert(file.position == 18 + 13 + 4); assert(file.position == 18 + 13 + 4);
// we must be at the end of file // we must be at the end of file
assert(file.eof()); assert(file.eof);
file.close(); file.close();
remove("stream.$$$"); remove("stream.$$$");
} }
@ -2294,7 +2294,7 @@ class EndianStream : FilterStream {
immutable ubyte[] bom = ByteOrderMarks[i]; immutable ubyte[] bom = ByteOrderMarks[i];
for (j=0; j < bom.length; ++j) { for (j=0; j < bom.length; ++j) {
if (n <= j) { // have to read more if (n <= j) { // have to read more
if (eof()) if (eof)
break; break;
readExact(&BOM_buffer[n++],1); 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; } override @property ulong size() { return s.size; }
unittest { unittest {
@ -2472,12 +2472,12 @@ class EndianStream : FilterStream {
assert( m.data[1] == 0x22 ); assert( m.data[1] == 0x22 );
assert( m.data[2] == 0x33 ); assert( m.data[2] == 0x33 );
assert( m.data[3] == 0x44 ); assert( m.data[3] == 0x44 );
em.position(0); em.position = 0;
ushort x2 = 0x5566; ushort x2 = 0x5566;
em.write(x2); em.write(x2);
assert( m.data[0] == 0x55 ); assert( m.data[0] == 0x55 );
assert( m.data[1] == 0x66 ); 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]; static ubyte[12] x3 = [1,2,3,4,5,6,7,8,9,10,11,12];
em.fixBO(x3.ptr,12); em.fixBO(x3.ptr,12);
if (std.system.endian == Endian.littleEndian) { if (std.system.endian == Endian.littleEndian) {
@ -2498,11 +2498,11 @@ class EndianStream : FilterStream {
assert( m.data[1] == 0x33 ); assert( m.data[1] == 0x33 );
assert( m.data[2] == 0x22 ); assert( m.data[2] == 0x22 );
assert( m.data[3] == 0x11 ); assert( m.data[3] == 0x11 );
em.position(0); em.position = 0;
em.write(x2); em.write(x2);
assert( m.data[0] == 0x66 ); assert( m.data[0] == 0x66 );
assert( m.data[1] == 0x55 ); assert( m.data[1] == 0x55 );
em.position(0); em.position = 0;
em.fixBO(x3.ptr,12); em.fixBO(x3.ptr,12);
if (std.system.endian == Endian.bigEndian) { if (std.system.endian == Endian.bigEndian) {
assert( x3[0] == 12 ); assert( x3[0] == 12 );
@ -2522,28 +2522,28 @@ class EndianStream : FilterStream {
assert( m.data[1] == 0xBB ); assert( m.data[1] == 0xBB );
assert( m.data[2] == 0xBF ); assert( m.data[2] == 0xBF );
em.writeString ("Hello, world"); em.writeString ("Hello, world");
em.position(0); em.position = 0;
assert( m.position == 0 ); assert( m.position == 0 );
assert( em.readBOM() == BOM.UTF8 ); assert( em.readBOM() == BOM.UTF8 );
assert( m.position == 3 ); assert( m.position == 3 );
assert( em.getc() == 'H' ); assert( em.getc() == 'H' );
em.position(0); em.position = 0;
em.writeBOM(BOM.UTF16BE); em.writeBOM(BOM.UTF16BE);
assert( m.data[0] == 0xFE ); assert( m.data[0] == 0xFE );
assert( m.data[1] == 0xFF ); assert( m.data[1] == 0xFF );
em.position(0); em.position = 0;
em.writeBOM(BOM.UTF16LE); em.writeBOM(BOM.UTF16LE);
assert( m.data[0] == 0xFF ); assert( m.data[0] == 0xFF );
assert( m.data[1] == 0xFE ); assert( m.data[1] == 0xFE );
em.position(0); em.position = 0;
em.writeString ("Hello, world"); em.writeString ("Hello, world");
em.position(0); em.position = 0;
assert( em.readBOM() == -1 ); assert( em.readBOM() == -1 );
assert( em.getc() == 'H' ); assert( em.getc() == 'H' );
assert( em.getc() == 'e' ); assert( em.getc() == 'e' );
assert( em.getc() == 'l' ); assert( em.getc() == 'l' );
assert( em.getc() == 'l' ); assert( em.getc() == 'l' );
em.position(0); em.position = 0;
} }
} }
@ -2645,7 +2645,7 @@ unittest {
m = new TArrayStream!(char[]) (buf); m = new TArrayStream!(char[]) (buf);
assert (m.isOpen); assert (m.isOpen);
m.writeString ("Hello, world"); m.writeString ("Hello, world");
assert (m.position () == 12); assert (m.position == 12);
assert (m.available == 88); assert (m.available == 88);
assert (m.seekSet (0) == 0); assert (m.seekSet (0) == 0);
assert (m.available == 100); assert (m.available == 100);
@ -2698,7 +2698,7 @@ class MemoryStream: TArrayStream!(ubyte[]) {
m = new MemoryStream (); m = new MemoryStream ();
assert (m.isOpen); assert (m.isOpen);
m.writeString ("Hello, world"); m.writeString ("Hello, world");
assert (m.position () == 12); assert (m.position == 12);
assert (m.seekSet (0) == 0); assert (m.seekSet (0) == 0);
assert (m.available == 12); assert (m.available == 12);
assert (m.seekCur (4) == 4); assert (m.seekCur (4) == 4);
@ -2708,13 +2708,13 @@ class MemoryStream: TArrayStream!(ubyte[]) {
assert (m.size == 12); assert (m.size == 12);
assert (m.readString (4) == "o, w"); assert (m.readString (4) == "o, w");
m.writeString ("ie"); m.writeString ("ie");
assert (cast(char[]) m.data () == "Hello, wield"); assert (cast(char[]) m.data == "Hello, wield");
m.seekEnd (0); m.seekEnd (0);
m.writeString ("Foo"); m.writeString ("Foo");
assert (m.position () == 15); assert (m.position == 15);
assert (m.available == 0); assert (m.available == 0);
m.writeString ("Foo foo foo foo foo foo foo"); m.writeString ("Foo foo foo foo foo foo foo");
assert (m.position () == 42); assert (m.position == 42);
m.position = 0; m.position = 0;
assert (m.available == 42); assert (m.available == 42);
m.writef("%d %d %s",100,345,"hello"); m.writef("%d %d %s",100,345,"hello");
@ -2774,7 +2774,7 @@ unittest {
MmFileStream m; MmFileStream m;
m = new MmFileStream (mf); m = new MmFileStream (mf);
m.writeString ("Hello, world"); m.writeString ("Hello, world");
assert (m.position () == 12); assert (m.position == 12);
assert (m.seekSet (0) == 0); assert (m.seekSet (0) == 0);
assert (m.seekCur (4) == 4); assert (m.seekCur (4) == 4);
assert (m.seekEnd (-8) == 92); assert (m.seekEnd (-8) == 92);
@ -2782,13 +2782,13 @@ unittest {
assert (m.seekSet (4)); assert (m.seekSet (4));
assert (m.readString (4) == "o, w"); assert (m.readString (4) == "o, w");
m.writeString ("ie"); m.writeString ("ie");
ubyte[] dd = m.data(); ubyte[] dd = m.data;
assert ((cast(char[]) dd)[0 .. 12] == "Hello, wield"); assert ((cast(char[]) dd)[0 .. 12] == "Hello, wield");
m.position = 12; m.position = 12;
m.writeString ("Foo"); m.writeString ("Foo");
assert (m.position () == 15); assert (m.position == 15);
m.writeString ("Foo foo foo foo foo foo foo"); m.writeString ("Foo foo foo foo foo foo foo");
assert (m.position () == 42); assert (m.position == 42);
m.close(); m.close();
mf = new MmFile("testing.txt"); mf = new MmFile("testing.txt");
m = new MmFileStream (mf); m = new MmFileStream (mf);
@ -2944,21 +2944,21 @@ class SliceStream : FilterStream {
m = new MemoryStream ((cast(char[])"Hello, world").dup); m = new MemoryStream ((cast(char[])"Hello, world").dup);
s = new SliceStream (m, 4, 8); s = new SliceStream (m, 4, 8);
assert (s.size == 4); assert (s.size == 4);
assert (m.position () == 0); assert (m.position == 0);
assert (s.position () == 0); assert (s.position == 0);
assert (m.available == 12); assert (m.available == 12);
assert (s.available == 4); assert (s.available == 4);
assert (s.writeBlock (cast(char *) "Vroom", 5) == 4); assert (s.writeBlock (cast(char *) "Vroom", 5) == 4);
assert (m.position () == 0); assert (m.position == 0);
assert (s.position () == 4); assert (s.position == 4);
assert (m.available == 12); assert (m.available == 12);
assert (s.available == 0); assert (s.available == 0);
assert (s.seekEnd (-2) == 2); assert (s.seekEnd (-2) == 2);
assert (s.available == 2); assert (s.available == 2);
assert (s.seekEnd (2) == 4); assert (s.seekEnd (2) == 4);
assert (s.available == 0); assert (s.available == 0);
assert (m.position () == 0); assert (m.position == 0);
assert (m.available == 12); assert (m.available == 12);
m.seekEnd(0); m.seekEnd(0);
@ -2975,10 +2975,10 @@ class SliceStream : FilterStream {
assert (s.available == 0); assert (s.available == 0);
s.writeString (", etcetera."); s.writeString (", etcetera.");
assert (s.position () == 25); assert (s.position == 25);
assert (s.seekSet (0) == 0); assert (s.seekSet (0) == 0);
assert (s.size == 25); assert (s.size == 25);
assert (m.position () == 18); assert (m.position == 18);
assert (m.size == 29); assert (m.size == 29);
assert (m.toString() == "HellVrooorld\nBlaho, etcetera."); assert (m.toString() == "HellVrooorld\nBlaho, etcetera.");
} }

View file

@ -2320,7 +2320,7 @@ private static:
* Returns D code which declares function parameters. * Returns D code which declares function parameters.
* "ref int a0, real a1, ..." * "ref int a0, real a1, ..."
*/ */
private string generateParameters(string myFuncInfo, func...)() @property private string generateParameters(string myFuncInfo, func...)()
{ {
alias ParameterStorageClass STC; alias ParameterStorageClass STC;
alias ParameterStorageClassTuple!(func) stcs; alias ParameterStorageClassTuple!(func) stcs;

View file

@ -1074,7 +1074,7 @@ unittest
* //provide a custom RNG. Must be seeded manually. * //provide a custom RNG. Must be seeded manually.
* Xorshift192 gen; * Xorshift192 gen;
* *
* gen.seed(unpredictableSeed()); * gen.seed(unpredictableSeed);
* auto uuid3 = randomUUID(gen); * auto uuid3 = randomUUID(gen);
* ------------------------------------------ * ------------------------------------------
*/ */
@ -1127,7 +1127,7 @@ unittest
//provide a custom RNG. Must be seeded manually. //provide a custom RNG. Must be seeded manually.
Xorshift192 gen; Xorshift192 gen;
gen.seed(unpredictableSeed()); gen.seed(unpredictableSeed);
auto uuid3 = randomUUID(gen); auto uuid3 = randomUUID(gen);
auto u1 = randomUUID(); auto u1 = randomUUID();

View file

@ -704,7 +704,7 @@ public:
{ {
static if (isNumeric!(T)) static if (isNumeric!(T))
{ {
if (convertsTo!real()) if (convertsTo!real)
{ {
// maybe optimize this fella; handle ints separately // maybe optimize this fella; handle ints separately
return to!T(get!real); return to!T(get!real);
@ -725,7 +725,7 @@ public:
else else
{ {
enforce(false, text("Type ", type(), " does not convert to ", enforce(false, text("Type ", type, " does not convert to ",
typeid(T))); typeid(T)));
assert(0); assert(0);
} }
@ -1055,7 +1055,7 @@ public:
int opApply(Delegate)(scope Delegate dg) if (is(Delegate == delegate)) int opApply(Delegate)(scope Delegate dg) if (is(Delegate == delegate))
{ {
alias ParameterTypeTuple!(Delegate)[0] A; alias ParameterTypeTuple!(Delegate)[0] A;
if (type() == typeid(A[])) if (type == typeid(A[]))
{ {
auto arr = get!(A[]); auto arr = get!(A[]);
foreach (ref e; arr) foreach (ref e; arr)
@ -1077,7 +1077,7 @@ public:
} }
else else
{ {
enforce(false, text("Variant type ", type(), enforce(false, text("Variant type ", type,
" not iterable with values of type ", " not iterable with values of type ",
A.stringof)); A.stringof));
} }
@ -1497,7 +1497,7 @@ unittest
unittest unittest
{ {
const x = Variant(42); const x = Variant(42);
auto y1 = x.get!(const int)(); auto y1 = x.get!(const int);
// @@@BUG@@@ // @@@BUG@@@
//auto y2 = x.get!(immutable int)(); //auto y2 = x.get!(immutable int)();
} }
@ -1829,7 +1829,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant
enum HandlerOverloadMap = visitGetOverloadMap(); enum HandlerOverloadMap = visitGetOverloadMap();
if (!variant.hasValue()) if (!variant.hasValue)
{ {
// Call the exception function. The HandlerOverloadMap // Call the exception function. The HandlerOverloadMap
// will have its exceptionFuncIdx field set to value != -1 if an // will have its exceptionFuncIdx field set to value != -1 if an

View file

@ -77,8 +77,8 @@ version (all)
OutBuffer b = new OutBuffer(); // outbuffer OutBuffer b = new OutBuffer(); // outbuffer
std.ctype.tolower('A'); // ctype std.ctype.tolower('A'); // ctype
RegExp r = new RegExp(null, null); // regexp RegExp r = new RegExp(null, null); // regexp
uint ranseed = std.random.unpredictableSeed(); uint ranseed = std.random.unpredictableSeed;
thisTid(); thisTid;
int a[]; int a[];
a.reverse; // adi a.reverse; // adi
a.sort; // qsort a.sort; // qsort