Mercurial > projects > ldc
annotate lphobos/internal/cast.d @ 1411:e57859ca8f1e
Fix `scope(exit) foreach (ref v; arr) foo(v);`
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 22 May 2009 21:38:01 +0200 |
parents | 27b9f749d9fe |
children |
rev | line source |
---|---|
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
1 /* |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
2 * Copyright (C) 2004-2006 by Digital Mars, www.digitalmars.com |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
3 * Written by Walter Bright |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
4 * |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
5 * This software is provided 'as-is', without any express or implied |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
6 * warranty. In no event will the authors be held liable for any damages |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
7 * arising from the use of this software. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
8 * |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
9 * Permission is granted to anyone to use this software for any purpose, |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
10 * including commercial applications, and to alter it and redistribute it |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
11 * freely, in both source and binary form, subject to the following |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
12 * restrictions: |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
13 * |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
14 * o The origin of this software must not be misrepresented; you must not |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
15 * claim that you wrote the original software. If you use this software |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
16 * in a product, an acknowledgment in the product documentation would be |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
17 * appreciated but is not required. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
18 * o Altered source versions must be plainly marked as such, and must not |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
19 * be misrepresented as being the original software. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
20 * o This notice may not be removed or altered from any source |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
21 * distribution. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
22 */ |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
23 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
24 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
25 import object; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
26 import std.c.stdio; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
27 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
28 extern (C): |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
29 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
30 /****************************************** |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
31 * Given a pointer: |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
32 * If it is an Object, return that Object. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
33 * If it is an interface, return the Object implementing the interface. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
34 * If it is null, return null. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
35 * Else, undefined crash |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
36 */ |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
37 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
38 Object _d_toObject(void* p) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
39 { Object o; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
40 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
41 if (p) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
42 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
43 o = cast(Object)p; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
44 //ClassInfo oc = o.classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
45 Interface *pi = **cast(Interface ***)p; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
46 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
47 /* Interface.offset lines up with ClassInfo.name.ptr, |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
48 * so we rely on pointers never being less than 64K, |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
49 * and Objects never being greater. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
50 */ |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
51 if (pi.offset < 0x10000) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
52 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
53 //printf("\tpi.offset = %d\n", pi.offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
54 o = cast(Object)(p - pi.offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
55 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
56 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
57 return o; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
58 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
59 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
60 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
61 /************************************* |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
62 * Attempts to cast Object o to class c. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
63 * Returns o if successful, null if not. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
64 */ |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
65 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
66 Object _d_interface_cast(void* p, ClassInfo c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
67 { Object o; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
68 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
69 //printf("_d_interface_cast(p = %p, c = '%.*s')\n", p, c.name); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
70 if (p) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
71 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
72 Interface *pi = **cast(Interface ***)p; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
73 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
74 //printf("\tpi.offset = %d\n", pi.offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
75 o = cast(Object)(p - pi.offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
76 return _d_dynamic_cast(o, c); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
77 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
78 return o; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
79 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
80 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
81 Object _d_dynamic_cast(Object o, ClassInfo c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
82 { ClassInfo oc; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
83 uint offset = 0; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
84 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
85 //printf("_d_dynamic_cast(o = %p, c = '%.*s')\n", o, c.name); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
86 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
87 if (o) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
88 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
89 oc = o.classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
90 if (_d_isbaseof2(oc, c, offset)) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
91 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
92 //printf("\toffset = %d\n", offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
93 o = cast(Object)(cast(void*)o + offset); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
94 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
95 else |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
96 o = null; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
97 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
98 //printf("\tresult = %p\n", o); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
99 return o; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
100 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
101 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
102 int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout uint offset) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
103 { int i; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
104 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
105 if (oc is c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
106 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
107 do |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
108 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
109 if (oc.base is c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
110 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
111 for (i = 0; i < oc.interfaces.length; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
112 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
113 ClassInfo ic; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
114 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
115 ic = oc.interfaces[i].classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
116 if (ic is c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
117 { offset = oc.interfaces[i].offset; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
118 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
119 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
120 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
121 for (i = 0; i < oc.interfaces.length; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
122 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
123 ClassInfo ic; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
124 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
125 ic = oc.interfaces[i].classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
126 if (_d_isbaseof2(ic, c, offset)) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
127 { offset = oc.interfaces[i].offset; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
128 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
129 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
130 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
131 oc = oc.base; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
132 } while (oc); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
133 return 0; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
134 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
135 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
136 int _d_isbaseof(ClassInfo oc, ClassInfo c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
137 { int i; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
138 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
139 if (oc is c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
140 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
141 do |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
142 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
143 if (oc.base is c) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
144 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
145 for (i = 0; i < oc.interfaces.length; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
146 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
147 ClassInfo ic; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
148 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
149 ic = oc.interfaces[i].classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
150 if (ic is c || _d_isbaseof(ic, c)) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
151 return 1; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
152 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
153 oc = oc.base; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
154 } while (oc); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
155 return 0; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
156 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
157 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
158 /********************************* |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
159 * Find the vtbl[] associated with Interface ic. |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
160 */ |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
161 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
162 void *_d_interface_vtbl(ClassInfo ic, Object o) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
163 { int i; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
164 ClassInfo oc; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
165 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
166 //printf("__d_interface_vtbl(o = %p, ic = %p)\n", o, ic); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
167 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
168 assert(o); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
169 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
170 oc = o.classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
171 for (i = 0; i < oc.interfaces.length; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
172 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
173 ClassInfo oic; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
174 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
175 oic = oc.interfaces[i].classinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
176 if (oic is ic) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
177 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
178 return cast(void *)oc.interfaces[i].vtbl; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
179 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
180 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
181 assert(0); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
diff
changeset
|
182 } |