PageRenderTime 24ms CodeModel.GetById 13ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/runtime/typeinfo/ti_byte.d

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