From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcp90/cxx.h | 64 +++++++++++++++++++++++++++------------- dlls/msvcp90/exception.c | 8 ++--- dlls/msvcrt/cppexcept.h | 9 ------ dlls/msvcrt/cxx.h | 64 +++++++++++++++++++++++++++------------- 4 files changed, 90 insertions(+), 55 deletions(-)
diff --git a/dlls/msvcp90/cxx.h b/dlls/msvcp90/cxx.h index b803d35a283..64776822d9e 100644 --- a/dlls/msvcp90/cxx.h +++ b/dlls/msvcp90/cxx.h @@ -21,6 +21,15 @@ #include "rtlsupportapi.h" #include "wine/asm.h"
+#define CLASS_IS_SIMPLE_TYPE 1 +#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 +#define CLASS_IS_WINRT 8 + +#define TYPE_FLAG_CONST 1 +#define TYPE_FLAG_VOLATILE 2 +#define TYPE_FLAG_REFERENCE 8 +#define TYPE_FLAG_WINRT 16 + #ifdef __i386__ #undef CXX_USE_RVA #else @@ -139,63 +148,70 @@ static void init_ ## name ## _rtti(char *base) \
#ifndef CXX_USE_RVA
-#define DEFINE_CXX_TYPE(type, dtor, ...) \ +#define CXX_FUNC(func) THISCALL(func) +#define CXX_NULL NULL + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ static const cxx_type_info type ## _cxx_type_info[1] = \ - { { 0, &type ##_type_info, { 0, -1, 0 }, sizeof(type), THISCALL(type ##_copy_ctor) } }; \ + { { ti_flags, &type ##_type_info, { 0, -1, 0 }, sizeof(type), copyctor } }; \ \ static const cxx_type_info_table type ## _cxx_type_table = \ - { ARRAY_SIZE(((const void *[]){ NULL, __VA_ARGS__ })), { type ## _cxx_type_info, __VA_ARGS__ } }; \ + { ARRAY_SIZE(((const void *[]){ __VA_ARGS__ })), { __VA_ARGS__ } }; \ \ static const cxx_exception_type type ## _exception_type = \ - { 0, THISCALL(dtor), NULL, & type ## _cxx_type_table }; + { flags, dtor, NULL, & type ## _cxx_type_table };
#define INIT_CXX_TYPE(name,base) (void)name ## _exception_type
#elif defined __WINE_PE_BUILD
-#define DEFINE_CXX_TYPE2(type, dtor, ...) \ +#define CXX_FUNC(func) ".rva " #func +#define CXX_NULL ".long 0" + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ extern const cxx_type_info type ## _cxx_type_info[1]; \ extern const cxx_exception_type type ## _exception_type; \ void __asm_dummy_ ## type ## _exception_type(void) \ { \ asm( ".balign 4\n\t" \ __ASM_GLOBL(#type "_cxx_type_info") "\n\t" \ - ".long 0\n\t" \ + ".long %c0\n\t" \ ".rva " #type "_type_info\n\t" \ - ".long 0, -1, 0, %c0\n\t" \ - ".rva " #type "_copy_ctor\n" \ + ".long 0, -1, 0, %c1\n\t" \ + copyctor "\n\t" \ #type "_type_table:\n\t" \ - ".long %c1\n\t" \ + ".long %c2\n\t" \ ".rva " #__VA_ARGS__ "\n\t" \ __ASM_GLOBL(#type "_exception_type") "\n\t" \ - ".long 0\n\t" \ - ".rva " #dtor "\n\t" \ + ".long %c3\n\t" \ + dtor "\n\t" \ ".long 0\n\t" \ ".rva " #type "_type_table\n\t" \ - :: "i"(sizeof(type)), "i"(ARRAY_SIZE(((const void *[]){ &__VA_ARGS__ }))) ); \ + :: "i"(ti_flags), "i"(sizeof(type)), "i"(ARRAY_SIZE(((const void *[]){ &__VA_ARGS__ }))), "i"(flags) ); \ } -#define DEFINE_CXX_TYPE(type, dtor, ...) \ - DEFINE_CXX_TYPE2(type, dtor, type ## _cxx_type_info, ##__VA_ARGS__)
#define INIT_CXX_TYPE(name,base) /* nothing to do */
#else /* CXX_USE_RVA */
-#define DEFINE_CXX_TYPE(type, dtor, ...) \ +#define CXX_FUNC(func) func +#define CXX_NULL NULL + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ static cxx_type_info type ## _cxx_type_info[1] = \ - { { 0, 0xdeadbeef, { 0, -1, 0 }, sizeof(type), 0xdeadbeef } }; \ + { { ti_flags, 0xdeadbeef, { 0, -1, 0 }, sizeof(type), 0xdeadbeef } }; \ \ -static const void * const type ## _cxx_type_classes[] = { type ## _cxx_type_info, __VA_ARGS__ }; \ +static const void * const type ## _cxx_type_classes[] = { __VA_ARGS__ }; \ static cxx_type_info_table type ## _cxx_type_table = { ARRAY_SIZE(type ## _cxx_type_classes) }; \ -static cxx_exception_type type ##_exception_type; \ +static cxx_exception_type type ##_exception_type = {flags}; \ \ static void init_ ## type ## _cxx(char *base) \ { \ type ## _cxx_type_info[0].type_info = (char *)&type ## _type_info - base; \ - type ## _cxx_type_info[0].copy_ctor = (char *)type ## _copy_ctor - base; \ + type ## _cxx_type_info[0].copy_ctor = (copyctor) ? (char *)(copyctor) - base : 0; \ for (unsigned int i = 0; i < ARRAY_SIZE(type ## _cxx_type_classes); i++) \ type ## _cxx_type_table.info[i] = (char *)type ## _cxx_type_classes[i] - base; \ - type ## _exception_type.destructor = (char *)dtor - base; \ + type ## _exception_type.destructor = (dtor) ? (char *)(dtor) - base : 0; \ type ## _exception_type.type_info_table = (char *)&type ## _cxx_type_table - base; \ }
@@ -203,6 +219,14 @@ static void init_ ## type ## _cxx(char *base) \
#endif /* CXX_USE_RVA */
+#define DEFINE_CXX_TYPE(type, dtor, ...) \ + DEFINE_CXX_TYPE2(type, 0, 0, CXX_FUNC(dtor), CXX_FUNC(type ##_copy_ctor), \ + type ## _cxx_type_info, ##__VA_ARGS__) + +#define DEFINE_WINRT_CXX_TYPE(type, ...) \ + DEFINE_CXX_TYPE2(type, TYPE_FLAG_WINRT, CLASS_IS_SIMPLE_TYPE | CLASS_IS_WINRT, \ + CXX_NULL, CXX_NULL, type ## _cxx_type_info, ##__VA_ARGS__) + #ifdef __ASM_USE_THISCALL_WRAPPER
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index aef1268068c..ab8de5de782 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -41,10 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
CREATE_TYPE_INFO_VTABLE
-#define CLASS_IS_SIMPLE_TYPE 1 -#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 -#define CLASS_IS_IUNKNOWN 8 - int* __cdecl __processing_throw(void);
#if _MSVCP_VER >= 70 || defined(_MSVCIRT) @@ -1200,7 +1196,7 @@ static inline void copy_exception( void *object, void **dest, UINT catch_flags, { if (type->flags & CLASS_IS_SIMPLE_TYPE) { - if (type->flags & CLASS_IS_IUNKNOWN && *(IUnknown**)object) + if (type->flags & CLASS_IS_WINRT && *(IUnknown**)object) IUnknown_AddRef(*(IUnknown**)object); memmove( dest, object, type->size ); /* if it is a pointer, adjust it */ @@ -1216,7 +1212,7 @@ static inline void copy_exception( void *object, void **dest, UINT catch_flags, } else { - if (type->flags & CLASS_IS_IUNKNOWN && *(IUnknown**)object) + if (type->flags & CLASS_IS_WINRT && *(IUnknown**)object) IUnknown_AddRef(*(IUnknown**)object); memmove( dest, get_this_pointer( &type->offsets, object ), type->size ); } diff --git a/dlls/msvcrt/cppexcept.h b/dlls/msvcrt/cppexcept.h index 0f64f97dd20..cf9e7a25cbc 100644 --- a/dlls/msvcrt/cppexcept.h +++ b/dlls/msvcrt/cppexcept.h @@ -133,15 +133,6 @@ typedef struct #define FUNC_DESCR_SYNCHRONOUS 1 /* synchronous exceptions only (built with /EHs and /EHsc) */ #define FUNC_DESCR_NOEXCEPT 4 /* noexcept function */
-#define CLASS_IS_SIMPLE_TYPE 1 -#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 -#define CLASS_IS_WINRT 8 - -#define TYPE_FLAG_CONST 1 -#define TYPE_FLAG_VOLATILE 2 -#define TYPE_FLAG_REFERENCE 8 -#define TYPE_FLAG_WINRT 16 - typedef struct winrt_exception_info { BSTR description; diff --git a/dlls/msvcrt/cxx.h b/dlls/msvcrt/cxx.h index b803d35a283..64776822d9e 100644 --- a/dlls/msvcrt/cxx.h +++ b/dlls/msvcrt/cxx.h @@ -21,6 +21,15 @@ #include "rtlsupportapi.h" #include "wine/asm.h"
+#define CLASS_IS_SIMPLE_TYPE 1 +#define CLASS_HAS_VIRTUAL_BASE_CLASS 4 +#define CLASS_IS_WINRT 8 + +#define TYPE_FLAG_CONST 1 +#define TYPE_FLAG_VOLATILE 2 +#define TYPE_FLAG_REFERENCE 8 +#define TYPE_FLAG_WINRT 16 + #ifdef __i386__ #undef CXX_USE_RVA #else @@ -139,63 +148,70 @@ static void init_ ## name ## _rtti(char *base) \
#ifndef CXX_USE_RVA
-#define DEFINE_CXX_TYPE(type, dtor, ...) \ +#define CXX_FUNC(func) THISCALL(func) +#define CXX_NULL NULL + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ static const cxx_type_info type ## _cxx_type_info[1] = \ - { { 0, &type ##_type_info, { 0, -1, 0 }, sizeof(type), THISCALL(type ##_copy_ctor) } }; \ + { { ti_flags, &type ##_type_info, { 0, -1, 0 }, sizeof(type), copyctor } }; \ \ static const cxx_type_info_table type ## _cxx_type_table = \ - { ARRAY_SIZE(((const void *[]){ NULL, __VA_ARGS__ })), { type ## _cxx_type_info, __VA_ARGS__ } }; \ + { ARRAY_SIZE(((const void *[]){ __VA_ARGS__ })), { __VA_ARGS__ } }; \ \ static const cxx_exception_type type ## _exception_type = \ - { 0, THISCALL(dtor), NULL, & type ## _cxx_type_table }; + { flags, dtor, NULL, & type ## _cxx_type_table };
#define INIT_CXX_TYPE(name,base) (void)name ## _exception_type
#elif defined __WINE_PE_BUILD
-#define DEFINE_CXX_TYPE2(type, dtor, ...) \ +#define CXX_FUNC(func) ".rva " #func +#define CXX_NULL ".long 0" + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ extern const cxx_type_info type ## _cxx_type_info[1]; \ extern const cxx_exception_type type ## _exception_type; \ void __asm_dummy_ ## type ## _exception_type(void) \ { \ asm( ".balign 4\n\t" \ __ASM_GLOBL(#type "_cxx_type_info") "\n\t" \ - ".long 0\n\t" \ + ".long %c0\n\t" \ ".rva " #type "_type_info\n\t" \ - ".long 0, -1, 0, %c0\n\t" \ - ".rva " #type "_copy_ctor\n" \ + ".long 0, -1, 0, %c1\n\t" \ + copyctor "\n\t" \ #type "_type_table:\n\t" \ - ".long %c1\n\t" \ + ".long %c2\n\t" \ ".rva " #__VA_ARGS__ "\n\t" \ __ASM_GLOBL(#type "_exception_type") "\n\t" \ - ".long 0\n\t" \ - ".rva " #dtor "\n\t" \ + ".long %c3\n\t" \ + dtor "\n\t" \ ".long 0\n\t" \ ".rva " #type "_type_table\n\t" \ - :: "i"(sizeof(type)), "i"(ARRAY_SIZE(((const void *[]){ &__VA_ARGS__ }))) ); \ + :: "i"(ti_flags), "i"(sizeof(type)), "i"(ARRAY_SIZE(((const void *[]){ &__VA_ARGS__ }))), "i"(flags) ); \ } -#define DEFINE_CXX_TYPE(type, dtor, ...) \ - DEFINE_CXX_TYPE2(type, dtor, type ## _cxx_type_info, ##__VA_ARGS__)
#define INIT_CXX_TYPE(name,base) /* nothing to do */
#else /* CXX_USE_RVA */
-#define DEFINE_CXX_TYPE(type, dtor, ...) \ +#define CXX_FUNC(func) func +#define CXX_NULL NULL + +#define DEFINE_CXX_TYPE2(type, flags, ti_flags, dtor, copyctor, ...) \ static cxx_type_info type ## _cxx_type_info[1] = \ - { { 0, 0xdeadbeef, { 0, -1, 0 }, sizeof(type), 0xdeadbeef } }; \ + { { ti_flags, 0xdeadbeef, { 0, -1, 0 }, sizeof(type), 0xdeadbeef } }; \ \ -static const void * const type ## _cxx_type_classes[] = { type ## _cxx_type_info, __VA_ARGS__ }; \ +static const void * const type ## _cxx_type_classes[] = { __VA_ARGS__ }; \ static cxx_type_info_table type ## _cxx_type_table = { ARRAY_SIZE(type ## _cxx_type_classes) }; \ -static cxx_exception_type type ##_exception_type; \ +static cxx_exception_type type ##_exception_type = {flags}; \ \ static void init_ ## type ## _cxx(char *base) \ { \ type ## _cxx_type_info[0].type_info = (char *)&type ## _type_info - base; \ - type ## _cxx_type_info[0].copy_ctor = (char *)type ## _copy_ctor - base; \ + type ## _cxx_type_info[0].copy_ctor = (copyctor) ? (char *)(copyctor) - base : 0; \ for (unsigned int i = 0; i < ARRAY_SIZE(type ## _cxx_type_classes); i++) \ type ## _cxx_type_table.info[i] = (char *)type ## _cxx_type_classes[i] - base; \ - type ## _exception_type.destructor = (char *)dtor - base; \ + type ## _exception_type.destructor = (dtor) ? (char *)(dtor) - base : 0; \ type ## _exception_type.type_info_table = (char *)&type ## _cxx_type_table - base; \ }
@@ -203,6 +219,14 @@ static void init_ ## type ## _cxx(char *base) \
#endif /* CXX_USE_RVA */
+#define DEFINE_CXX_TYPE(type, dtor, ...) \ + DEFINE_CXX_TYPE2(type, 0, 0, CXX_FUNC(dtor), CXX_FUNC(type ##_copy_ctor), \ + type ## _cxx_type_info, ##__VA_ARGS__) + +#define DEFINE_WINRT_CXX_TYPE(type, ...) \ + DEFINE_CXX_TYPE2(type, TYPE_FLAG_WINRT, CLASS_IS_SIMPLE_TYPE | CLASS_IS_WINRT, \ + CXX_NULL, CXX_NULL, type ## _cxx_type_info, ##__VA_ARGS__) + #ifdef __ASM_USE_THISCALL_WRAPPER
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args