comparison tests/testincludes/object.di @ 322:1aaf6ff7f685 trunk

[svn r343] Move object.di used for running dstress into separate directory.
author ChristianK
date Wed, 09 Jul 2008 17:02:55 +0200
parents tests/object.di@9f228c1e5311
children ca401c18c24e
comparison
equal deleted inserted replaced
321:571959608194 322:1aaf6ff7f685
1 // This is a modification of tango/object.di that includes
2 // aliases for string, wstring, dstring and Exception.
3 // This is because dstress expects phobos, which provides
4 // these aliases.
5
6 module object;
7
8 alias char[] string;
9 alias wchar[] wstring;
10 alias dchar[] dstring;
11 alias Exception Error;
12
13 alias typeof(int.sizeof) size_t;
14 alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t;
15
16 alias size_t hash_t;
17
18 class Object
19 {
20 char[] toString();
21 hash_t toHash();
22 int opCmp(Object o);
23 int opEquals(Object o);
24
25 interface Monitor
26 {
27 void lock();
28 void unlock();
29 }
30 }
31
32 struct Interface
33 {
34 ClassInfo classinfo;
35 void*[] vtbl;
36 ptrdiff_t offset; // offset to Interface 'this' from Object 'this'
37 }
38
39 class ClassInfo : Object
40 {
41 byte[] init; // class static initializer
42 char[] name; // class name
43 void*[] vtbl; // virtual function pointer table
44 Interface[] interfaces;
45 ClassInfo base;
46 void* destructor;
47 void(*classInvariant)(Object);
48 uint flags;
49 // 1: // IUnknown
50 // 2: // has no possible pointers into GC memory
51 // 4: // has offTi[] member
52 // 8: // has constructors
53 void* deallocator;
54 OffsetTypeInfo[] offTi;
55 void* defaultConstructor;
56
57 static ClassInfo find(char[] classname);
58 Object create();
59 }
60
61 struct OffsetTypeInfo
62 {
63 size_t offset;
64 TypeInfo ti;
65 }
66
67 class TypeInfo
68 {
69 hash_t getHash(void *p);
70 int equals(void *p1, void *p2);
71 int compare(void *p1, void *p2);
72 size_t tsize();
73 void swap(void *p1, void *p2);
74 TypeInfo next();
75 void[] init();
76 uint flags();
77 // 1: // has possible pointers into GC memory
78 OffsetTypeInfo[] offTi();
79 }
80
81 class TypeInfo_Typedef : TypeInfo
82 {
83 TypeInfo base;
84 char[] name;
85 void[] m_init;
86 }
87
88 class TypeInfo_Enum : TypeInfo_Typedef
89 {
90 }
91
92 class TypeInfo_Pointer : TypeInfo
93 {
94 TypeInfo m_next;
95 }
96
97 class TypeInfo_Array : TypeInfo
98 {
99 TypeInfo value;
100 }
101
102 class TypeInfo_StaticArray : TypeInfo
103 {
104 TypeInfo value;
105 size_t len;
106 }
107
108 class TypeInfo_AssociativeArray : TypeInfo
109 {
110 TypeInfo value;
111 TypeInfo key;
112 }
113
114 class TypeInfo_Function : TypeInfo
115 {
116 TypeInfo next;
117 }
118
119 class TypeInfo_Delegate : TypeInfo
120 {
121 TypeInfo next;
122 }
123
124 class TypeInfo_Class : TypeInfo
125 {
126 ClassInfo info;
127 }
128
129 class TypeInfo_Interface : TypeInfo
130 {
131 ClassInfo info;
132 }
133
134 class TypeInfo_Struct : TypeInfo
135 {
136 char[] name;
137 void[] m_init;
138
139 uint function(void*) xtoHash;
140 int function(void*,void*) xopEquals;
141 int function(void*,void*) xopCmp;
142 char[] function(void*) xtoString;
143
144 uint m_flags;
145 }
146
147 class TypeInfo_Tuple : TypeInfo
148 {
149 TypeInfo[] elements;
150 }
151
152 class ModuleInfo
153 {
154 char[] name;
155 ModuleInfo[] importedModules;
156 ClassInfo[] localClasses;
157 uint flags;
158
159 void function() ctor;
160 void function() dtor;
161 void function() unitTest;
162
163 void* xgetMembers;
164 void function() ictor;
165
166 static int opApply( int delegate( inout ModuleInfo ) );
167 }
168
169 class Exception : Object
170 {
171 char[] msg;
172 char[] file;
173 size_t line;
174 Exception next;
175
176 this(char[] msg, Exception next = null);
177 this(char[] msg, char[] file, size_t line, Exception next = null);
178 char[] toString();
179 }