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

Commit

Permalink
move towards const correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 17, 2012
1 parent 0d0c4e3 commit 55e77ee
Show file tree
Hide file tree
Showing 41 changed files with 348 additions and 92 deletions.
10 changes: 5 additions & 5 deletions src/core/exception.d
Expand Up @@ -151,7 +151,7 @@ class FinalizeError : Error
info = ci;
}

override string toString()
@safe override const string toString()
{
return "An exception was thrown while finalizing an instance of class " ~ info.name;
}
Expand Down Expand Up @@ -234,9 +234,9 @@ class OutOfMemoryError : Error
super( "Memory allocation failed", file, line, next );
}

override string toString()
@trusted override const string toString()
{
return msg ? super.toString() : "Memory allocation failed";
return msg ? (cast()super).toString() : "Memory allocation failed";
}
}

Expand Down Expand Up @@ -275,9 +275,9 @@ class InvalidMemoryOperationError : Error
super( "Invalid memory operation", file, line, next );
}

override string toString()
@trusted override const string toString()
{
return msg ? super.toString() : "Invalid memory operation";
return msg ? (cast()super).toString() : "Invalid memory operation";
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/sync/mutex.d
Expand Up @@ -128,7 +128,7 @@ class Mutex :
* Throws:
* SyncException on error.
*/
void lock()
@trusted void lock()
{
version( Windows )
{
Expand All @@ -150,7 +150,7 @@ class Mutex :
* Throws:
* SyncException on error.
*/
void unlock()
@trusted void unlock()
{
version( Windows )
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/sync/rwmutex.d
Expand Up @@ -183,7 +183,7 @@ class ReadWriteMutex
/**
* Acquires a read lock on the enclosing mutex.
*/
void lock()
@trusted void lock()
{
synchronized( m_commonMutex )
{
Expand All @@ -200,7 +200,7 @@ class ReadWriteMutex
/**
* Releases a read lock on the enclosing mutex.
*/
void unlock()
@trusted void unlock()
{
synchronized( m_commonMutex )
{
Expand Down Expand Up @@ -286,7 +286,7 @@ class ReadWriteMutex
/**
* Acquires a write lock on the enclosing mutex.
*/
void lock()
@trusted void lock()
{
synchronized( m_commonMutex )
{
Expand All @@ -303,7 +303,7 @@ class ReadWriteMutex
/**
* Releases a write lock on the enclosing mutex.
*/
void unlock()
@trusted void unlock()
{
synchronized( m_commonMutex )
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/sys/windows/stacktrace.d
Expand Up @@ -249,7 +249,7 @@ public:
}


override string toString()
@safe override string toString() const pure nothrow
{
string result;

Expand All @@ -272,8 +272,8 @@ private:
return traceNoSync();
}
}


static char[][] traceNoSync()
{
auto dbghelp = DbgHelp.get();
Expand Down
5 changes: 5 additions & 0 deletions src/rt/typeinfo/ti_AC.d
Expand Up @@ -17,6 +17,11 @@ module rt.typeinfo.ti_AC;

class TypeInfo_AC : TypeInfo
{
@trusted:
const:
//pure:
//nothrow:

override hash_t getHash(in void* p)
{ Object[] s = *cast(Object[]*)p;
hash_t hash = 0;
Expand Down
7 changes: 6 additions & 1 deletion src/rt/typeinfo/ti_Acdouble.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Ar : TypeInfo
{
override string toString() { return "cdouble[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "cdouble[]"; }

override hash_t getHash(in void* p)
{ cdouble[] s = *cast(cdouble[]*)p;
Expand Down
7 changes: 6 additions & 1 deletion src/rt/typeinfo/ti_Acfloat.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Aq : TypeInfo
{
override string toString() { return "cfloat[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "cfloat[]"; }

override hash_t getHash(in void* p)
{ cfloat[] s = *cast(cfloat[]*)p;
Expand Down
7 changes: 6 additions & 1 deletion src/rt/typeinfo/ti_Acreal.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Ac : TypeInfo
{
override string toString() { return "creal[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "creal[]"; }

override hash_t getHash(in void* p)
{ creal[] s = *cast(creal[]*)p;
Expand Down
14 changes: 12 additions & 2 deletions src/rt/typeinfo/ti_Adouble.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Ad : TypeInfo
{
override string toString() { return "double[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "double[]"; }

override hash_t getHash(in void* p)
{ double[] s = *cast(double[]*)p;
Expand Down Expand Up @@ -96,7 +101,12 @@ class TypeInfo_Ad : TypeInfo

class TypeInfo_Ap : TypeInfo_Ad
{
override string toString() { return "idouble[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "idouble[]"; }

@property override TypeInfo next() nothrow pure
{
Expand Down
14 changes: 12 additions & 2 deletions src/rt/typeinfo/ti_Afloat.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Af : TypeInfo
{
override string toString() { return "float[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "float[]"; }

override hash_t getHash(in void* p)
{ float[] s = *cast(float[]*)p;
Expand Down Expand Up @@ -96,7 +101,12 @@ class TypeInfo_Af : TypeInfo

class TypeInfo_Ao : TypeInfo_Af
{
override string toString() { return "ifloat[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "ifloat[]"; }

@property override TypeInfo next() nothrow pure
{
Expand Down
42 changes: 36 additions & 6 deletions src/rt/typeinfo/ti_Ag.d
Expand Up @@ -21,7 +21,12 @@ private import rt.util.string;

class TypeInfo_Ag : TypeInfo
{
override string toString() { return "byte[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "byte[]"; }

override hash_t getHash(in void* p)
{ byte[] s = *cast(byte[]*)p;
Expand Down Expand Up @@ -91,7 +96,12 @@ class TypeInfo_Ag : TypeInfo

class TypeInfo_Ah : TypeInfo_Ag
{
override string toString() { return "ubyte[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "ubyte[]"; }

override int compare(in void* p1, in void* p2)
{
Expand All @@ -111,7 +121,12 @@ class TypeInfo_Ah : TypeInfo_Ag

class TypeInfo_Av : TypeInfo_Ah
{
override string toString() { return "void[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "void[]"; }

@property override TypeInfo next() nothrow pure
{
Expand All @@ -123,7 +138,12 @@ class TypeInfo_Av : TypeInfo_Ah

class TypeInfo_Ab : TypeInfo_Ah
{
override string toString() { return "bool[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "bool[]"; }

@property override TypeInfo next() nothrow pure
{
Expand All @@ -135,7 +155,12 @@ class TypeInfo_Ab : TypeInfo_Ah

class TypeInfo_Aa : TypeInfo_Ag
{
override string toString() { return "char[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "char[]"; }

override hash_t getHash(in void* p)
{ char[] s = *cast(char[]*)p;
Expand Down Expand Up @@ -196,7 +221,12 @@ else

class TypeInfo_Aya : TypeInfo_Aa
{
override string toString() { return "immutable(char)[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "immutable(char)[]"; }

@property override TypeInfo next() nothrow pure
{
Expand Down
21 changes: 18 additions & 3 deletions src/rt/typeinfo/ti_Aint.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Ai : TypeInfo
{
override string toString() { return "int[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "int[]"; }

override hash_t getHash(in void* p)
{ int[] s = *cast(int[]*)p;
Expand Down Expand Up @@ -100,7 +105,12 @@ unittest

class TypeInfo_Ak : TypeInfo_Ai
{
override string toString() { return "uint[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "uint[]"; }

override int compare(in void* p1, in void* p2)
{
Expand Down Expand Up @@ -133,7 +143,12 @@ class TypeInfo_Ak : TypeInfo_Ai

class TypeInfo_Aw : TypeInfo_Ak
{
override string toString() { return "dchar[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "dchar[]"; }

@property override TypeInfo next() nothrow pure
{
Expand Down
14 changes: 12 additions & 2 deletions src/rt/typeinfo/ti_Along.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Al : TypeInfo
{
override string toString() { return "long[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "long[]"; }

override hash_t getHash(in void* p)
{ long[] s = *cast(long[]*)p;
Expand Down Expand Up @@ -91,7 +96,12 @@ class TypeInfo_Al : TypeInfo

class TypeInfo_Am : TypeInfo_Al
{
override string toString() { return "ulong[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "ulong[]"; }

override int compare(in void* p1, in void* p2)
{
Expand Down
14 changes: 12 additions & 2 deletions src/rt/typeinfo/ti_Areal.d
Expand Up @@ -20,7 +20,12 @@ private import rt.util.hash;

class TypeInfo_Ae : TypeInfo
{
override string toString() { return "real[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "real[]"; }

override hash_t getHash(in void* p)
{ real[] s = *cast(real[]*)p;
Expand Down Expand Up @@ -96,7 +101,12 @@ class TypeInfo_Ae : TypeInfo

class TypeInfo_Aj : TypeInfo_Ae
{
override string toString() { return "ireal[]"; }
@trusted:
const:
pure:
nothrow:

override string toString() const pure nothrow @safe { return "ireal[]"; }

@property override TypeInfo next() nothrow pure
{
Expand Down

0 comments on commit 55e77ee

Please sign in to comment.