Mercurial > projects > ldc
diff lphobos/typeinfo/ti_char.d @ 52:0c77619e803b trunk
[svn r56] Initial support for TypeInfo.
Enums not work.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 23 Oct 2007 05:55:12 +0200 |
parents | lphobos/std/typeinfo/ti_char.d@c53b6e3fe49a |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lphobos/typeinfo/ti_char.d Tue Oct 23 05:55:12 2007 +0200 @@ -0,0 +1,43 @@ + +module typeinfo.ti_char; + +class TypeInfo_a : TypeInfo +{ + char[] toString() { return "char"; } + + hash_t getHash(void *p) + { + return *cast(char *)p; + } + + int equals(void *p1, void *p2) + { + return *cast(char *)p1 == *cast(char *)p2; + } + + int compare(void *p1, void *p2) + { + return *cast(char *)p1 - *cast(char *)p2; + } + + size_t tsize() + { + return char.sizeof; + } + + void swap(void *p1, void *p2) + { + char t; + + t = *cast(char *)p1; + *cast(char *)p1 = *cast(char *)p2; + *cast(char *)p2 = t; + } + + void[] init() + { static char c; + + return (cast(char *)&c)[0 .. 1]; + } +} +