106
|
1 /*
|
|
2 * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com
|
|
3 * Written by Walter Bright
|
|
4 *
|
|
5 * This software is provided 'as-is', without any express or implied
|
|
6 * warranty. In no event will the authors be held liable for any damages
|
|
7 * arising from the use of this software.
|
|
8 *
|
|
9 * Permission is granted to anyone to use this software for any purpose,
|
|
10 * including commercial applications, and to alter it and redistribute it
|
|
11 * freely, in both source and binary form, subject to the following
|
|
12 * restrictions:
|
|
13 *
|
|
14 * o The origin of this software must not be misrepresented; you must not
|
|
15 * claim that you wrote the original software. If you use this software
|
|
16 * in a product, an acknowledgment in the product documentation would be
|
|
17 * appreciated but is not required.
|
|
18 * o Altered source versions must be plainly marked as such, and must not
|
|
19 * be misrepresented as being the original software.
|
|
20 * o This notice may not be removed or altered from any source
|
|
21 * distribution.
|
|
22 */
|
|
23
|
|
24 module std.typeinfo.ti_C;
|
|
25
|
|
26 // Object
|
|
27
|
|
28 class TypeInfo_C : TypeInfo
|
|
29 {
|
|
30 hash_t getHash(void *p)
|
|
31 {
|
|
32 Object o = *cast(Object*)p;
|
|
33 assert(o);
|
|
34 return o.toHash();
|
|
35 }
|
|
36
|
|
37 int equals(void *p1, void *p2)
|
|
38 {
|
|
39 Object o1 = *cast(Object*)p1;
|
|
40 Object o2 = *cast(Object*)p2;
|
|
41
|
|
42 return o1 == o2;
|
|
43 }
|
|
44
|
|
45 int compare(void *p1, void *p2)
|
|
46 {
|
|
47 Object o1 = *cast(Object*)p1;
|
|
48 Object o2 = *cast(Object*)p2;
|
|
49 int c = 0;
|
|
50
|
|
51 // Regard null references as always being "less than"
|
|
52 if (!(o1 is o2))
|
|
53 {
|
|
54 if (o1)
|
|
55 { if (!o2)
|
|
56 c = 1;
|
|
57 else
|
|
58 c = o1.opCmp(o2);
|
|
59 }
|
|
60 else
|
|
61 c = -1;
|
|
62 }
|
|
63 return c;
|
|
64 }
|
|
65
|
|
66 size_t tsize()
|
|
67 {
|
|
68 return Object.sizeof;
|
|
69 }
|
|
70
|
|
71 uint flags()
|
|
72 {
|
|
73 return 1;
|
|
74 }
|
|
75 }
|
|
76
|