comparison tango/object.di @ 132:1700239cab2e trunk

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