Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Revert "not really pure"
Browse files Browse the repository at this point in the history
This reverts commit 40defe5.

Since Walter put weakly pure back in, these changes need to be undone.
  • Loading branch information
jmdavis committed Jul 7, 2011
1 parent 6afabc0 commit eb8246c
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/core/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public:
$(TR $(TD this > rhs) $(TD > 0))
)
+/
int opCmp(in Duration rhs) const nothrow
int opCmp(in Duration rhs) const pure nothrow
{
if(_hnsecs < rhs._hnsecs)
return -1;
Expand Down Expand Up @@ -166,7 +166,7 @@ public:
not have access to std.traits, and naming it Unqual as well would
result in a name clash, so it's TUnqual.
+/
Duration opBinary(string op, D)(in D rhs) const nothrow
Duration opBinary(string op, D)(in D rhs) const pure nothrow
if((op == "+" || op == "-") &&
(is(TUnqual!D == Duration) ||
is(TUnqual!D == TickDuration)))
Expand Down Expand Up @@ -422,7 +422,7 @@ public:
Params:
value = The value to multiply this duration by.
+/
Duration opBinary(string op)(long value) const nothrow
Duration opBinary(string op)(long value) const pure nothrow
if(op == "*")
{
return Duration(_hnsecs * value);
Expand Down Expand Up @@ -520,7 +520,7 @@ public:
Throws:
TimeException if an attempt to divide by 0 is made.
+/
Duration opBinary(string op)(long value) const
Duration opBinary(string op)(long value) pure const
if(op == "/")
{
if(value == 0)
Expand Down Expand Up @@ -626,7 +626,7 @@ public:
Params:
value = The number of units to multiply this duration by.
+/
Duration opBinaryRight(string op)(long value) const nothrow
Duration opBinaryRight(string op)(long value) const pure nothrow
if(op == "*")
{
return opBinary!op(value);
Expand Down Expand Up @@ -659,7 +659,7 @@ public:
/++
Returns the negation of this Duration.
+/
Duration opUnary(string op)() const nothrow
Duration opUnary(string op)() const pure nothrow
if(op == "-")
{
return Duration(-_hnsecs);
Expand Down Expand Up @@ -696,7 +696,7 @@ assert(dur!"hours"(49).get!"days"() == 2);
assert(dur!"hours"(49).get!"hours"() == 1);
--------------------
+/
long get(string units)() const nothrow
long get(string units)() const pure nothrow
if(units == "weeks" ||
units == "days" ||
units == "hours" ||
Expand Down Expand Up @@ -884,7 +884,7 @@ assert(dur!"hnsecs"(50_007).fracSec == FracSec.from!"hnsecs"(50_007));
assert(dur!"nsecs"(62_127).fracSec == FracSec.from!"nsecs"(62_100));
--------------------
+/
@property FracSec fracSec() const nothrow
@property FracSec fracSec() const pure nothrow
{
try
{
Expand Down Expand Up @@ -945,7 +945,7 @@ assert(dur!"nsecs"(2007).total!"hnsecs"() == 20);
assert(dur!"nsecs"(2007).total!"nsecs"() == 2000);
--------------------
+/
long total(string units)() const nothrow
long total(string units)() const pure nothrow
if(units == "weeks" ||
units == "days" ||
units == "hours" ||
Expand Down Expand Up @@ -1004,7 +1004,7 @@ assert(dur!"nsecs"(2007).total!"nsecs"() == 2000);
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
string toString() const pure nothrow
{
return _toStringImpl();
}
Expand All @@ -1020,7 +1020,7 @@ assert(dur!"nsecs"(2007).total!"nsecs"() == 2000);
}


@property bool isNegative() const nothrow
@property bool isNegative() const pure nothrow
{
return _hnsecs < 0;
}
Expand All @@ -1041,7 +1041,7 @@ private:
Since we have two versions of toString(), we have _toStringImpl()
so that they can share implementations.
+/
string _toStringImpl() const nothrow
string _toStringImpl() const pure nothrow
{
long hnsecs = _hnsecs;

Expand Down Expand Up @@ -1182,7 +1182,7 @@ private:
hnsecs = The total number of hecto-nanoseconds in this duration.
+/
@safe
nothrow this(long hnsecs)
pure nothrow this(long hnsecs)
{
_hnsecs = hnsecs;
}
Expand All @@ -1205,7 +1205,7 @@ private:
length = The number of units in the duration.
+/
@safe
Duration dur(string units)(long length) nothrow
Duration dur(string units)(long length) pure nothrow
if(units == "weeks" ||
units == "days" ||
units == "hours" ||
Expand Down Expand Up @@ -1321,7 +1321,7 @@ struct TickDuration
units = The units to convert to. "seconds" and smaller only.
T = The integral type to convert to.
+/
T to(string units, T)() const nothrow
T to(string units, T)() const pure nothrow
if((units == "seconds" ||
units == "msecs" ||
units == "usecs" ||
Expand All @@ -1345,7 +1345,7 @@ struct TickDuration
units = The units to convert to. "seconds" and smaller only.
T = The floating point type to convert to.
+/
T to(string units, T)() const nothrow
T to(string units, T)() const pure nothrow
if((units == "seconds" ||
units == "msecs" ||
units == "usecs" ||
Expand Down Expand Up @@ -1424,7 +1424,7 @@ struct TickDuration
units = The units to convert from. "seconds" and smaller.
value = The number of the units to convert from.
+/
static TickDuration from(string units)(long value) nothrow
static TickDuration from(string units)(long value) pure nothrow
if(units == "seconds" ||
units == "msecs" ||
units == "usecs" ||
Expand Down Expand Up @@ -1555,7 +1555,7 @@ struct TickDuration
/++
Returns a Duration with the same number of hnsecs as this TickDuration.
+/
Duration opCast(T)() const nothrow
Duration opCast(T)() const pure nothrow
if(is(T == Duration))
{
return Duration(hnsecs);
Expand Down Expand Up @@ -1618,7 +1618,7 @@ struct TickDuration
/++
operator overloading "-, +"
+/
TickDuration opBinary(string op)(in TickDuration rhs) const nothrow
TickDuration opBinary(string op)(in TickDuration rhs) const pure nothrow
if(op == "-" || op == "+")
{
return TickDuration(mixin("length " ~ op ~ " rhs.length"));
Expand All @@ -1636,7 +1636,7 @@ struct TickDuration
/++
Returns the negation of this TickDuration.
+/
TickDuration opUnary(string op)() const nothrow
TickDuration opUnary(string op)() const pure nothrow
if(op == "-")
{
return TickDuration(-length);
Expand All @@ -1660,7 +1660,7 @@ struct TickDuration
/++
operator overloading "=="
+/
bool opEquals(ref const TickDuration rhs) const nothrow
bool opEquals(ref const TickDuration rhs) const pure nothrow
{
return length == rhs.length;
}
Expand All @@ -1675,7 +1675,7 @@ struct TickDuration
/++
operator overloading "<, >, <=, >="
+/
int opCmp(ref const TickDuration rhs) const nothrow
int opCmp(ref const TickDuration rhs) const pure nothrow
{
return length < rhs.length ? -1 : (length == rhs.length ? 0 : 1);
}
Expand Down Expand Up @@ -1764,7 +1764,7 @@ struct TickDuration
Params:
value = The value to divide from this duration.
+/
TickDuration opBinary(string op, T)(T value) const nothrow
TickDuration opBinary(string op, T)(T value) const pure nothrow
if(op == "*" &&
(__traits(isIntegral, T) || __traits(isFloating, T)))
{
Expand Down Expand Up @@ -1794,7 +1794,7 @@ struct TickDuration
Throws:
TimeException if an attempt to divide by 0 is made.
+/
TickDuration opBinary(string op, T)(T value) const
TickDuration opBinary(string op, T)(T value) const pure
if(op == "/" &&
(__traits(isIntegral, T) || __traits(isFloating, T)))
{
Expand All @@ -1809,7 +1809,7 @@ struct TickDuration
Params:
ticks = The number of ticks in the TickDuration.
+/
nothrow this(long ticks)
pure nothrow this(long ticks)
{
this.length = ticks;
}
Expand Down Expand Up @@ -1915,7 +1915,7 @@ assert(convert!("months", "years")(12) == 1);
--------------------
+/
@safe
long convert(string from, string to)(long value) nothrow
long convert(string from, string to)(long value) pure nothrow
if((from == "years" || from == "months") &&
(to == "years" || to == "months"))
{
Expand Down Expand Up @@ -1986,7 +1986,7 @@ assert(convert!("seconds", "days")(86_400) == 1);
--------------------
+/
@safe
static long convert(string from, string to)(long value) nothrow
static long convert(string from, string to)(long value) pure nothrow
if((from == "weeks" ||
from == "days" ||
from == "hours" ||
Expand Down Expand Up @@ -2085,7 +2085,7 @@ assert(convert!("seconds", "nsecs")(1) == 1_000_000_000);
--------------------
+/
@safe
static long convert(string from, string to)(long value) nothrow
static long convert(string from, string to)(long value) pure nothrow
if((from == "nsecs" &&
(to == "weeks" ||
to == "days" ||
Expand Down Expand Up @@ -2181,7 +2181,7 @@ public:
TimeException if the given value is less than 0 or would result in a
FracSec greater than or equal to 1 second.
+/
static FracSec from(string units)(long value)
static FracSec from(string units)(long value) pure
if(units == "msecs" ||
units == "usecs" ||
units == "hnsecs" ||
Expand Down Expand Up @@ -2230,7 +2230,7 @@ public:
/++
The value of this FracSec as milliseconds.
+/
@property int msecs() const nothrow
@property int msecs() const pure nothrow
{
return cast(int)convert!("hnsecs", "msecs")(_hnsecs);
}
Expand Down Expand Up @@ -2261,7 +2261,7 @@ public:
Throws:
TimeException if the given value is not less than one second.
+/
@property void msecs(int milliseconds)
@property void msecs(int milliseconds) pure
{
immutable hnsecs = cast(int)convert!("msecs", "hnsecs")(milliseconds);

Expand Down Expand Up @@ -2300,7 +2300,7 @@ public:
/++
The value of this FracSec as microseconds.
+/
@property int usecs() const nothrow
@property int usecs() const pure nothrow
{
return cast(int)convert!("hnsecs", "usecs")(_hnsecs);
}
Expand Down Expand Up @@ -2331,7 +2331,7 @@ public:
Throws:
TimeException if the given value is not less than one second.
+/
@property void usecs(int microseconds)
@property void usecs(int microseconds) pure
{
immutable hnsecs = cast(int)convert!("usecs", "hnsecs")(microseconds);

Expand Down Expand Up @@ -2371,7 +2371,7 @@ public:
/++
The value of this FracSec as hnsecs.
+/
@property int hnsecs() const nothrow
@property int hnsecs() const pure nothrow
{
return _hnsecs;
}
Expand Down Expand Up @@ -2402,7 +2402,7 @@ public:
Throws:
TimeException if the given value is not less than one second.
+/
@property void hnsecs(int hnsecs)
@property void hnsecs(int hnsecs) pure
{
_enforceValid(hnsecs);
_hnsecs = hnsecs;
Expand Down Expand Up @@ -2444,7 +2444,7 @@ public:
Note that this does not give you any greater precision
than getting the value of this FracSec as hnsecs.
+/
@property int nsecs() const nothrow
@property int nsecs() const pure nothrow
{
return cast(int)convert!("hnsecs", "nsecs")(_hnsecs);
}
Expand Down Expand Up @@ -2478,7 +2478,7 @@ public:
Throws:
TimeException if the given value is not less than one second.
+/
@property void nsecs(long nsecs)
@property void nsecs(long nsecs) pure
{
//So that -99 through -1 throw instead of result in FracSec(0).
if(nsecs < 0)
Expand Down Expand Up @@ -2540,7 +2540,7 @@ public:
//Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
//have versions of toString() with extra modifiers, so we define one version
//with modifiers and one without.
string toString() const nothrow
string toString() const pure nothrow
{
return _toStringImpl();
}
Expand All @@ -2562,7 +2562,7 @@ private:
Since we have two versions of toString(), we have _toStringImpl()
so that they can share implementations.
+/
string _toStringImpl() const nothrow
string _toStringImpl() const pure nothrow
{
try
{
Expand Down Expand Up @@ -2679,14 +2679,14 @@ private:
TimeException if the given hnsecs less than 0 or would result in a
FracSec greater than or equal to 1 second.
+/
this(int hnsecs)
pure this(int hnsecs)
{
_enforceValid(hnsecs);
_hnsecs = hnsecs;
}


invariant()
pure invariant()
{
if(!_valid(_hnsecs))
throw new AssertError("Invaliant Failure: hnsecs [" ~ numToString(_hnsecs) ~ "]", __FILE__, __LINE__);
Expand Down

0 comments on commit eb8246c

Please sign in to comment.