Handle the %f case in wsprintf.
[wine.git] / dlls / msvcrt / cpp.c
blobaed3a3e75d7c43e9e3bd1d13f49332a767d46de6
1 /*
2 * msvcrt.dll C++ objects
4 * Copyright 2000 Jon Griffiths
5 */
6 #include "msvcrt.h"
8 #include "msvcrt/stdlib.h"
11 DEFAULT_DEBUG_CHANNEL(msvcrt);
14 void _purecall(void);
16 typedef void (*v_table_ptr)();
18 static v_table_ptr exception_vtable[2];
19 static v_table_ptr bad_typeid_vtable[3];
20 static v_table_ptr __non_rtti_object_vtable[3];
21 static v_table_ptr bad_cast_vtable[3];
22 static v_table_ptr type_info_vtable[1];
24 typedef struct __exception
26 v_table_ptr *vtable;
27 const char *name;
28 int do_free; /* FIXME: take string copy with char* ctor? */
29 } exception;
31 typedef struct __bad_typeid
33 exception base;
34 } bad_typeid;
36 typedef struct ____non_rtti_object
38 bad_typeid base;
39 } __non_rtti_object;
41 typedef struct __bad_cast
43 exception base;
44 } bad_cast;
46 typedef struct __type_info
48 v_table_ptr *vtable;
49 void *data;
50 char name[1];
51 } type_info;
53 /******************************************************************
54 * exception_ctor (MSVCRT.@)
56 void MSVCRT_exception_ctor(exception * _this, const char ** name)
58 TRACE("(%p %s)\n",_this,*name);
59 _this->vtable = exception_vtable;
60 _this->name = *name;
61 TRACE("name = %s\n",_this->name);
62 _this->do_free = 0; /* FIXME */
65 /******************************************************************
66 * exception_copy_ctor (MSVCRT.@)
68 void MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs)
70 TRACE("(%p %p)\n",_this,rhs);
71 if (_this != rhs)
72 memcpy (_this, rhs, sizeof (*_this));
73 TRACE("name = %s\n",_this->name);
76 /******************************************************************
77 * exception_default_ctor (MSVCRT.@)
79 void MSVCRT_exception_default_ctor(exception * _this)
81 TRACE("(%p)\n",_this);
82 _this->vtable = exception_vtable;
83 _this->name = "";
84 _this->do_free = 0; /* FIXME */
87 /******************************************************************
88 * exception_dtor (MSVCRT.@)
90 void MSVCRT_exception_dtor(exception * _this)
92 TRACE("(%p)\n",_this);
95 /******************************************************************
96 * exception_opequals (MSVCRT.@)
98 exception * MSVCRT_exception_opequals(exception * _this, const exception * rhs)
100 TRACE("(%p %p)\n",_this,rhs);
101 memcpy (_this, rhs, sizeof (*_this));
102 TRACE("name = %s\n",_this->name);
103 return _this;
106 /******************************************************************
107 * exception__unknown_E (MSVCRT.@)
109 void * MSVCRT_exception__unknown_E(exception * _this, unsigned int arg1)
111 TRACE("(%p %d)\n",_this,arg1);
112 _purecall();
113 return NULL;
116 /******************************************************************
117 * exception__unknown_G (MSVCRT.@)
119 void * MSVCRT_exception__unknown_G(exception * _this, unsigned int arg1)
121 TRACE("(%p %d)\n",_this,arg1);
122 _purecall();
123 return NULL;
126 /******************************************************************
127 * exception_what (MSVCRT.@)
129 const char * __stdcall MSVCRT_exception_what(exception * _this)
131 TRACE("(%p) returning %s\n",_this,_this->name);
132 return _this->name;
136 /******************************************************************
137 * bad_typeid_copy_ctor (MSVCRT.@)
139 void MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs)
141 TRACE("(%p %p)\n",_this,rhs);
142 MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
145 /******************************************************************
146 * bad_typeid_ctor (MSVCRT.@)
148 void MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name)
150 TRACE("(%p %s)\n",_this,name);
151 MSVCRT_exception_ctor(&_this->base, &name);
152 _this->base.vtable = bad_typeid_vtable;
155 /******************************************************************
156 * bad_typeid_dtor (MSVCRT.@)
158 void MSVCRT_bad_typeid_dtor(bad_typeid * _this)
160 TRACE("(%p)\n",_this);
161 MSVCRT_exception_dtor(&_this->base);
164 /******************************************************************
165 * bad_typeid_opequals (MSVCRT.@)
167 bad_typeid * MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs)
169 TRACE("(%p %p)\n",_this,rhs);
170 MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
171 return _this;
174 /******************************************************************
175 * __non_rtti_object_copy_ctor (MSVCRT.@)
177 void MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this,
178 const __non_rtti_object * rhs)
180 TRACE("(%p %p)\n",_this,rhs);
181 MSVCRT_bad_typeid_copy_ctor(&_this->base,&rhs->base);
184 /******************************************************************
185 * __non_rtti_object_ctor (MSVCRT.@)
187 void MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this,
188 const char * name)
190 TRACE("(%p %s)\n",_this,name);
191 MSVCRT_bad_typeid_ctor(&_this->base,name);
192 _this->base.base.vtable = __non_rtti_object_vtable;
195 /******************************************************************
196 * __non_rtti_object_dtor (MSVCRT.@)
198 void MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this)
200 TRACE("(%p)\n",_this);
201 MSVCRT_bad_typeid_dtor(&_this->base);
204 /******************************************************************
205 * __non_rtti_object_opequals (MSVCRT.@)
207 __non_rtti_object * MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this,
208 const __non_rtti_object *rhs)
210 TRACE("(%p %p)\n",_this,rhs);
211 memcpy (_this, rhs, sizeof (*_this));
212 TRACE("name = %s\n",_this->base.base.name);
213 return _this;
216 /******************************************************************
217 * __non_rtti_object__unknown_E (MSVCRT.@)
219 void * MSVCRT___non_rtti_object__unknown_E(__non_rtti_object * _this, unsigned int arg1)
221 TRACE("(%p %d)\n",_this,arg1);
222 _purecall();
223 return NULL;
226 /******************************************************************
227 * __non_rtti_object__unknown_G (MSVCRT.@)
229 void * MSVCRT___non_rtti_object__unknown_G(__non_rtti_object * _this, unsigned int arg1)
231 TRACE("(%p %d)\n",_this,arg1);
232 _purecall();
233 return NULL;
236 /******************************************************************
237 * bad_cast_ctor (MSVCRT.@)
239 void MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name)
241 TRACE("(%p %s)\n",_this,*name);
242 MSVCRT_exception_ctor(&_this->base, name);
243 _this->base.vtable = bad_cast_vtable;
246 /******************************************************************
247 * bad_cast_copy_ctor (MSVCRT.@)
249 void MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs)
251 TRACE("(%p %p)\n",_this,rhs);
252 MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
255 /******************************************************************
256 * bad_cast_dtor (MSVCRT.@)
258 void MSVCRT_bad_cast_dtor(bad_cast * _this)
260 TRACE("(%p)\n",_this);
261 MSVCRT_exception_dtor(&_this->base);
264 /******************************************************************
265 * bad_cast_opequals (MSVCRT.@)
267 bad_cast * MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs)
269 TRACE("(%p %p)\n",_this,rhs);
270 MSVCRT_exception_copy_ctor(&_this->base,&rhs->base);
271 return _this;
274 /******************************************************************
275 * type_info_opequals_equals (MSVCRT.@)
277 int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs)
279 TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
280 return _this->name == rhs->name;
283 /******************************************************************
284 * type_info_opnot_equals (MSVCRT.@)
286 int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs)
288 TRACE("(%p %p) returning %d\n",_this,rhs,_this->name == rhs->name);
289 return _this->name != rhs->name;
292 /******************************************************************
293 * type_info_dtor (MSVCRT.@)
295 void MSVCRT_type_info_dtor(type_info * _this)
297 TRACE("(%p)\n",_this);
298 if (_this->data)
299 MSVCRT_free(_this->data);
302 /******************************************************************
303 * type_info_name (MSVCRT.@)
305 const char * __stdcall MSVCRT_type_info_name(type_info * _this)
307 TRACE("(%p) returning %s\n",_this,_this->name);
308 return _this->name;
311 /******************************************************************
312 * type_info_raw_name (MSVCRT.@)
314 const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this)
316 TRACE("(%p) returning %s\n",_this,_this->name);
317 return _this->name;
321 /* INTERNAL: Set up vtables
322 * FIXME:should be static, cope with versions?
324 void msvcrt_init_vtables(void)
326 exception_vtable[0] = MSVCRT_exception_dtor;
327 exception_vtable[1] = (void*)MSVCRT_exception_what;
329 bad_typeid_vtable[0] = MSVCRT_bad_typeid_dtor;
330 bad_typeid_vtable[1] = exception_vtable[1];
331 bad_typeid_vtable[2] = _purecall; /* FIXME */
333 __non_rtti_object_vtable[0] = MSVCRT___non_rtti_object_dtor;
334 __non_rtti_object_vtable[1] = bad_typeid_vtable[1];
335 __non_rtti_object_vtable[2] = bad_typeid_vtable[2];
337 bad_cast_vtable[0] = MSVCRT_bad_cast_dtor;
338 bad_cast_vtable[1] = exception_vtable[1];
339 bad_cast_vtable[2] = _purecall; /* FIXME */
341 type_info_vtable[0] = MSVCRT_type_info_dtor;