riched20: Remove the unneeded DEFINE_STDCALL_WRAPPER.

Dylan Smith dylan.ah.smith at gmail.com
Thu Apr 7 12:00:16 CDT 2011


On Thu, Apr 7, 2011 at 12:17 PM, Michael Stefaniuc <mstefani at redhat.com> wrote:
>
> Dylan Smith wrote:
> > On Thu, Apr 7, 2011 at 5:30 AM, Michael Stefaniuc <mstefani at redhat.de>wrote:
> >
> >> The COM methods are already __stdcall.
> >> ---
> >>  dlls/riched20/txthost.c |  128
> >> ++++++++++++++--------------------------------
> >>  1 files changed, 39 insertions(+), 89 deletions(-)
> >>
> >> COM methods are supposed to use the stdcall calling convention, but the
> > native riched20 and the native headers just defines ITextHost and
> > ITextServices to be a c++ class (i.e. using the thiscall calling
> > convention).  Just look at the native TextServ.h header.
> Right, but for that you have the textHostVtbl with the THISCALL() wrapper.
>
> The itextHostStdcallVtbl is just for the C COM macros used from Wine
> code as calling a thiscall function from Wine is a PITA. That is handled
> in editor.h:
> #ifdef __i386__ /* Use wrappers to perform thiscall on i386 */
> #define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)
> #else /* __i386__ */
> #define TXTHOST_VTABLE(This) (This)->lpVtbl
> #endif /* __i386__ */
>  /*** ITextHost methods ***/
> #define ITextHost_TxGetDC(This) TXTHOST_VTABLE(This)->TxGetDC(This)
> #define ITextHost_TxReleaseDC(This,a)
> TXTHOST_VTABLE(This)->TxReleaseDC(This,a)
> ...
>
> On i386 Wine is calling functions from the static itextHostStdcallVtbl
> and those functions are not thiscall. Of course I might miss something
> as that code is mind warping...
>

I'll try to explain.

The ITextHost interface may be user provided for windowless richedit
controls, but for windowed richedit controls the internal
ITextHostImpl implementation is used.  They both must be defined using
the thiscall calling convention, so in wine ITextHostImpl has a set of
thunks to fill the textHostVtbl that perform thiscall->stdcall
conversion before jumping to the stdcall defined methods.

The rest of the richedit code needs to call the ITextHost interface
using the thiscall calling convention, so on i386 it calls a thunk in
itextHostStdcallVtbl which are defined using the stdcall calling
convention, and perform stdcall->thiscall conversion before jumping to
the thiscall defined method (i.e. the actual method for user provided
ITextHost, and a thunk to reverse the calling convention in Wine).



More information about the wine-devel mailing list