Module: wine Branch: master Commit: 1c8bad803770ff0df36bcae71183fe19a77088f8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c8bad803770ff0df36bcae711...
Author: Michael Stefaniuc mstefani@redhat.de Date: Thu Apr 28 00:48:47 2011 +0200
shdocvw: COM cleanup in shlinstobj.c.
---
dlls/shdocvw/shlinstobj.c | 66 ++++++++++++++++++++++++++------------------- 1 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/dlls/shdocvw/shlinstobj.c b/dlls/shdocvw/shlinstobj.c index 63bf0e6..921a909 100644 --- a/dlls/shdocvw/shlinstobj.c +++ b/dlls/shdocvw/shlinstobj.c @@ -40,8 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
-#define ADJUST_THIS(c,m,p) ((c*)(((long)p)-(long)&(((c*)0)->lp##m##Vtbl))) -#define STATIC_CAST(i,p) ((i*)&p->lp##i##Vtbl) #define CHARS_IN_GUID 39
/****************************************************************************** @@ -50,11 +48,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); * Gives access to a registry key's values via the IPropertyBag interface. */ typedef struct _RegistryPropertyBag { - const IPropertyBagVtbl *lpIPropertyBagVtbl; + IPropertyBag IPropertyBag_iface; LONG m_cRef; HKEY m_hInitPropertyBagKey; } RegistryPropertyBag;
+static inline RegistryPropertyBag *impl_from_IPropertyBag(IPropertyBag *iface) +{ + return CONTAINING_RECORD(iface, RegistryPropertyBag, IPropertyBag_iface); +} + static void RegistryPropertyBag_Destroy(RegistryPropertyBag *This) { TRACE("This=%p)\n", This);
@@ -65,7 +68,7 @@ static void RegistryPropertyBag_Destroy(RegistryPropertyBag *This) { static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface, REFIID riid, void **ppv) { - RegistryPropertyBag *This = ADJUST_THIS(RegistryPropertyBag, IPropertyBag, iface); + RegistryPropertyBag *This = impl_from_IPropertyBag(iface);
TRACE("(iface=%p, riid=%s, ppv=%p)\n", iface, debugstr_guid(riid), ppv);
@@ -73,7 +76,7 @@ static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyB return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IPropertyBag, riid)) { - *ppv = STATIC_CAST(IPropertyBag, This); + *ppv = &This->IPropertyBag_iface; } else { *ppv = NULL; return E_NOINTERFACE; @@ -83,8 +86,9 @@ static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyB return S_OK; }
-static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef(IPropertyBag *iface) { - RegistryPropertyBag *This = ADJUST_THIS(RegistryPropertyBag, IPropertyBag, iface); +static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef(IPropertyBag *iface) +{ + RegistryPropertyBag *This = impl_from_IPropertyBag(iface); ULONG cRef;
TRACE("(iface=%p)\n", iface); @@ -97,8 +101,9 @@ static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef(IPropertyBag *iface) return cRef; }
-static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release(IPropertyBag *iface) { - RegistryPropertyBag *This = ADJUST_THIS(RegistryPropertyBag, IPropertyBag, iface); +static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release(IPropertyBag *iface) +{ + RegistryPropertyBag *This = impl_from_IPropertyBag(iface); ULONG cRef;
TRACE("(iface=%p)\n", iface); @@ -116,7 +121,7 @@ static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release(IPropertyBag *iface static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read(IPropertyBag *iface, LPCOLESTR pwszPropName, VARIANT *pVar, IErrorLog *pErrorLog) { - RegistryPropertyBag *This = ADJUST_THIS(RegistryPropertyBag, IPropertyBag, iface); + RegistryPropertyBag *This = impl_from_IPropertyBag(iface); WCHAR *pwszValue; DWORD dwType, cbData; LONG res; @@ -178,15 +183,15 @@ static HRESULT RegistryPropertyBag_Constructor(HKEY hInitPropertyBagKey, REFIID
pRegistryPropertyBag = heap_alloc(sizeof(RegistryPropertyBag)); if (pRegistryPropertyBag) { - pRegistryPropertyBag->lpIPropertyBagVtbl = &RegistryPropertyBag_IPropertyBagVtbl; + pRegistryPropertyBag->IPropertyBag_iface.lpVtbl = &RegistryPropertyBag_IPropertyBagVtbl; pRegistryPropertyBag->m_cRef = 0; pRegistryPropertyBag->m_hInitPropertyBagKey = hInitPropertyBagKey;
/* The clasping AddRef/Release is for the case that QueryInterface fails, which will result * in a reference count of 0 in the Release call, which will result in object destruction.*/ - IPropertyBag_AddRef(STATIC_CAST(IPropertyBag, pRegistryPropertyBag)); - hr = IPropertyBag_QueryInterface(STATIC_CAST(IPropertyBag, pRegistryPropertyBag), riid, ppvObject); - IPropertyBag_Release(STATIC_CAST(IPropertyBag, pRegistryPropertyBag)); + IPropertyBag_AddRef(&pRegistryPropertyBag->IPropertyBag_iface); + hr = IPropertyBag_QueryInterface(&pRegistryPropertyBag->IPropertyBag_iface, riid, ppvObject); + IPropertyBag_Release(&pRegistryPropertyBag->IPropertyBag_iface); }
return hr; @@ -198,21 +203,26 @@ static HRESULT RegistryPropertyBag_Constructor(HKEY hInitPropertyBagKey, REFIID * values of a PropertyBag. */ typedef struct _InstanceObjectFactory { - const IClassFactoryVtbl *lpIClassFactoryVtbl; + IClassFactory IClassFactory_iface; LONG m_cRef; CLSID m_clsidInstance; /* CLSID of the objects to create. */ IPropertyBag *m_pPropertyBag; /* PropertyBag to initialize those objects. */ } InstanceObjectFactory;
+static inline InstanceObjectFactory *impl_from_IClassFactory(IClassFactory *iface) +{ + return CONTAINING_RECORD(iface, InstanceObjectFactory, IClassFactory_iface); +} + static void InstanceObjectFactory_Destroy(InstanceObjectFactory *This) { IPropertyBag_Release(This->m_pPropertyBag); heap_free(This); }
-static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, - REFIID riid, LPVOID* ppv) +static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, + REFIID riid, void **ppv) { - InstanceObjectFactory *This = ADJUST_THIS(InstanceObjectFactory, IClassFactory, iface); + InstanceObjectFactory *This = impl_from_IClassFactory(iface);
TRACE("iface=%p, riid=%s, ppv=%p)\n", iface, debugstr_guid(riid), ppv);
@@ -220,7 +230,7 @@ static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassF return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IClassFactory, riid)) { - *ppv = STATIC_CAST(IClassFactory, This); + *ppv = &This->IClassFactory_iface; } else { *ppv = NULL; return E_NOINTERFACE; @@ -232,7 +242,7 @@ static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassF
static ULONG WINAPI InstanceObjectFactory_IClassFactory_AddRef(IClassFactory *iface) { - InstanceObjectFactory *This = ADJUST_THIS(InstanceObjectFactory, IClassFactory, iface); + InstanceObjectFactory *This = impl_from_IClassFactory(iface); ULONG cRef;
TRACE("(iface=%p)\n", iface); @@ -247,7 +257,7 @@ static ULONG WINAPI InstanceObjectFactory_IClassFactory_AddRef(IClassFactory *if
static ULONG WINAPI InstanceObjectFactory_IClassFactory_Release(IClassFactory *iface) { - InstanceObjectFactory *This = ADJUST_THIS(InstanceObjectFactory, IClassFactory, iface); + InstanceObjectFactory *This = impl_from_IClassFactory(iface); ULONG cRef;
TRACE("(iface=%p)\n", iface); @@ -265,12 +275,12 @@ static ULONG WINAPI InstanceObjectFactory_IClassFactory_Release(IClassFactory *i static HRESULT WINAPI InstanceObjectFactory_IClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObj) { - InstanceObjectFactory *This = ADJUST_THIS(InstanceObjectFactory, IClassFactory, iface); + InstanceObjectFactory *This = impl_from_IClassFactory(iface); IPersistPropertyBag *pPersistPropertyBag; HRESULT hr; - + TRACE("(pUnkOuter=%p, riid=%s, ppvObj=%p)\n", pUnkOuter, debugstr_guid(riid), ppvObj); - + hr = CoCreateInstance(&This->m_clsidInstance, NULL, CLSCTX_INPROC_SERVER, &IID_IPersistPropertyBag, (LPVOID*)&pPersistPropertyBag); if (FAILED(hr)) { @@ -324,16 +334,16 @@ static HRESULT InstanceObjectFactory_Constructor(REFCLSID rclsid, IPropertyBag *
pInstanceObjectFactory = heap_alloc(sizeof(InstanceObjectFactory)); if (pInstanceObjectFactory) { - pInstanceObjectFactory->lpIClassFactoryVtbl = &InstanceObjectFactory_IClassFactoryVtbl; + pInstanceObjectFactory->IClassFactory_iface.lpVtbl = &InstanceObjectFactory_IClassFactoryVtbl; pInstanceObjectFactory->m_cRef = 0; pInstanceObjectFactory->m_clsidInstance = *rclsid; pInstanceObjectFactory->m_pPropertyBag = pPropertyBag; IPropertyBag_AddRef(pPropertyBag);
- IClassFactory_AddRef(STATIC_CAST(IClassFactory, pInstanceObjectFactory)); - hr = IClassFactory_QueryInterface(STATIC_CAST(IClassFactory, pInstanceObjectFactory), + IClassFactory_AddRef(&pInstanceObjectFactory->IClassFactory_iface); + hr = IClassFactory_QueryInterface(&pInstanceObjectFactory->IClassFactory_iface, riid, ppvObject); - IClassFactory_Release(STATIC_CAST(IClassFactory, pInstanceObjectFactory)); + IClassFactory_Release(&pInstanceObjectFactory->IClassFactory_iface); }
return hr;