Huw Davies : riched20: Add ITextServices stdcall wrappers.

Alexandre Julliard julliard at winehq.org
Thu Mar 11 15:59:34 CST 2021


Module: wine
Branch: master
Commit: 7ea39932844ebafb0ef6eb60954b97ddf7b99793
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7ea39932844ebafb0ef6eb60954b97ddf7b99793

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Mar 11 08:50:59 2021 +0000

riched20: Add ITextServices stdcall wrappers.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.h  | 31 +++++++++++++++++++---
 dlls/riched20/editstr.h |  4 ---
 dlls/riched20/txthost.c |  8 +++---
 dlls/riched20/txtsrv.c  | 69 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 102 insertions(+), 10 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 38d99f4351a..ee2cde833c4 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -318,10 +318,11 @@ static inline ME_DisplayItem *cell_get_di(ME_Cell *cell)
 
 /* txthost.c */
 #ifdef __ASM_USE_THISCALL_WRAPPER
-#define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)
-#else /* __i386__ */
+extern const struct ITextHostVtbl text_host_stdcall_vtbl DECLSPEC_HIDDEN;
+#define TXTHOST_VTABLE(This) (&text_host_stdcall_vtbl)
+#else
 #define TXTHOST_VTABLE(This) (This)->lpVtbl
-#endif /* __i386__ */
+#endif
  /*** ITextHost methods ***/
 #define ITextHost_TxGetDC(This) TXTHOST_VTABLE(This)->TxGetDC(This)
 #define ITextHost_TxReleaseDC(This,a) TXTHOST_VTABLE(This)->TxReleaseDC(This,a)
@@ -379,6 +380,30 @@ 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
+extern const struct ITextServicesVtbl text_services_stdcall_vtbl DECLSPEC_HIDDEN;
+#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/editstr.h b/dlls/riched20/editstr.h
index 204e078c986..57dd45136af 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -49,10 +49,6 @@
 #include "wine/list.h"
 #include "wine/rbtree.h"
 
-#ifdef __ASM_USE_THISCALL_WRAPPER
-extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN;
-#endif /* __i386__ */
-
 typedef struct tagME_String
 {
   WCHAR *szData;
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index 291c9a3b677..51dccf3b7ed 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -584,7 +584,8 @@ DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
 DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
 DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
 
-const ITextHostVtbl itextHostStdcallVtbl = {
+const ITextHostVtbl text_host_stdcall_vtbl =
+{
     NULL,
     NULL,
     NULL,
@@ -629,9 +630,10 @@ const ITextHostVtbl itextHostStdcallVtbl = {
     STDCALL(ITextHostImpl_TxGetSelectionBarWidth),
 };
 
-#endif /* __i386__ */
+#endif /* __ASM_USE_THISCALL_WRAPPER */
 
-static const ITextHostVtbl textHostVtbl = {
+static const ITextHostVtbl textHostVtbl =
+{
     ITextHostImpl_QueryInterface,
     ITextHostImpl_AddRef,
     ITextHostImpl_Release,
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 =
 {




More information about the wine-cvs mailing list