msvcp90: Added macro to call functions from vtable.

This commit is contained in:
Piotr Caban 2011-12-20 15:56:42 +01:00 committed by Alexandre Julliard
parent b83c587f6e
commit ddebdbf1e6
3 changed files with 28 additions and 19 deletions

View File

@ -117,6 +117,8 @@ void __thiscall locale_facet_dtor(locale_facet *this)
} }
DEFINE_THISCALL_WRAPPER(MSVCP_locale_facet_vector_dtor, 8) DEFINE_THISCALL_WRAPPER(MSVCP_locale_facet_vector_dtor, 8)
#define call_locale_facet_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0, \
locale_facet*, (locale_facet*, unsigned int), (this, flags))
locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsigned int flags) locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
{ {
TRACE("(%p %x)\n", this, flags); TRACE("(%p %x)\n", this, flags);
@ -139,25 +141,6 @@ locale_facet* __thiscall MSVCP_locale_facet_vector_dtor(locale_facet *this, unsi
const vtable_ptr MSVCP_locale_facet_vtable[] = { const vtable_ptr MSVCP_locale_facet_vtable[] = {
(vtable_ptr)THISCALL_NAME(MSVCP_locale_facet_vector_dtor) (vtable_ptr)THISCALL_NAME(MSVCP_locale_facet_vector_dtor)
}; };
#ifdef __i386__
static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
{
locale_facet *ret;
void *dummy;
__asm__ __volatile__ ("pushl %3\n\tcall *%2"
: "=a" (ret), "=c" (dummy)
: "r" (this->vtable[0]), "r" (flags), "1" (this)
: "edx", "memory" );
return ret;
}
#else
static inline locale_facet* call_locale_facet_vector_dtor(locale_facet *this, unsigned int flags)
{
locale_facet * (__thiscall *dtor)(locale_facet *, unsigned int) = (void *)this->vtable[0];
return dtor(this, flags);
}
#endif
/* ??0id@locale@std@@QAE@I@Z */ /* ??0id@locale@std@@QAE@I@Z */
/* ??0id@locale@std@@QEAA@_K@Z */ /* ??0id@locale@std@@QEAA@_K@Z */

View File

@ -130,6 +130,18 @@ const rtti_object_locator name ## _rtti = { \
&name ## _hierarchy \ &name ## _hierarchy \
} }
#ifdef __i386__
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
extern void *vtbl_wrapper_0;
#else
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__cdecl***)type)this)[0][off/4]args
#endif
/* exception object */ /* exception object */
typedef void (*vtable_ptr)(void); typedef void (*vtable_ptr)(void);
typedef struct __exception typedef struct __exception

View File

@ -28,6 +28,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcp90); WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
#ifdef __i386__
#define DEFINE_VTBL_WRAPPER(off) \
__ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
"popl %eax\n\t" \
"popl %ecx\n\t" \
"pushl %eax\n\t" \
"movl 0(%ecx), %eax\n\t" \
"jmp *" #off "(%eax)\n\t")
DEFINE_VTBL_WRAPPER(0);
#endif
void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t); void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
void (__cdecl *MSVCRT_operator_delete)(void*); void (__cdecl *MSVCRT_operator_delete)(void*);
void* (__cdecl *MSVCRT_set_new_handler)(void*); void* (__cdecl *MSVCRT_set_new_handler)(void*);