dwrite: Always initialize output glyph count in GetGlyphs().
[wine.git] / dlls / msvcp90 / exception.c
blob8ea4e132a0fd7618643968360de51edbbe3e519a
1 /*
2 * Copyright 2010 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #include "msvcp90.h"
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winternl.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
29 #define CLASS_IS_SIMPLE_TYPE 1
30 #define CLASS_HAS_VIRTUAL_BASE_CLASS 4
32 void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
33 int* __cdecl __processing_throw(void);
35 #if _MSVCP_VER >= 70 || defined(_MSVCIRT)
36 typedef const char **exception_name;
37 #define EXCEPTION_STR(name) (*name)
38 #define EXCEPTION_NAME(str) ((exception_name)&str)
39 #else
40 typedef const char *exception_name;
41 #define EXCEPTION_STR(name) (name)
42 #define EXCEPTION_NAME(str) (str)
43 #endif
45 void (CDECL *_Raise_handler)(const exception*) = NULL;
47 /* vtables */
48 extern const vtable_ptr MSVCP_exception_vtable;
49 /* ??_7bad_alloc@std@@6B@ */
50 extern const vtable_ptr MSVCP_bad_alloc_vtable;
51 /* ??_7logic_error@std@@6B@ */
52 extern const vtable_ptr MSVCP_logic_error_vtable;
53 /* ??_7length_error@std@@6B@ */
54 extern const vtable_ptr MSVCP_length_error_vtable;
55 /* ??_7out_of_range@std@@6B@ */
56 extern const vtable_ptr MSVCP_out_of_range_vtable;
57 extern const vtable_ptr MSVCP_invalid_argument_vtable;
58 /* ??_7runtime_error@std@@6B@ */
59 extern const vtable_ptr MSVCP_runtime_error_vtable;
60 extern const vtable_ptr MSVCP__System_error_vtable;
61 extern const vtable_ptr MSVCP_system_error_vtable;
62 extern const vtable_ptr MSVCP_failure_vtable;
63 /* ??_7bad_cast@std@@6B@ */
64 extern const vtable_ptr MSVCP_bad_cast_vtable;
65 /* ??_7range_error@std@@6B@ */
66 extern const vtable_ptr MSVCP_range_error_vtable;
68 static void MSVCP_type_info_dtor(type_info * _this)
70 free(_this->name);
73 /* Unexported */
74 DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8)
75 void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int flags)
77 TRACE("(%p %x)\n", _this, flags);
78 if (flags & 2)
80 /* we have an array, with the number of elements stored before the first object */
81 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
83 for (i = *ptr - 1; i >= 0; i--) MSVCP_type_info_dtor(_this + i);
84 MSVCRT_operator_delete(ptr);
86 else
88 MSVCP_type_info_dtor(_this);
89 if (flags & 1) MSVCRT_operator_delete(_this);
91 return _this;
94 DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" )
96 /* ??0exception@@QAE@ABQBD@Z */
97 /* ??0exception@@QEAA@AEBQEBD@Z */
98 DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor,8)
99 exception* __thiscall MSVCP_exception_ctor(exception *this, exception_name name)
101 TRACE("(%p %s)\n", this, EXCEPTION_STR(name));
103 this->vtable = &MSVCP_exception_vtable;
104 if(EXCEPTION_STR(name)) {
105 unsigned int name_len = strlen(EXCEPTION_STR(name)) + 1;
106 this->name = malloc(name_len);
107 memcpy(this->name, EXCEPTION_STR(name), name_len);
108 this->do_free = TRUE;
109 } else {
110 this->name = NULL;
111 this->do_free = FALSE;
113 return this;
116 DEFINE_THISCALL_WRAPPER(MSVCP_exception_copy_ctor,8)
117 exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception *rhs)
119 TRACE("(%p,%p)\n", this, rhs);
121 if(!rhs->do_free) {
122 this->vtable = &MSVCP_exception_vtable;
123 this->name = rhs->name;
124 this->do_free = FALSE;
125 } else
126 MSVCP_exception_ctor(this, EXCEPTION_NAME(rhs->name));
127 TRACE("name = %s\n", this->name);
128 return this;
131 /* ??0exception@@QAE@XZ */
132 /* ??0exception@@QEAA@XZ */
133 DEFINE_THISCALL_WRAPPER(MSVCP_exception_default_ctor,4)
134 exception* __thiscall MSVCP_exception_default_ctor(exception *this)
136 TRACE("(%p)\n", this);
137 this->vtable = &MSVCP_exception_vtable;
138 this->name = NULL;
139 this->do_free = FALSE;
140 return this;
143 DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
144 void __thiscall MSVCP_exception_dtor(exception *this)
146 TRACE("(%p)\n", this);
147 this->vtable = &MSVCP_exception_vtable;
148 if(this->do_free)
149 free(this->name);
152 DEFINE_THISCALL_WRAPPER(MSVCP_exception_vector_dtor, 8)
153 void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flags)
155 TRACE("%p %x\n", this, flags);
156 if(flags & 2) {
157 /* we have an array, with the number of elements stored before the first object */
158 INT_PTR i, *ptr = (INT_PTR *)this-1;
160 for(i=*ptr-1; i>=0; i--)
161 MSVCP_exception_dtor(this+i);
162 MSVCRT_operator_delete(ptr);
163 } else {
164 MSVCP_exception_dtor(this);
165 if(flags & 1)
166 MSVCRT_operator_delete(this);
169 return this;
172 /* ??_Gexception@@UAEPAXI@Z */
173 DEFINE_THISCALL_WRAPPER(MSVCP_exception_scalar_dtor, 8)
174 void * __thiscall MSVCP_exception_scalar_dtor(exception *this, unsigned int flags)
176 TRACE("(%p %x)\n", this, flags);
177 MSVCP_exception_dtor(this);
178 if (flags & 1) MSVCRT_operator_delete(this);
179 return this;
182 /* ??4exception@@QAEAAV0@ABV0@@Z */
183 /* ??4exception@@QEAAAEAV0@AEBV0@@Z */
184 DEFINE_THISCALL_WRAPPER(MSVCP_exception_assign, 8)
185 exception* __thiscall MSVCP_exception_assign(exception *this, const exception *assign)
187 MSVCP_exception_dtor(this);
188 return MSVCP_exception_copy_ctor(this, assign);
191 /* ?_Doraise@bad_alloc@std@@MBEXXZ */
192 /* ?_Doraise@bad_alloc@std@@MEBAXXZ */
193 /* ?_Doraise@logic_error@std@@MBEXXZ */
194 /* ?_Doraise@logic_error@std@@MEBAXXZ */
195 /* ?_Doraise@length_error@std@@MBEXXZ */
196 /* ?_Doraise@length_error@std@@MEBAXXZ */
197 /* ?_Doraise@out_of_range@std@@MBEXXZ */
198 /* ?_Doraise@out_of_range@std@@MEBAXXZ */
199 /* ?_Doraise@runtime_error@std@@MBEXXZ */
200 /* ?_Doraise@runtime_error@std@@MEBAXXZ */
201 /* ?_Doraise@bad_cast@std@@MBEXXZ */
202 /* ?_Doraise@bad_cast@std@@MEBAXXZ */
203 /* ?_Doraise@range_error@std@@MBEXXZ */
204 /* ?_Doraise@range_error@std@@MEBAXXZ */
205 DEFINE_THISCALL_WRAPPER(MSVCP_exception__Doraise, 4)
206 void __thiscall MSVCP_exception__Doraise(exception *this)
208 FIXME("(%p) stub\n", this);
211 DEFINE_THISCALL_WRAPPER(MSVCP_exception_what,4)
212 const char* __thiscall MSVCP_exception_what(exception * this)
214 TRACE("(%p) returning %s\n", this, this->name);
215 return this->name ? this->name : "Unknown exception";
218 #if _MSVCP_VER >= 80
219 DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@")
220 #else
221 DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@@")
222 #endif
223 DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
225 /* bad_alloc class data */
226 typedef exception bad_alloc;
228 /* ??0bad_alloc@std@@QAE@PBD@Z */
229 /* ??0bad_alloc@std@@QEAA@PEBD@Z */
230 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_ctor, 8)
231 bad_alloc* __thiscall MSVCP_bad_alloc_ctor(bad_alloc *this, exception_name name)
233 TRACE("%p %s\n", this, EXCEPTION_STR(name));
234 MSVCP_exception_ctor(this, name);
235 this->vtable = &MSVCP_bad_alloc_vtable;
236 return this;
239 /* ??0bad_alloc@std@@QAE@XZ */
240 /* ??0bad_alloc@std@@QEAA@XZ */
241 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_default_ctor, 4)
242 bad_alloc* __thiscall MSVCP_bad_alloc_default_ctor(bad_alloc *this)
244 static const char name[] = "bad allocation";
245 return MSVCP_bad_alloc_ctor(this, EXCEPTION_NAME(name));
248 /* ??0bad_alloc@std@@QAE@ABV01@@Z */
249 /* ??0bad_alloc@std@@QEAA@AEBV01@@Z */
250 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
251 bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
253 TRACE("%p %p\n", this, rhs);
254 MSVCP_exception_copy_ctor(this, rhs);
255 this->vtable = &MSVCP_bad_alloc_vtable;
256 return this;
259 /* ??1bad_alloc@std@@UAE@XZ */
260 /* ??1bad_alloc@std@@UEAA@XZ */
261 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
262 void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
264 TRACE("%p\n", this);
265 MSVCP_exception_dtor(this);
268 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_vector_dtor, 8)
269 void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *this, unsigned int flags)
271 TRACE("%p %x\n", this, flags);
272 if(flags & 2) {
273 /* we have an array, with the number of elements stored before the first object */
274 INT_PTR i, *ptr = (INT_PTR *)this-1;
276 for(i=*ptr-1; i>=0; i--)
277 MSVCP_bad_alloc_dtor(this+i);
278 MSVCRT_operator_delete(ptr);
279 } else {
280 MSVCP_bad_alloc_dtor(this);
281 if(flags & 1)
282 MSVCRT_operator_delete(this);
285 return this;
288 /* ??4bad_alloc@std@@QAEAAV01@ABV01@@Z */
289 /* ??4bad_alloc@std@@QEAAAEAV01@AEBV01@@Z */
290 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_assign, 8)
291 bad_alloc* __thiscall MSVCP_bad_alloc_assign(bad_alloc *this, const bad_alloc *assign)
293 MSVCP_bad_alloc_dtor(this);
294 return MSVCP_bad_alloc_copy_ctor(this, assign);
297 DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@")
298 DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor)
300 /* logic_error class data */
301 typedef struct {
302 exception e;
303 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
304 basic_string_char str;
305 #endif
306 } logic_error;
308 /* ??0logic_error@@QAE@ABQBD@Z */
309 /* ??0logic_error@@QEAA@AEBQEBD@Z */
310 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor, 8)
311 logic_error* __thiscall MSVCP_logic_error_ctor( logic_error *this, exception_name name )
313 TRACE("%p %s\n", this, EXCEPTION_STR(name));
314 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
315 #if _MSVCP_VER == 60
316 MSVCP_exception_ctor(&this->e, "");
317 #else
318 MSVCP_exception_default_ctor(&this->e);
319 #endif
320 MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name));
321 #else
322 MSVCP_exception_ctor(&this->e, name);
323 #endif
324 this->e.vtable = &MSVCP_logic_error_vtable;
325 return this;
328 /* ??0logic_error@std@@QAE@ABV01@@Z */
329 /* ??0logic_error@std@@QEAA@AEBV01@@Z */
330 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
331 logic_error* __thiscall MSVCP_logic_error_copy_ctor(
332 logic_error *this, const logic_error *rhs)
334 TRACE("%p %p\n", this, rhs);
335 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
336 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
337 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
338 #endif
339 this->e.vtable = &MSVCP_logic_error_vtable;
340 return this;
343 /* ??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
344 /* ??0logic_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
345 #ifndef _MSVCIRT
346 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor_bstr, 8)
347 logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const basic_string_char *str)
349 const char *name = MSVCP_basic_string_char_c_str(str);
350 TRACE("(%p %p %s)\n", this, str, name);
351 return MSVCP_logic_error_ctor(this, EXCEPTION_NAME(name));
353 #endif
355 /* ??1logic_error@std@@UAE@XZ */
356 /* ??1logic_error@std@@UEAA@XZ */
357 /* ??1length_error@std@@UAE@XZ */
358 /* ??1length_error@std@@UEAA@XZ */
359 /* ??1out_of_range@std@@UAE@XZ */
360 /* ??1out_of_range@std@@UEAA@XZ */
361 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
362 void __thiscall MSVCP_logic_error_dtor(logic_error *this)
364 TRACE("%p\n", this);
365 MSVCP_exception_dtor(&this->e);
366 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
367 MSVCP_basic_string_char_dtor(&this->str);
368 #endif
371 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8)
372 void* __thiscall MSVCP_logic_error_vector_dtor(
373 logic_error *this, unsigned int flags)
375 TRACE("%p %x\n", this, flags);
376 if(flags & 2) {
377 /* we have an array, with the number of elements stored before the first object */
378 INT_PTR i, *ptr = (INT_PTR *)this-1;
380 for(i=*ptr-1; i>=0; i--)
381 MSVCP_logic_error_dtor(this+i);
382 MSVCRT_operator_delete(ptr);
383 } else {
384 MSVCP_logic_error_dtor(this);
385 if(flags & 1)
386 MSVCRT_operator_delete(this);
389 return this;
392 /* ??_Glogic_error@@UAEPAXI@Z */
393 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_scalar_dtor, 8)
394 void * __thiscall MSVCP_logic_error_scalar_dtor(logic_error *this, unsigned int flags)
396 TRACE("(%p %x)\n", this, flags);
397 MSVCP_logic_error_dtor(this);
398 if (flags & 1) MSVCRT_operator_delete(this);
399 return this;
402 /* ??4logic_error@std@@QAEAAV01@ABV01@@Z */
403 /* ??4logic_error@std@@QEAAAEAV01@AEBV01@@Z */
404 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_assign, 8)
405 logic_error* __thiscall MSVCP_logic_error_assign(logic_error *this, const logic_error *assign)
407 MSVCP_logic_error_dtor(this);
408 return MSVCP_logic_error_copy_ctor(this, assign);
411 /* ?what@logic_error@std@@UBEPBDXZ */
412 /* ?what@logic_error@std@@UEBAPEBDXZ */
413 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
414 const char* __thiscall MSVCP_logic_error_what(logic_error *this)
416 TRACE("%p\n", this);
417 #if _MSVCP_VER > 90 || defined _MSVCIRT
418 return MSVCP_exception_what( &this->e );
419 #else
420 return MSVCP_basic_string_char_c_str(&this->str);
421 #endif
424 #if _MSVCP_VER >= 80
425 DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@std@@")
426 #else
427 DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@@")
428 #endif
429 DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
431 /* length_error class data */
432 typedef logic_error length_error;
434 static length_error* MSVCP_length_error_ctor( length_error *this, exception_name name )
436 TRACE("%p %s\n", this, EXCEPTION_STR(name));
437 MSVCP_logic_error_ctor(this, name);
438 this->e.vtable = &MSVCP_length_error_vtable;
439 return this;
442 /* ??0length_error@std@@QAE@ABV01@@Z */
443 /* ??0length_error@std@@QEAA@AEBV01@@Z */
444 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
445 length_error* __thiscall MSVCP_length_error_copy_ctor(
446 length_error *this, const length_error *rhs)
448 TRACE("%p %p\n", this, rhs);
449 MSVCP_logic_error_copy_ctor(this, rhs);
450 this->e.vtable = &MSVCP_length_error_vtable;
451 return this;
454 /* ??0length_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
455 /* ??0length_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
456 #ifndef _MSVCIRT
457 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_ctor_bstr, 8)
458 length_error* __thiscall MSVCP_length_error_ctor_bstr(length_error *this, const basic_string_char *str)
460 const char *name = MSVCP_basic_string_char_c_str(str);
461 TRACE("(%p %p %s)\n", this, str, name);
462 return MSVCP_length_error_ctor(this, EXCEPTION_NAME(name));
464 #endif
466 /* ??4length_error@std@@QAEAAV01@ABV01@@Z */
467 /* ??4length_error@std@@QEAAAEAV01@AEBV01@@Z */
468 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_assign, 8)
469 length_error* __thiscall MSVCP_length_error_assign(length_error *this, const length_error *assign)
471 MSVCP_logic_error_dtor(this);
472 return MSVCP_length_error_copy_ctor(this, assign);
475 DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@")
476 DEFINE_CXX_DATA2(length_error, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
478 /* out_of_range class data */
479 typedef logic_error out_of_range;
481 static out_of_range* MSVCP_out_of_range_ctor( out_of_range *this, exception_name name )
483 TRACE("%p %s\n", this, EXCEPTION_STR(name));
484 MSVCP_logic_error_ctor(this, name);
485 this->e.vtable = &MSVCP_out_of_range_vtable;
486 return this;
489 /* ??0out_of_range@std@@QAE@ABV01@@Z */
490 /* ??0out_of_range@std@@QEAA@AEBV01@@Z */
491 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
492 out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
493 out_of_range *this, const out_of_range *rhs)
495 TRACE("%p %p\n", this, rhs);
496 MSVCP_logic_error_copy_ctor(this, rhs);
497 this->e.vtable = &MSVCP_out_of_range_vtable;
498 return this;
501 /* ??0out_of_range@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
502 /* ??0out_of_range@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
503 #ifndef _MSVCIRT
504 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_ctor_bstr, 8)
505 out_of_range* __thiscall MSVCP_out_of_range_ctor_bstr(out_of_range *this, const basic_string_char *str)
507 const char *name = MSVCP_basic_string_char_c_str(str);
508 TRACE("(%p %p %s)\n", this, str, name);
509 return MSVCP_out_of_range_ctor(this, EXCEPTION_NAME(name));
511 #endif
513 /* ??4out_of_range@std@@QAEAAV01@ABV01@@Z */
514 /* ??4out_of_range@std@@QEAAAEAV01@AEBV01@@Z */
515 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_assign, 8)
516 out_of_range* __thiscall MSVCP_out_of_range_assign(out_of_range *this, const out_of_range *assign)
518 MSVCP_logic_error_dtor(this);
519 return MSVCP_out_of_range_copy_ctor(this, assign);
522 DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@")
523 DEFINE_CXX_DATA2(out_of_range, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
525 /* invalid_argument class data */
526 typedef logic_error invalid_argument;
528 static invalid_argument* MSVCP_invalid_argument_ctor( invalid_argument *this, exception_name name )
530 TRACE("%p %s\n", this, EXCEPTION_STR(name));
531 MSVCP_logic_error_ctor(this, name);
532 this->e.vtable = &MSVCP_invalid_argument_vtable;
533 return this;
536 DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_copy_ctor, 8)
537 invalid_argument* __thiscall MSVCP_invalid_argument_copy_ctor(
538 invalid_argument *this, invalid_argument *rhs)
540 TRACE("%p %p\n", this, rhs);
541 MSVCP_logic_error_copy_ctor(this, rhs);
542 this->e.vtable = &MSVCP_invalid_argument_vtable;
543 return this;
546 DEFINE_RTTI_DATA2(invalid_argument, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVinvalid_argument@std@@")
547 DEFINE_CXX_DATA2(invalid_argument, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
549 /* runtime_error class data */
550 typedef struct {
551 exception e;
552 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
553 basic_string_char str;
554 #endif
555 } runtime_error;
557 static runtime_error* MSVCP_runtime_error_ctor( runtime_error *this, exception_name name )
559 TRACE("%p %s\n", this, EXCEPTION_STR(name));
560 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
561 #if _MSVCP_VER == 60
562 MSVCP_exception_ctor(&this->e, "");
563 #else
564 MSVCP_exception_default_ctor(&this->e);
565 #endif
566 MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name));
567 #else
568 MSVCP_exception_ctor(&this->e, name);
569 #endif
570 this->e.vtable = &MSVCP_runtime_error_vtable;
571 return this;
574 /* ??0runtime_error@std@@QAE@ABV01@@Z */
575 /* ??0runtime_error@std@@QEAA@AEBV01@@Z */
576 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
577 runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
578 runtime_error *this, const runtime_error *rhs)
580 TRACE("%p %p\n", this, rhs);
581 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
582 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
583 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
584 #endif
585 this->e.vtable = &MSVCP_runtime_error_vtable;
586 return this;
589 /* ??0runtime_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
590 /* ??0runtime_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
591 #ifndef _MSVCIRT
592 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_ctor_bstr, 8)
593 runtime_error* __thiscall MSVCP_runtime_error_ctor_bstr(runtime_error *this, const basic_string_char *str)
595 const char *name = MSVCP_basic_string_char_c_str(str);
596 TRACE("(%p %p %s)\n", this, str, name);
597 return MSVCP_runtime_error_ctor(this, EXCEPTION_NAME(name));
599 #endif
601 /* ??1runtime_error@std@@UAE@XZ */
602 /* ??1runtime_error@std@@UEAA@XZ */
603 /* ??1range_error@std@@UAE@XZ */
604 /* ??1range_error@std@@UEAA@XZ */
605 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4)
606 void __thiscall MSVCP_runtime_error_dtor(runtime_error *this)
608 TRACE("%p\n", this);
609 MSVCP_exception_dtor(&this->e);
610 #if _MSVCP_VER <= 90 && !defined _MSVCIRT
611 MSVCP_basic_string_char_dtor(&this->str);
612 #endif
615 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_vector_dtor, 8)
616 void* __thiscall MSVCP_runtime_error_vector_dtor(
617 runtime_error *this, unsigned int flags)
619 TRACE("%p %x\n", this, flags);
620 if(flags & 2) {
621 /* we have an array, with the number of elements stored before the first object */
622 INT_PTR i, *ptr = (INT_PTR *)this-1;
624 for(i=*ptr-1; i>=0; i--)
625 MSVCP_runtime_error_dtor(this+i);
626 MSVCRT_operator_delete(ptr);
627 } else {
628 MSVCP_runtime_error_dtor(this);
629 if(flags & 1)
630 MSVCRT_operator_delete(this);
633 return this;
636 /* ??4runtime_error@std@@QAEAAV01@ABV01@@Z */
637 /* ??4runtime_error@std@@QEAAAEAV01@AEBV01@@Z */
638 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_assign, 8)
639 runtime_error* __thiscall MSVCP_runtime_error_assign(runtime_error *this, const runtime_error *assign)
641 MSVCP_runtime_error_dtor(this);
642 return MSVCP_runtime_error_copy_ctor(this, assign);
645 /* ?what@runtime_error@std@@UBEPBDXZ */
646 /* ?what@runtime_error@std@@UEBAPEBDXZ */
647 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4)
648 const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
650 TRACE("%p\n", this);
651 #if _MSVCP_VER > 90 || defined _MSVCIRT
652 return MSVCP_exception_what( &this->e );
653 #else
654 return MSVCP_basic_string_char_c_str(&this->str);
655 #endif
658 DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@")
659 DEFINE_CXX_DATA1(runtime_error, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
661 /* failure class data */
662 typedef struct {
663 runtime_error base;
664 #if _MSVCP_VER > 90
665 int err;
666 #endif
667 } system_error;
668 typedef system_error _System_error;
669 typedef system_error failure;
671 static failure* MSVCP_failure_ctor( failure *this, exception_name name )
673 TRACE("%p %s\n", this, EXCEPTION_STR(name));
674 MSVCP_runtime_error_ctor(&this->base, name);
675 #if _MSVCP_VER > 90
676 /* FIXME: set err correctly */
677 this->err = 0;
678 #endif
679 this->base.e.vtable = &MSVCP_failure_vtable;
680 return this;
683 DEFINE_THISCALL_WRAPPER(MSVCP_failure_copy_ctor, 8)
684 failure* __thiscall MSVCP_failure_copy_ctor(
685 failure *this, failure *rhs)
687 TRACE("%p %p\n", this, rhs);
688 MSVCP_runtime_error_copy_ctor(&this->base, &rhs->base);
689 #if _MSVCP_VER > 90
690 this->err = rhs->err;
691 #endif
692 this->base.e.vtable = &MSVCP_failure_vtable;
693 return this;
696 DEFINE_THISCALL_WRAPPER(MSVCP_failure_dtor, 4)
697 void __thiscall MSVCP_failure_dtor(failure *this)
699 TRACE("%p\n", this);
700 MSVCP_runtime_error_dtor(&this->base);
703 DEFINE_THISCALL_WRAPPER(MSVCP_failure_vector_dtor, 8)
704 void* __thiscall MSVCP_failure_vector_dtor(
705 failure *this, unsigned int flags)
707 TRACE("%p %x\n", this, flags);
708 return MSVCP_runtime_error_vector_dtor(&this->base, flags);
711 DEFINE_THISCALL_WRAPPER(MSVCP_failure_what, 4)
712 const char* __thiscall MSVCP_failure_what(failure *this)
714 TRACE("%p\n", this);
715 return MSVCP_runtime_error_what(&this->base);
718 #if _MSVCP_VER > 90
719 DEFINE_THISCALL_WRAPPER(MSVCP_system_error_copy_ctor, 8)
720 system_error* __thiscall MSVCP_system_error_copy_ctor(
721 system_error *this, system_error *rhs)
723 MSVCP_failure_copy_ctor(this, rhs);
724 this->base.e.vtable = &MSVCP_system_error_vtable;
725 return this;
727 #endif
729 #if _MSVCP_VER > 110
730 DEFINE_THISCALL_WRAPPER(MSVCP__System_error_copy_ctor, 8)
731 _System_error* __thiscall MSVCP__System_error_copy_ctor(
732 _System_error *this, _System_error *rhs)
734 MSVCP_failure_copy_ctor(this, rhs);
735 this->base.e.vtable = &MSVCP__System_error_vtable;
736 return this;
738 #endif
740 #if _MSVCP_VER > 110
741 DEFINE_RTTI_DATA2(_System_error, 0, &runtime_error_rtti_base_descriptor,
742 &exception_rtti_base_descriptor, ".?AV_System_error@std@@")
743 DEFINE_RTTI_DATA3(system_error, 0, &_System_error_rtti_base_descriptor,
744 &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor,
745 ".?AVsystem_error@std@@")
746 DEFINE_RTTI_DATA4(failure, 0, &system_error_rtti_base_descriptor,
747 &_System_error_rtti_base_descriptor, &runtime_error_rtti_base_descriptor,
748 &exception_rtti_base_descriptor, ".?AVfailure@ios_base@std@@")
749 DEFINE_CXX_TYPE_INFO(_System_error)
750 DEFINE_CXX_TYPE_INFO(system_error);
751 DEFINE_CXX_DATA4(failure, &system_error_cxx_type_info,
752 &_System_error_cxx_type_info, &runtime_error_cxx_type_info,
753 &exception_cxx_type_info, MSVCP_runtime_error_dtor)
754 #elif _MSVCP_VER > 90
755 DEFINE_RTTI_DATA2(system_error, 0, &runtime_error_rtti_base_descriptor,
756 &exception_rtti_base_descriptor, ".?AVsystem_error@std@@")
757 DEFINE_RTTI_DATA3(failure, 0, &system_error_rtti_base_descriptor,
758 &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor,
759 ".?AVfailure@ios_base@std@@")
760 DEFINE_CXX_TYPE_INFO(system_error);
761 DEFINE_CXX_DATA3(failure, &system_error_cxx_type_info, &runtime_error_cxx_type_info,
762 &exception_cxx_type_info, MSVCP_runtime_error_dtor)
763 #else
764 DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor,
765 &exception_rtti_base_descriptor, ".?AVfailure@ios_base@std@@")
766 DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info,
767 &exception_cxx_type_info, MSVCP_runtime_error_dtor)
768 #endif
770 /* bad_cast class data */
771 typedef exception bad_cast;
773 /* ??0bad_cast@std@@QAE@PBD@Z */
774 /* ??0bad_cast@std@@QEAA@PEBD@Z */
775 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8)
776 bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name)
778 TRACE("%p %s\n", this, name);
779 MSVCP_exception_ctor(this, EXCEPTION_NAME(name));
780 this->vtable = &MSVCP_bad_cast_vtable;
781 return this;
784 /* ??_Fbad_cast@@QAEXXZ */
785 /* ??_Fbad_cast@std@@QEAAXXZ */
786 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4)
787 bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this)
789 return MSVCP_bad_cast_ctor(this, "bad cast");
792 /* ??0bad_cast@std@@QAE@ABV01@@Z */
793 /* ??0bad_cast@std@@QEAA@AEBV01@@Z */
794 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8)
795 bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs)
797 TRACE("%p %p\n", this, rhs);
798 MSVCP_exception_copy_ctor(this, rhs);
799 this->vtable = &MSVCP_bad_cast_vtable;
800 return this;
803 /* ??1bad_cast@@UAE@XZ */
804 /* ??1bad_cast@std@@UEAA@XZ */
805 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4)
806 void __thiscall MSVCP_bad_cast_dtor(bad_cast *this)
808 TRACE("%p\n", this);
809 MSVCP_exception_dtor(this);
812 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_vector_dtor, 8)
813 void * __thiscall MSVCP_bad_cast_vector_dtor(bad_cast *this, unsigned int flags)
815 TRACE("%p %x\n", this, flags);
816 if(flags & 2) {
817 /* we have an array, with the number of elements stored before the first object */
818 INT_PTR i, *ptr = (INT_PTR *)this-1;
820 for(i=*ptr-1; i>=0; i--)
821 MSVCP_bad_cast_dtor(this+i);
822 MSVCRT_operator_delete(ptr);
823 } else {
824 MSVCP_bad_cast_dtor(this);
825 if(flags & 1)
826 MSVCRT_operator_delete(this);
829 return this;
832 /* ??4bad_cast@std@@QAEAAV01@ABV01@@Z */
833 /* ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z */
834 DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8)
835 bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs)
837 TRACE("(%p %p)\n", this, rhs);
839 if(this != rhs) {
840 MSVCP_exception_dtor(this);
841 MSVCP_exception_copy_ctor(this, rhs);
843 return this;
846 DEFINE_RTTI_DATA1(bad_cast, 0, &exception_rtti_base_descriptor, ".?AVbad_cast@std@@")
847 DEFINE_CXX_DATA1(bad_cast, &exception_cxx_type_info, MSVCP_bad_cast_dtor)
849 /* range_error class data */
850 typedef runtime_error range_error;
852 static range_error* MSVCP_range_error_ctor( range_error *this, exception_name name )
854 TRACE("%p %s\n", this, EXCEPTION_STR(name));
855 MSVCP_runtime_error_ctor(this, name);
856 this->e.vtable = &MSVCP_range_error_vtable;
857 return this;
860 /* ??0range_error@std@@QAE@ABV01@@Z */
861 /* ??0range_error@std@@QEAA@AEBV01@@Z */
862 DEFINE_THISCALL_WRAPPER(MSVCP_range_error_copy_ctor, 8)
863 range_error* __thiscall MSVCP_range_error_copy_ctor(
864 range_error *this, const range_error *rhs)
866 TRACE("%p %p\n", this, rhs);
867 MSVCP_runtime_error_copy_ctor(this, rhs);
868 this->e.vtable = &MSVCP_range_error_vtable;
869 return this;
872 /* ??0range_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
873 /* ??0range_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
874 #ifndef _MSVCIRT
875 DEFINE_THISCALL_WRAPPER(MSVCP_range_error_ctor_bstr, 8)
876 range_error* __thiscall MSVCP_range_error_ctor_bstr(range_error *this, const basic_string_char *str)
878 const char *name = MSVCP_basic_string_char_c_str(str);
879 TRACE("(%p %p %s)\n", this, str, name);
880 return MSVCP_range_error_ctor(this, EXCEPTION_NAME(name));
882 #endif
884 /* ??4range_error@std@@QAEAAV01@ABV01@@Z */
885 /* ??4range_error@std@@QEAAAEAV01@AEBV01@@Z */
886 DEFINE_THISCALL_WRAPPER(MSVCP_range_error_assign, 8)
887 range_error* __thiscall MSVCP_range_error_assign(range_error *this, const range_error *assign)
889 MSVCP_runtime_error_dtor(this);
890 return MSVCP_range_error_copy_ctor(this, assign);
893 DEFINE_RTTI_DATA2(range_error, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVrange_error@std@@")
894 DEFINE_CXX_DATA2(range_error, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
896 /* ?_Nomemory@std@@YAXXZ */
897 void __cdecl _Nomemory(void)
899 TRACE("()\n");
900 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
903 /* ?_Xmem@tr1@std@@YAXXZ */
904 void __cdecl _Xmem(void)
906 TRACE("()\n");
907 throw_exception(EXCEPTION_BAD_ALLOC, NULL);
910 /* ?_Xinvalid_argument@std@@YAXPBD@Z */
911 /* ?_Xinvalid_argument@std@@YAXPEBD@Z */
912 void __cdecl _Xinvalid_argument(const char *str)
914 TRACE("(%s)\n", debugstr_a(str));
915 throw_exception(EXCEPTION_INVALID_ARGUMENT, str);
918 /* ?_Xlength_error@std@@YAXPBD@Z */
919 /* ?_Xlength_error@std@@YAXPEBD@Z */
920 void __cdecl _Xlength_error(const char *str)
922 TRACE("(%s)\n", debugstr_a(str));
923 throw_exception(EXCEPTION_LENGTH_ERROR, str);
926 /* ?_Xout_of_range@std@@YAXPBD@Z */
927 /* ?_Xout_of_range@std@@YAXPEBD@Z */
928 void __cdecl _Xout_of_range(const char *str)
930 TRACE("(%s)\n", debugstr_a(str));
931 throw_exception(EXCEPTION_OUT_OF_RANGE, str);
934 /* ?_Xruntime_error@std@@YAXPBD@Z */
935 /* ?_Xruntime_error@std@@YAXPEBD@Z */
936 void __cdecl _Xruntime_error(const char *str)
938 TRACE("(%s)\n", debugstr_a(str));
939 throw_exception(EXCEPTION_RUNTIME_ERROR, str);
942 /* ?uncaught_exception@std@@YA_NXZ */
943 bool __cdecl MSVCP__uncaught_exception(void)
945 return __uncaught_exception();
948 #if _MSVCP_VER >= 140
949 int __cdecl __uncaught_exceptions(void)
951 return *__processing_throw();
954 typedef struct
956 EXCEPTION_RECORD *rec;
957 int *ref; /* not binary compatible with native */
958 } exception_ptr;
960 /*********************************************************************
961 * ?__ExceptionPtrCreate@@YAXPAX@Z
962 * ?__ExceptionPtrCreate@@YAXPEAX@Z
964 void __cdecl __ExceptionPtrCreate(exception_ptr *ep)
966 TRACE("(%p)\n", ep);
968 ep->rec = NULL;
969 ep->ref = NULL;
972 #ifdef __ASM_USE_THISCALL_WRAPPER
973 extern void call_dtor(const cxx_exception_type *type, void *func, void *object);
975 __ASM_GLOBAL_FUNC( call_dtor,
976 "movl 12(%esp),%ecx\n\t"
977 "call *8(%esp)\n\t"
978 "ret" );
979 #elif __x86_64__
980 static inline void call_dtor(const cxx_exception_type *type, unsigned int dtor, void *object)
982 char *base = RtlPcToFileHeader((void*)type, (void**)&base);
983 void (__cdecl *func)(void*) = (void*)(base + dtor);
984 func(object);
986 #else
987 #define call_dtor(type, func, object) ((void (__thiscall*)(void*))(func))(object)
988 #endif
990 /*********************************************************************
991 * ?__ExceptionPtrDestroy@@YAXPAX@Z
992 * ?__ExceptionPtrDestroy@@YAXPEAX@Z
994 void __cdecl __ExceptionPtrDestroy(exception_ptr *ep)
996 TRACE("(%p)\n", ep);
998 if (!ep->rec)
999 return;
1001 if (!InterlockedDecrement(ep->ref))
1003 if (ep->rec->ExceptionCode == CXX_EXCEPTION)
1005 const cxx_exception_type *type = (void*)ep->rec->ExceptionInformation[2];
1006 void *obj = (void*)ep->rec->ExceptionInformation[1];
1008 if (type && type->destructor) call_dtor(type, type->destructor, obj);
1009 HeapFree(GetProcessHeap(), 0, obj);
1012 HeapFree(GetProcessHeap(), 0, ep->rec);
1013 HeapFree(GetProcessHeap(), 0, ep->ref);
1016 #endif
1018 #if _MSVCP_VER >= 70 || defined(_MSVCIRT)
1019 #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs)
1020 #else
1021 #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs VTABLE_ADD_FUNC(MSVCP_exception__Doraise))
1022 #endif
1024 __ASM_BLOCK_BEGIN(exception_vtables)
1025 __ASM_VTABLE(type_info,
1026 VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor));
1027 EXCEPTION_VTABLE(exception,
1028 VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor)
1029 VTABLE_ADD_FUNC(MSVCP_exception_what));
1030 EXCEPTION_VTABLE(bad_alloc,
1031 VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor)
1032 VTABLE_ADD_FUNC(MSVCP_exception_what));
1033 EXCEPTION_VTABLE(logic_error,
1034 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
1035 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
1036 EXCEPTION_VTABLE(length_error,
1037 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
1038 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
1039 EXCEPTION_VTABLE(out_of_range,
1040 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
1041 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
1042 EXCEPTION_VTABLE(invalid_argument,
1043 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
1044 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
1045 EXCEPTION_VTABLE(runtime_error,
1046 VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
1047 VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
1048 #if _MSVCP_VER > 110
1049 EXCEPTION_VTABLE(_System_error,
1050 VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
1051 VTABLE_ADD_FUNC(MSVCP_failure_what));
1052 #endif
1053 #if _MSVCP_VER > 90
1054 EXCEPTION_VTABLE(system_error,
1055 VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
1056 VTABLE_ADD_FUNC(MSVCP_failure_what));
1057 #endif
1058 EXCEPTION_VTABLE(failure,
1059 VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
1060 VTABLE_ADD_FUNC(MSVCP_failure_what));
1061 EXCEPTION_VTABLE(bad_cast,
1062 VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor)
1063 VTABLE_ADD_FUNC(MSVCP_exception_what));
1064 EXCEPTION_VTABLE(range_error,
1065 VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
1066 VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
1067 __ASM_BLOCK_END
1069 /* Internal: throws selected exception */
1070 void throw_exception(exception_type et, const char *str)
1072 exception_name name = EXCEPTION_NAME(str);
1074 switch(et) {
1075 case EXCEPTION_RERAISE:
1076 _CxxThrowException(NULL, NULL);
1077 case EXCEPTION: {
1078 exception e;
1079 MSVCP_exception_ctor(&e, name);
1080 _CxxThrowException(&e, &exception_cxx_type);
1082 case EXCEPTION_BAD_ALLOC: {
1083 bad_alloc e;
1084 MSVCP_bad_alloc_ctor(&e, name);
1085 _CxxThrowException(&e, &bad_alloc_cxx_type);
1087 case EXCEPTION_BAD_CAST: {
1088 bad_cast e;
1089 MSVCP_bad_cast_ctor(&e, str);
1090 _CxxThrowException(&e, &bad_cast_cxx_type);
1092 case EXCEPTION_LOGIC_ERROR: {
1093 logic_error e;
1094 MSVCP_logic_error_ctor(&e, name);
1095 _CxxThrowException((exception*)&e, &logic_error_cxx_type);
1097 case EXCEPTION_LENGTH_ERROR: {
1098 length_error e;
1099 MSVCP_length_error_ctor(&e, name);
1100 _CxxThrowException((exception*)&e, &length_error_cxx_type);
1102 case EXCEPTION_OUT_OF_RANGE: {
1103 out_of_range e;
1104 MSVCP_out_of_range_ctor(&e, name);
1105 _CxxThrowException((exception*)&e, &out_of_range_cxx_type);
1107 case EXCEPTION_INVALID_ARGUMENT: {
1108 invalid_argument e;
1109 MSVCP_invalid_argument_ctor(&e, name);
1110 _CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
1112 case EXCEPTION_RUNTIME_ERROR: {
1113 runtime_error e;
1114 MSVCP_runtime_error_ctor(&e, name);
1115 _CxxThrowException((exception*)&e, &runtime_error_cxx_type);
1117 case EXCEPTION_FAILURE: {
1118 failure e;
1119 MSVCP_failure_ctor(&e, name);
1120 _CxxThrowException((exception*)&e, &failure_cxx_type);
1122 case EXCEPTION_RANGE_ERROR: {
1123 range_error e;
1124 MSVCP_range_error_ctor(&e, name);
1125 _CxxThrowException((exception*)&e, &range_error_cxx_type);
1130 void init_exception(void *base)
1132 #ifdef __x86_64__
1133 init_type_info_rtti(base);
1134 init_exception_rtti(base);
1135 init_bad_alloc_rtti(base);
1136 init_logic_error_rtti(base);
1137 init_length_error_rtti(base);
1138 init_out_of_range_rtti(base);
1139 init_invalid_argument_rtti(base);
1140 init_runtime_error_rtti(base);
1141 #if _MSVCP_VER > 110
1142 init__System_error_rtti(base);
1143 #endif
1144 #if _MSVCP_VER > 90
1145 init_system_error_rtti(base);
1146 #endif
1147 init_failure_rtti(base);
1148 init_bad_cast_rtti(base);
1149 init_range_error_rtti(base);
1151 init_exception_cxx(base);
1152 init_bad_alloc_cxx(base);
1153 init_logic_error_cxx(base);
1154 init_length_error_cxx(base);
1155 init_out_of_range_cxx(base);
1156 init_invalid_argument_cxx(base);
1157 init_runtime_error_cxx(base);
1158 #if _MSVCP_VER > 110
1159 init__System_error_cxx_type_info(base);
1160 #endif
1161 #if _MSVCP_VER > 90
1162 init_system_error_cxx_type_info(base);
1163 #endif
1164 init_failure_cxx(base);
1165 init_bad_cast_cxx(base);
1166 init_range_error_cxx(base);
1167 #endif