[PATCH 1/5] riched20: Add ITextServices stdcall wrappers.

Huw Davies huw at codeweavers.com
Wed Mar 10 03:31:16 CST 2021


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/editor.h | 23 ++++++++++++++
 dlls/riched20/txtsrv.c | 69 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 38d99f4351a..5d4b360c1bb 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -379,6 +379,29 @@ void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 
 /* txtsrv.c */
 HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10, ME_TextEditor **editor ) DECLSPEC_HIDDEN;
+#ifdef __ASM_USE_THISCALL_WRAPPER
+#define TXTSERV_VTABLE(This) (&text_services_stdcall_vtbl)
+#else
+#define TXTSERV_VTABLE(This) (This)->lpVtbl
+#endif
+#define ITextServices_TxSendMessage(This,a,b,c,d) TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)
+#define ITextServices_TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l) TXTSERV_VTABLE(This)->ITextServices_TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l)
+#define ITextServices_TxGetHScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)
+#define ITextServices_TxGetVScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)
+#define ITextServices_OnTxSetCursor(This,a,b,c,d,e,f,g,h,i) TXTSERV_VTABLE(This)->OnTxSetCursor(This,a,b,c,d,e,f,g,h,i)
+#define ITextServices_TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j) TXTSERV_VTABLE(This)->TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j)
+#define ITextServices_OnTxInplaceActivate(This,a) TXTSERV_VTABLE(This)->OnTxInplaceActivate(This,a)
+#define ITextServices_OnTxInplaceDeactivate(This) TXTSERV_VTABLE(This)->OnTxInplaceDeactivate(This)
+#define ITextServices_OnTxUIActivate(This) TXTSERV_VTABLE(This)->OnTxUIActivate(This)
+#define ITextServices_OnTxUIDeactivate(This) TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)
+#define ITextServices_TxGetText(This,a) TXTSERV_VTABLE(This)->TxGetText(This,a)
+#define ITextServices_TxSetText(This,a) TXTSERV_VTABLE(This)->TxSetText(This,a)
+#define ITextServices_TxGetCurTargetX(This,a) TXTSERV_VTABLE(This)->TxGetCurTargetX(This,a)
+#define ITextServices_TxGetBaseLinePos(This,a) TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)
+#define ITextServices_TxGetNaturalSize(This,a,b,c,d,e,f,g,h) TXTSERV_VTABLE(This)->TxGetNaturalSize(This,a,b,c,d,e,f,g,h)
+#define ITextServices_TxGetDropTarget(This,a) TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)
+#define ITextServices_OnTxPropertyBitsChange(This,a,b) TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)
+#define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)
 
 /* writer.c */
 LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 49d1c706076..7893888af57 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -339,6 +339,75 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *ifac
     return E_NOTIMPL;
 }
 
+#ifdef __ASM_USE_THISCALL_WRAPPER
+
+#define STDCALL(func) (void *) __stdcall_ ## func
+#ifdef _MSC_VER
+#define DEFINE_STDCALL_WRAPPER(num,func) \
+    __declspec(naked) HRESULT __stdcall_##func(void) \
+    { \
+        __asm pop eax \
+        __asm pop ecx \
+        __asm push eax \
+        __asm mov eax, [ecx] \
+        __asm jmp dword ptr [eax + 4*num] \
+    }
+#else /* _MSC_VER */
+#define DEFINE_STDCALL_WRAPPER(num,func) \
+   extern HRESULT __stdcall_ ## func(void); \
+   __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
+                   "popl %eax\n\t" \
+                   "popl %ecx\n\t" \
+                   "pushl %eax\n\t" \
+                   "movl (%ecx), %eax\n\t" \
+                   "jmp *(4*(" #num "))(%eax)" )
+#endif /* _MSC_VER */
+
+DEFINE_STDCALL_WRAPPER(3, ITextServices_TxSendMessage)
+DEFINE_STDCALL_WRAPPER(4, ITextServices_TxDraw)
+DEFINE_STDCALL_WRAPPER(5, ITextServices_TxGetHScroll)
+DEFINE_STDCALL_WRAPPER(6, ITextServices_TxGetVScroll)
+DEFINE_STDCALL_WRAPPER(7, ITextServices_OnTxSetCursor)
+DEFINE_STDCALL_WRAPPER(8, ITextServices_TxQueryHitPoint)
+DEFINE_STDCALL_WRAPPER(9, ITextServices_OnTxInplaceActivate)
+DEFINE_STDCALL_WRAPPER(10, ITextServices_OnTxInplaceDeactivate)
+DEFINE_STDCALL_WRAPPER(11, ITextServices_OnTxUIActivate)
+DEFINE_STDCALL_WRAPPER(12, ITextServices_OnTxUIDeactivate)
+DEFINE_STDCALL_WRAPPER(13, ITextServices_TxGetText)
+DEFINE_STDCALL_WRAPPER(14, ITextServices_TxSetText)
+DEFINE_STDCALL_WRAPPER(15, ITextServices_TxGetCurTargetX)
+DEFINE_STDCALL_WRAPPER(16, ITextServices_TxGetBaseLinePos)
+DEFINE_STDCALL_WRAPPER(17, ITextServices_TxGetNaturalSize)
+DEFINE_STDCALL_WRAPPER(18, ITextServices_TxGetDropTarget)
+DEFINE_STDCALL_WRAPPER(19, ITextServices_OnTxPropertyBitsChange)
+DEFINE_STDCALL_WRAPPER(20, ITextServices_TxGetCachedSize)
+
+const ITextServicesVtbl text_services_stdcall_vtbl =
+{
+    NULL,
+    NULL,
+    NULL,
+    STDCALL(ITextServices_TxSendMessage),
+    STDCALL(ITextServices_TxDraw),
+    STDCALL(ITextServices_TxGetHScroll),
+    STDCALL(ITextServices_TxGetVScroll),
+    STDCALL(ITextServices_OnTxSetCursor),
+    STDCALL(ITextServices_TxQueryHitPoint),
+    STDCALL(ITextServices_OnTxInplaceActivate),
+    STDCALL(ITextServices_OnTxInplaceDeactivate),
+    STDCALL(ITextServices_OnTxUIActivate),
+    STDCALL(ITextServices_OnTxUIDeactivate),
+    STDCALL(ITextServices_TxGetText),
+    STDCALL(ITextServices_TxSetText),
+    STDCALL(ITextServices_TxGetCurTargetX),
+    STDCALL(ITextServices_TxGetBaseLinePos),
+    STDCALL(ITextServices_TxGetNaturalSize),
+    STDCALL(ITextServices_TxGetDropTarget),
+    STDCALL(ITextServices_OnTxPropertyBitsChange),
+    STDCALL(ITextServices_TxGetCachedSize),
+};
+
+#endif /* __ASM_USE_THISCALL_WRAPPER */
 
 static const ITextServicesVtbl textservices_vtbl =
 {
-- 
2.23.0




More information about the wine-devel mailing list