On Sat, Feb 11, 2012 at 2:27 PM, Maarten Lankhorst <span dir="ltr"><<a href="mailto:m.b.lankhorst@gmail.com">m.b.lankhorst@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5"><blockquote type="cite"><div class="gmail_quote">
      </div>
    </blockquote></div></div>
    Are you sure? I don't see any example calls being wrapped to
    ITextHost for example..</div></blockquote><div><br></div><div>�Yup, I worked on it myself. �All those ITextHost_*(...), which you can easily grep for in editor.c, are using macros in editor.h:</div><div><br class="Apple-interchange-newline">

--- snip ---</div><div>#ifdef __i386__ /* Use wrappers to perform thiscall on i386 */</div><div><div>#define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)</div><div>#else /* __i386__ */</div><div>#define TXTHOST_VTABLE(This) (This)->lpVtbl</div>

<div>#endif /* __i386__ */</div><div>�/*** ITextHost methods ***/</div><div>#define ITextHost_TxGetDC(This) TXTHOST_VTABLE(This)->TxGetDC(This)</div></div><div>...</div>--- end snip ---<div><br></div><div>So for i386 it will use the itextHostStdcallVtbl, which is defined in txthost.c to pop the This pointer off the stack and into a register, then grab the pointer to the vtable, and jump to the thiscall method.</div>

<div><br class="Apple-interchange-newline">--- snip ---</div><div><div>#define STDCALL(func) __stdcall_ ## func</div><div>#define DEFINE_STDCALL_WRAPPER(num,func,args) \</div><div>� �extern typeof(func) __stdcall_ ## func; \</div>

<div>� �__ASM_STDCALL_FUNC(__stdcall_ ## func, args, \</div><div>� � � � � � � � � �"popl %eax\n\t" \</div><div>� � � � � � � � � �"popl %ecx\n\t" \</div><div>� � � � � � � � � �"pushl %eax\n\t" \</div>

<div>� � � � � � � � � �"movl (%ecx), %eax\n\t" \</div><div>� � � � � � � � � �"jmp *(4*(" #num "))(%eax)" )</div></div><div><br></div><div><div>DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)</div>

</div><div>...</div><div><br></div><div><div>const ITextHostVtbl itextHostStdcallVtbl = {</div><div>� � NULL,</div><div>� � NULL,</div><div>� � NULL,</div><div>� � __stdcall_ITextHostImpl_TxGetDC,</div></div><div>...</div>

<div>--- end snip ---</div><div><br></div><div>The ITextHost interface is also implemented in txthost.c for non-windowless richedit controls. �That interface is implemented using thiscall wrappers which do the reverse of the standard call wrappers.</div>

</div>