2010-08-18 10:36:40 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Piotr Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "msvcp90.h"
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/debug.h"
|
2012-08-14 10:51:34 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
|
2010-08-18 10:36:40 +02:00
|
|
|
|
|
|
|
#define CLASS_IS_SIMPLE_TYPE 1
|
|
|
|
#define CLASS_HAS_VIRTUAL_BASE_CLASS 4
|
|
|
|
|
2011-05-14 10:40:16 +02:00
|
|
|
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
|
2010-08-18 10:36:40 +02:00
|
|
|
|
2010-08-18 10:36:52 +02:00
|
|
|
/* vtables */
|
2012-03-27 12:41:39 +02:00
|
|
|
extern const vtable_ptr MSVCP_exception_vtable;
|
2010-08-18 10:36:52 +02:00
|
|
|
extern const vtable_ptr MSVCP_bad_alloc_vtable;
|
2010-08-19 23:48:56 +02:00
|
|
|
extern const vtable_ptr MSVCP_logic_error_vtable;
|
2010-08-19 23:49:08 +02:00
|
|
|
extern const vtable_ptr MSVCP_length_error_vtable;
|
2010-08-19 23:49:18 +02:00
|
|
|
extern const vtable_ptr MSVCP_out_of_range_vtable;
|
2010-08-23 16:34:15 +02:00
|
|
|
extern const vtable_ptr MSVCP_invalid_argument_vtable;
|
2011-11-25 10:46:48 +01:00
|
|
|
extern const vtable_ptr MSVCP_runtime_error_vtable;
|
2012-03-29 16:11:31 +02:00
|
|
|
extern const vtable_ptr MSVCP_failure_vtable;
|
2014-02-07 10:35:10 +01:00
|
|
|
extern const vtable_ptr MSVCP_bad_cast_vtable;
|
2010-08-18 10:36:52 +02:00
|
|
|
|
2012-04-04 20:12:07 +02:00
|
|
|
static void MSVCP_type_info_dtor(type_info * _this)
|
|
|
|
{
|
|
|
|
free(_this->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unexported */
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8)
|
|
|
|
void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("(%p %x)\n", _this, flags);
|
|
|
|
if (flags & 2)
|
|
|
|
{
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
2012-08-20 12:47:04 +02:00
|
|
|
INT_PTR i, *ptr = (INT_PTR *)_this - 1;
|
2012-04-04 20:12:07 +02:00
|
|
|
|
|
|
|
for (i = *ptr - 1; i >= 0; i--) MSVCP_type_info_dtor(_this + i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MSVCP_type_info_dtor(_this);
|
|
|
|
if (flags & 1) MSVCRT_operator_delete(_this);
|
|
|
|
}
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" )
|
2012-04-04 20:12:07 +02:00
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static exception* MSVCP_exception_ctor(exception *this, const char **name)
|
2010-08-18 10:36:40 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p %s)\n", this, *name);
|
|
|
|
|
2012-03-27 12:41:39 +02:00
|
|
|
this->vtable = &MSVCP_exception_vtable;
|
2010-08-18 10:36:40 +02:00
|
|
|
if(*name) {
|
|
|
|
unsigned int name_len = strlen(*name) + 1;
|
|
|
|
this->name = malloc(name_len);
|
|
|
|
memcpy(this->name, *name, name_len);
|
|
|
|
this->do_free = TRUE;
|
|
|
|
} else {
|
|
|
|
this->name = NULL;
|
|
|
|
this->do_free = FALSE;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_exception_copy_ctor,8)
|
2010-08-24 16:31:25 +02:00
|
|
|
exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception *rhs)
|
2010-08-18 10:36:40 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p,%p)\n", this, rhs);
|
|
|
|
|
|
|
|
if(!rhs->do_free) {
|
2012-03-27 12:41:39 +02:00
|
|
|
this->vtable = &MSVCP_exception_vtable;
|
2010-08-18 10:36:40 +02:00
|
|
|
this->name = rhs->name;
|
|
|
|
this->do_free = FALSE;
|
|
|
|
} else
|
|
|
|
MSVCP_exception_ctor(this, (const char**)&rhs->name);
|
|
|
|
TRACE("name = %s\n", this->name);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
|
2010-08-24 16:31:25 +02:00
|
|
|
void __thiscall MSVCP_exception_dtor(exception *this)
|
2010-08-18 10:36:40 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", this);
|
2012-03-27 12:41:39 +02:00
|
|
|
this->vtable = &MSVCP_exception_vtable;
|
2010-08-18 10:36:40 +02:00
|
|
|
if(this->do_free)
|
|
|
|
free(this->name);
|
|
|
|
}
|
|
|
|
|
2012-03-27 12:41:39 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_exception_vector_dtor, 8)
|
|
|
|
void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
if(flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
2012-08-20 12:47:04 +02:00
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
2012-03-27 12:41:39 +02:00
|
|
|
|
|
|
|
for(i=*ptr-1; i>=0; i--)
|
|
|
|
MSVCP_exception_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
MSVCP_exception_dtor(this);
|
|
|
|
if(flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
|
2010-08-18 10:36:40 +02:00
|
|
|
|
2010-08-18 10:36:52 +02:00
|
|
|
/* bad_alloc class data */
|
|
|
|
typedef exception bad_alloc;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static bad_alloc* MSVCP_bad_alloc_ctor(bad_alloc *this, const char **name)
|
2010-08-18 10:36:52 +02:00
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
MSVCP_exception_ctor(this, name);
|
|
|
|
this->vtable = &MSVCP_bad_alloc_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
|
2010-08-18 10:36:52 +02:00
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_exception_copy_ctor(this, rhs);
|
|
|
|
this->vtable = &MSVCP_bad_alloc_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
|
2010-08-24 16:31:25 +02:00
|
|
|
void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
|
2010-08-18 10:36:52 +02:00
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
MSVCP_exception_dtor(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_vector_dtor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *this, unsigned int flags)
|
2010-08-18 10:36:52 +02:00
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
if(flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
2012-08-20 12:47:04 +02:00
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
2010-08-18 10:36:52 +02:00
|
|
|
|
|
|
|
for(i=*ptr-1; i>=0; i--)
|
|
|
|
MSVCP_bad_alloc_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
MSVCP_bad_alloc_dtor(this);
|
|
|
|
if(flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_what_exception,4)
|
2010-08-24 16:31:25 +02:00
|
|
|
const char* __thiscall MSVCP_what_exception(exception * this)
|
2010-08-18 10:36:52 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p) returning %s\n", this, this->name);
|
|
|
|
return this->name ? this->name : "Unknown exception";
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor)
|
2010-08-18 10:36:52 +02:00
|
|
|
|
2010-08-19 23:48:56 +02:00
|
|
|
/* logic_error class data */
|
|
|
|
typedef struct _logic_error {
|
|
|
|
exception e;
|
|
|
|
basic_string_char str;
|
|
|
|
} logic_error;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static logic_error* MSVCP_logic_error_ctor(
|
2010-08-19 23:48:56 +02:00
|
|
|
logic_error *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
this->e.vtable = &MSVCP_logic_error_vtable;
|
|
|
|
this->e.name = NULL;
|
|
|
|
this->e.do_free = FALSE;
|
|
|
|
MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
logic_error* __thiscall MSVCP_logic_error_copy_ctor(
|
2010-08-19 23:48:56 +02:00
|
|
|
logic_error *this, logic_error *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_exception_copy_ctor(&this->e, &rhs->e);
|
|
|
|
MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
|
|
|
|
this->e.vtable = &MSVCP_logic_error_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
|
2010-08-24 16:31:25 +02:00
|
|
|
void __thiscall MSVCP_logic_error_dtor(logic_error *this)
|
2010-08-19 23:48:56 +02:00
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
MSVCP_exception_dtor(&this->e);
|
|
|
|
MSVCP_basic_string_char_dtor(&this->str);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
void* __thiscall MSVCP_logic_error_vector_dtor(
|
2010-08-19 23:48:56 +02:00
|
|
|
logic_error *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
if(flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
2012-08-20 12:47:04 +02:00
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
2010-08-19 23:48:56 +02:00
|
|
|
|
|
|
|
for(i=*ptr-1; i>=0; i--)
|
|
|
|
MSVCP_logic_error_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
MSVCP_logic_error_dtor(this);
|
|
|
|
if(flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
|
2010-08-24 16:31:25 +02:00
|
|
|
const char* __thiscall MSVCP_logic_error_what(logic_error *this)
|
2010-08-19 23:48:56 +02:00
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
return MSVCP_basic_string_char_c_str(&this->str);
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
|
2010-08-19 23:48:56 +02:00
|
|
|
|
2010-08-19 23:49:08 +02:00
|
|
|
/* length_error class data */
|
|
|
|
typedef logic_error length_error;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static length_error* MSVCP_length_error_ctor(
|
2010-08-19 23:49:08 +02:00
|
|
|
length_error *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
MSVCP_logic_error_ctor(this, name);
|
|
|
|
this->e.vtable = &MSVCP_length_error_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
length_error* __thiscall MSVCP_length_error_copy_ctor(
|
2010-08-19 23:49:08 +02:00
|
|
|
length_error *this, length_error *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_logic_error_copy_ctor(this, rhs);
|
|
|
|
this->e.vtable = &MSVCP_length_error_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA2(length_error, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
|
2010-08-19 23:49:08 +02:00
|
|
|
|
2010-08-19 23:49:18 +02:00
|
|
|
/* out_of_range class data */
|
|
|
|
typedef logic_error out_of_range;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static out_of_range* MSVCP_out_of_range_ctor(
|
2010-08-19 23:49:18 +02:00
|
|
|
out_of_range *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
MSVCP_logic_error_ctor(this, name);
|
|
|
|
this->e.vtable = &MSVCP_out_of_range_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
|
2010-08-19 23:49:18 +02:00
|
|
|
out_of_range *this, out_of_range *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_logic_error_copy_ctor(this, rhs);
|
|
|
|
this->e.vtable = &MSVCP_out_of_range_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA2(out_of_range, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
|
2010-08-19 23:49:18 +02:00
|
|
|
|
2010-08-23 16:34:15 +02:00
|
|
|
/* invalid_argument class data */
|
|
|
|
typedef logic_error invalid_argument;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static invalid_argument* MSVCP_invalid_argument_ctor(
|
2010-08-23 16:34:15 +02:00
|
|
|
invalid_argument *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
MSVCP_logic_error_ctor(this, name);
|
|
|
|
this->e.vtable = &MSVCP_invalid_argument_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_copy_ctor, 8)
|
2010-08-24 16:31:25 +02:00
|
|
|
invalid_argument* __thiscall MSVCP_invalid_argument_copy_ctor(
|
2010-08-23 16:34:15 +02:00
|
|
|
invalid_argument *this, invalid_argument *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_logic_error_copy_ctor(this, rhs);
|
|
|
|
this->e.vtable = &MSVCP_invalid_argument_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA2(invalid_argument, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVinvalid_argument@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA2(invalid_argument, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
|
2010-08-23 16:34:15 +02:00
|
|
|
|
2011-11-25 10:46:48 +01:00
|
|
|
/* runtime_error class data */
|
|
|
|
typedef struct {
|
|
|
|
exception e;
|
|
|
|
basic_string_char str;
|
|
|
|
} runtime_error;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static runtime_error* MSVCP_runtime_error_ctor(
|
2011-11-25 10:46:48 +01:00
|
|
|
runtime_error *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
this->e.vtable = &MSVCP_runtime_error_vtable;
|
|
|
|
this->e.name = NULL;
|
|
|
|
this->e.do_free = FALSE;
|
|
|
|
MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
|
|
|
|
runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
|
|
|
|
runtime_error *this, runtime_error *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_exception_copy_ctor(&this->e, &rhs->e);
|
|
|
|
MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
|
|
|
|
this->e.vtable = &MSVCP_runtime_error_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4)
|
|
|
|
void __thiscall MSVCP_runtime_error_dtor(runtime_error *this)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
MSVCP_exception_dtor(&this->e);
|
|
|
|
MSVCP_basic_string_char_dtor(&this->str);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_vector_dtor, 8)
|
|
|
|
void* __thiscall MSVCP_runtime_error_vector_dtor(
|
|
|
|
runtime_error *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
if(flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
2012-08-20 12:47:04 +02:00
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
2011-11-25 10:46:48 +01:00
|
|
|
|
|
|
|
for(i=*ptr-1; i>=0; i--)
|
|
|
|
MSVCP_runtime_error_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
MSVCP_runtime_error_dtor(this);
|
|
|
|
if(flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-03-29 16:11:31 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4)
|
|
|
|
const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
return MSVCP_basic_string_char_c_str(&this->str);
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA1(runtime_error, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
|
2011-11-25 10:46:48 +01:00
|
|
|
|
2012-03-29 16:11:31 +02:00
|
|
|
/* failure class data */
|
|
|
|
typedef runtime_error failure;
|
|
|
|
|
2012-09-14 12:44:29 +02:00
|
|
|
static failure* MSVCP_failure_ctor(
|
2012-03-29 16:11:31 +02:00
|
|
|
failure *this, const char **name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, *name);
|
|
|
|
MSVCP_runtime_error_ctor(this, name);
|
|
|
|
this->e.vtable = &MSVCP_failure_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_failure_copy_ctor, 8)
|
|
|
|
failure* __thiscall MSVCP_failure_copy_ctor(
|
|
|
|
failure *this, failure *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_runtime_error_copy_ctor(this, rhs);
|
|
|
|
this->e.vtable = &MSVCP_failure_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_failure_dtor, 4)
|
|
|
|
void __thiscall MSVCP_failure_dtor(failure *this)
|
2011-11-25 10:46:48 +01:00
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
2012-03-29 16:11:31 +02:00
|
|
|
MSVCP_runtime_error_dtor(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_failure_vector_dtor, 8)
|
|
|
|
void* __thiscall MSVCP_failure_vector_dtor(
|
|
|
|
failure *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
return MSVCP_runtime_error_vector_dtor(this, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_failure_what, 4)
|
|
|
|
const char* __thiscall MSVCP_failure_what(failure *this)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
return MSVCP_runtime_error_what(this);
|
2011-11-25 10:46:48 +01:00
|
|
|
}
|
|
|
|
|
2012-11-28 13:01:33 +01:00
|
|
|
DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVfailure@std@@")
|
2012-11-26 20:42:28 +01:00
|
|
|
DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
|
2012-03-29 16:11:31 +02:00
|
|
|
|
2014-02-07 10:35:10 +01:00
|
|
|
/* bad_cast class data */
|
|
|
|
typedef exception bad_cast;
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8)
|
|
|
|
bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", this, name);
|
|
|
|
MSVCP_exception_ctor(this, &name);
|
|
|
|
this->vtable = &MSVCP_bad_cast_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4)
|
|
|
|
bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this)
|
|
|
|
{
|
|
|
|
return MSVCP_bad_cast_ctor(this, "bad cast");
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8)
|
|
|
|
bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs)
|
|
|
|
{
|
|
|
|
TRACE("%p %p\n", this, rhs);
|
|
|
|
MSVCP_exception_copy_ctor(this, rhs);
|
|
|
|
this->vtable = &MSVCP_bad_cast_vtable;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4)
|
|
|
|
void __thiscall MSVCP_bad_cast_dtor(bad_cast *this)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", this);
|
|
|
|
MSVCP_exception_dtor(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_vector_dtor, 8)
|
|
|
|
void * __thiscall MSVCP_bad_cast_vector_dtor(bad_cast *this, unsigned int flags)
|
|
|
|
{
|
|
|
|
TRACE("%p %x\n", this, flags);
|
|
|
|
if(flags & 2) {
|
|
|
|
/* we have an array, with the number of elements stored before the first object */
|
|
|
|
INT_PTR i, *ptr = (INT_PTR *)this-1;
|
|
|
|
|
|
|
|
for(i=*ptr-1; i>=0; i--)
|
|
|
|
MSVCP_bad_cast_dtor(this+i);
|
|
|
|
MSVCRT_operator_delete(ptr);
|
|
|
|
} else {
|
|
|
|
MSVCP_bad_cast_dtor(this);
|
|
|
|
if(flags & 1)
|
|
|
|
MSVCRT_operator_delete(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8)
|
|
|
|
bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", this, rhs);
|
|
|
|
|
|
|
|
if(this != rhs) {
|
|
|
|
MSVCP_exception_dtor(this);
|
|
|
|
MSVCP_exception_copy_ctor(this, rhs);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_RTTI_DATA1(bad_cast, 0, &exception_rtti_base_descriptor, ".?AVbad_cast@std@@")
|
|
|
|
DEFINE_CXX_DATA1(bad_cast, &exception_cxx_type_info, MSVCP_bad_cast_dtor)
|
|
|
|
|
2012-10-17 09:58:25 +02:00
|
|
|
/* ?_Nomemory@std@@YAXXZ */
|
|
|
|
void __cdecl _Nomemory(void)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
|
|
|
|
}
|
|
|
|
|
2013-12-19 17:02:11 +01:00
|
|
|
/* ?_Xmem@tr1@std@@YAXXZ */
|
|
|
|
void __cdecl _Xmem(void)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?_Xinvalid_argument@std@@YAXPBD@Z */
|
|
|
|
/* ?_Xinvalid_argument@std@@YAXPEBD@Z */
|
|
|
|
void __cdecl _Xinvalid_argument(const char *str)
|
|
|
|
{
|
|
|
|
TRACE("(%s)\n", debugstr_a(str));
|
|
|
|
throw_exception(EXCEPTION_INVALID_ARGUMENT, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?_Xlength_error@std@@YAXPBD@Z */
|
|
|
|
/* ?_Xlength_error@std@@YAXPEBD@Z */
|
|
|
|
void __cdecl _Xlength_error(const char *str)
|
|
|
|
{
|
|
|
|
TRACE("(%s)\n", debugstr_a(str));
|
|
|
|
throw_exception(EXCEPTION_LENGTH_ERROR, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?_Xout_of_range@std@@YAXPBD@Z */
|
|
|
|
/* ?_Xout_of_range@std@@YAXPEBD@Z */
|
|
|
|
void __cdecl _Xout_of_range(const char *str)
|
|
|
|
{
|
|
|
|
TRACE("(%s)\n", debugstr_a(str));
|
|
|
|
throw_exception(EXCEPTION_OUT_OF_RANGE, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ?_Xruntime_error@std@@YAXPBD@Z */
|
|
|
|
/* ?_Xruntime_error@std@@YAXPEBD@Z */
|
|
|
|
void __cdecl _Xruntime_error(const char *str)
|
|
|
|
{
|
|
|
|
TRACE("(%s)\n", debugstr_a(str));
|
|
|
|
throw_exception(EXCEPTION_RUNTIME_ERROR, str);
|
|
|
|
}
|
|
|
|
|
2013-12-26 23:42:03 +01:00
|
|
|
/* ?uncaught_exception@std@@YA_NXZ */
|
|
|
|
MSVCP_bool __cdecl MSVCP__uncaught_exception(void)
|
|
|
|
{
|
|
|
|
return __uncaught_exception();
|
|
|
|
}
|
|
|
|
|
2010-08-18 10:36:52 +02:00
|
|
|
#ifndef __GNUC__
|
|
|
|
void __asm_dummy_vtables(void) {
|
|
|
|
#endif
|
2012-08-17 11:25:35 +02:00
|
|
|
__ASM_VTABLE(type_info,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor));
|
|
|
|
__ASM_VTABLE(exception,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_what_exception));
|
|
|
|
__ASM_VTABLE(bad_alloc,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_what_exception));
|
|
|
|
__ASM_VTABLE(logic_error,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
|
|
|
__ASM_VTABLE(length_error,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
|
|
|
__ASM_VTABLE(out_of_range,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
|
|
|
__ASM_VTABLE(invalid_argument,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
|
|
|
__ASM_VTABLE(runtime_error,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
|
|
|
|
__ASM_VTABLE(failure,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_failure_what));
|
2014-02-07 10:35:10 +01:00
|
|
|
__ASM_VTABLE(bad_cast,
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor)
|
|
|
|
VTABLE_ADD_FUNC(MSVCP_what_exception));
|
2010-08-18 10:36:52 +02:00
|
|
|
#ifndef __GNUC__
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-18 10:36:40 +02:00
|
|
|
/* Internal: throws selected exception */
|
|
|
|
void throw_exception(exception_type et, const char *str)
|
|
|
|
{
|
|
|
|
const char *addr = str;
|
|
|
|
|
|
|
|
switch(et) {
|
2012-03-29 16:13:13 +02:00
|
|
|
case EXCEPTION_RERAISE:
|
|
|
|
_CxxThrowException(NULL, NULL);
|
2010-08-18 10:36:40 +02:00
|
|
|
case EXCEPTION: {
|
|
|
|
exception e;
|
|
|
|
MSVCP_exception_ctor(&e, &addr);
|
|
|
|
_CxxThrowException(&e, &exception_cxx_type);
|
|
|
|
}
|
2010-08-18 10:36:52 +02:00
|
|
|
case EXCEPTION_BAD_ALLOC: {
|
|
|
|
bad_alloc e;
|
|
|
|
MSVCP_bad_alloc_ctor(&e, &addr);
|
|
|
|
_CxxThrowException(&e, &bad_alloc_cxx_type);
|
2010-08-19 23:48:56 +02:00
|
|
|
}
|
|
|
|
case EXCEPTION_LOGIC_ERROR: {
|
|
|
|
logic_error e;
|
|
|
|
MSVCP_logic_error_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &logic_error_cxx_type);
|
2010-08-18 10:36:52 +02:00
|
|
|
}
|
2010-08-19 23:49:08 +02:00
|
|
|
case EXCEPTION_LENGTH_ERROR: {
|
|
|
|
length_error e;
|
|
|
|
MSVCP_length_error_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &length_error_cxx_type);
|
|
|
|
}
|
2010-08-19 23:49:18 +02:00
|
|
|
case EXCEPTION_OUT_OF_RANGE: {
|
|
|
|
out_of_range e;
|
|
|
|
MSVCP_out_of_range_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &out_of_range_cxx_type);
|
|
|
|
}
|
2010-08-23 16:34:15 +02:00
|
|
|
case EXCEPTION_INVALID_ARGUMENT: {
|
|
|
|
invalid_argument e;
|
|
|
|
MSVCP_invalid_argument_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
|
|
|
|
}
|
2011-11-25 10:46:48 +01:00
|
|
|
case EXCEPTION_RUNTIME_ERROR: {
|
|
|
|
runtime_error e;
|
|
|
|
MSVCP_runtime_error_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &runtime_error_cxx_type);
|
|
|
|
}
|
2012-03-29 16:11:31 +02:00
|
|
|
case EXCEPTION_FAILURE: {
|
|
|
|
failure e;
|
|
|
|
MSVCP_failure_ctor(&e, &addr);
|
|
|
|
_CxxThrowException((exception*)&e, &failure_cxx_type);
|
|
|
|
}
|
2010-08-18 10:36:40 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-05 14:36:16 +02:00
|
|
|
|
2012-09-07 11:01:35 +02:00
|
|
|
void init_exception(void *base)
|
2012-09-05 14:36:16 +02:00
|
|
|
{
|
|
|
|
#ifdef __x86_64__
|
|
|
|
init_type_info_rtti(base);
|
|
|
|
init_exception_rtti(base);
|
|
|
|
init_bad_alloc_rtti(base);
|
|
|
|
init_logic_error_rtti(base);
|
|
|
|
init_length_error_rtti(base);
|
|
|
|
init_out_of_range_rtti(base);
|
|
|
|
init_invalid_argument_rtti(base);
|
|
|
|
init_runtime_error_rtti(base);
|
|
|
|
init_failure_rtti(base);
|
2014-02-07 10:35:10 +01:00
|
|
|
init_bad_cast_rtti(base);
|
2012-10-04 23:54:51 +02:00
|
|
|
|
|
|
|
init_exception_cxx(base);
|
|
|
|
init_bad_alloc_cxx(base);
|
|
|
|
init_logic_error_cxx(base);
|
|
|
|
init_length_error_cxx(base);
|
|
|
|
init_out_of_range_cxx(base);
|
|
|
|
init_invalid_argument_cxx(base);
|
|
|
|
init_runtime_error_cxx(base);
|
|
|
|
init_failure_cxx(base);
|
2014-02-07 10:35:10 +01:00
|
|
|
init_bad_cast_cxx(base);
|
2012-09-05 14:36:16 +02:00
|
|
|
#endif
|
|
|
|
}
|