comparison lphobos/std/typeinfounsupported/ti_Acreal.d @ 1:c53b6e3fe49a trunk

[svn r5] Initial commit. Most things are very rough.
author lindquist
date Sat, 01 Sep 2007 21:43:27 +0200
parents
children
comparison
equal deleted inserted replaced
0:a9e71648e74d 1:c53b6e3fe49a
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_Acreal;
25
26 private import std.typeinfo.ti_creal;
27
28 // creal[]
29
30 class TypeInfo_Ac : TypeInfo
31 {
32 char[] toString() { return "creal[]"; }
33
34 hash_t getHash(void *p)
35 { creal[] s = *cast(creal[]*)p;
36 size_t len = s.length;
37 creal *str = s.ptr;
38 hash_t hash = 0;
39
40 while (len)
41 {
42 hash *= 9;
43 hash += (cast(uint *)str)[0];
44 hash += (cast(uint *)str)[1];
45 hash += (cast(uint *)str)[2];
46 hash += (cast(uint *)str)[3];
47 hash += (cast(uint *)str)[4];
48 str++;
49 len--;
50 }
51
52 return hash;
53 }
54
55 int equals(void *p1, void *p2)
56 {
57 creal[] s1 = *cast(creal[]*)p1;
58 creal[] s2 = *cast(creal[]*)p2;
59 size_t len = s1.length;
60
61 if (len != s2.length)
62 return 0;
63 for (size_t u = 0; u < len; u++)
64 {
65 int c = TypeInfo_c._equals(s1[u], s2[u]);
66 if (c == 0)
67 return 0;
68 }
69 return 1;
70 }
71
72 int compare(void *p1, void *p2)
73 {
74 creal[] s1 = *cast(creal[]*)p1;
75 creal[] s2 = *cast(creal[]*)p2;
76 size_t len = s1.length;
77
78 if (s2.length < len)
79 len = s2.length;
80 for (size_t u = 0; u < len; u++)
81 {
82 int c = TypeInfo_c._compare(s1[u], s2[u]);
83 if (c)
84 return c;
85 }
86 return cast(int)s1.length - cast(int)s2.length;
87 }
88
89 size_t tsize()
90 {
91 return (creal[]).sizeof;
92 }
93
94 uint flags()
95 {
96 return 1;
97 }
98
99 TypeInfo next()
100 {
101 return typeid(creal);
102 }
103 }
104