msvcp60: Share exception functions implementation with msvcp90.

This commit is contained in:
Alexandre Julliard 2015-03-12 22:07:09 +09:00
parent 62ae503fa1
commit 42500b0cfe
6 changed files with 258 additions and 1204 deletions

View File

@ -3,6 +3,7 @@ IMPORTS = msvcrt
EXTRADEFS = -D_MSVCP_VER=60 EXTRADEFS = -D_MSVCP_VER=60
PARENTSRC = ../msvcp90 PARENTSRC = ../msvcp90
C_SRCS = \ C_SRCS = \
exception.c \ exception.c \
ios.c \ ios.c \

View File

@ -1,446 +0,0 @@
/*
* Copyright 2012 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
*/
/* Copied from dlls/msvcrt/cxx.h */
#undef __thiscall
#ifdef __i386__ /* thiscall functions are i386-specific */
#define THISCALL(func) __thiscall_ ## func
#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
#define __thiscall __stdcall
#define DEFINE_THISCALL_WRAPPER(func,args) \
extern void THISCALL(func)(void); \
__ASM_GLOBAL_FUNC(__thiscall_ ## func, \
"popl %eax\n\t" \
"pushl %ecx\n\t" \
"pushl %eax\n\t" \
"jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
#else /* __i386__ */
#define THISCALL(func) func
#define THISCALL_NAME(func) __ASM_NAME(#func)
#define __thiscall __cdecl
#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
#endif /* __i386__ */
#ifdef _WIN64
#define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
#define __ASM_VTABLE(name,funcs) \
__asm__(".data\n" \
"\t.align 8\n" \
"\t.quad " __ASM_NAME(#name "_rtti") "\n" \
"\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
__ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
funcs "\n\t.text")
#else
#define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
#define __ASM_VTABLE(name,funcs) \
__asm__(".data\n" \
"\t.align 4\n" \
"\t.long " __ASM_NAME(#name "_rtti") "\n" \
"\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
__ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
funcs "\n\t.text")
#endif /* _WIN64 */
#ifndef __x86_64__
#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
static const type_info name ## _type_info = { \
&MSVCP_type_info_vtable, \
NULL, \
mangled_name \
}; \
\
static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
&name ##_type_info, \
base_classes_no, \
{ 0, -1, 0}, \
64 \
}; \
\
static const rtti_base_array name ## _rtti_base_array = { \
{ \
&name ## _rtti_base_descriptor, \
cl1, \
cl2, \
cl3, \
cl4, \
cl5, \
cl6, \
cl7, \
cl8, \
cl9, \
} \
}; \
\
static const rtti_object_hierarchy name ## _hierarchy = { \
0, \
0, \
base_classes_no+1, \
&name ## _rtti_base_array \
}; \
\
const rtti_object_locator name ## _rtti = { \
0, \
off, \
0, \
&name ## _type_info, \
&name ## _hierarchy \
};
#define DEFINE_CXX_DATA(type, base_no, cl1, cl2, dtor) \
\
static const cxx_type_info type ## _cxx_type_info = { \
0, \
& type ##_type_info, \
{ 0, -1, 0 }, \
sizeof(type), \
(cxx_copy_ctor)THISCALL(MSVCP_ ## type ##_copy_ctor) \
}; \
\
static const cxx_type_info_table type ## _cxx_type_table = { \
base_no+1, \
{ \
& type ## _cxx_type_info, \
cl1, \
cl2 \
} \
}; \
\
static const cxx_exception_type type ## _cxx_type = { \
0, \
(cxx_copy_ctor)THISCALL(dtor), \
NULL, \
& type ## _cxx_type_table \
};
#else
#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
static const type_info name ## _type_info = { \
&MSVCP_type_info_vtable, \
NULL, \
mangled_name \
}; \
\
static rtti_base_descriptor name ## _rtti_base_descriptor = { \
0xdeadbeef, \
base_classes_no, \
{ 0, -1, 0}, \
64 \
}; \
\
static rtti_base_array name ## _rtti_base_array = { \
{ \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef, \
} \
}; \
\
static rtti_object_hierarchy name ## _hierarchy = { \
0, \
0, \
base_classes_no+1, \
0xdeadbeef \
}; \
\
rtti_object_locator name ## _rtti = { \
1, \
off, \
0, \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef \
};\
\
static void init_ ## name ## _rtti(char *base) \
{ \
name ## _rtti_base_descriptor.type_descriptor = (char*)&name ## _type_info - base; \
name ## _rtti_base_array.bases[0] = (char*)&name ## _rtti_base_descriptor - base; \
name ## _rtti_base_array.bases[1] = (char*)cl1 - base; \
name ## _rtti_base_array.bases[2] = (char*)cl2 - base; \
name ## _rtti_base_array.bases[3] = (char*)cl3 - base; \
name ## _rtti_base_array.bases[4] = (char*)cl4 - base; \
name ## _rtti_base_array.bases[5] = (char*)cl5 - base; \
name ## _rtti_base_array.bases[6] = (char*)cl6 - base; \
name ## _rtti_base_array.bases[7] = (char*)cl7 - base; \
name ## _rtti_base_array.bases[8] = (char*)cl8 - base; \
name ## _rtti_base_array.bases[9] = (char*)cl9 - base; \
name ## _hierarchy.base_classes = (char*)&name ## _rtti_base_array - base; \
name ## _rtti.type_descriptor = (char*)&name ## _type_info - base; \
name ## _rtti.type_hierarchy = (char*)&name ## _hierarchy - base; \
name ## _rtti.object_locator = (char*)&name ## _rtti - base; \
}
#define DEFINE_CXX_DATA(type, base_no, cl1, cl2, dtor) \
\
static cxx_type_info type ## _cxx_type_info = { \
0, \
0xdeadbeef, \
{ 0, -1, 0 }, \
sizeof(type), \
0xdeadbeef \
}; \
\
static cxx_type_info_table type ## _cxx_type_table = { \
base_no+1, \
{ \
0xdeadbeef, \
0xdeadbeef, \
0xdeadbeef \
} \
}; \
\
static cxx_exception_type type ##_cxx_type = { \
0, \
0xdeadbeef, \
0, \
0xdeadbeef \
}; \
\
static void init_ ## type ## _cxx(char *base) \
{ \
type ## _cxx_type_info.type_info = (char *)&type ## _type_info - base; \
type ## _cxx_type_info.copy_ctor = (char *)MSVCP_ ## type ## _copy_ctor - base; \
type ## _cxx_type_table.info[0] = (char *)&type ## _cxx_type_info - base; \
type ## _cxx_type_table.info[1] = (char *)cl1 - base; \
type ## _cxx_type_table.info[2] = (char *)cl2 - base; \
type ## _cxx_type.destructor = (char *)dtor - base; \
type ## _cxx_type.type_info_table = (char *)&type ## _cxx_type_table - base; \
}
#endif
#define DEFINE_RTTI_DATA0(name, off, mangled_name) \
DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \
DEFINE_RTTI_DATA(name, off, 1, cl1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA2(name, off, cl1, cl2, mangled_name) \
DEFINE_RTTI_DATA(name, off, 2, cl1, cl2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA3(name, off, cl1, cl2, cl3, mangled_name) \
DEFINE_RTTI_DATA(name, off, 3, cl1, cl2, cl3, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA4(name, off, cl1, cl2, cl3, cl4, mangled_name) \
DEFINE_RTTI_DATA(name, off, 4, cl1, cl2, cl3, cl4, NULL, NULL, NULL, NULL, NULL, mangled_name)
#define DEFINE_RTTI_DATA8(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, mangled_name) \
DEFINE_RTTI_DATA(name, off, 8, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, NULL, mangled_name)
#define DEFINE_RTTI_DATA9(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
DEFINE_RTTI_DATA(name, off, 9, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name)
#define DEFINE_CXX_DATA0(name, dtor) \
DEFINE_CXX_DATA(name, 0, NULL, NULL, dtor)
#define DEFINE_CXX_DATA1(name, cl1, dtor) \
DEFINE_CXX_DATA(name, 1, cl1, NULL, dtor)
#define DEFINE_CXX_DATA2(name, cl1, cl2, dtor) \
DEFINE_CXX_DATA(name, 2, cl1, cl2, dtor)
#ifdef __i386__
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
extern void *vtbl_wrapper_0;
extern void *vtbl_wrapper_4;
extern void *vtbl_wrapper_8;
extern void *vtbl_wrapper_12;
extern void *vtbl_wrapper_16;
extern void *vtbl_wrapper_20;
extern void *vtbl_wrapper_24;
extern void *vtbl_wrapper_28;
extern void *vtbl_wrapper_32;
extern void *vtbl_wrapper_36;
extern void *vtbl_wrapper_40;
extern void *vtbl_wrapper_44;
extern void *vtbl_wrapper_48;
#else
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__cdecl***)type)this)[0][off/4]args
#endif
/* exception object */
typedef void (*vtable_ptr)(void);
typedef struct __exception
{
const vtable_ptr *vtable;
char *name; /* Name of this exception, always a new copy for each object */
int do_free; /* Whether to free 'name' in our dtor */
} exception;
/* Internal: throws selected exception */
typedef enum __exception_type {
EXCEPTION_RERAISE,
EXCEPTION,
EXCEPTION_BAD_ALLOC,
EXCEPTION_LOGIC_ERROR,
EXCEPTION_LENGTH_ERROR,
EXCEPTION_OUT_OF_RANGE,
EXCEPTION_INVALID_ARGUMENT,
EXCEPTION_RUNTIME_ERROR,
EXCEPTION_FAILURE,
} exception_type;
void throw_exception(exception_type, const char *);
/* rtti */
typedef struct __type_info
{
const vtable_ptr *vtable;
char *name; /* Unmangled name, allocated lazily */
char mangled[128]; /* Variable length, but we declare it large enough for static RTTI */
} type_info;
extern const vtable_ptr MSVCP_type_info_vtable;
/* offsets for computing the this pointer */
typedef struct
{
int this_offset; /* offset of base class this pointer from start of object */
int vbase_descr; /* offset of virtual base class descriptor */
int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
} this_ptr_offsets;
/* dlls/msvcrt/cppexcept.h */
typedef void (*cxx_copy_ctor)(void);
#ifndef __x86_64__
typedef struct _rtti_base_descriptor
{
const type_info *type_descriptor;
int num_base_classes;
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int attributes;
} rtti_base_descriptor;
typedef struct _rtti_base_array
{
const rtti_base_descriptor *bases[10]; /* First element is the class itself */
} rtti_base_array;
typedef struct _rtti_object_hierarchy
{
unsigned int signature;
unsigned int attributes;
int array_len; /* Size of the array pointed to by 'base_classes' */
const rtti_base_array *base_classes;
} rtti_object_hierarchy;
typedef struct _rtti_object_locator
{
unsigned int signature;
int base_class_offset;
unsigned int flags;
const type_info *type_descriptor;
const rtti_object_hierarchy *type_hierarchy;
} rtti_object_locator;
typedef struct
{
UINT flags;
const type_info *type_info;
this_ptr_offsets offsets;
unsigned int size;
cxx_copy_ctor copy_ctor;
} cxx_type_info;
typedef struct
{
UINT count;
const cxx_type_info *info[3];
} cxx_type_info_table;
typedef struct
{
UINT flags;
void (*destructor)(void);
void* /*cxx_exc_custom_handler*/ custom_handler;
const cxx_type_info_table *type_info_table;
} cxx_exception_type;
#else
typedef struct
{
unsigned int type_descriptor;
int num_base_classes;
this_ptr_offsets offsets; /* offsets for computing the this pointer */
unsigned int attributes;
} rtti_base_descriptor;
typedef struct
{
unsigned int bases[10]; /* First element is the class itself */
} rtti_base_array;
typedef struct
{
unsigned int signature;
unsigned int attributes;
int array_len; /* Size of the array pointed to by 'base_classes' */
unsigned int base_classes;
} rtti_object_hierarchy;
typedef struct
{
unsigned int signature;
int base_class_offset;
unsigned int flags;
unsigned int type_descriptor;
unsigned int type_hierarchy;
unsigned int object_locator;
} rtti_object_locator;
typedef struct
{
UINT flags;
unsigned int type_info;
this_ptr_offsets offsets;
unsigned int size;
unsigned int copy_ctor;
} cxx_type_info;
typedef struct
{
UINT count;
unsigned int info[3];
} cxx_type_info_table;
typedef struct
{
UINT flags;
unsigned int destructor;
unsigned int custom_handler;
unsigned int type_info_table;
} cxx_exception_type;
#endif

View File

@ -1,682 +0,0 @@
/*
* 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 "msvcp.h"
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
#define CLASS_IS_SIMPLE_TYPE 1
#define CLASS_HAS_VIRTUAL_BASE_CLASS 4
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
/* vtables */
extern const vtable_ptr MSVCP_type_info_vtable;
extern const vtable_ptr MSVCP_exception_vtable;
/* ??_7bad_alloc@std@@6B@ */
extern const vtable_ptr MSVCP_bad_alloc_vtable;
/* ??_7logic_error@std@@6B@ */
extern const vtable_ptr MSVCP_logic_error_vtable;
/* ??_7length_error@std@@6B@ */
extern const vtable_ptr MSVCP_length_error_vtable;
/* ??_7out_of_range@std@@6B@ */
extern const vtable_ptr MSVCP_out_of_range_vtable;
extern const vtable_ptr MSVCP_invalid_argument_vtable;
/* ??_7runtime_error@std@@6B@ */
extern const vtable_ptr MSVCP_runtime_error_vtable;
extern const vtable_ptr MSVCP_failure_vtable;
static void MSVCP_type_info_dtor(type_info * _this)
{
free(_this->name);
}
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 */
INT_PTR i, *ptr = (INT_PTR *)_this - 1;
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;
}
DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" )
static exception* MSVCP_exception_ctor(exception *this, const char *name)
{
TRACE("(%p %s)\n", this, name);
this->vtable = &MSVCP_exception_vtable;
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)
exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception *rhs)
{
TRACE("(%p,%p)\n", this, rhs);
if(!rhs->do_free) {
this->vtable = &MSVCP_exception_vtable;
this->name = rhs->name;
this->do_free = FALSE;
} else
MSVCP_exception_ctor(this, rhs->name);
TRACE("name = %s\n", this->name);
return this;
}
DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
void __thiscall MSVCP_exception_dtor(exception *this)
{
TRACE("(%p)\n", this);
this->vtable = &MSVCP_exception_vtable;
if(this->do_free)
free(this->name);
}
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 */
INT_PTR i, *ptr = (INT_PTR *)this-1;
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;
}
DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@")
DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
/* ?_Doraise@bad_alloc@std@@MBEXXZ */
/* ?_Doraise@bad_alloc@std@@MEBAXXZ */
/* ?_Doraise@logic_error@std@@MBEXXZ */
/* ?_Doraise@logic_error@std@@MEBAXXZ */
/* ?_Doraise@length_error@std@@MBEXXZ */
/* ?_Doraise@length_error@std@@MEBAXXZ */
/* ?_Doraise@out_of_range@std@@MBEXXZ */
/* ?_Doraise@out_of_range@std@@MEBAXXZ */
/* ?_Doraise@runtime_error@std@@MBEXXZ */
/* ?_Doraise@runtime_error@std@@MEBAXXZ */
/* ?_Doraise@bad_cast@std@@MBEXXZ */
/* ?_Doraise@bad_cast@std@@MEBAXXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_exception__Doraise, 4)
void __thiscall MSVCP_exception__Doraise(exception *this)
{
FIXME("(%p) stub\n", this);
}
DEFINE_THISCALL_WRAPPER(MSVCP_exception_what,4)
const char* __thiscall MSVCP_exception_what(exception * this)
{
TRACE("(%p) returning %s\n", this, this->name);
return this->name ? this->name : "Unknown exception";
}
/* bad_alloc class data */
typedef exception bad_alloc;
/* ??0bad_alloc@std@@QAE@PBD@Z */
/* ??0bad_alloc@std@@QEAA@PEBD@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_ctor, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_ctor(bad_alloc *this, const char *name)
{
TRACE("%p %s\n", this, name);
MSVCP_exception_ctor(this, name);
this->vtable = &MSVCP_bad_alloc_vtable;
return this;
}
/* ??0bad_alloc@std@@QAE@XZ */
/* ??0bad_alloc@std@@QEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_default_ctor, 4)
bad_alloc* __thiscall MSVCP_bad_alloc_default_ctor(bad_alloc *this)
{
return MSVCP_bad_alloc_ctor(this, "bad allocation");
}
/* ??0bad_alloc@std@@QAE@ABV01@@Z */
/* ??0bad_alloc@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
{
TRACE("%p %p\n", this, rhs);
MSVCP_exception_copy_ctor(this, rhs);
this->vtable = &MSVCP_bad_alloc_vtable;
return this;
}
/* ??1bad_alloc@std@@UAE@XZ */
/* ??1bad_alloc@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
{
TRACE("%p\n", this);
MSVCP_exception_dtor(this);
}
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_vector_dtor, 8)
void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *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_alloc_dtor(this+i);
MSVCRT_operator_delete(ptr);
} else {
MSVCP_bad_alloc_dtor(this);
if(flags & 1)
MSVCRT_operator_delete(this);
}
return this;
}
/* ??4bad_alloc@std@@QAEAAV01@ABV01@@Z */
/* ??4bad_alloc@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_assign, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_assign(bad_alloc *this, const bad_alloc *assign)
{
MSVCP_bad_alloc_dtor(this);
return MSVCP_bad_alloc_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@")
DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor)
/* logic_error class data */
typedef struct {
exception e;
basic_string_char str;
} logic_error;
static logic_error* MSVCP_logic_error_ctor(
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;
}
/* ??0logic_error@std@@QAE@ABV01@@Z */
/* ??0logic_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
logic_error* __thiscall MSVCP_logic_error_copy_ctor(
logic_error *this, const 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;
}
/* ??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0logic_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor_bstr, 8)
logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const basic_string_char *str)
{
TRACE("(%p %p)\n", this, str);
return MSVCP_logic_error_ctor(this, MSVCP_basic_string_char_c_str(str));
}
/* ??1logic_error@std@@UAE@XZ */
/* ??1logic_error@std@@UEAA@XZ */
/* ??1length_error@std@@UAE@XZ */
/* ??1length_error@std@@UEAA@XZ */
/* ??1out_of_range@std@@UAE@XZ */
/* ??1out_of_range@std@@UEAA@XZ */
/* ??1runtime_error@std@@UAE@XZ */
/* ??1runtime_error@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
void __thiscall MSVCP_logic_error_dtor(logic_error *this)
{
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)
void* __thiscall MSVCP_logic_error_vector_dtor(
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 */
INT_PTR i, *ptr = (INT_PTR *)this-1;
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;
}
/* ??4logic_error@std@@QAEAAV01@ABV01@@Z */
/* ??4logic_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_assign, 8)
logic_error* __thiscall MSVCP_logic_error_assign(logic_error *this, const logic_error *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_logic_error_copy_ctor(this, assign);
}
/* ?what@logic_error@std@@UBEPBDXZ */
/* ?what@logic_error@std@@UEBAPEBDXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
const char* __thiscall MSVCP_logic_error_what(logic_error *this)
{
TRACE("%p\n", this);
return MSVCP_basic_string_char_c_str(&this->str);
}
DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@std@@")
DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* length_error class data */
typedef logic_error length_error;
static length_error* MSVCP_length_error_ctor(
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;
}
/* ??0length_error@std@@QAE@ABV01@@Z */
/* ??0length_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
length_error* __thiscall MSVCP_length_error_copy_ctor(
length_error *this, const 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;
}
/* ??0length_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0length_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_ctor_bstr, 8)
length_error* __thiscall MSVCP_length_error_ctor_bstr(length_error *this, const basic_string_char *str)
{
TRACE("(%p %p)\n", this, str);
return MSVCP_length_error_ctor(this, MSVCP_basic_string_char_c_str(str));
}
/* ??4length_error@std@@QAEAAV01@ABV01@@Z */
/* ??4length_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_assign, 8)
length_error* __thiscall MSVCP_length_error_assign(length_error *this, const length_error *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_length_error_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@")
DEFINE_CXX_DATA2(length_error, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* out_of_range class data */
typedef logic_error out_of_range;
static out_of_range* MSVCP_out_of_range_ctor(
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;
}
/* ??0out_of_range@std@@QAE@ABV01@@Z */
/* ??0out_of_range@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
out_of_range *this, const 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;
}
/* ??0out_of_range@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0out_of_range@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_ctor_bstr, 8)
out_of_range* __thiscall MSVCP_out_of_range_ctor_bstr(out_of_range *this, const basic_string_char *str)
{
TRACE("(%p %p)\n", this, str);
return MSVCP_out_of_range_ctor(this, MSVCP_basic_string_char_c_str(str));
}
/* ??4out_of_range@std@@QAEAAV01@ABV01@@Z */
/* ??4out_of_range@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_assign, 8)
out_of_range* __thiscall MSVCP_out_of_range_assign(out_of_range *this, const out_of_range *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_out_of_range_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@")
DEFINE_CXX_DATA2(out_of_range, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* invalid_argument class data */
typedef logic_error invalid_argument;
static invalid_argument* MSVCP_invalid_argument_ctor(
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)
invalid_argument* __thiscall MSVCP_invalid_argument_copy_ctor(
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;
}
DEFINE_RTTI_DATA2(invalid_argument, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVinvalid_argument@std@@")
DEFINE_CXX_DATA2(invalid_argument, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* runtime_error class data */
typedef logic_error runtime_error;
static runtime_error* MSVCP_runtime_error_ctor(
runtime_error *this, const char *name)
{
TRACE("%p %s\n", this, name);
MSVCP_logic_error_ctor(this, name);
this->e.vtable = &MSVCP_runtime_error_vtable;
return this;
}
/* ??0runtime_error@std@@QAE@ABV01@@Z */
/* ??0runtime_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
runtime_error *this, const runtime_error *rhs)
{
TRACE("%p %p\n", this, rhs);
MSVCP_logic_error_copy_ctor(this, rhs);
this->e.vtable = &MSVCP_runtime_error_vtable;
return this;
}
/* ??0runtime_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0runtime_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_ctor_bstr, 8)
runtime_error* __thiscall MSVCP_runtime_error_ctor_bstr(runtime_error *this, const basic_string_char *str)
{
TRACE("(%p %p)\n", this, str);
return MSVCP_runtime_error_ctor(this, MSVCP_basic_string_char_c_str(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);
return MSVCP_logic_error_vector_dtor(this, flags);
}
/* ??4runtime_error@std@@QAEAAV01@ABV01@@Z */
/* ??4runtime_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_assign, 8)
runtime_error* __thiscall MSVCP_runtime_error_assign(runtime_error *this, const runtime_error *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_runtime_error_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@")
DEFINE_CXX_DATA1(runtime_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* ?what@runtime_error@std@@UBEPBDXZ */
/* ?what@runtime_error@std@@UEBAPEBDXZ */
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);
}
/* failure class data */
typedef runtime_error failure;
static failure* MSVCP_failure_ctor(
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)
{
TRACE("%p\n", this);
MSVCP_logic_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);
}
DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVfailure@std@@")
DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* ?_Nomemory@std@@YAXXZ */
void __cdecl _Nomemory(void)
{
TRACE("()\n");
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
}
#ifndef __GNUC__
void __asm_dummy_vtables(void) {
#endif
__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_exception_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(bad_alloc,
VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_exception_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(logic_error,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(length_error,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(out_of_range,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(invalid_argument,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(runtime_error,
VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_runtime_error_what)
VTABLE_ADD_FUNC(MSVCP_exception__Doraise));
__ASM_VTABLE(failure,
VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_failure_what));
#ifndef __GNUC__
}
#endif
/* Internal: throws selected exception */
void throw_exception(exception_type et, const char *str)
{
switch(et) {
case EXCEPTION_RERAISE:
_CxxThrowException(NULL, NULL);
case EXCEPTION: {
exception e;
MSVCP_exception_ctor(&e, str);
_CxxThrowException(&e, &exception_cxx_type);
}
case EXCEPTION_BAD_ALLOC: {
bad_alloc e;
MSVCP_bad_alloc_ctor(&e, str);
_CxxThrowException(&e, &bad_alloc_cxx_type);
}
case EXCEPTION_LOGIC_ERROR: {
logic_error e;
MSVCP_logic_error_ctor(&e, str);
_CxxThrowException((exception*)&e, &logic_error_cxx_type);
}
case EXCEPTION_LENGTH_ERROR: {
length_error e;
MSVCP_length_error_ctor(&e, str);
_CxxThrowException((exception*)&e, &length_error_cxx_type);
}
case EXCEPTION_OUT_OF_RANGE: {
out_of_range e;
MSVCP_out_of_range_ctor(&e, str);
_CxxThrowException((exception*)&e, &out_of_range_cxx_type);
}
case EXCEPTION_INVALID_ARGUMENT: {
invalid_argument e;
MSVCP_invalid_argument_ctor(&e, str);
_CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
}
case EXCEPTION_RUNTIME_ERROR: {
runtime_error e;
MSVCP_runtime_error_ctor(&e, str);
_CxxThrowException((exception*)&e, &runtime_error_cxx_type);
}
case EXCEPTION_FAILURE: {
failure e;
MSVCP_failure_ctor(&e, str);
_CxxThrowException((exception*)&e, &failure_cxx_type);
}
default:
ERR("exception type not handled: %d\n", et);
}
}
void init_exception(void *base)
{
#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);
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);
#endif
}

View File

@ -845,10 +845,10 @@
@ cdecl -arch=win64 ??0bad_alloc@std@@QEAA@PEBD@Z(ptr str) MSVCP_bad_alloc_ctor @ cdecl -arch=win64 ??0bad_alloc@std@@QEAA@PEBD@Z(ptr str) MSVCP_bad_alloc_ctor
@ thiscall -arch=win32 ??0bad_alloc@std@@QAE@XZ(ptr) MSVCP_bad_alloc_default_ctor @ thiscall -arch=win32 ??0bad_alloc@std@@QAE@XZ(ptr) MSVCP_bad_alloc_default_ctor
@ cdecl -arch=win64 ??0bad_alloc@std@@QEAA@XZ(ptr) MSVCP_bad_alloc_default_ctor @ cdecl -arch=win64 ??0bad_alloc@std@@QEAA@XZ(ptr) MSVCP_bad_alloc_default_ctor
@ thiscall -arch=i386 ??0bad_cast@std@@QAE@ABV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QAE@ABV0@@Z @ thiscall -arch=i386 ??0bad_cast@std@@QAE@ABV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor
@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@AEBV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QEAA@AEBV0@@Z @ cdecl -arch=win64 ??0bad_cast@std@@QEAA@AEBV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor
@ thiscall -arch=i386 ??0bad_cast@std@@QAE@PBD@Z(ptr str) msvcrt.??0bad_cast@@QAE@PBD@Z @ thiscall -arch=i386 ??0bad_cast@std@@QAE@PBD@Z(ptr str) MSVCP_bad_cast_ctor
@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@PEBD@Z(ptr str) msvcrt.??0bad_cast@@QEAA@PEBD@Z @ cdecl -arch=win64 ??0bad_cast@std@@QEAA@PEBD@Z(ptr str) MSVCP_bad_cast_ctor
@ stub -arch=win32 ??0bad_exception@std@@QAE@ABV01@@Z @ stub -arch=win32 ??0bad_exception@std@@QAE@ABV01@@Z
@ stub -arch=win64 ??0bad_exception@std@@QEAA@AEBV01@@Z @ stub -arch=win64 ??0bad_exception@std@@QEAA@AEBV01@@Z
@ stub -arch=win32 ??0bad_exception@std@@QAE@PBD@Z @ stub -arch=win32 ??0bad_exception@std@@QAE@PBD@Z
@ -1049,8 +1049,8 @@
@ stub -arch=win64 ??1__non_rtti_object@std@@UEAA@XZ @ stub -arch=win64 ??1__non_rtti_object@std@@UEAA@XZ
@ thiscall -arch=win32 ??1bad_alloc@std@@UAE@XZ(ptr) MSVCP_bad_alloc_dtor @ thiscall -arch=win32 ??1bad_alloc@std@@UAE@XZ(ptr) MSVCP_bad_alloc_dtor
@ cdecl -arch=win64 ??1bad_alloc@std@@UEAA@XZ(ptr) MSVCP_bad_alloc_dtor @ cdecl -arch=win64 ??1bad_alloc@std@@UEAA@XZ(ptr) MSVCP_bad_alloc_dtor
@ thiscall -arch=i386 ??1bad_cast@std@@UAE@XZ(ptr) msvcrt.??1bad_cast@@UAE@XZ @ thiscall -arch=i386 ??1bad_cast@std@@UAE@XZ(ptr) MSVCP_bad_cast_dtor
@ cdecl -arch=win64 ??1bad_cast@std@@UEAA@XZ(ptr) msvcrt.??1bad_cast@@UEAA@XZ @ cdecl -arch=win64 ??1bad_cast@std@@UEAA@XZ(ptr) MSVCP_bad_cast_dtor
@ stub -arch=win32 ??1bad_exception@std@@UAE@XZ @ stub -arch=win32 ??1bad_exception@std@@UAE@XZ
@ stub -arch=win64 ??1bad_exception@std@@UEAA@XZ @ stub -arch=win64 ??1bad_exception@std@@UEAA@XZ
@ stub -arch=win32 ??1bad_typeid@std@@UAE@XZ @ stub -arch=win32 ??1bad_typeid@std@@UAE@XZ
@ -1235,8 +1235,8 @@
@ stub -arch=win64 ??4__non_rtti_object@std@@QEAAAEAV01@AEBV01@@Z @ stub -arch=win64 ??4__non_rtti_object@std@@QEAAAEAV01@AEBV01@@Z
@ thiscall -arch=win32 ??4bad_alloc@std@@QAEAAV01@ABV01@@Z(ptr ptr) MSVCP_bad_alloc_assign @ thiscall -arch=win32 ??4bad_alloc@std@@QAEAAV01@ABV01@@Z(ptr ptr) MSVCP_bad_alloc_assign
@ cdecl -arch=win64 ??4bad_alloc@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) MSVCP_bad_alloc_assign @ cdecl -arch=win64 ??4bad_alloc@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) MSVCP_bad_alloc_assign
@ thiscall -arch=i386 ??4bad_cast@std@@QAEAAV01@ABV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QAEAAV0@ABV0@@Z @ thiscall -arch=i386 ??4bad_cast@std@@QAEAAV01@ABV01@@Z(ptr ptr) MSVCP_bad_cast_opequals
@ cdecl -arch=win64 ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QEAAAEAV0@AEBV0@@Z @ cdecl -arch=win64 ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) MSVCP_bad_cast_opequals
@ stub -arch=win32 ??4bad_exception@std@@QAEAAV01@ABV01@@Z @ stub -arch=win32 ??4bad_exception@std@@QAEAAV01@ABV01@@Z
@ stub -arch=win64 ??4bad_exception@std@@QEAAAEAV01@AEBV01@@Z @ stub -arch=win64 ??4bad_exception@std@@QEAAAEAV01@AEBV01@@Z
@ stub -arch=win32 ??4bad_typeid@std@@QAEAAV01@ABV01@@Z @ stub -arch=win32 ??4bad_typeid@std@@QAEAAV01@ABV01@@Z
@ -1815,7 +1815,7 @@
@ extern ??_7?$time_put@GV?$ostreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@6B@ MSVCP_time_put_short_vtable @ extern ??_7?$time_put@GV?$ostreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@6B@ MSVCP_time_put_short_vtable
# extern ??_7__non_rtti_object@std@@6B@ # extern ??_7__non_rtti_object@std@@6B@
@ extern ??_7bad_alloc@std@@6B@ MSVCP_bad_alloc_vtable @ extern ??_7bad_alloc@std@@6B@ MSVCP_bad_alloc_vtable
@ extern ??_7bad_cast@std@@6B@ msvcrt.??_7bad_cast@@6B@ @ extern ??_7bad_cast@std@@6B@ MSVCP_bad_cast_vtable
# extern ??_7bad_exception@std@@6B@ # extern ??_7bad_exception@std@@6B@
# extern ??_7bad_typeid@std@@6B@ # extern ??_7bad_typeid@std@@6B@
@ extern ??_7codecvt_base@std@@6B@ MSVCP_codecvt_base_vtable @ extern ??_7codecvt_base@std@@6B@ MSVCP_codecvt_base_vtable
@ -1979,8 +1979,8 @@
@ cdecl -arch=win64 ??_F_Locinfo@std@@QEAAXXZ(ptr) _Locinfo_ctor @ cdecl -arch=win64 ??_F_Locinfo@std@@QEAAXXZ(ptr) _Locinfo_ctor
@ thiscall -arch=win32 ??_F_Timevec@std@@QAEXXZ(ptr) _Timevec_ctor @ thiscall -arch=win32 ??_F_Timevec@std@@QAEXXZ(ptr) _Timevec_ctor
@ cdecl -arch=win64 ??_F_Timevec@std@@QEAAXXZ(ptr) _Timevec_ctor @ cdecl -arch=win64 ??_F_Timevec@std@@QEAAXXZ(ptr) _Timevec_ctor
@ thiscall -arch=i386 ??_Fbad_cast@std@@QAEXXZ(ptr) msvcrt.??_Fbad_cast@@QAEXXZ @ thiscall -arch=i386 ??_Fbad_cast@std@@QAEXXZ(ptr) MSVCP_bad_cast_default_ctor
@ cdecl -arch=win64 ??_Fbad_cast@std@@QEAAXXZ(ptr) msvcrt.??_Fbad_cast@@QEAAXXZ @ cdecl -arch=win64 ??_Fbad_cast@std@@QEAAXXZ(ptr) MSVCP_bad_cast_default_ctor
@ stub -arch=win32 ??_Fbad_exception@std@@QAEXXZ @ stub -arch=win32 ??_Fbad_exception@std@@QAEXXZ
@ stub -arch=win64 ??_Fbad_exception@std@@QEAAXXZ @ stub -arch=win64 ??_Fbad_exception@std@@QEAAXXZ
@ stub -arch=win32 ??_Fbad_typeid@std@@QAEXXZ @ stub -arch=win32 ??_Fbad_typeid@std@@QAEXXZ
@ -4192,7 +4192,7 @@
@ cdecl -arch=win64 ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ(ptr) basic_streambuf_char_uflow @ cdecl -arch=win64 ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ(ptr) basic_streambuf_char_uflow
@ thiscall -arch=win32 ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ(ptr) basic_streambuf_wchar_uflow @ thiscall -arch=win32 ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ(ptr) basic_streambuf_wchar_uflow
@ cdecl -arch=win64 ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ(ptr) basic_streambuf_wchar_uflow @ cdecl -arch=win64 ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ(ptr) basic_streambuf_wchar_uflow
@ cdecl ?uncaught_exception@std@@YA_NXZ() msvcp90.?uncaught_exception@std@@YA_NXZ @ cdecl ?uncaught_exception@std@@YA_NXZ() MSVCP__uncaught_exception
@ thiscall -arch=win32 ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ(ptr) basic_filebuf_char_underflow @ thiscall -arch=win32 ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ(ptr) basic_filebuf_char_underflow
@ cdecl -arch=win64 ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ(ptr) basic_filebuf_char_underflow @ cdecl -arch=win64 ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ(ptr) basic_filebuf_char_underflow
@ thiscall -arch=win32 ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ(ptr) basic_filebuf_wchar_underflow @ thiscall -arch=win32 ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ(ptr) basic_filebuf_wchar_underflow

View File

@ -32,15 +32,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*); void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
#if _MSVCP_VER >= 70
typedef const char **exception_name;
#define EXCEPTION_STR(name) (*name)
#define EXCEPTION_NAME(str) ((exception_name)&str)
#else
typedef const char *exception_name;
#define EXCEPTION_STR(name) (name)
#define EXCEPTION_NAME(str) (str)
#endif
/* vtables */ /* vtables */
extern const vtable_ptr MSVCP_exception_vtable; extern const vtable_ptr MSVCP_exception_vtable;
/* ??_7bad_alloc@std@@6B@ */
extern const vtable_ptr MSVCP_bad_alloc_vtable; extern const vtable_ptr MSVCP_bad_alloc_vtable;
/* ??_7logic_error@std@@6B@ */
extern const vtable_ptr MSVCP_logic_error_vtable; extern const vtable_ptr MSVCP_logic_error_vtable;
/* ??_7length_error@std@@6B@ */
extern const vtable_ptr MSVCP_length_error_vtable; extern const vtable_ptr MSVCP_length_error_vtable;
/* ??_7out_of_range@std@@6B@ */
extern const vtable_ptr MSVCP_out_of_range_vtable; extern const vtable_ptr MSVCP_out_of_range_vtable;
extern const vtable_ptr MSVCP_invalid_argument_vtable; extern const vtable_ptr MSVCP_invalid_argument_vtable;
/* ??_7runtime_error@std@@6B@ */
extern const vtable_ptr MSVCP_runtime_error_vtable; extern const vtable_ptr MSVCP_runtime_error_vtable;
extern const vtable_ptr MSVCP_failure_vtable; extern const vtable_ptr MSVCP_failure_vtable;
/* ??_7bad_cast@std@@6B@ */
extern const vtable_ptr MSVCP_bad_cast_vtable; extern const vtable_ptr MSVCP_bad_cast_vtable;
static void MSVCP_type_info_dtor(type_info * _this) static void MSVCP_type_info_dtor(type_info * _this)
@ -71,15 +87,15 @@ void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int fl
DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" ) DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" )
static exception* MSVCP_exception_ctor(exception *this, const char **name) static exception* MSVCP_exception_ctor(exception *this, exception_name name)
{ {
TRACE("(%p %s)\n", this, *name); TRACE("(%p %s)\n", this, EXCEPTION_STR(name));
this->vtable = &MSVCP_exception_vtable; this->vtable = &MSVCP_exception_vtable;
if(*name) { if(EXCEPTION_STR(name)) {
unsigned int name_len = strlen(*name) + 1; unsigned int name_len = strlen(EXCEPTION_STR(name)) + 1;
this->name = malloc(name_len); this->name = malloc(name_len);
memcpy(this->name, *name, name_len); memcpy(this->name, EXCEPTION_STR(name), name_len);
this->do_free = TRUE; this->do_free = TRUE;
} else { } else {
this->name = NULL; this->name = NULL;
@ -98,7 +114,7 @@ exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception
this->name = rhs->name; this->name = rhs->name;
this->do_free = FALSE; this->do_free = FALSE;
} else } else
MSVCP_exception_ctor(this, (const char**)&rhs->name); MSVCP_exception_ctor(this, EXCEPTION_NAME(rhs->name));
TRACE("name = %s\n", this->name); TRACE("name = %s\n", this->name);
return this; return this;
} }
@ -135,17 +151,56 @@ void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flag
DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@") DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@")
DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor) DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor)
/* ?_Doraise@bad_alloc@std@@MBEXXZ */
/* ?_Doraise@bad_alloc@std@@MEBAXXZ */
/* ?_Doraise@logic_error@std@@MBEXXZ */
/* ?_Doraise@logic_error@std@@MEBAXXZ */
/* ?_Doraise@length_error@std@@MBEXXZ */
/* ?_Doraise@length_error@std@@MEBAXXZ */
/* ?_Doraise@out_of_range@std@@MBEXXZ */
/* ?_Doraise@out_of_range@std@@MEBAXXZ */
/* ?_Doraise@runtime_error@std@@MBEXXZ */
/* ?_Doraise@runtime_error@std@@MEBAXXZ */
/* ?_Doraise@bad_cast@std@@MBEXXZ */
/* ?_Doraise@bad_cast@std@@MEBAXXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_exception__Doraise, 4)
void __thiscall MSVCP_exception__Doraise(exception *this)
{
FIXME("(%p) stub\n", this);
}
DEFINE_THISCALL_WRAPPER(MSVCP_exception_what,4)
const char* __thiscall MSVCP_exception_what(exception * this)
{
TRACE("(%p) returning %s\n", this, this->name);
return this->name ? this->name : "Unknown exception";
}
/* bad_alloc class data */ /* bad_alloc class data */
typedef exception bad_alloc; typedef exception bad_alloc;
static bad_alloc* MSVCP_bad_alloc_ctor(bad_alloc *this, const char **name) /* ??0bad_alloc@std@@QAE@PBD@Z */
/* ??0bad_alloc@std@@QEAA@PEBD@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_ctor, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_ctor(bad_alloc *this, exception_name name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
MSVCP_exception_ctor(this, name); MSVCP_exception_ctor(this, name);
this->vtable = &MSVCP_bad_alloc_vtable; this->vtable = &MSVCP_bad_alloc_vtable;
return this; return this;
} }
/* ??0bad_alloc@std@@QAE@XZ */
/* ??0bad_alloc@std@@QEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_default_ctor, 4)
bad_alloc* __thiscall MSVCP_bad_alloc_default_ctor(bad_alloc *this)
{
static const char name[] = "bad allocation";
return MSVCP_bad_alloc_ctor(this, EXCEPTION_NAME(name));
}
/* ??0bad_alloc@std@@QAE@ABV01@@Z */
/* ??0bad_alloc@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs) bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
{ {
@ -155,6 +210,8 @@ bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc
return this; return this;
} }
/* ??1bad_alloc@std@@UAE@XZ */
/* ??1bad_alloc@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4) DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this) void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
{ {
@ -182,36 +239,39 @@ void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *this, unsigned int flag
return this; return this;
} }
DEFINE_THISCALL_WRAPPER(MSVCP_what_exception,4) /* ??4bad_alloc@std@@QAEAAV01@ABV01@@Z */
const char* __thiscall MSVCP_what_exception(exception * this) /* ??4bad_alloc@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_assign, 8)
bad_alloc* __thiscall MSVCP_bad_alloc_assign(bad_alloc *this, const bad_alloc *assign)
{ {
TRACE("(%p) returning %s\n", this, this->name); MSVCP_bad_alloc_dtor(this);
return this->name ? this->name : "Unknown exception"; return MSVCP_bad_alloc_copy_ctor(this, assign);
} }
DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@") DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@")
DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor) DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor)
/* logic_error class data */ /* logic_error class data */
typedef struct _logic_error { typedef struct {
exception e; exception e;
basic_string_char str; basic_string_char str;
} logic_error; } logic_error;
static logic_error* MSVCP_logic_error_ctor( static logic_error* MSVCP_logic_error_ctor( logic_error *this, exception_name name )
logic_error *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
this->e.vtable = &MSVCP_logic_error_vtable; this->e.vtable = &MSVCP_logic_error_vtable;
this->e.name = NULL; this->e.name = NULL;
this->e.do_free = FALSE; this->e.do_free = FALSE;
MSVCP_basic_string_char_ctor_cstr(&this->str, *name); MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name));
return this; return this;
} }
/* ??0logic_error@std@@QAE@ABV01@@Z */
/* ??0logic_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
logic_error* __thiscall MSVCP_logic_error_copy_ctor( logic_error* __thiscall MSVCP_logic_error_copy_ctor(
logic_error *this, logic_error *rhs) logic_error *this, const logic_error *rhs)
{ {
TRACE("%p %p\n", this, rhs); TRACE("%p %p\n", this, rhs);
MSVCP_exception_copy_ctor(&this->e, &rhs->e); MSVCP_exception_copy_ctor(&this->e, &rhs->e);
@ -220,6 +280,22 @@ logic_error* __thiscall MSVCP_logic_error_copy_ctor(
return this; return this;
} }
/* ??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0logic_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor_bstr, 8)
logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const basic_string_char *str)
{
const char *name = MSVCP_basic_string_char_c_str(str);
TRACE("(%p %p %s)\n", this, str, name);
return MSVCP_logic_error_ctor(this, EXCEPTION_NAME(name));
}
/* ??1logic_error@std@@UAE@XZ */
/* ??1logic_error@std@@UEAA@XZ */
/* ??1length_error@std@@UAE@XZ */
/* ??1length_error@std@@UEAA@XZ */
/* ??1out_of_range@std@@UAE@XZ */
/* ??1out_of_range@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4) DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
void __thiscall MSVCP_logic_error_dtor(logic_error *this) void __thiscall MSVCP_logic_error_dtor(logic_error *this)
{ {
@ -249,6 +325,17 @@ void* __thiscall MSVCP_logic_error_vector_dtor(
return this; return this;
} }
/* ??4logic_error@std@@QAEAAV01@ABV01@@Z */
/* ??4logic_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_assign, 8)
logic_error* __thiscall MSVCP_logic_error_assign(logic_error *this, const logic_error *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_logic_error_copy_ctor(this, assign);
}
/* ?what@logic_error@std@@UBEPBDXZ */
/* ?what@logic_error@std@@UEBAPEBDXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4) DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
const char* __thiscall MSVCP_logic_error_what(logic_error *this) const char* __thiscall MSVCP_logic_error_what(logic_error *this)
{ {
@ -262,18 +349,19 @@ DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* length_error class data */ /* length_error class data */
typedef logic_error length_error; typedef logic_error length_error;
static length_error* MSVCP_length_error_ctor( static length_error* MSVCP_length_error_ctor( length_error *this, exception_name name )
length_error *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
MSVCP_logic_error_ctor(this, name); MSVCP_logic_error_ctor(this, name);
this->e.vtable = &MSVCP_length_error_vtable; this->e.vtable = &MSVCP_length_error_vtable;
return this; return this;
} }
/* ??0length_error@std@@QAE@ABV01@@Z */
/* ??0length_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
length_error* __thiscall MSVCP_length_error_copy_ctor( length_error* __thiscall MSVCP_length_error_copy_ctor(
length_error *this, length_error *rhs) length_error *this, const length_error *rhs)
{ {
TRACE("%p %p\n", this, rhs); TRACE("%p %p\n", this, rhs);
MSVCP_logic_error_copy_ctor(this, rhs); MSVCP_logic_error_copy_ctor(this, rhs);
@ -281,24 +369,44 @@ length_error* __thiscall MSVCP_length_error_copy_ctor(
return this; return this;
} }
/* ??0length_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0length_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_ctor_bstr, 8)
length_error* __thiscall MSVCP_length_error_ctor_bstr(length_error *this, const basic_string_char *str)
{
const char *name = MSVCP_basic_string_char_c_str(str);
TRACE("(%p %p %s)\n", this, str, name);
return MSVCP_length_error_ctor(this, EXCEPTION_NAME(name));
}
/* ??4length_error@std@@QAEAAV01@ABV01@@Z */
/* ??4length_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_length_error_assign, 8)
length_error* __thiscall MSVCP_length_error_assign(length_error *this, const length_error *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_length_error_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@") DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@")
DEFINE_CXX_DATA2(length_error, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor) DEFINE_CXX_DATA2(length_error, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* out_of_range class data */ /* out_of_range class data */
typedef logic_error out_of_range; typedef logic_error out_of_range;
static out_of_range* MSVCP_out_of_range_ctor( static out_of_range* MSVCP_out_of_range_ctor( out_of_range *this, exception_name name )
out_of_range *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
MSVCP_logic_error_ctor(this, name); MSVCP_logic_error_ctor(this, name);
this->e.vtable = &MSVCP_out_of_range_vtable; this->e.vtable = &MSVCP_out_of_range_vtable;
return this; return this;
} }
/* ??0out_of_range@std@@QAE@ABV01@@Z */
/* ??0out_of_range@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
out_of_range* __thiscall MSVCP_out_of_range_copy_ctor( out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
out_of_range *this, out_of_range *rhs) out_of_range *this, const out_of_range *rhs)
{ {
TRACE("%p %p\n", this, rhs); TRACE("%p %p\n", this, rhs);
MSVCP_logic_error_copy_ctor(this, rhs); MSVCP_logic_error_copy_ctor(this, rhs);
@ -306,16 +414,34 @@ out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
return this; return this;
} }
/* ??0out_of_range@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0out_of_range@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_ctor_bstr, 8)
out_of_range* __thiscall MSVCP_out_of_range_ctor_bstr(out_of_range *this, const basic_string_char *str)
{
const char *name = MSVCP_basic_string_char_c_str(str);
TRACE("(%p %p %s)\n", this, str, name);
return MSVCP_out_of_range_ctor(this, EXCEPTION_NAME(name));
}
/* ??4out_of_range@std@@QAEAAV01@ABV01@@Z */
/* ??4out_of_range@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_assign, 8)
out_of_range* __thiscall MSVCP_out_of_range_assign(out_of_range *this, const out_of_range *assign)
{
MSVCP_logic_error_dtor(this);
return MSVCP_out_of_range_copy_ctor(this, assign);
}
DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@") DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@")
DEFINE_CXX_DATA2(out_of_range, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor) DEFINE_CXX_DATA2(out_of_range, &logic_error_cxx_type_info, &exception_cxx_type_info, MSVCP_logic_error_dtor)
/* invalid_argument class data */ /* invalid_argument class data */
typedef logic_error invalid_argument; typedef logic_error invalid_argument;
static invalid_argument* MSVCP_invalid_argument_ctor( static invalid_argument* MSVCP_invalid_argument_ctor( invalid_argument *this, exception_name name )
invalid_argument *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
MSVCP_logic_error_ctor(this, name); MSVCP_logic_error_ctor(this, name);
this->e.vtable = &MSVCP_invalid_argument_vtable; this->e.vtable = &MSVCP_invalid_argument_vtable;
return this; return this;
@ -340,20 +466,21 @@ typedef struct {
basic_string_char str; basic_string_char str;
} runtime_error; } runtime_error;
static runtime_error* MSVCP_runtime_error_ctor( static runtime_error* MSVCP_runtime_error_ctor( runtime_error *this, exception_name name )
runtime_error *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
this->e.vtable = &MSVCP_runtime_error_vtable; this->e.vtable = &MSVCP_runtime_error_vtable;
this->e.name = NULL; this->e.name = NULL;
this->e.do_free = FALSE; this->e.do_free = FALSE;
MSVCP_basic_string_char_ctor_cstr(&this->str, *name); MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name));
return this; return this;
} }
/* ??0runtime_error@std@@QAE@ABV01@@Z */
/* ??0runtime_error@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
runtime_error* __thiscall MSVCP_runtime_error_copy_ctor( runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
runtime_error *this, runtime_error *rhs) runtime_error *this, const runtime_error *rhs)
{ {
TRACE("%p %p\n", this, rhs); TRACE("%p %p\n", this, rhs);
MSVCP_exception_copy_ctor(&this->e, &rhs->e); MSVCP_exception_copy_ctor(&this->e, &rhs->e);
@ -362,6 +489,18 @@ runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
return this; return this;
} }
/* ??0runtime_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
/* ??0runtime_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_ctor_bstr, 8)
runtime_error* __thiscall MSVCP_runtime_error_ctor_bstr(runtime_error *this, const basic_string_char *str)
{
const char *name = MSVCP_basic_string_char_c_str(str);
TRACE("(%p %p %s)\n", this, str, name);
return MSVCP_runtime_error_ctor(this, EXCEPTION_NAME(name));
}
/* ??1runtime_error@std@@UAE@XZ */
/* ??1runtime_error@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4) DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4)
void __thiscall MSVCP_runtime_error_dtor(runtime_error *this) void __thiscall MSVCP_runtime_error_dtor(runtime_error *this)
{ {
@ -391,6 +530,17 @@ void* __thiscall MSVCP_runtime_error_vector_dtor(
return this; return this;
} }
/* ??4runtime_error@std@@QAEAAV01@ABV01@@Z */
/* ??4runtime_error@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_assign, 8)
runtime_error* __thiscall MSVCP_runtime_error_assign(runtime_error *this, const runtime_error *assign)
{
MSVCP_runtime_error_dtor(this);
return MSVCP_runtime_error_copy_ctor(this, assign);
}
/* ?what@runtime_error@std@@UBEPBDXZ */
/* ?what@runtime_error@std@@UEBAPEBDXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4) DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4)
const char* __thiscall MSVCP_runtime_error_what(runtime_error *this) const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
{ {
@ -404,10 +554,9 @@ DEFINE_CXX_DATA1(runtime_error, &exception_cxx_type_info, MSVCP_runtime_error_dt
/* failure class data */ /* failure class data */
typedef runtime_error failure; typedef runtime_error failure;
static failure* MSVCP_failure_ctor( static failure* MSVCP_failure_ctor( failure *this, exception_name name )
failure *this, const char **name)
{ {
TRACE("%p %s\n", this, *name); TRACE("%p %s\n", this, EXCEPTION_STR(name));
MSVCP_runtime_error_ctor(this, name); MSVCP_runtime_error_ctor(this, name);
this->e.vtable = &MSVCP_failure_vtable; this->e.vtable = &MSVCP_failure_vtable;
return this; return this;
@ -451,21 +600,27 @@ DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info, &exception_cxx_type_info
/* bad_cast class data */ /* bad_cast class data */
typedef exception bad_cast; typedef exception bad_cast;
/* ??0bad_cast@std@@QAE@PBD@Z */
/* ??0bad_cast@std@@QEAA@PEBD@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8)
bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name) bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name)
{ {
TRACE("%p %s\n", this, name); TRACE("%p %s\n", this, name);
MSVCP_exception_ctor(this, &name); MSVCP_exception_ctor(this, EXCEPTION_NAME(name));
this->vtable = &MSVCP_bad_cast_vtable; this->vtable = &MSVCP_bad_cast_vtable;
return this; return this;
} }
/* ??_Fbad_cast@@QAEXXZ */
/* ??_Fbad_cast@std@@QEAAXXZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4) DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4)
bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this) bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this)
{ {
return MSVCP_bad_cast_ctor(this, "bad cast"); return MSVCP_bad_cast_ctor(this, "bad cast");
} }
/* ??0bad_cast@std@@QAE@ABV01@@Z */
/* ??0bad_cast@std@@QEAA@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8)
bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs) bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs)
{ {
@ -475,6 +630,8 @@ bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rh
return this; return this;
} }
/* ??1bad_cast@@UAE@XZ */
/* ??1bad_cast@std@@UEAA@XZ */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4) DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4)
void __thiscall MSVCP_bad_cast_dtor(bad_cast *this) void __thiscall MSVCP_bad_cast_dtor(bad_cast *this)
{ {
@ -502,6 +659,8 @@ void * __thiscall MSVCP_bad_cast_vector_dtor(bad_cast *this, unsigned int flags)
return this; return this;
} }
/* ??4bad_cast@std@@QAEAAV01@ABV01@@Z */
/* ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z */
DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8) DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8)
bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs) bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs)
{ {
@ -569,38 +728,44 @@ MSVCP_bool __cdecl MSVCP__uncaught_exception(void)
return __uncaught_exception(); return __uncaught_exception();
} }
#if _MSVCP_VER >= 70
#define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs)
#else
#define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs VTABLE_ADD_FUNC(MSVCP_exception__Doraise))
#endif
#ifndef __GNUC__ #ifndef __GNUC__
void __asm_dummy_vtables(void) { void __asm_dummy_vtables(void) {
#endif #endif
__ASM_VTABLE(type_info, __ASM_VTABLE(type_info,
VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor)); VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor));
__ASM_VTABLE(exception, EXCEPTION_VTABLE(exception,
VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor) VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_what_exception)); VTABLE_ADD_FUNC(MSVCP_exception_what));
__ASM_VTABLE(bad_alloc, EXCEPTION_VTABLE(bad_alloc,
VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor) VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_what_exception)); VTABLE_ADD_FUNC(MSVCP_exception_what));
__ASM_VTABLE(logic_error, EXCEPTION_VTABLE(logic_error,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor) VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)); VTABLE_ADD_FUNC(MSVCP_logic_error_what));
__ASM_VTABLE(length_error, EXCEPTION_VTABLE(length_error,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor) VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)); VTABLE_ADD_FUNC(MSVCP_logic_error_what));
__ASM_VTABLE(out_of_range, EXCEPTION_VTABLE(out_of_range,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor) VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)); VTABLE_ADD_FUNC(MSVCP_logic_error_what));
__ASM_VTABLE(invalid_argument, EXCEPTION_VTABLE(invalid_argument,
VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor) VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_logic_error_what)); VTABLE_ADD_FUNC(MSVCP_logic_error_what));
__ASM_VTABLE(runtime_error, EXCEPTION_VTABLE(runtime_error,
VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor) VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_runtime_error_what)); VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
__ASM_VTABLE(failure, EXCEPTION_VTABLE(failure,
VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor) VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_failure_what)); VTABLE_ADD_FUNC(MSVCP_failure_what));
__ASM_VTABLE(bad_cast, EXCEPTION_VTABLE(bad_cast,
VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor) VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor)
VTABLE_ADD_FUNC(MSVCP_what_exception)); VTABLE_ADD_FUNC(MSVCP_exception_what));
#ifndef __GNUC__ #ifndef __GNUC__
} }
#endif #endif
@ -608,19 +773,19 @@ void __asm_dummy_vtables(void) {
/* Internal: throws selected exception */ /* Internal: throws selected exception */
void throw_exception(exception_type et, const char *str) void throw_exception(exception_type et, const char *str)
{ {
const char *addr = str; exception_name name = EXCEPTION_NAME(str);
switch(et) { switch(et) {
case EXCEPTION_RERAISE: case EXCEPTION_RERAISE:
_CxxThrowException(NULL, NULL); _CxxThrowException(NULL, NULL);
case EXCEPTION: { case EXCEPTION: {
exception e; exception e;
MSVCP_exception_ctor(&e, &addr); MSVCP_exception_ctor(&e, name);
_CxxThrowException(&e, &exception_cxx_type); _CxxThrowException(&e, &exception_cxx_type);
} }
case EXCEPTION_BAD_ALLOC: { case EXCEPTION_BAD_ALLOC: {
bad_alloc e; bad_alloc e;
MSVCP_bad_alloc_ctor(&e, &addr); MSVCP_bad_alloc_ctor(&e, name);
_CxxThrowException(&e, &bad_alloc_cxx_type); _CxxThrowException(&e, &bad_alloc_cxx_type);
} }
case EXCEPTION_BAD_CAST: { case EXCEPTION_BAD_CAST: {
@ -630,32 +795,32 @@ void throw_exception(exception_type et, const char *str)
} }
case EXCEPTION_LOGIC_ERROR: { case EXCEPTION_LOGIC_ERROR: {
logic_error e; logic_error e;
MSVCP_logic_error_ctor(&e, &addr); MSVCP_logic_error_ctor(&e, name);
_CxxThrowException((exception*)&e, &logic_error_cxx_type); _CxxThrowException((exception*)&e, &logic_error_cxx_type);
} }
case EXCEPTION_LENGTH_ERROR: { case EXCEPTION_LENGTH_ERROR: {
length_error e; length_error e;
MSVCP_length_error_ctor(&e, &addr); MSVCP_length_error_ctor(&e, name);
_CxxThrowException((exception*)&e, &length_error_cxx_type); _CxxThrowException((exception*)&e, &length_error_cxx_type);
} }
case EXCEPTION_OUT_OF_RANGE: { case EXCEPTION_OUT_OF_RANGE: {
out_of_range e; out_of_range e;
MSVCP_out_of_range_ctor(&e, &addr); MSVCP_out_of_range_ctor(&e, name);
_CxxThrowException((exception*)&e, &out_of_range_cxx_type); _CxxThrowException((exception*)&e, &out_of_range_cxx_type);
} }
case EXCEPTION_INVALID_ARGUMENT: { case EXCEPTION_INVALID_ARGUMENT: {
invalid_argument e; invalid_argument e;
MSVCP_invalid_argument_ctor(&e, &addr); MSVCP_invalid_argument_ctor(&e, name);
_CxxThrowException((exception*)&e, &invalid_argument_cxx_type); _CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
} }
case EXCEPTION_RUNTIME_ERROR: { case EXCEPTION_RUNTIME_ERROR: {
runtime_error e; runtime_error e;
MSVCP_runtime_error_ctor(&e, &addr); MSVCP_runtime_error_ctor(&e, name);
_CxxThrowException((exception*)&e, &runtime_error_cxx_type); _CxxThrowException((exception*)&e, &runtime_error_cxx_type);
} }
case EXCEPTION_FAILURE: { case EXCEPTION_FAILURE: {
failure e; failure e;
MSVCP_failure_ctor(&e, &addr); MSVCP_failure_ctor(&e, name);
_CxxThrowException((exception*)&e, &failure_cxx_type); _CxxThrowException((exception*)&e, &failure_cxx_type);
} }
} }

View File

@ -71,14 +71,16 @@ extern MSVCP_bool (__thiscall *critical_section_trylock)(critical_section*);
#endif #endif
/* basic_string<char, char_traits<char>, allocator<char>> */ /* basic_string<char, char_traits<char>, allocator<char>> */
#define BUF_SIZE_CHAR 16
typedef struct typedef struct
{ {
#if _MSVCP_VER <= 90 #if _MSVCP_VER <= 90
void *allocator; void *allocator;
#endif #endif
union { union {
#if _MSVCP_VER >= 70
#define BUF_SIZE_CHAR 16
char buf[BUF_SIZE_CHAR]; char buf[BUF_SIZE_CHAR];
#endif
char *ptr; char *ptr;
} data; } data;
MSVCP_size_t size; MSVCP_size_t size;
@ -99,14 +101,16 @@ basic_string_char* __thiscall MSVCP_basic_string_char_append_ch(basic_string_cha
MSVCP_size_t __thiscall MSVCP_basic_string_char_length(const basic_string_char*); MSVCP_size_t __thiscall MSVCP_basic_string_char_length(const basic_string_char*);
basic_string_char* __thiscall MSVCP_basic_string_char_assign(basic_string_char*, const basic_string_char*); basic_string_char* __thiscall MSVCP_basic_string_char_assign(basic_string_char*, const basic_string_char*);
#define BUF_SIZE_WCHAR 8
typedef struct typedef struct
{ {
#if _MSVCP_VER <= 90 #if _MSVCP_VER <= 90
void *allocator; void *allocator;
#endif #endif
union { union {
#if _MSVCP_VER >= 70
#define BUF_SIZE_WCHAR 8
wchar_t buf[BUF_SIZE_WCHAR]; wchar_t buf[BUF_SIZE_WCHAR];
#endif
wchar_t *ptr; wchar_t *ptr;
} data; } data;
MSVCP_size_t size; MSVCP_size_t size;
@ -366,8 +370,12 @@ typedef struct _ios_base {
streamsize wide; streamsize wide;
IOS_BASE_iosarray *arr; IOS_BASE_iosarray *arr;
IOS_BASE_fnarray *calls; IOS_BASE_fnarray *calls;
#if _MSVCP_VER < 70
locale loc;
#else
locale *loc; locale *loc;
#if _MSVCP_VER == 70 #endif
#if _MSVCP_VER <= 70
MSVCP_size_t stdstr; MSVCP_size_t stdstr;
#endif #endif
} ios_base; } ios_base;
@ -375,7 +383,7 @@ typedef struct _ios_base {
/* class basic_streambuf<char> */ /* class basic_streambuf<char> */
typedef struct { typedef struct {
const vtable_ptr *vtable; const vtable_ptr *vtable;
#if _MSVCP_VER <= 100 #if _MSVCP_VER >= 70 && _MSVCP_VER <= 100
mutex lock; mutex lock;
#endif #endif
char *rbuf; char *rbuf;
@ -390,7 +398,11 @@ typedef struct {
int wsize; int wsize;
int *prsize; int *prsize;
int *pwsize; int *pwsize;
#if _MSVCP_VER < 70
locale loc;
#else
locale *loc; locale *loc;
#endif
} basic_streambuf_char; } basic_streambuf_char;
typedef struct { typedef struct {
@ -414,7 +426,7 @@ int __thiscall basic_streambuf_char_sputc(basic_streambuf_char*, char);
/* class basic_streambuf<wchar> */ /* class basic_streambuf<wchar> */
typedef struct { typedef struct {
const vtable_ptr *vtable; const vtable_ptr *vtable;
#if _MSVCP_VER <= 100 #if _MSVCP_VER >= 70 && _MSVCP_VER <= 100
mutex lock; mutex lock;
#endif #endif
wchar_t *rbuf; wchar_t *rbuf;
@ -429,7 +441,11 @@ typedef struct {
int wsize; int wsize;
int *prsize; int *prsize;
int *pwsize; int *pwsize;
#if _MSVCP_VER < 70
locale loc;
#else
locale *loc; locale *loc;
#endif
} basic_streambuf_wchar; } basic_streambuf_wchar;
typedef struct { typedef struct {