Strict @property syntax compliance.

This enables the test suite to build with the -property switch enabled.

std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid.
std.xml: Element.text() cannot be a property due to the optional parameter.
This commit is contained in:
David Nadlinger 2011-12-01 22:49:16 +01:00
parent 0eddab60b9
commit e312f9898b
33 changed files with 603 additions and 593 deletions

View file

@ -492,9 +492,9 @@ unittest
assert(squares2.back == 16);
assert(squares2.front == 1);
squares2.popFront;
squares2.popFront();
assert(squares2.front == 4);
squares2.popBack;
squares2.popBack();
assert(squares2.front == 4);
assert(squares2.back == 9);
@ -527,10 +527,10 @@ unittest
// stuff is disabled.
auto fibsSquares = map!"a * a"(recurrence!("a[n-1] + a[n-2]")(1, 1));
assert(fibsSquares.front == 1);
fibsSquares.popFront;
fibsSquares.popFront;
fibsSquares.popFront();
fibsSquares.popFront();
assert(fibsSquares.front == 4);
fibsSquares.popFront;
fibsSquares.popFront();
assert(fibsSquares.front == 9);
auto repeatMap = map!"a"(repeat(1));
@ -641,7 +641,7 @@ template reduce(fun...) if (fun.length >= 1)
alias args[0] seed;
alias args[1] r;
Unqual!(Args[0]) result = seed;
for (; !r.empty; r.popFront)
for (; !r.empty; r.popFront())
{
static if (fun.length == 1)
{
@ -849,7 +849,7 @@ if (isForwardRange!Range && is(typeof(range.front = filler)))
alias ElementType!Range T;
static if (hasElaborateCopyConstructor!T || !isDynamicArray!Range)
{
for (; !range.empty; range.popFront)
for (; !range.empty; range.popFront())
{
range.front = filler;
}
@ -912,7 +912,7 @@ if (isForwardRange!Range1 && isForwardRange!Range2
{
enforce(!filler.empty);
auto t = filler.save;
for (; !range.empty; range.popFront, t.popFront)
for (; !range.empty; range.popFront(), t.popFront())
{
if (t.empty) t = filler;
range.front = t.front;
@ -950,7 +950,7 @@ if (isForwardRange!Range && is(typeof(range.front = filler)))
static if (hasElaborateCopyConstructor!T)
{
// Must construct stuff by the book
for (; !range.empty; range.popFront)
for (; !range.empty; range.popFront())
{
emplace(&range.front, filler);
}
@ -1006,7 +1006,7 @@ if (isForwardRange!Range && is(typeof(range.front = range.front)))
static if (is(typeof(&(range.front()))))
{
// Range exposes references
for (; !range.empty; range.popFront)
for (; !range.empty; range.popFront())
{
memcpy(&(range.front()), &T.init, T.sizeof);
}
@ -1014,7 +1014,7 @@ if (isForwardRange!Range && is(typeof(range.front = range.front)))
else
{
// Go the slow route
for (; !range.empty; range.popFront)
for (; !range.empty; range.popFront())
{
range.front = filler;
}
@ -1104,7 +1104,7 @@ template filter(alias pred) if (is(typeof(unaryFun!pred)))
{
do
{
_input.popFront;
_input.popFront();
} while (!_input.empty && !unaryFun!pred(_input.front));
}
@ -1258,7 +1258,7 @@ template filterBidirectional(alias pred)
{
do
{
_input.popFront;
_input.popFront();
} while (!_input.empty && !predFun(_input.front));
}
@ -1271,7 +1271,7 @@ template filterBidirectional(alias pred)
{
do
{
_input.popBack;
_input.popBack();
} while (!_input.empty && !predFun(_input.back));
}
@ -1422,7 +1422,7 @@ Range2 moveAll(Range1, Range2)(Range1 src, Range2 tgt)
if (isInputRange!Range1 && isInputRange!Range2
&& is(typeof(move(src.front, tgt.front))))
{
for (; !src.empty; src.popFront, tgt.popFront)
for (; !src.empty; src.popFront(), tgt.popFront())
{
enforce(!tgt.empty);
move(src.front, tgt.front);
@ -1452,7 +1452,7 @@ Tuple!(Range1, Range2) moveSome(Range1, Range2)(Range1 src, Range2 tgt)
if (isInputRange!Range1 && isInputRange!Range2
&& is(typeof(move(src.front, tgt.front))))
{
for (; !src.empty && !tgt.empty; src.popFront, tgt.popFront)
for (; !src.empty && !tgt.empty; src.popFront(), tgt.popFront())
{
enforce(!tgt.empty);
move(src.front, tgt.front);
@ -1859,7 +1859,7 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
static if (isBidirectionalRange!Range)
RIndexType _backLength = RIndexType.max;
auto separatorLength() { return _separator.length; }
@property auto separatorLength() { return _separator.length; }
void ensureFrontLength()
{
@ -1913,7 +1913,7 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
void popFront()
{
assert(!empty);
ensureFrontLength;
ensureFrontLength();
if (_frontLength == _input.length)
{
// done, there's no separator in sight
@ -1955,13 +1955,13 @@ if (is(typeof(Range.init.front == Separator.init.front) : bool))
{
@property Range back()
{
ensureBackLength;
ensureBackLength();
return _input[_input.length - _backLength .. _input.length];
}
void popBack()
{
ensureBackLength;
ensureBackLength();
if (_backLength == _input.length)
{
// done
@ -2482,7 +2482,7 @@ if (isInputRange!Range && is(typeof(binaryFun!pred(r.front, r.front)) == bool))
auto last = _input.front;
do
{
_input.popFront;
_input.popFront();
}
while (!_input.empty && binaryFun!(pred)(last, _input.front));
}
@ -2496,7 +2496,7 @@ if (isInputRange!Range && is(typeof(binaryFun!pred(r.front, r.front)) == bool))
auto last = _input.back;
do
{
_input.popBack;
_input.popBack();
}
while (!_input.empty && binaryFun!pred(last, _input.back));
}
@ -2575,7 +2575,7 @@ struct Group(alias pred, R) if (isInputRange!R)
this(R input)
{
_input = input;
if (!_input.empty) popFront;
if (!_input.empty) popFront();
}
void popFront()
@ -2587,11 +2587,11 @@ struct Group(alias pred, R) if (isInputRange!R)
else
{
_current = tuple(_input.front, 1u);
_input.popFront;
_input.popFront();
while (!_input.empty && comp(_current[0], _input.front))
{
++_current[1];
_input.popFront;
_input.popFront();
}
}
}
@ -2680,12 +2680,12 @@ assert(r == [ 1, 2, 3, 4, 5 ]);
// //auto target = begin(r), e = end(r);
// auto target = r;
// auto source = r;
// source.popFront;
// source.popFront();
// while (!source.empty)
// {
// if (!pred(target.front, source.front))
// {
// target.popFront;
// target.popFront();
// continue;
// }
// // found an equal *source and *target
@ -2694,9 +2694,9 @@ assert(r == [ 1, 2, 3, 4, 5 ]);
// //@@@
// //move(source.front, target.front);
// target[0] = source[0];
// source.popFront;
// source.popFront();
// if (source.empty) break;
// if (!pred(target.front, source.front)) target.popFront;
// if (!pred(target.front, source.front)) target.popFront();
// }
// break;
// }
@ -3093,7 +3093,7 @@ Tuple!(Range, size_t) find(alias pred = "a == b", Range, Ranges...)
(Range haystack, Ranges needles)
if (Ranges.length > 1 && allSatisfy!(isForwardRange, Ranges))
{
for (;; haystack.popFront)
for (;; haystack.popFront())
{
size_t r = startsWith!pred(haystack, needles);
if (r || haystack.empty)
@ -3324,7 +3324,7 @@ assert(find!(pred)(arr) == arr);
Range find(alias pred, Range)(Range haystack) if (isInputRange!(Range))
{
alias unaryFun!(pred) predFun;
for (; !haystack.empty && !predFun(haystack.front); haystack.popFront)
for (; !haystack.empty && !predFun(haystack.front); haystack.popFront())
{
}
return haystack;
@ -3794,13 +3794,13 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
_done = true;
return;
}
_input.popFront;
_input.popFront();
_done = _input.empty;
}
else
{
_input.popFront;
_done = _input.empty || predSatisfied;
_input.popFront();
_done = _input.empty || predSatisfied();
}
}
@ -4402,7 +4402,7 @@ Range findAdjacent(alias pred = "a == b", Range)(Range r)
auto ahead = r;
if (!ahead.empty)
{
for (ahead.popFront; !ahead.empty; r.popFront, ahead.popFront)
for (ahead.popFront(); !ahead.empty; r.popFront(), ahead.popFront())
{
if (binaryFun!(pred)(r.front, ahead.front)) return r;
}
@ -4449,7 +4449,7 @@ Range1 findAmong(alias pred = "a == b", Range1, Range2)(
Range1 seq, Range2 choices)
if (isInputRange!Range1 && isForwardRange!Range2)
{
for (; !seq.empty && find!pred(choices, seq.front).empty; seq.popFront)
for (; !seq.empty && find!pred(choices, seq.front).empty; seq.popFront())
{
}
return seq;
@ -4968,7 +4968,7 @@ minCount(alias pred = "a < b", Range)(Range range)
if (range.empty) return typeof(return)();
auto p = &(range.front());
size_t occurrences = 1;
for (range.popFront; !range.empty; range.popFront)
for (range.popFront(); !range.empty; range.popFront())
{
if (binaryFun!(pred)(*p, range.front)) continue;
if (binaryFun!(pred)(range.front, *p))
@ -5018,7 +5018,7 @@ Range minPos(alias pred = "a < b", Range)(Range range)
{
if (range.empty) return range;
auto result = range;
for (range.popFront; !range.empty; range.popFront)
for (range.popFront(); !range.empty; range.popFront())
{
if (binaryFun!(pred)(result.front, range.front)
|| !binaryFun!(pred)(range.front, result.front)) continue;
@ -5294,7 +5294,7 @@ levenshteinDistanceAndPath(alias equals = "a == b", Range1, Range2)
{
Levenshtein!(Range1, binaryFun!(equals)) lev;
auto d = lev.distance(s, t);
return tuple(d, lev.path);
return tuple(d, lev.path());
}
unittest
@ -5429,7 +5429,7 @@ swapRanges(Range1, Range2)(Range1 r1, Range2 r2)
&& hasSwappableElements!(Range1) && hasSwappableElements!(Range2)
&& is(ElementType!(Range1) == ElementType!(Range2)))
{
for (; !r1.empty && !r2.empty; r1.popFront, r2.popFront)
for (; !r1.empty && !r2.empty; r1.popFront(), r2.popFront())
{
swap(r1.front, r2.front);
}
@ -5466,9 +5466,9 @@ if (isBidirectionalRange!(Range) && hasSwappableElements!(Range))
while (!r.empty)
{
swap(r.front, r.back);
r.popFront;
r.popFront();
if (r.empty) break;
r.popBack;
r.popBack();
}
}
@ -5874,8 +5874,8 @@ if (isBidirectionalRange!Range && hasLength!Range && s != SwapStrategy.stable
foreach (i; 0 .. rid)
{
move(range.back, t.front);
range.popBack;
t.popFront;
range.popBack();
t.popFront();
}
if (rEnd - rStart == lEnd - lStart)
{
@ -5947,14 +5947,14 @@ if ((isForwardRange!Range && !isBidirectionalRange!Range
enum delta = 1;
}
assert(pos <= from);
for (; pos < from; ++pos, src.popFront, tgt.popFront)
for (; pos < from; ++pos, src.popFront(), tgt.popFront())
{
move(src.front, tgt.front);
}
// now skip source to the "to" position
src.popFrontN(delta);
pos += delta;
foreach (j; 0 .. delta) result.popBack;
foreach (j; 0 .. delta) result.popBack();
}
// leftover move
moveAll(src, tgt);
@ -6023,28 +6023,28 @@ if (isBidirectionalRange!Range)
{
if (!unaryFun!(pred)(range.front))
{
range.popFront;
range.popFront();
continue;
}
move(range.back, range.front);
range.popBack;
result.popBack;
range.popBack();
result.popBack();
}
}
else
{
auto tgt = range;
for (; !range.empty; range.popFront)
for (; !range.empty; range.popFront())
{
if (unaryFun!(pred)(range.front))
{
// yank this guy
result.popBack;
result.popBack();
continue;
}
// keep this guy
move(range.front, tgt.front);
tgt.popFront;
tgt.popFront();
}
}
return result;
@ -6203,7 +6203,7 @@ Range partition(alias predicate,
{
if (r.length == 1)
{
if (pred(r.front)) r.popFront;
if (pred(r.front)) r.popFront();
return r;
}
const middle = r.length / 2;
@ -6215,17 +6215,17 @@ Range partition(alias predicate,
}
else static if (ss == SwapStrategy.semistable)
{
for (; !r.empty; r.popFront)
for (; !r.empty; r.popFront())
{
// skip the initial portion of "correct" elements
if (pred(r.front)) continue;
// hit the first "bad" element
auto result = r;
for (r.popFront; !r.empty; r.popFront)
for (r.popFront(); !r.empty; r.popFront())
{
if (!pred(r.front)) continue;
swap(result.front, r.front);
result.popFront;
result.popFront();
}
return result;
}
@ -6242,15 +6242,15 @@ Range partition(alias predicate,
{
if (r.empty) return result;
if (!pred(r.front)) break;
r.popFront;
result.popFront;
r.popFront();
result.popFront();
}
// found the left bound
assert(!r.empty);
for (;;)
{
if (pred(r.back)) break;
r.popBack;
r.popBack();
if (r.empty) return result;
}
// found the right bound, swap & make progress
@ -6264,9 +6264,9 @@ Range partition(alias predicate,
r.front = t2;
r.back = t1;
}
r.popFront;
result.popFront;
r.popBack;
r.popFront();
result.popFront();
r.popBack();
}
}
}
@ -6307,7 +6307,7 @@ unittest // partition
auto a = rndstuff!(int)();
partition!(even)(a);
assert(isPartitioned!(even)(a));
auto b = rndstuff!(string);
auto b = rndstuff!(string)();
partition!(`a.length < 5`)(b);
assert(isPartitioned!(`a.length < 5`)(b));
}
@ -6325,10 +6325,10 @@ assert(isPartitioned!("a & 1")(r));
bool isPartitioned(alias pred, Range)(Range r)
if (isForwardRange!(Range))
{
for (; !r.empty; r.popFront)
for (; !r.empty; r.popFront())
{
if (unaryFun!(pred)(r.front)) continue;
for (r.popFront; !r.empty; r.popFront)
for (r.popFront(); !r.empty; r.popFront())
{
if (unaryFun!(pred)(r.front)) return false;
}
@ -6602,7 +6602,7 @@ void topN(alias less = "a < b",
static assert(ss == SwapStrategy.unstable,
"Stable topN not yet implemented");
auto heap = BinaryHeap!Range1(r1);
for (; !r2.empty; r2.popFront)
for (; !r2.empty; r2.popFront())
{
heap.conditionalInsert(r2.front);
}
@ -6714,10 +6714,10 @@ unittest
//sort!("b - a")(a);
//assert(isSorted!(less)(a));
a = rndstuff!(int);
a = rndstuff!(int)();
sort(a);
assert(isSorted(a));
auto b = rndstuff!(string);
auto b = rndstuff!(string)();
sort!("toLower(a) < toLower(b)")(b);
assert(isSorted!("toUpper(a) < toUpper(b)")(b));
}
@ -7251,7 +7251,7 @@ void makeIndex(
{
// assume collection already ordered
size_t i;
for (; !r.empty; r.popFront, ++i)
for (; !r.empty; r.popFront(), ++i)
index[i] = &(r.front);
enforce(index.length == i);
// sort the index
@ -7280,16 +7280,16 @@ void makeIndex(
static if(I.sizeof < size_t.sizeof)
{
enforce(r.length <= I.max, "Cannot create an index with " ~
"element type " ~ I.stringof ~ " with length " ~
"element type " ~ I.stringof ~ " with length " ~
to!string(r.length) ~ "."
);
}
for(I i = 0; i < r.length; ++i)
for(I i = 0; i < r.length; ++i)
{
index[cast(size_t) i] = i;
}
// sort the index
bool indirectLess(ElementType!(RangeIndex) a, ElementType!(RangeIndex) b)
{
@ -7593,7 +7593,7 @@ unittest
}
// random data
auto b = rndstuff!(string);
auto b = rndstuff!(string)();
auto index = new string*[b.length];
partialIndex!("std.uni.toUpper(a) < std.uni.toUpper(b)")(b, index);
assert(isSorted!("std.uni.toUpper(*a) < std.uni.toUpper(*b)")(index));
@ -7672,7 +7672,7 @@ unittest
// && *index[2] == "c" && *index[3] == "C");
// // random data
// auto b = rndstuff!(string);
// auto b = rndstuff!(string)();
// auto index1 = schwartzMakeIndex!(toUpper)(b);
// assert(isSorted!("toUpper(*a) < toUpper(*b)")(index1));
// }
@ -7694,7 +7694,7 @@ unittest
{
debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
auto a = rndstuff!(int);
auto a = rndstuff!(int)();
if (a.length)
{
auto b = a[a.length / 2];
@ -7883,7 +7883,7 @@ public:
if (i < _crt) continue;
// found _crt
assert(!_r[i].empty);
_r[i].popFront;
_r[i].popFront();
adjustPosition();
return;
}
@ -7985,11 +7985,11 @@ private:
{
if (comp(_input[0].front, _input[1].front))
{
_input[0].popFront;
_input[0].popFront();
}
else if (comp(_input[1].front, _input[0].front))
{
_input[1].popFront;
_input[1].popFront();
}
else
{
@ -8003,7 +8003,7 @@ public:
{
this._input = input;
// position to the first element
adjustPosition;
adjustPosition();
}
@property bool empty()
@ -8020,9 +8020,9 @@ public:
assert(!empty);
assert(!comp(_input[0].front, _input[1].front)
&& !comp(_input[1].front, _input[0].front));
_input[0].popFront;
_input[1].popFront;
adjustPosition;
_input[0].popFront();
_input[1].popFront();
adjustPosition();
}
@property ElementType front()
@ -8102,13 +8102,13 @@ private:
if (r2.empty || comp(r1.front, r2.front)) break;
if (comp(r2.front, r1.front))
{
r2.popFront;
r2.popFront();
}
else
{
// both are equal
r1.popFront;
r2.popFront;
r1.popFront();
r2.popFront();
}
}
}
@ -8119,13 +8119,13 @@ public:
this.r1 = r1;
this.r2 = r2;
// position to the first element
adjustPosition;
adjustPosition();
}
void popFront()
{
r1.popFront;
adjustPosition;
r1.popFront();
adjustPosition();
}
@property ElementType!(R1) front()
@ -8145,7 +8145,7 @@ public:
}
}
bool empty() { return r1.empty; }
@property bool empty() { return r1.empty; }
}
/// Ditto
@ -8198,8 +8198,8 @@ private:
break;
}
// equal, pop both
r1.popFront;
r2.popFront;
r1.popFront();
r2.popFront();
}
}
@ -8209,28 +8209,28 @@ public:
this.r1 = r1;
this.r2 = r2;
// position to the first element
adjustPosition;
adjustPosition();
}
void popFront()
{
assert(!empty);
if (r1.empty) r2.popFront;
else if (r2.empty) r1.popFront;
if (r1.empty) r2.popFront();
else if (r2.empty) r1.popFront();
else
{
// neither is empty
if (comp(r1.front, r2.front))
{
r1.popFront;
r1.popFront();
}
else
{
assert(comp(r2.front, r1.front));
r2.popFront;
r2.popFront();
}
}
adjustPosition;
adjustPosition();
}
@property ElementType!(R1) front()
@ -8409,10 +8409,10 @@ struct NWayUnion(alias less, RangeOfRanges)
{
_heap.removeFront();
// let's look at the guy just popped
_ror.back.popFront;
_ror.back.popFront();
if (_ror.back.empty)
{
_ror.popBack;
_ror.popBack();
// nothing else to do: the empty range is not in the
// heap and not in _ror
return;