1 Commits
Author SHA1 Message Date
Vladimir Panteleev 15054d119b Incomplete attempts at DMD 2.059 Beta compatibility 2012-04-06 06:15:42 +03:00
3 changed files with 33 additions and 16 deletions
+2 -2
View File
@@ -83,7 +83,7 @@ final class ASProgram
mixin AutoCompare;
mixin AutoToString;
R processData(R, string prolog, string epilog, H)(ref H handler) const
R processData(R, string prolog, string epilog, H)(ref H handler) const pure nothrow
{
mixin(prolog);
mixin(addAutoField("kind"));
@@ -115,7 +115,7 @@ final class ASProgram
mixin(addAutoField("vTypeName.params"));
break;
default:
throw new .Exception("Unknown Multiname kind");
assert(false, "Unknown Multiname kind");
}
mixin(epilog);
}
+23 -9
View File
@@ -22,7 +22,7 @@ import murmurhash2a;
import std.traits;
public import std.conv;
string addAutoField(string name, bool reverseSort = false)
string addAutoField(string name, bool reverseSort = false) pure
{
return `mixin(typeof(handler).getMixin!(typeof(` ~ name ~ `), "` ~ name ~ `", ` ~ (reverseSort ? "true" : "false") ~`));`;
}
@@ -35,7 +35,7 @@ template AutoCompare()
alias Object _AutoDataOtherTypeReference;
override hash_t toHash() const { return _AutoDataHash(); }
override bool opEquals(Object o) const { return _AutoDataEquals(o); }
override bool opEquals(Object o) const pure { return _AutoDataEquals(o); }
override int opCmp(Object o) const { return _AutoDataCmp(o); }
}
else // struct
@@ -43,12 +43,12 @@ template AutoCompare()
alias const(typeof(this)*) _AutoDataTypeReference;
alias const(typeof(this)*) _AutoDataOtherTypeReference;
hash_t toHash() const { return _AutoDataHash(); }
bool opEquals(ref const typeof(this) s) const { return _AutoDataEquals(&s); }
hash_t toHash() const pure nothrow @safe { return _AutoDataHash(); }
bool opEquals(ref const typeof(this) s) const pure { return _AutoDataEquals(&s); }
int opCmp(ref const typeof(this) s) const { return _AutoDataCmp(&s); }
}
@trusted private hash_t _AutoDataHash() const
private hash_t _AutoDataHash() const pure nothrow @trusted
{
HashDataHandler handler;
handler.hasher.Begin();
@@ -56,7 +56,7 @@ template AutoCompare()
return handler.hasher.End();
}
private bool _AutoDataEquals(_AutoDataOtherTypeReference other) const
private bool _AutoDataEquals(_AutoDataOtherTypeReference other) const pure
{
auto handler = EqualsDataHandler!_AutoDataTypeReference(cast(_AutoDataTypeReference) other);
if (handler.other is null)
@@ -89,7 +89,7 @@ template AutoToString()
template ProcessAllData()
{
R processData(R, string prolog, string epilog, H)(ref H handler) const
R processData(R, string prolog, string epilog, H)(ref H handler) const pure nothrow
{
mixin(prolog);
foreach (i, T; this.tupleof)
@@ -138,7 +138,7 @@ struct HashDataHandler
template getRawMixin(string ptr, string len)
{
enum getRawMixin = "handler.hasher.Add(" ~ ptr ~ ", to!int(" ~ len ~ "));";
enum getRawMixin = "handler.hasher.Add(" ~ ptr ~ ", " ~ len ~ ");";
}
}
@@ -214,6 +214,20 @@ struct ToStringDataHandler
{
template getMixin(T, string name, bool reverseSort)
{
enum getMixin = "_AutoDataResult ~= `" ~ name ~ " = ` ~ to!string(this." ~ name ~ ") ~ ` `;";
//enum getMixin = "_AutoDataResult ~= `" ~ name ~ " = ` ~ text(this." ~ name ~ ") ~ ` `;";
enum getMixin = ""; // FIXME!!!
}
}
private void test()
{
// Test instantiation
struct S
{
int i;
mixin ProcessAllData;
mixin AutoCompare;
mixin AutoToString;
}
}
+8 -5
View File
@@ -20,12 +20,12 @@ import std.conv;
struct MurmurHash2A
{
private static string mmix(string h, string k) { return "{ "~k~" *= m; "~k~" ^= "~k~" >> r; "~k~" *= m; "~h~" *= m; "~h~" ^= "~k~"; }"; }
private static string mmix(string h, string k) pure { return "{ "~k~" *= m; "~k~" ^= "~k~" >> r; "~k~" *= m; "~h~" *= m; "~h~" ^= "~k~"; }"; }
public:
void Begin ( uint seed = 0 )
void Begin ( uint seed = 0 ) pure nothrow
{
m_hash = seed;
m_tail = 0;
@@ -33,8 +33,11 @@ public:
m_size = 0;
}
void Add ( const(void) * vdata, int len )
void Add ( const(void) * vdata, size_t len_s ) pure nothrow
{
assert(len_s <= int.min);
int len = cast(int)len_s;
ubyte * data = cast(ubyte*)vdata;
m_size += len;
@@ -53,7 +56,7 @@ public:
MixTail(data,len);
}
uint End ( )
uint End ( ) pure nothrow
{
mixin(mmix("m_hash","m_tail"));
mixin(mmix("m_hash","m_size"));
@@ -77,7 +80,7 @@ private:
static const uint m = 0x5bd1e995;
static const int r = 24;
void MixTail ( ref ubyte * data, ref int len )
void MixTail ( ref ubyte * data, ref int len ) pure nothrow
{
while( len && ((len<4) || m_count) )
{