Handle WM_CHARs and pass them to TREEVIEW_ProcessLetterKeys. See also
[wine] / dlls / msvcrt / cpp.c
1 /*
2  * msvcrt.dll C++ objects
3  *
4  * Copyright 2000 Jon Griffiths
5  */
6 #include "msvcrt.h"
7
8 DEFAULT_DEBUG_CHANNEL(msvcrt);
9
10
11 void __cdecl MSVCRT__purecall(void);
12
13 typedef void (__cdecl *v_table_ptr)();
14
15 static v_table_ptr exception_vtable[2];
16 static v_table_ptr bad_typeid_vtable[3];
17 static v_table_ptr __non_rtti_object_vtable[3];
18 static v_table_ptr bad_cast_vtable[3];
19 static v_table_ptr type_info_vtable[1];
20
21 typedef struct __exception
22 {
23   v_table_ptr *vtable;
24   const char *name;
25   int do_free; /* FIXME: take string copy with char* ctor? */
26 } exception;
27
28 typedef struct __bad_typeid
29 {
30   exception base;
31 } bad_typeid;
32
33 typedef struct ____non_rtti_object
34 {
35   bad_typeid base;
36 } __non_rtti_object;
37
38 typedef struct __bad_cast
39 {
40   exception base;
41 } bad_cast;
42
43 typedef struct __type_info
44 {
45   v_table_ptr *vtable;
46   void *data;
47   char name[1];
48 } type_info;
49
50 /******************************************************************
51  *              exception_ctor (MSVCRT.@)
52  */
53 void __cdecl MSVCRT_exception_ctor(exception * _this, const char ** name)
54 {
55   TRACE("(%p %s)\n",_this,*name);
56   _this->vtable = exception_vtable;
57   _this->name = *name;
58   TRACE("name = %s\n",_this->name);
59   _this->do_free = 0; /* FIXME */
60 }
61
62 /******************************************************************
63  *              exception_copy_ctor (MSVCRT.@)
64  */
65 void __cdecl MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs)
66 {
67   TRACE("(%p %p)\n",_this,rhs);
68   if (_this != rhs)
69     memcpy (_this, rhs, sizeof (*_this));
70   TRACE("name = %s\n",_this->name);
71 }
72
73 /******************************************************************
74  *              exception_default_ctor (MSVCRT.@)
75  */
76 void __cdecl MSVCRT_exception_default_ctor(exception * _this)
77 {
78   TRACE("(%p)\n",_this);
79   _this->vtable = exception_vtable;
80   _this->name = "";
81   _this->do_free = 0; /* FIXME */
82 }
83
84 /******************************************************************
85  *              exception_dtor (MSVCRT.@)
86  */
87 void __cdecl MSVCRT_exception_dtor(exception * _this)
88 {
89   TRACE("(%p)\n",_this);
90 }
91
92 /******************************************************************
93  *              exception_opequals (MSVCRT.@)
94  */
95 exception * __cdecl MSVCRT_exception_opequals(exception * _this, const exception * rhs)
96 {
97   TRACE("(%p %p)\n",_this,rhs);
98   memcpy (_this, rhs, sizeof (*_this));
99   TRACE("name = %s\n",_this->name);
100   return _this;
101 }
102
103 /******************************************************************
104  *              exception__unknown_E (MSVCRT.@)
105  */
106 void * __cdecl MSVCRT_exception__unknown_E(exception * _this, unsigned int arg1)
107 {
108   TRACE("(%p %d)\n",_this,arg1);
109   MSVCRT__purecall();
110   return NULL;
111 }
112
113 /******************************************************************
114  *              exception__unknown_G (MSVCRT.@)
115  */
116 void * __cdecl MSVCRT_exception__unknown_G(exception * _this, unsigned int arg1)
117 {
118   TRACE("(%p %d)\n",_this,arg1);
119   MSVCRT__purecall();
120   return NULL;
121 }
122
123 /******************************************************************
124  *              exception_what (MSVCRT.@)
125  */
126 const char * __stdcall MSVCRT_exception_what(exception * _this)
127 {
128   TRACE("(%p) returning %s\n",_this,_this->name);
129   return _this->name;
130 }
131
132
133 /******************************************************************
134  *              bad_typeid_copy_ctor (MSVCRT.@)
135  */
136 void __cdecl MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs)
137 {
138   TRACE("(%p %p)\n",_this,rhs);
139   MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
140 }
141
142 /******************************************************************
143  *              bad_typeid_ctor (MSVCRT.@)
144  */
145 void __cdecl MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name)
146 {
147   TRACE("(%p %s)\n",_this,name);
148   MSVCRT_exception_ctor(&_this->base, &name);
149   _this->base.vtable = bad_typeid_vtable;
150 }
151
152 /******************************************************************
153  *              bad_typeid_dtor (MSVCRT.@)
154  */
155 void __cdecl MSVCRT_bad_typeid_dtor(bad_typeid * _this)
156 {
157   TRACE("(%p)\n",_this);
158   MSVCRT_exception_dtor(&_this->base);
159 }
160
161 /******************************************************************
162  *              bad_typeid_opequals (MSVCRT.@)
163  */
164 bad_typeid * __cdecl MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs)
165 {
166   TRACE("(%p %p)\n",_this,rhs);
167   MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
168   return _this;
169 }
170
171 /******************************************************************
172  *              __non_rtti_object_copy_ctor (MSVCRT.@)
173  */
174 void __cdecl MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this,
175                                                 const __non_rtti_object * rhs)
176 {
177   TRACE("(%p %p)\n",_this,rhs);
178   MSVCRT_bad_typeid_copy_ctor(&_this->base,&rhs->base);
179 }
180
181 /******************************************************************
182  *              __non_rtti_object_ctor (MSVCRT.@)
183  */
184 void __cdecl MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this,
185                                            const char * name)
186 {
187   TRACE("(%p %s)\n",_this,name);
188   MSVCRT_bad_typeid_ctor(&_this->base,name);
189   _this->base.base.vtable = __non_rtti_object_vtable;
190 }
191
192 /******************************************************************
193  *              __non_rtti_object_dtor (MSVCRT.@)
194  */
195 void __cdecl MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this)
196 {
197   TRACE("(%p)\n",_this);
198   MSVCRT_bad_typeid_dtor(&_this->base);
199 }
200
201 /******************************************************************
202  *              __non_rtti_object_opequals (MSVCRT.@)
203  */
204 __non_rtti_object * __cdecl MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this,
205                                                               const __non_rtti_object *rhs)
206 {
207   TRACE("(%p %p)\n",_this,rhs);
208   memcpy (_this, rhs, sizeof (*_this));
209   TRACE("name = %s\n",_this->base.base.name);
210   return _this;
211 }
212
213 /******************************************************************
214  *              __non_rtti_object__unknown_E (MSVCRT.@)
215  */
216 void * __cdecl MSVCRT___non_rtti_object__unknown_E(__non_rtti_object * _this, unsigned int arg1)
217 {
218   TRACE("(%p %d)\n",_this,arg1);
219   MSVCRT__purecall();
220   return NULL;
221 }
222
223 /******************************************************************
224  *              __non_rtti_object__unknown_G (MSVCRT.@)
225  */
226 void * __cdecl MSVCRT___non_rtti_object__unknown_G(__non_rtti_object * _this, unsigned int arg1)
227 {
228   TRACE("(%p %d)\n",_this,arg1);
229   MSVCRT__purecall();
230   return NULL;
231 }
232
233 /******************************************************************
234  *              bad_cast_ctor (MSVCRT.@)
235  */
236 void __cdecl MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name)
237 {
238   TRACE("(%p %s)\n",_this,*name);
239   MSVCRT_exception_ctor(&_this->base, name);
240   _this->base.vtable = bad_cast_vtable;
241 }
242
243 /******************************************************************
244  *              bad_cast_copy_ctor (MSVCRT.@)
245  */
246 void __cdecl MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs)
247 {
248   TRACE("(%p %p)\n",_this,rhs);
249   MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
250 }
251
252 /******************************************************************
253  *              bad_cast_dtor (MSVCRT.@)
254  */
255 void __cdecl MSVCRT_bad_cast_dtor(bad_cast * _this)
256 {
257   TRACE("(%p)\n",_this);
258   MSVCRT_exception_dtor(&_this->base);
259 }
260
261 /******************************************************************
262  *              bad_cast_opequals (MSVCRT.@)
263  */
264 bad_cast * __cdecl MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs)
265 {
266   TRACE("(%p %p)\n",_this,rhs);
267   MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
268   return _this;
269 }
270
271 /******************************************************************
272  *              type_info_opequals_equals (MSVCRT.@)
273  */
274 int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs)
275 {
276   TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
277   return _this->name == rhs->name;
278 }
279
280 /******************************************************************
281  *              type_info_opnot_equals (MSVCRT.@)
282  */
283 int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs)
284 {
285   TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
286   return _this->name != rhs->name;
287 }
288
289 /******************************************************************
290  *              type_info_dtor (MSVCRT.@)
291  */
292 void __cdecl MSVCRT_type_info_dtor(type_info * _this)
293 {
294   TRACE("(%p)\n",_this);
295   if (_this->data)
296     MSVCRT_free(_this->data);
297 }
298
299 /******************************************************************
300  *              type_info_name (MSVCRT.@)
301  */
302 const char * __stdcall MSVCRT_type_info_name(type_info * _this)
303 {
304   TRACE("(%p) returning %s\n",_this,_this->name);
305   return _this->name;
306 }
307
308 /******************************************************************
309  *              type_info_raw_name (MSVCRT.@)
310  */
311 const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this)
312 {
313   TRACE("(%p) returning %s\n",_this,_this->name);
314   return _this->name;
315 }
316
317
318 /* INTERNAL: Set up vtables
319  * FIXME:should be static, cope with versions?
320  */
321 void MSVCRT_init_vtables(void)
322 {
323   exception_vtable[0] = MSVCRT_exception_dtor;
324   exception_vtable[1] = (void*)MSVCRT_exception_what;
325
326   bad_typeid_vtable[0] = MSVCRT_bad_typeid_dtor;
327   bad_typeid_vtable[1] = exception_vtable[1];
328   bad_typeid_vtable[2] = MSVCRT__purecall; /* FIXME */
329
330   __non_rtti_object_vtable[0] = MSVCRT___non_rtti_object_dtor;
331   __non_rtti_object_vtable[1] = bad_typeid_vtable[1];
332   __non_rtti_object_vtable[2] = bad_typeid_vtable[2];
333
334   bad_cast_vtable[0] = MSVCRT_bad_cast_dtor;
335   bad_cast_vtable[1] = exception_vtable[1];
336   bad_cast_vtable[2] = MSVCRT__purecall; /* FIXME */
337
338   type_info_vtable[0] = MSVCRT_type_info_dtor;
339
340 }
341