PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 1ms

/runtime/typeinfo/ti_char.d

http://github.com/wilkie/djehuty
D | 45 lines | 28 code | 11 blank | 6 comment | 1 complexity | 16c08691593c576a272da48b9ba5b6b2 MD5 | raw file
 1/*
 2 * ti_char.d
 3 *
 4 * This module implements the TypeInfo for the char type.
 5 *
 6 */
 7
 8module runtime.typeinfo.ti_char;
 9
10class TypeInfo_a : TypeInfo {
11	char[] toString() {
12		return "char";
13	}
14
15	hash_t getHash(void *p) {
16		return *cast(char *)p;
17	}
18
19	int equals(void *p1, void *p2) {
20		return *cast(char *)p1 == *cast(char *)p2;
21	}
22
23	int compare(void *p1, void *p2) {
24		return *cast(char *)p1 - *cast(char *)p2;
25	}
26
27	size_t tsize() {
28		return char.sizeof;
29	}
30
31	void swap(void *p1, void *p2) {
32		char t;
33
34		t = *cast(char *)p1;
35		*cast(char *)p1 = *cast(char *)p2;
36		*cast(char *)p2 = t;
37	}
38
39	void[] init() {
40		static char c;
41
42		return (cast(char *)&c)[0 .. 1];
43	}
44}
45