\r
this(string msg, Exception next = null);\r
this(string msg, string file, size_t line, Exception next = null);\r
- string toString();\r
+ override string toString();\r
}\r
{
version( Windows )
{
- wchar* wnamez = toUTF16z( name );
+ auto wnamez = toUTF16z( name );
HANDLE file = CreateFileW( wnamez,
GENERIC_READ,
FILE_SHARE_READ,
* These functions must be defined for any D program linked
* against this library.
*/
-extern (C) void onAssertError( char[] file, size_t line );
-extern (C) void onAssertErrorMsg( char[] file, size_t line, char[] msg );
-extern (C) void onArrayBoundsError( char[] file, size_t line );
-extern (C) void onSwitchError( char[] file, size_t line );
+extern (C) void onAssertError( string file, size_t line );
+extern (C) void onAssertErrorMsg( string file, size_t line, string msg );
+extern (C) void onArrayBoundsError( string file, size_t line );
+extern (C) void onSwitchError( string file, size_t line );
extern (C) bool runModuleUnitTests();
// this function is called from the utf module
-//extern (C) void onUnicodeError( char[] msg, size_t idx );
+//extern (C) void onUnicodeError( string msg, size_t idx );
/***********************************
* These are internal callbacks for various language errors.
*/
-extern (C) void _d_assert( char[] file, uint line )
+extern (C) void _d_assert( string file, uint line )
{
onAssertError( file, line );
}
-extern (C) static void _d_assert_msg( char[] msg, char[] file, uint line )
+extern (C) static void _d_assert_msg( string msg, string file, uint line )
{
onAssertErrorMsg( file, line, msg );
}
-extern (C) void _d_array_bounds( char[] file, uint line )
+extern (C) void _d_array_bounds( string file, uint line )
{
onArrayBoundsError( file, line );
}
-extern (C) void _d_switch_error( char[] file, uint line )
+extern (C) void _d_switch_error( string file, uint line )
{
onSwitchError( file, line );
}
*/
class TypeInfo
{
- hash_t toHash()
+ override hash_t toHash()
{ hash_t hash;
foreach (char c; this.toString())
return hash;
}
- int opCmp(Object o)
+ override int opCmp(Object o)
{
if (this is o)
return 0;
return dstrcmp(this.toString(), ti.toString());
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
/* TypeInfo instances are singletons, but duplicates can exist
* across DLL's. Therefore, comparing for a name match is
class TypeInfo_Typedef : TypeInfo
{
- string toString() { return name; }
+ override string toString() { return name; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Typedef c;
return this is o ||
this.base == c.base);
}
- hash_t getHash(in void* p) { return base.getHash(p); }
- equals_t equals(in void* p1, in void* p2) { return base.equals(p1, p2); }
- int compare(in void* p1, in void* p2) { return base.compare(p1, p2); }
- size_t tsize() { return base.tsize(); }
- void swap(void* p1, void* p2) { return base.swap(p1, p2); }
+ override hash_t getHash(in void* p) { return base.getHash(p); }
+ override equals_t equals(in void* p1, in void* p2) { return base.equals(p1, p2); }
+ override int compare(in void* p1, in void* p2) { return base.compare(p1, p2); }
+ override size_t tsize() { return base.tsize(); }
+ override void swap(void* p1, void* p2) { return base.swap(p1, p2); }
- TypeInfo next() { return base.next(); }
- uint flags() { return base.flags(); }
- void[] init() { return m_init.length ? m_init : base.init(); }
+ override TypeInfo next() { return base.next(); }
+ override uint flags() { return base.flags(); }
+ override void[] init() { return m_init.length ? m_init : base.init(); }
TypeInfo base;
string name;
class TypeInfo_Pointer : TypeInfo
{
- string toString() { return m_next.toString() ~ "*"; }
+ override string toString() { return m_next.toString() ~ "*"; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Pointer c;
return this is o ||
this.m_next == c.m_next);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return cast(hash_t)*cast(void**)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(void**)p1 == *cast(void**)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
if (*cast(void**)p1 < *cast(void**)p2)
return -1;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (void*).sizeof;
}
- void swap(void* p1, void* p2)
+ override void swap(void* p1, void* p2)
{
void* tmp = *cast(void**)p1;
*cast(void**)p1 = *cast(void**)p2;
*cast(void**)p2 = tmp;
}
- TypeInfo next() { return m_next; }
- uint flags() { return 1; }
+ override TypeInfo next() { return m_next; }
+ override uint flags() { return 1; }
TypeInfo m_next;
}
class TypeInfo_Array : TypeInfo
{
- string toString() { return value.toString() ~ "[]"; }
+ override string toString() { return value.toString() ~ "[]"; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Array c;
return this is o ||
this.value == c.value);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
size_t sz = value.tsize();
hash_t hash = 0;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
void[] a1 = *cast(void[]*)p1;
void[] a2 = *cast(void[]*)p2;
return cast(int)a1.length - cast(int)a2.length;
}
- size_t tsize()
+ override size_t tsize()
{
return (void[]).sizeof;
}
- void swap(void* p1, void* p2)
+ override void swap(void* p1, void* p2)
{
void[] tmp = *cast(void[]*)p1;
*cast(void[]*)p1 = *cast(void[]*)p2;
TypeInfo value;
- TypeInfo next()
+ override TypeInfo next()
{
return value;
}
- uint flags() { return 1; }
+ override uint flags() { return 1; }
}
class TypeInfo_StaticArray : TypeInfo
{
- string toString()
+ override string toString()
{
- char [10] tmp = void;
- return value.toString() ~ "[" ~ tmp.intToString(len) ~ "]";
+ char[10] tmp = void;
+ return cast(string)(value.toString() ~ "[" ~ tmp.intToString(len) ~ "]");
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_StaticArray c;
return this is o ||
this.value == c.value);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
size_t sz = value.tsize();
hash_t hash = 0;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
size_t sz = value.tsize();
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
size_t sz = value.tsize();
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return len * value.tsize();
}
- void swap(void* p1, void* p2)
+ override void swap(void* p1, void* p2)
{
void* tmp;
size_t sz = value.tsize();
delete pbuffer;
}
- void[] init() { return value.init(); }
- TypeInfo next() { return value; }
- uint flags() { return value.flags(); }
+ override void[] init() { return value.init(); }
+ override TypeInfo next() { return value; }
+ override uint flags() { return value.flags(); }
TypeInfo value;
size_t len;
class TypeInfo_AssociativeArray : TypeInfo
{
- string toString()
+ override string toString()
{
- return next.toString() ~ "[" ~ key.toString() ~ "]";
+ return cast(string)(next.toString() ~ "[" ~ key.toString() ~ "]");
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_AssociativeArray c;
return this is o ||
// BUG: need to add the rest of the functions
- size_t tsize()
+ override size_t tsize()
{
return (char[int]).sizeof;
}
- TypeInfo next() { return value; }
- uint flags() { return 1; }
+ override TypeInfo next() { return value; }
+ override uint flags() { return 1; }
TypeInfo value;
TypeInfo key;
class TypeInfo_Function : TypeInfo
{
- string toString()
+ override string toString()
{
- return next.toString() ~ "()";
+ return cast(string)(next.toString() ~ "()");
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Function c;
return this is o ||
// BUG: need to add the rest of the functions
- size_t tsize()
+ override size_t tsize()
{
return 0; // no size for functions
}
class TypeInfo_Delegate : TypeInfo
{
- string toString()
+ override string toString()
{
- return next.toString() ~ " delegate()";
+ return cast(string)(next.toString() ~ " delegate()");
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Delegate c;
return this is o ||
// BUG: need to add the rest of the functions
- size_t tsize()
+ override size_t tsize()
{
alias int delegate() dg;
return dg.sizeof;
}
- uint flags() { return 1; }
+ override uint flags() { return 1; }
TypeInfo next;
}
class TypeInfo_Class : TypeInfo
{
- string toString() { return info.name; }
+ override string toString() { return info.name; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Class c;
return this is o ||
this.info.name == c.classinfo.name);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
Object o = *cast(Object*)p;
return o ? o.toHash() : 0;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return (o1 is o2) || (o1 && o1.opEquals(o2));
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return c;
}
- size_t tsize()
+ override size_t tsize()
{
return Object.sizeof;
}
- uint flags() { return 1; }
+ override uint flags() { return 1; }
- OffsetTypeInfo[] offTi()
+ override OffsetTypeInfo[] offTi()
{
return (info.flags & 4) ? info.offTi : null;
}
class TypeInfo_Interface : TypeInfo
{
- string toString() { return info.name; }
+ override string toString() { return info.name; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Interface c;
return this is o ||
this.info.name == c.classinfo.name);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
Interface* pi = **cast(Interface ***)*cast(void**)p;
Object o = cast(Object)(*cast(void**)p - pi.offset);
return o.toHash();
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
Interface* pi = **cast(Interface ***)*cast(void**)p1;
Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
return c;
}
- size_t tsize()
+ override size_t tsize()
{
return Object.sizeof;
}
- uint flags() { return 1; }
+ override uint flags() { return 1; }
ClassInfo info;
}
class TypeInfo_Struct : TypeInfo
{
- string toString() { return name; }
+ override string toString() { return name; }
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
TypeInfo_Struct s;
return this is o ||
this.init.length == s.init.length);
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
assert(p);
if (xtoHash)
}
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
if (p1 == p2)
return true;
return memcmp(p1, p2, init.length) == 0;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
// Regard null references as always being "less than"
if (p1 != p2)
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return init.length;
}
- void[] init() { return m_init; }
+ override void[] init() { return m_init; }
- uint flags() { return m_flags; }
+ override uint flags() { return m_flags; }
string name;
void[] m_init; // initializer; init.ptr == null if 0 initialize
{
TypeInfo[] elements;
- string toString()
+ override string toString()
{
string s = "(";
foreach (i, element; elements)
return s;
}
- equals_t opEquals(Object o)
+ override equals_t opEquals(Object o)
{
if (this is o)
return true;
return false;
}
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
assert(0);
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
assert(0);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
assert(0);
}
- size_t tsize()
+ override size_t tsize()
{
assert(0);
}
- void swap(void* p1, void* p2)
+ override void swap(void* p1, void* p2)
{
assert(0);
}
this.info = traceContext();
}
- string toString()
+ override string toString()
{
return msg;
}
static Symbol** psymbols;
static uint nsymbols; // number of symbols
-static char[] trace_logfilename = "trace.log";
+static string trace_logfilename = "trace.log";
static FILE* fplog;
-static char[] trace_deffilename = "trace.def";
+static string trace_deffilename = "trace.def";
static FILE* fpdef;
// 0 success
// !=0 failure
-int trace_setlogfilename(char[] name)
+int trace_setlogfilename(string name)
{
trace_logfilename = name;
return 0;
// 0 success
// !=0 failure
-int trace_setdeffilename(char[] name)
+int trace_setdeffilename(string name)
{
trace_deffilename = name;
return 0;
//////////////////////////////////////
// Qsort() comparison routine for array of pointers to SymPair's.
-static int sympair_cmp(void* e1, void* e2)
+static int sympair_cmp(in void* e1, in void* e2)
{ SymPair** psp1;
SymPair** psp2;
//////////////////////////////////////
// Qsort() comparison routine for array of pointers to Symbol's.
-static int symbol_cmp(void* e1, void* e2)
+static int symbol_cmp(in void* e1, in void* e2)
{ Symbol** ps1;
Symbol** ps2;
timer_t diff;
class TypeInfo_AC : TypeInfo
{
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ Object[] s = *cast(Object[]*)p;
hash_t hash = 0;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
Object[] s1 = *cast(Object[]*)p1;
Object[] s2 = *cast(Object[]*)p2;
return false;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
Object[] s1 = *cast(Object[]*)p1;
Object[] s2 = *cast(Object[]*)p2;
return c;
}
- size_t tsize()
+ override size_t tsize()
{
return (Object[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(Object);
}
class TypeInfo_Ar : TypeInfo
{
- string toString() { return "cdouble[]"; }
+ override string toString() { return "cdouble[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ cdouble[] s = *cast(cdouble[]*)p;
size_t len = s.length;
cdouble *str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
cdouble[] s1 = *cast(cdouble[]*)p1;
cdouble[] s2 = *cast(cdouble[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
cdouble[] s1 = *cast(cdouble[]*)p1;
cdouble[] s2 = *cast(cdouble[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (cdouble[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(cdouble);
}
class TypeInfo_Aq : TypeInfo
{
- string toString() { return "cfloat[]"; }
+ override string toString() { return "cfloat[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ cfloat[] s = *cast(cfloat[]*)p;
size_t len = s.length;
cfloat *str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
cfloat[] s1 = *cast(cfloat[]*)p1;
cfloat[] s2 = *cast(cfloat[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
cfloat[] s1 = *cast(cfloat[]*)p1;
cfloat[] s2 = *cast(cfloat[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (cfloat[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(cfloat);
}
class TypeInfo_Ac : TypeInfo
{
- string toString() { return "creal[]"; }
+ override string toString() { return "creal[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ creal[] s = *cast(creal[]*)p;
size_t len = s.length;
creal *str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
creal[] s1 = *cast(creal[]*)p1;
creal[] s2 = *cast(creal[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
creal[] s1 = *cast(creal[]*)p1;
creal[] s2 = *cast(creal[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (creal[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(creal);
}
class TypeInfo_Ad : TypeInfo
{
- string toString() { return "double[]"; }
+ override string toString() { return "double[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ double[] s = *cast(double[]*)p;
size_t len = s.length;
auto str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
double[] s1 = *cast(double[]*)p1;
double[] s2 = *cast(double[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
double[] s1 = *cast(double[]*)p1;
double[] s2 = *cast(double[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (double[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(double);
}
class TypeInfo_Ap : TypeInfo_Ad
{
- string toString() { return "idouble[]"; }
+ override string toString() { return "idouble[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(idouble);
}
class TypeInfo_Af : TypeInfo
{
- string toString() { return "float[]"; }
+ override string toString() { return "float[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ float[] s = *cast(float[]*)p;
size_t len = s.length;
auto str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
float[] s1 = *cast(float[]*)p1;
float[] s2 = *cast(float[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
float[] s1 = *cast(float[]*)p1;
float[] s2 = *cast(float[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (float[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(float);
}
class TypeInfo_Ao : TypeInfo_Af
{
- string toString() { return "ifloat[]"; }
+ override string toString() { return "ifloat[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(ifloat);
}
class TypeInfo_Ag : TypeInfo
{
- string toString() { return "byte[]"; }
+ override string toString() { return "byte[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ byte[] s = *cast(byte[]*)p;
size_t len = s.length;
byte *str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
byte[] s1 = *cast(byte[]*)p1;
byte[] s2 = *cast(byte[]*)p2;
memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
byte[] s1 = *cast(byte[]*)p1;
byte[] s2 = *cast(byte[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (byte[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(byte);
}
class TypeInfo_Ah : TypeInfo_Ag
{
- string toString() { return "ubyte[]"; }
+ override string toString() { return "ubyte[]"; }
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
char[] s1 = *cast(char[]*)p1;
char[] s2 = *cast(char[]*)p2;
return dstrcmp(s1, s2);
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(ubyte);
}
class TypeInfo_Av : TypeInfo_Ah
{
- string toString() { return "void[]"; }
+ override string toString() { return "void[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(void);
}
class TypeInfo_Ab : TypeInfo_Ah
{
- string toString() { return "bool[]"; }
+ override string toString() { return "bool[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(bool);
}
class TypeInfo_Aa : TypeInfo_Ag
{
- string toString() { return "char[]"; }
+ override string toString() { return "char[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ char[] s = *cast(char[]*)p;
hash_t hash = 0;
return hash;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(char);
}
class TypeInfo_Ai : TypeInfo
{
- string toString() { return "int[]"; }
+ override string toString() { return "int[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ int[] s = *cast(int[]*)p;
auto len = s.length;
auto str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
int[] s1 = *cast(int[]*)p1;
int[] s2 = *cast(int[]*)p2;
memcmp(cast(void *)s1, cast(void *)s2, s1.length * int.sizeof) == 0;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
int[] s1 = *cast(int[]*)p1;
int[] s2 = *cast(int[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (int[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(int);
}
class TypeInfo_Ak : TypeInfo_Ai
{
- string toString() { return "uint[]"; }
+ override string toString() { return "uint[]"; }
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
uint[] s1 = *cast(uint[]*)p1;
uint[] s2 = *cast(uint[]*)p2;
return 0;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(uint);
}
class TypeInfo_Aw : TypeInfo_Ak
{
- string toString() { return "dchar[]"; }
+ override string toString() { return "dchar[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(dchar);
}
class TypeInfo_Al : TypeInfo
{
- string toString() { return "long[]"; }
+ override string toString() { return "long[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ long[] s = *cast(long[]*)p;
size_t len = s.length;
auto str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
long[] s1 = *cast(long[]*)p1;
long[] s2 = *cast(long[]*)p2;
memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
long[] s1 = *cast(long[]*)p1;
long[] s2 = *cast(long[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (long[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(long);
}
class TypeInfo_Am : TypeInfo_Al
{
- string toString() { return "ulong[]"; }
+ override string toString() { return "ulong[]"; }
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
ulong[] s1 = *cast(ulong[]*)p1;
ulong[] s2 = *cast(ulong[]*)p2;
return 0;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(ulong);
}
class TypeInfo_Ae : TypeInfo
{
- string toString() { return "real[]"; }
+ override string toString() { return "real[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ real[] s = *cast(real[]*)p;
size_t len = s.length;
auto str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
real[] s1 = *cast(real[]*)p1;
real[] s2 = *cast(real[]*)p2;
return true;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
real[] s1 = *cast(real[]*)p1;
real[] s2 = *cast(real[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (real[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(real);
}
class TypeInfo_Aj : TypeInfo_Ae
{
- string toString() { return "ireal[]"; }
+ override string toString() { return "ireal[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(ireal);
}
class TypeInfo_As : TypeInfo
{
- string toString() { return "short[]"; }
+ override string toString() { return "short[]"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ short[] s = *cast(short[]*)p;
size_t len = s.length;
short *str = s.ptr;
return hash;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
short[] s1 = *cast(short[]*)p1;
short[] s2 = *cast(short[]*)p2;
memcmp(cast(void *)s1, cast(void *)s2, s1.length * short.sizeof) == 0;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
short[] s1 = *cast(short[]*)p1;
short[] s2 = *cast(short[]*)p2;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (short[]).sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(short);
}
class TypeInfo_At : TypeInfo_As
{
- string toString() { return "ushort[]"; }
+ override string toString() { return "ushort[]"; }
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
ushort[] s1 = *cast(ushort[]*)p1;
ushort[] s2 = *cast(ushort[]*)p2;
return 0;
}
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(ushort);
}
class TypeInfo_Au : TypeInfo_At
{
- string toString() { return "wchar[]"; }
+ override string toString() { return "wchar[]"; }
- TypeInfo next()
+ override TypeInfo next()
{
return typeid(wchar);
}
class TypeInfo_C : TypeInfo
{
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
Object o = *cast(Object*)p;
return o ? o.toHash() : 0;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return o1 == o2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
Object o1 = *cast(Object*)p1;
Object o2 = *cast(Object*)p2;
return c;
}
- size_t tsize()
+ override size_t tsize()
{
return Object.sizeof;
}
- uint flags()
+ override uint flags()
{
return 1;
}
class TypeInfo_g : TypeInfo
{
- string toString() { return "byte"; }
+ override string toString() { return "byte"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(byte *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(byte *)p1 == *cast(byte *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(byte *)p1 - *cast(byte *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return byte.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
byte t;
class TypeInfo_r : TypeInfo
{
- string toString() { return "cdouble"; }
+ override string toString() { return "cdouble"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return (cast(uint *)p)[0] + (cast(uint *)p)[1] +
(cast(uint *)p)[2] + (cast(uint *)p)[3];
return result;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(cdouble *)p1, *cast(cdouble *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return cdouble.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
cdouble t;
*cast(cdouble *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static cdouble r;
return (cast(cdouble *)&r)[0 .. 1];
class TypeInfo_q : TypeInfo
{
- string toString() { return "cfloat"; }
+ override string toString() { return "cfloat"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return (cast(uint *)p)[0] + (cast(uint *)p)[1];
}
return result;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return cfloat.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
cfloat t;
*cast(cfloat *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static cfloat r;
return (cast(cfloat *)&r)[0 .. 1];
class TypeInfo_a : TypeInfo
{
- string toString() { return "char"; }
+ override string toString() { return "char"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(char *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(char *)p1 == *cast(char *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(char *)p1 - *cast(char *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return char.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
char t;
*cast(char *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static char c;
return (cast(char *)&c)[0 .. 1];
class TypeInfo_c : TypeInfo
{
- string toString() { return "creal"; }
+ override string toString() { return "creal"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return (cast(uint *)p)[0] + (cast(uint *)p)[1] +
(cast(uint *)p)[2] + (cast(uint *)p)[3] +
return result;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(creal *)p1, *cast(creal *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(creal *)p1, *cast(creal *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return creal.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
creal t;
*cast(creal *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static creal r;
return (cast(creal *)&r)[0 .. 1];
class TypeInfo_w : TypeInfo
{
- string toString() { return "dchar"; }
+ override string toString() { return "dchar"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(dchar *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(dchar *)p1 == *cast(dchar *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(dchar *)p1 - *cast(dchar *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return dchar.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
dchar t;
*cast(dchar *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static dchar c;
return (cast(dchar *)&c)[0 .. 1];
class TypeInfo_D : TypeInfo
{
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{ long l = *cast(long *)p;
return cast(uint)(l + (l >> 32));
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(dg *)p1 == *cast(dg *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return dg.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
dg t;
*cast(dg *)p2 = t;
}
- uint flags()
+ override uint flags()
{
return 1;
}
class TypeInfo_d : TypeInfo
{
- string toString() { return "double"; }
+ override string toString() { return "double"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return (cast(uint *)p)[0] + (cast(uint *)p)[1];
}
return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(double *)p1, *cast(double *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(double *)p1, *cast(double *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return double.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
double t;
*cast(double *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static double r;
return (cast(double *)&r)[0 .. 1];
class TypeInfo_f : TypeInfo
{
- string toString() { return "float"; }
+ override string toString() { return "float"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(uint *)p;
}
return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(float *)p1, *cast(float *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(float *)p1, *cast(float *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return float.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
float t;
*cast(float *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static float r;
return (cast(float *)&r)[0 .. 1];
class TypeInfo_p : TypeInfo_d
{
- string toString() { return "idouble"; }
+ override string toString() { return "idouble"; }
}
class TypeInfo_o : TypeInfo_f
{
- string toString() { return "ifloat"; }
+ override string toString() { return "ifloat"; }
}
class TypeInfo_i : TypeInfo
{
- string toString() { return "int"; }
+ override string toString() { return "int"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(uint *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(uint *)p1 == *cast(uint *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
if (*cast(int*) p1 < *cast(int*) p2)
return -1;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return int.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
int t;
class TypeInfo_j : TypeInfo_e
{
- string toString() { return "ireal"; }
+ override string toString() { return "ireal"; }
}
class TypeInfo_l : TypeInfo
{
- string toString() { return "long"; }
+ override string toString() { return "long"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(uint *)p + (cast(uint *)p)[1];
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(long *)p1 == *cast(long *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
if (*cast(long *)p1 < *cast(long *)p2)
return -1;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return long.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
long t;
class TypeInfo_P : TypeInfo
{
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return cast(uint)*cast(void* *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(void* *)p1 == *cast(void* *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
auto c = *cast(void* *)p1 - *cast(void* *)p2;
if (c < 0)
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return (void*).sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
void* t;
*cast(void* *)p2 = t;
}
- uint flags()
+ override uint flags()
{
return 1;
}
class TypeInfo_e : TypeInfo
{
- string toString() { return "real"; }
+ override string toString() { return "real"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4];
}
return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return _equals(*cast(real *)p1, *cast(real *)p2);
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return _compare(*cast(real *)p1, *cast(real *)p2);
}
- size_t tsize()
+ override size_t tsize()
{
return real.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
real t;
*cast(real *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static real r;
return (cast(real *)&r)[0 .. 1];
class TypeInfo_s : TypeInfo
{
- string toString() { return "short"; }
+ override string toString() { return "short"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(short *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(short *)p1 == *cast(short *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(short *)p1 - *cast(short *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return short.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
short t;
class TypeInfo_h : TypeInfo
{
- string toString() { return "ubyte"; }
+ override string toString() { return "ubyte"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(ubyte *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(ubyte *)p1 == *cast(ubyte *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(ubyte *)p1 - *cast(ubyte *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return ubyte.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
ubyte t;
class TypeInfo_b : TypeInfo_h
{
- string toString() { return "bool"; }
+ override string toString() { return "bool"; }
}
class TypeInfo_k : TypeInfo
{
- string toString() { return "uint"; }
+ override string toString() { return "uint"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(uint *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(uint *)p1 == *cast(uint *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
if (*cast(uint*) p1 < *cast(uint*) p2)
return -1;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return uint.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
int t;
class TypeInfo_m : TypeInfo
{
- string toString() { return "ulong"; }
+ override string toString() { return "ulong"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(uint *)p + (cast(uint *)p)[1];
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(ulong *)p1 == *cast(ulong *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
if (*cast(ulong *)p1 < *cast(ulong *)p2)
return -1;
return 0;
}
- size_t tsize()
+ override size_t tsize()
{
return ulong.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
ulong t;
class TypeInfo_t : TypeInfo
{
- string toString() { return "ushort"; }
+ override string toString() { return "ushort"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(ushort *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(ushort *)p1 == *cast(ushort *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(ushort *)p1 - *cast(ushort *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return ushort.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
ushort t;
class TypeInfo_v : TypeInfo
{
- string toString() { return "void"; }
+ override string toString() { return "void"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
assert(0);
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(byte *)p1 == *cast(byte *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(byte *)p1 - *cast(byte *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return void.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
byte t;
*cast(byte *)p2 = t;
}
- uint flags()
+ override uint flags()
{
return 1;
}
class TypeInfo_u : TypeInfo
{
- string toString() { return "wchar"; }
+ override string toString() { return "wchar"; }
- hash_t getHash(in void* p)
+ override hash_t getHash(in void* p)
{
return *cast(wchar *)p;
}
- equals_t equals(in void* p1, in void* p2)
+ override equals_t equals(in void* p1, in void* p2)
{
return *cast(wchar *)p1 == *cast(wchar *)p2;
}
- int compare(in void* p1, in void* p2)
+ override int compare(in void* p1, in void* p2)
{
return *cast(wchar *)p1 - *cast(wchar *)p2;
}
- size_t tsize()
+ override size_t tsize()
{
return wchar.sizeof;
}
- void swap(void *p1, void *p2)
+ override void swap(void *p1, void *p2)
{
wchar t;
*cast(wchar *)p2 = t;
}
- void[] init()
+ override void[] init()
{ static wchar c;
return (cast(wchar *)&c)[0 .. 1];
/// Returns vendor string
char[] vendor() {return vendorStr;}
/// Returns processor string
- char[] processor() {return processorStr;}
+ string processor() {return processorStr;}
/// Is MMX supported?
bool mmx() {return (flags&MMX_BIT)!=0;}
uint flags, misc, exflags, apic, signature;
uint _stepping, _model, _family;
- char[12] vendorStr = "";
- char[] processorStr = "";
+ char[12] vendorStr = 0;
+ string processorStr = "";
uint maxThreads=1;
uint maxCores=1;
return;
// seems many intel processors prepend whitespace
- processorStr = strip(toString(dst)).dup;
+ processorStr = cast(string)strip(toString(dst)).dup;
}
private void getFeatureFlags()
return stripr(stripl(s));
}
- string toString(char *s)
+ char[] toString(char* s)
{
- return s ? s[0 .. strlen(s)] : cast(char[])null;
+ return s ? s[0 .. strlen(s)] : null;
+ }
+
+ string toString(invariant(char)* s)
+ {
+ return s ? s[0 .. strlen(s)] : null;
}
}
}
-// utf.d
+// Written in the D programming language
/*
* Copyright (C) 2003-2004 by Digital Mars, www.digitalmars.com
* distribution.
*/
-// Description of UTF-8 at:
-// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
-// http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335
-
+/********************************************
+ * Encode and decode UTF-8, UTF-16 and UTF-32 strings.
+ *
+ * For Win32 systems, the C wchar_t type is UTF-16 and corresponds to the D
+ * wchar type.
+ * For linux systems, the C wchar_t type is UTF-32 and corresponds to
+ * the D utf.dchar type.
+ *
+ * UTF character support is restricted to (\u0000 <= character <= \U0010FFFF).
+ *
+ * See_Also:
+ * $(LINK2 http://en.wikipedia.org/wiki/Unicode, Wikipedia)<br>
+ * $(LINK http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8)<br>
+ * $(LINK http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335)
+ * Macros:
+ * WIKI = Phobos/StdUtf
+ */
module rt.util.utf;
-extern (C) void onUnicodeError( char[] msg, size_t idx );
+extern (C) void onUnicodeError( string msg, size_t idx );
+/*******************************
+ * Test if c is a valid UTF-32 character.
+ *
+ * \uFFFE and \uFFFF are considered valid by this function,
+ * as they are permitted for internal use by an application,
+ * but they are not allowed for interchange by the Unicode standard.
+ *
+ * Returns: true if it is, false if not.
+ */
bool isValidDchar(dchar c)
{
}
-/* This array gives the length of a UTF-8 sequence indexed by the value
- * of the leading byte. An FF represents an illegal starting value of
- * a UTF-8 sequence.
- * FF is used instead of 0 to avoid having loops hang.
- */
-ubyte[256] UTF8stride =
+auto UTF8stride =
[
+ cast(ubyte)
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF,
];
-uint stride(char[] s, size_t i)
+/**
+ * stride() returns the length of a UTF-8 sequence starting at index i
+ * in string s.
+ * Returns:
+ * The number of bytes in the UTF-8 sequence or
+ * 0xFF meaning s[i] is not the start of of UTF-8 sequence.
+ */
+uint stride(in char[] s, size_t i)
{
return UTF8stride[s[i]];
}
-uint stride(wchar[] s, size_t i)
+/**
+ * stride() returns the length of a UTF-16 sequence starting at index i
+ * in string s.
+ */
+uint stride(in wchar[] s, size_t i)
{ uint u = s[i];
return 1 + (u >= 0xD800 && u <= 0xDBFF);
}
-uint stride(dchar[] s, size_t i)
+/**
+ * stride() returns the length of a UTF-32 sequence starting at index i
+ * in string s.
+ * Returns: The return value will always be 1.
+ */
+uint stride(in dchar[] s, size_t i)
{
return 1;
}
/*******************************************
- * Given an index into an array of char's,
- * and assuming that index is at the start of a UTF character,
- * determine the number of UCS characters up to that index.
+ * Given an index i into an array of characters s[],
+ * and assuming that index i is at the start of a UTF character,
+ * determine the number of UCS characters up to that index i.
*/
-size_t toUCSindex(char[] s, size_t i)
+size_t toUCSindex(in char[] s, size_t i)
{
size_t n;
size_t j;
- size_t stride;
- for (j = 0; j < i; j += stride)
+ for (j = 0; j < i; )
{
- stride = UTF8stride[s[j]];
- if (stride == 0xFF)
- goto Lerr;
+ j += stride(s, j);
n++;
}
if (j > i)
{
- Lerr:
- onUnicodeError("invalid UTF-8 sequence", j);
+ onUnicodeError("invalid UTF-8 sequence", j);
}
return n;
}
-size_t toUCSindex(wchar[] s, size_t i)
+/** ditto */
+size_t toUCSindex(in wchar[] s, size_t i)
{
size_t n;
size_t j;
for (j = 0; j < i; )
- { uint u = s[j];
-
- j += 1 + (u >= 0xD800 && u <= 0xDBFF);
+ {
+ j += stride(s, j);
n++;
}
if (j > i)
{
- Lerr:
- onUnicodeError("invalid UTF-16 sequence", j);
+ onUnicodeError("invalid UTF-16 sequence", j);
}
return n;
}
-size_t toUCSindex(dchar[] s, size_t i)
+/** ditto */
+size_t toUCSindex(in dchar[] s, size_t i)
{
return i;
}
/******************************************
- * Given a UCS index into an array of characters, return the UTF index.
+ * Given a UCS index n into an array of characters s[], return the UTF index.
*/
-size_t toUTFindex(char[] s, size_t n)
+size_t toUTFindex(in char[] s, size_t n)
{
size_t i;
return i;
}
-size_t toUTFindex(wchar[] s, size_t n)
+/** ditto */
+size_t toUTFindex(in wchar[] s, size_t n)
{
size_t i;
return i;
}
-size_t toUTFindex(dchar[] s, size_t n)
+/** ditto */
+size_t toUTFindex(in dchar[] s, size_t n)
{
return n;
}
/* =================== Decode ======================= */
-dchar decode(char[] s, inout size_t idx)
+/***************
+ * Decodes and returns character starting at s[idx]. idx is advanced past the
+ * decoded character. If the character is not well formed, a UtfException is
+ * thrown and idx remains unchanged.
+ */
+dchar decode(in char[] s, inout size_t idx)
in
{
assert(idx >= 0 && idx < s.length);
debug(utf) printf("utf.decode.unittest\n");
- static char[] s1 = "abcd";
+ static s1 = "abcd"c;
i = 0;
c = decode(s1, i);
assert(c == cast(dchar)'a');
assert(c == cast(dchar)'b');
assert(i == 2);
- static char[] s2 = "\xC2\xA9";
+ static s2 = "\xC2\xA9"c;
i = 0;
c = decode(s2, i);
assert(c == cast(dchar)'\u00A9');
assert(i == 2);
- static char[] s3 = "\xE2\x89\xA0";
+ static s3 = "\xE2\x89\xA0"c;
i = 0;
c = decode(s3, i);
assert(c == cast(dchar)'\u2260');
assert(i == 3);
- static char[][] s4 =
- [ "\xE2\x89", // too short
+ static s4 =
+ [ "\xE2\x89"c, // too short
"\xC0\x8A",
"\xE0\x80\x8A",
"\xF0\x80\x80\x8A",
}
}
-/********************************************************/
+/** ditto */
-dchar decode(wchar[] s, inout size_t idx)
+dchar decode(in wchar[] s, inout size_t idx)
in
{
assert(idx >= 0 && idx < s.length);
}
body
{
- char[] msg;
+ string msg;
dchar V;
size_t i = idx;
uint u = s[i];
return cast(dchar)u; // dummy return
}
-/********************************************************/
+/** ditto */
-dchar decode(dchar[] s, inout size_t idx)
+dchar decode(in dchar[] s, inout size_t idx)
in
{
assert(idx >= 0 && idx < s.length);
/* =================== Encode ======================= */
+/*******************************
+ * Encodes character c and appends it to array s[].
+ */
void encode(inout char[] s, dchar c)
in
{
{
debug(utf) printf("utf.encode.unittest\n");
- char[] s = "abcd";
+ char[] s = "abcd".dup;
encode(s, cast(dchar)'a');
assert(s.length == 5);
assert(s == "abcda");
assert(s == "abcda\xC2\xA9\xE2\x89\xA0");
}
-/********************************************************/
+/** ditto */
void encode(inout wchar[] s, dchar c)
in
s = r;
}
+/** ditto */
void encode(inout dchar[] s, dchar c)
in
{
s ~= c;
}
-/* =================== Validation ======================= */
+/**
+Returns the code length of $(D c) in the encoding using $(D C) as a
+code point. The code is returned in character count, not in bytes.
+ */
-void validate(char[] s)
+ubyte codeLength(C)(dchar c)
{
- size_t len = s.length;
- size_t i;
- for (i = 0; i < len; )
+ static if (C.sizeof == 1)
{
- decode(s, i);
- }
+ return
+ c <= 0x7F ? 1
+ : c <= 0x7FF ? 2
+ : c <= 0xFFFF ? 3
+ : c <= 0x10FFFF ? 4
+ : (assert(false), 6);
}
-void validate(wchar[] s)
+ else static if (C.sizeof == 2)
{
- size_t len = s.length;
- size_t i;
-
- for (i = 0; i < len; )
+ return c <= 0xFFFF ? 1 : 2;
+ }
+ else
{
- decode(s, i);
+ static assert(C.sizeof == 4);
+ return 1;
}
}
-void validate(dchar[] s)
-{
- size_t len = s.length;
- size_t i;
+/* =================== Validation ======================= */
- for (i = 0; i < len; )
+/***********************************
+Checks to see if string is well formed or not. $(D S) can be an array
+ of $(D char), $(D wchar), or $(D dchar). Throws a $(D UtfException)
+ if it is not. Use to check all untrusted input for correctness.
+ */
+void validate(S)(in S s)
+{
+ invariant len = s.length;
+ for (size_t i = 0; i < len; )
{
decode(s, i);
}
assert(0);
}
-char[] toUTF8(char[] s)
+/*******************
+ * Encodes string s into UTF-8 and returns the encoded string.
+ */
+string toUTF8(string s)
in
{
validate(s);
return s;
}
-char[] toUTF8(wchar[] s)
+/** ditto */
+string toUTF8(in wchar[] s)
{
char[] r;
size_t i;
break;
}
}
- return r;
+ return cast(string)r;
}
-char[] toUTF8(dchar[] s)
+/** ditto */
+string toUTF8(in dchar[] s)
{
char[] r;
size_t i;
break;
}
}
- return r;
+ return cast(string)r;
}
/* =================== Conversion to UTF16 ======================= */
}
}
-wchar[] toUTF16(char[] s)
+/****************
+ * Encodes string s into UTF-16 and returns the encoded string.
+ * toUTF16z() is suitable for calling the 'W' functions in the Win32 API that take
+ * an LPWSTR or LPCWSTR argument.
+ */
+wstring toUTF16(in char[] s)
{
wchar[] r;
size_t slen = s.length;
encode(r, c);
}
}
- return r;
+ return cast(wstring)r;
}
-wchar* toUTF16z(char[] s)
+alias const(wchar)* wptr;
+/** ditto */
+wptr toUTF16z(in char[] s)
{
wchar[] r;
size_t slen = s.length;
return r.ptr;
}
-wchar[] toUTF16(wchar[] s)
+/** ditto */
+wstring toUTF16(wstring s)
in
{
validate(s);
return s;
}
-wchar[] toUTF16(dchar[] s)
+/** ditto */
+wstring toUTF16(in dchar[] s)
{
wchar[] r;
size_t slen = s.length;
{
encode(r, s[i]);
}
- return r;
+ return cast(wstring)r;
}
/* =================== Conversion to UTF32 ======================= */
-dchar[] toUTF32(char[] s)
+/*****
+ * Encodes string s into UTF-32 and returns the encoded string.
+ */
+dstring toUTF32(in char[] s)
{
dchar[] r;
size_t slen = s.length;
i++; // c is ascii, no need for decode
r[j++] = c;
}
- return r[0 .. j];
+ return cast(dstring)r[0 .. j];
}
-dchar[] toUTF32(wchar[] s)
+/** ditto */
+dstring toUTF32(in wchar[] s)
{
dchar[] r;
size_t slen = s.length;
i++; // c is ascii, no need for decode
r[j++] = c;
}
- return r[0 .. j];
+ return cast(dstring)r[0 .. j];
}
-dchar[] toUTF32(dchar[] s)
+/** ditto */
+dstring toUTF32(dstring s)
in
{
validate(s);
{
debug(utf) printf("utf.toUTF.unittest\n");
- char[] c;
- wchar[] w;
- dchar[] d;
-
- c = "hello";
- w = toUTF16(c);
+ auto c = "hello"c;
+ auto w = toUTF16(c);
assert(w == "hello");
- d = toUTF32(c);
+ auto d = toUTF32(c);
assert(d == "hello");
c = toUTF8(w);
c = "he\U0010AAAAllo";
w = toUTF16(c);
//foreach (wchar c; w) printf("c = x%x\n", c);
- //foreach (wchar c; cast(wchar[])"he\U0010AAAAllo") printf("c = x%x\n", c);
+ //foreach (wchar c; cast(wstring)"he\U0010AAAAllo") printf("c = x%x\n", c);
assert(w == "he\U0010AAAAllo");
d = toUTF32(c);
assert(d == "he\U0010AAAAllo");
private
{
- alias void function( char[] file, size_t line, char[] msg = null ) assertHandlerType;
+ alias void function( string file, size_t line, string msg = null ) assertHandlerType;
assertHandlerType assertHandler = null;
}
*/
class ArrayBoundsException : Exception
{
- this( char[] file, size_t line )
+ this( string file, size_t line )
{
super( "Array index out of bounds", file, line );
}
*/
class AssertException : Exception
{
- this( char[] file, size_t line )
+ this( string file, size_t line )
{
super( "Assertion failure", file, line );
}
- this( char[] msg, char[] file, size_t line )
+ this( string msg, string file, size_t line )
{
super( msg, file, line );
}
info = c;
}
- string toString()
+ override string toString()
{
return "An exception was thrown while finalizing an instance of class " ~ info.name;
}
*/
class OutOfMemoryException : Exception
{
- this( char[] file, size_t line )
+ this( string file, size_t line )
{
super( "Memory allocation failed", file, line );
}
- string toString()
+ override string toString()
{
return msg ? super.toString() : "Memory allocation failed";
}
*/
class SwitchException : Exception
{
- this( char[] file, size_t line )
+ this( string file, size_t line )
{
super( "No appropriate switch clause found", file, line );
}
{
size_t idx;
- this( char[] msg, size_t idx )
+ this( string msg, size_t idx )
{
super( msg );
this.idx = idx;
* file = The name of the file that signaled this error.
* line = The line number on which this error occurred.
*/
-extern (C) void onAssertError( char[] file, size_t line )
+extern (C) void onAssertError( string file, size_t line )
{
if( assertHandler is null )
throw new AssertException( file, line );
* line = The line number on which this error occurred.
* msg = An error message supplied by the user.
*/
-extern (C) void onAssertErrorMsg( char[] file, size_t line, char[] msg )
+extern (C) void onAssertErrorMsg( string file, size_t line, string msg )
{
if( assertHandler is null )
throw new AssertException( msg, file, line );
* Throws:
* ArrayBoundsException.
*/
-extern (C) void onArrayBoundsError( char[] file, size_t line )
+extern (C) void onArrayBoundsError( string file, size_t line )
{
throw new ArrayBoundsException( file, line );
}
* Throws:
* SwitchException.
*/
-extern (C) void onSwitchError( char[] file, size_t line )
+extern (C) void onSwitchError( string file, size_t line )
{
throw new SwitchException( file, line );
}
* Throws:
* UnicodeException.
*/
-extern (C) void onUnicodeError( char[] msg, size_t idx )
+extern (C) void onUnicodeError( string msg, size_t idx )
{
throw new UnicodeException( msg, idx );
}
bitmanip.o : bitmanip.d\r
$(DC) -c $(DFLAGS) bitmanip.d -of$@\r
\r
+### thread\r
+\r
+thread.o : thread.d\r
+ $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@\r
+\r
######################################################\r
\r
clean :\r
*/
class ThreadException : Exception
{
- this( char[] msg )
+ this( string msg )
{
super( msg );
}
*/
class FiberException : Exception
{
- this( char[] msg )
+ this( string msg )
{
super( msg );
}
bitmanip.obj : bitmanip.d\r
$(DC) -c $(DFLAGS) bitmanip.d -of$@\r
\r
+### thread\r
+\r
+thread.obj : thread.d\r
+ $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@\r
+\r
######################################################\r
\r
clean :\r