mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 08:00:48 +03:00
Fix @property annotations and incorrect parenthesis
This commit is contained in:
parent
50c7b20959
commit
30356d606f
7 changed files with 35 additions and 20 deletions
|
@ -339,6 +339,8 @@ version(unittest)
|
|||
mixin(dummyRanges);
|
||||
}
|
||||
|
||||
private T* addressOf(T)(ref T val) { return &val; }
|
||||
|
||||
/**
|
||||
$(D auto map(Range)(Range r) if (isInputRange!(Unqual!Range));)
|
||||
|
||||
|
@ -1163,9 +1165,11 @@ void uninitializedFill(Range, Value)(Range range, Value filler)
|
|||
{
|
||||
alias ElementType!Range T;
|
||||
static if (hasElaborateAssign!T)
|
||||
{
|
||||
// Must construct stuff by the book
|
||||
for (; !range.empty; range.popFront())
|
||||
emplace(&range.front(), filler);
|
||||
emplace(addressOf(range.front), filler);
|
||||
}
|
||||
else
|
||||
// Doesn't matter whether fill is initialized or not
|
||||
return fill(range, filler);
|
||||
|
@ -1208,13 +1212,13 @@ void initializeAll(Range)(Range range)
|
|||
auto p = typeid(T).init().ptr;
|
||||
if (p)
|
||||
for ( ; !range.empty ; range.popFront() )
|
||||
memcpy(&range.front(), p, T.sizeof);
|
||||
memcpy(addressOf(range.front), p, T.sizeof);
|
||||
else
|
||||
static if (isDynamicArray!Range)
|
||||
memset(range.ptr, 0, range.length * T.sizeof);
|
||||
else
|
||||
for ( ; !range.empty ; range.popFront() )
|
||||
memset(&range.front(), 0, T.sizeof);
|
||||
memset(addressOf(range.front), 0, T.sizeof);
|
||||
}
|
||||
else
|
||||
fill(range, T.init);
|
||||
|
@ -9465,7 +9469,7 @@ makeIndex(
|
|||
// assume collection already ordered
|
||||
size_t i;
|
||||
for (; !r.empty; r.popFront(), ++i)
|
||||
index[i] = &(r.front);
|
||||
index[i] = addressOf(r.front);
|
||||
enforce(index.length == i);
|
||||
// sort the index
|
||||
sort!((a, b) => binaryFun!less(*a, *b), ss)(index);
|
||||
|
|
|
@ -234,7 +234,7 @@ struct SHA1
|
|||
|
||||
shared static this()
|
||||
{
|
||||
transform = hasSSSE3Support() ? &transformSSSE3 : &transformX86;
|
||||
transform = hasSSSE3Support ? &transformSSSE3 : &transformX86;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -847,7 +847,7 @@ unittest
|
|||
/++
|
||||
Returns whether the given file (or directory) exists.
|
||||
+/
|
||||
@property bool exists(in char[] name)
|
||||
bool exists(in char[] name)
|
||||
{
|
||||
version(Windows)
|
||||
{
|
||||
|
|
|
@ -4103,7 +4103,7 @@ unittest
|
|||
auto tSlow = task!slowFun();
|
||||
pool1.put(tSlow);
|
||||
pool1.finish();
|
||||
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.
|
||||
|
|
|
@ -1965,7 +1965,7 @@ private auto executeImpl(alias pipeFunc, Cmd)(
|
|||
// Store up to maxOutput bytes in a.
|
||||
foreach (ubyte[] chunk; p.stdout.byChunk(chunkSize))
|
||||
{
|
||||
immutable size_t remain = maxOutput - a.data().length;
|
||||
immutable size_t remain = maxOutput - a.data.length;
|
||||
|
||||
if (chunk.length < remain) a.put(chunk);
|
||||
else
|
||||
|
@ -2041,7 +2041,7 @@ class ProcessException : Exception
|
|||
{
|
||||
auto errnoMsg = to!string(std.c.string.strerror(errno));
|
||||
}
|
||||
auto msg = customMsg.empty() ? errnoMsg
|
||||
auto msg = customMsg.empty ? errnoMsg
|
||||
: customMsg ~ " (" ~ errnoMsg ~ ')';
|
||||
return new ProcessException(msg, file, line);
|
||||
}
|
||||
|
@ -2053,7 +2053,7 @@ class ProcessException : Exception
|
|||
size_t line = __LINE__)
|
||||
{
|
||||
auto lastMsg = sysErrorString(GetLastError());
|
||||
auto msg = customMsg.empty() ? lastMsg
|
||||
auto msg = customMsg.empty ? lastMsg
|
||||
: customMsg ~ " (" ~ lastMsg ~ ')';
|
||||
return new ProcessException(msg, file, line);
|
||||
}
|
||||
|
|
|
@ -1887,7 +1887,7 @@ unittest
|
|||
assert(s1[0..0].empty);
|
||||
assert(s1[3..3].empty);
|
||||
// assert(s1[$ .. $].empty);
|
||||
assert(s1[s1.opDollar() .. s1.opDollar()].empty);
|
||||
assert(s1[s1.opDollar .. s1.opDollar].empty);
|
||||
|
||||
auto s2 = stride(arr, 2);
|
||||
assert(equal(s2[0..2], [1,3]));
|
||||
|
@ -1897,7 +1897,7 @@ unittest
|
|||
assert(s2[0..0].empty);
|
||||
assert(s2[3..3].empty);
|
||||
// assert(s2[$ .. $].empty);
|
||||
assert(s2[s2.opDollar() .. s2.opDollar()].empty);
|
||||
assert(s2[s2.opDollar .. s2.opDollar].empty);
|
||||
|
||||
// Test fix for Bug 5035
|
||||
auto m = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]; // 3 rows, 4 columns
|
||||
|
|
|
@ -2670,7 +2670,7 @@ template wrap(Targets...)
|
|||
if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
|
||||
{
|
||||
// strict upcast
|
||||
@property wrap(Source)(inout Source src) @trusted pure nothrow
|
||||
auto wrap(Source)(inout Source src) @trusted pure nothrow
|
||||
if (Targets.length == 1 && is(Source : Targets[0]))
|
||||
{
|
||||
alias T = Select!(is(Source == shared), shared Targets[0], Targets[0]);
|
||||
|
@ -2680,7 +2680,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
|
|||
template wrap(Source)
|
||||
if (!allSatisfy!(Bind!(isImplicitlyConvertible, Source), Targets))
|
||||
{
|
||||
@property wrap(inout Source src)
|
||||
auto wrap(inout Source src)
|
||||
{
|
||||
static assert(hasRequireMethods!(),
|
||||
"Source "~Source.stringof~
|
||||
|
@ -2813,10 +2813,21 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
|
|||
return r;
|
||||
}
|
||||
enum n = to!string(i);
|
||||
static if (fa & FunctionAttribute.property)
|
||||
{
|
||||
static if (ParameterTypeTuple!(TargetMembers[i].type).length == 0)
|
||||
enum fbody = "_wrap_source."~name;
|
||||
else
|
||||
enum fbody = "_wrap_source."~name~" = forward!args";
|
||||
}
|
||||
else
|
||||
{
|
||||
enum fbody = "_wrap_source."~name~"(forward!args)";
|
||||
}
|
||||
enum generateFun =
|
||||
"override "~stc~"ReturnType!(TargetMembers["~n~"].type) "
|
||||
~ name~"(ParameterTypeTuple!(TargetMembers["~n~"].type) args) "~mod~
|
||||
"{ return _wrap_source."~name~"(forward!args); }";
|
||||
"{ return "~fbody~"; }";
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -2845,14 +2856,14 @@ template unwrap(Target)
|
|||
if (isMutable!Target)
|
||||
{
|
||||
// strict downcast
|
||||
@property unwrap(Source)(inout Source src) @trusted pure nothrow
|
||||
auto unwrap(Source)(inout Source src) @trusted pure nothrow
|
||||
if (is(Target : Source))
|
||||
{
|
||||
alias T = Select!(is(Source == shared), shared Target, Target);
|
||||
return cast(inout T)(src);
|
||||
}
|
||||
// structural downcast
|
||||
@property unwrap(Source)(inout Source src) @trusted pure nothrow
|
||||
auto unwrap(Source)(inout Source src) @trusted pure nothrow
|
||||
if (!is(Target : Source))
|
||||
{
|
||||
alias T = Select!(is(Source == shared), shared Target, Target);
|
||||
|
@ -2931,7 +2942,7 @@ unittest
|
|||
// structural upcast (two steps)
|
||||
Quack qx = h1.wrap!Quack; // Human -> Quack
|
||||
Flyer fx = qx.wrap!Flyer; // Quack -> Flyer
|
||||
assert(fx.height() == 20); // calls Human.height
|
||||
assert(fx.height == 20); // calls Human.height
|
||||
// strucural downcast (two steps)
|
||||
Quack qy = fx.unwrap!Quack; // Flyer -> Quack
|
||||
Human hy = qy.unwrap!Human; // Quack -> Human
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue