Michael Stefaniuc : atl: Use an iface instead of a vtbl pointer in the Registrar object.

Alexandre Julliard julliard at winehq.org
Mon Nov 29 13:38:37 CST 2010


Module: wine
Branch: master
Commit: 0fd3f0a006fc6b1a5372f267a259505f512ab034
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0fd3f0a006fc6b1a5372f267a259505f512ab034

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Mon Nov 29 00:54:44 2010 +0100

atl: Use an iface instead of a vtbl pointer in the Registrar object.

---

 dlls/atl/registrar.c |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/dlls/atl/registrar.c b/dlls/atl/registrar.c
index 99dfe73..2188850 100644
--- a/dlls/atl/registrar.c
+++ b/dlls/atl/registrar.c
@@ -78,7 +78,7 @@ typedef struct rep_list_str {
 } rep_list;
 
 typedef struct {
-    const IRegistrarVtbl *lpVtbl;
+    IRegistrar IRegistrar_iface;
     LONG ref;
     rep_list *rep;
 } Registrar;
@@ -89,6 +89,11 @@ typedef struct {
     DWORD len;
 } strbuf;
 
+static inline Registrar *impl_from_IRegistrar(IRegistrar *iface)
+{
+    return CONTAINING_RECORD(iface, Registrar, IRegistrar_iface);
+}
+
 static void strbuf_init(strbuf *buf)
 {
     buf->str = HeapAlloc(GetProcessHeap(), 0, 128*sizeof(WCHAR));
@@ -549,7 +554,7 @@ static HRESULT WINAPI Registrar_QueryInterface(IRegistrar *iface, REFIID riid, v
 
 static ULONG WINAPI Registrar_AddRef(IRegistrar *iface)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
     TRACE("(%p) ->%d\n", This, ref);
     return ref;
@@ -557,7 +562,7 @@ static ULONG WINAPI Registrar_AddRef(IRegistrar *iface)
 
 static ULONG WINAPI Registrar_Release(IRegistrar *iface)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("(%p) ->%d\n", This, ref);
@@ -571,7 +576,7 @@ static ULONG WINAPI Registrar_Release(IRegistrar *iface)
 
 static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key, LPCOLESTR item)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     int len;
     rep_list *new_rep;
 
@@ -595,7 +600,7 @@ static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key,
 
 static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     rep_list *iter, *iter2;
 
     TRACE("(%p)\n", This);
@@ -619,7 +624,7 @@ static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
 static HRESULT WINAPI Registrar_ResourceRegisterSz(IRegistrar* iface, LPCOLESTR resFileName,
                 LPCOLESTR szID, LPCOLESTR szType)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
     return resource_register(This, resFileName, szID, szType, TRUE);
 }
@@ -627,35 +632,35 @@ static HRESULT WINAPI Registrar_ResourceRegisterSz(IRegistrar* iface, LPCOLESTR
 static HRESULT WINAPI Registrar_ResourceUnregisterSz(IRegistrar* iface, LPCOLESTR resFileName,
                 LPCOLESTR szID, LPCOLESTR szType)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
     return resource_register(This, resFileName, szID, szType, FALSE);
 }
 
 static HRESULT WINAPI Registrar_FileRegister(IRegistrar* iface, LPCOLESTR fileName)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s)\n", This, debugstr_w(fileName));
     return file_register(This, fileName, TRUE);
 }
 
 static HRESULT WINAPI Registrar_FileUnregister(IRegistrar* iface, LPCOLESTR fileName)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     FIXME("(%p)->(%s)\n", This, debugstr_w(fileName));
     return file_register(This, fileName, FALSE);
 }
 
 static HRESULT WINAPI Registrar_StringRegister(IRegistrar* iface, LPCOLESTR data)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s)\n", This, debugstr_w(data));
     return string_register(This, data, TRUE);
 }
 
 static HRESULT WINAPI Registrar_StringUnregister(IRegistrar* iface, LPCOLESTR data)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s)\n", This, debugstr_w(data));
     return string_register(This, data, FALSE);
 }
@@ -663,7 +668,7 @@ static HRESULT WINAPI Registrar_StringUnregister(IRegistrar* iface, LPCOLESTR da
 static HRESULT WINAPI Registrar_ResourceRegister(IRegistrar* iface, LPCOLESTR resFileName,
                 UINT nID, LPCOLESTR szType)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s %d %s)\n", iface, debugstr_w(resFileName), nID, debugstr_w(szType));
     return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, TRUE);
 }
@@ -671,7 +676,7 @@ static HRESULT WINAPI Registrar_ResourceRegister(IRegistrar* iface, LPCOLESTR re
 static HRESULT WINAPI Registrar_ResourceUnregister(IRegistrar* iface, LPCOLESTR resFileName,
                 UINT nID, LPCOLESTR szType)
 {
-    Registrar *This = (Registrar*)iface;
+    Registrar *This = impl_from_IRegistrar(iface);
     TRACE("(%p)->(%s %d %s)\n", This, debugstr_w(resFileName), nID, debugstr_w(szType));
     return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, FALSE);
 }
@@ -700,7 +705,7 @@ static HRESULT Registrar_create(const IUnknown *pUnkOuter, REFIID riid, void **p
         return E_NOINTERFACE;
 
     ret = HeapAlloc(GetProcessHeap(), 0, sizeof(Registrar));
-    ret->lpVtbl = &RegistrarVtbl;
+    ret->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
     ret->ref = 1;
     ret->rep = NULL;
     *ppvObject = ret;




More information about the wine-cvs mailing list