Michael Stefaniuc : itss: Standardize the COM usage in moniker.c.
Alexandre Julliard
julliard at winehq.org
Sun Dec 5 12:10:08 CST 2010
Module: wine
Branch: master
Commit: 72f3765a5bea13c28d0b60f527c030bc0b824b32
URL: http://source.winehq.org/git/wine.git/?a=commit;h=72f3765a5bea13c28d0b60f527c030bc0b824b32
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Sun Dec 5 15:14:46 2010 +0100
itss: Standardize the COM usage in moniker.c.
---
dlls/itss/moniker.c | 40 +++++++++++++++++++++++++---------------
1 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/dlls/itss/moniker.c b/dlls/itss/moniker.c
index 76630cd..72d356b 100644
--- a/dlls/itss/moniker.c
+++ b/dlls/itss/moniker.c
@@ -43,19 +43,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss);
/*****************************************************************************/
typedef struct {
- const IMonikerVtbl *vtbl_ITS_IMoniker;
+ IMoniker IMoniker_iface;
LONG ref;
LPWSTR szHtml;
WCHAR szFile[1];
} ITS_IMonikerImpl;
+static inline ITS_IMonikerImpl *impl_from_IMoniker(IMoniker *iface)
+{
+ return CONTAINING_RECORD(iface, ITS_IMonikerImpl, IMoniker_iface);
+}
+
/*** IUnknown methods ***/
static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface(
IMoniker* iface,
REFIID riid,
void** ppvObject)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IParseDisplayName))
@@ -72,7 +77,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface(
static ULONG WINAPI ITS_IMonikerImpl_AddRef(
IMoniker* iface)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("%p\n", This);
return InterlockedIncrement(&This->ref);
}
@@ -80,7 +85,7 @@ static ULONG WINAPI ITS_IMonikerImpl_AddRef(
static ULONG WINAPI ITS_IMonikerImpl_Release(
IMoniker* iface)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
@@ -96,7 +101,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetClassID(
IMoniker* iface,
CLSID* pClassID)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("%p %p\n", This, pClassID);
*pClassID = CLSID_ITStorage;
@@ -155,7 +160,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_BindToStorage(
REFIID riid,
void** ppvObj)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE;
HRESULT r;
IStorage *stg = NULL;
@@ -279,7 +284,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName(
IMoniker* pmkToLeft,
LPOLESTR* ppszDisplayName)
{
- ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
+ ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
static const WCHAR szFormat[] = {
'm','s','-','i','t','s',':','%','s',':',':','%','s',0 };
DWORD len = sizeof szFormat / sizeof(WCHAR);
@@ -352,7 +357,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n )
sz = sizeof(ITS_IMonikerImpl) + strlenW( name )*sizeof(WCHAR);
itsmon = HeapAlloc( GetProcessHeap(), 0, sz );
- itsmon->vtbl_ITS_IMoniker = &ITS_IMonikerImpl_Vtbl;
+ itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl;
itsmon->ref = 1;
strcpyW( itsmon->szFile, name );
itsmon->szHtml = &itsmon->szFile[n];
@@ -362,7 +367,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n )
TRACE("-> %p %s %s\n", itsmon,
debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) );
- *ppObj = (IMoniker*) itsmon;
+ *ppObj = &itsmon->IMoniker_iface;
ITSS_LockModule();
return S_OK;
@@ -371,16 +376,21 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n )
/*****************************************************************************/
typedef struct {
- const IParseDisplayNameVtbl *vtbl_ITS_IParseDisplayName;
+ IParseDisplayName IParseDisplayName_iface;
LONG ref;
} ITS_IParseDisplayNameImpl;
+static inline ITS_IParseDisplayNameImpl *impl_from_IParseDisplayName(IParseDisplayName *iface)
+{
+ return CONTAINING_RECORD(iface, ITS_IParseDisplayNameImpl, IParseDisplayName_iface);
+}
+
static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface(
IParseDisplayName* iface,
REFIID riid,
void** ppvObject)
{
- ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
+ ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IParseDisplayName))
@@ -397,7 +407,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface(
static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
IParseDisplayName* iface)
{
- ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
+ ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
TRACE("%p\n", This);
return InterlockedIncrement(&This->ref);
}
@@ -405,7 +415,7 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
static ULONG WINAPI ITS_IParseDisplayNameImpl_Release(
IParseDisplayName* iface)
{
- ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
+ ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
@@ -428,7 +438,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName(
const DWORD prefix_len = (sizeof szPrefix/sizeof szPrefix[0])-1;
DWORD n;
- ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
+ ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
TRACE("%p %s %p %p\n", This,
debugstr_w( pszDisplayName ), pchEaten, ppmkOut );
@@ -469,7 +479,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
return CLASS_E_NOAGGREGATION;
its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITS_IParseDisplayNameImpl) );
- its->vtbl_ITS_IParseDisplayName = &ITS_IParseDisplayNameImpl_Vtbl;
+ its->IParseDisplayName_iface.lpVtbl = &ITS_IParseDisplayNameImpl_Vtbl;
its->ref = 1;
TRACE("-> %p\n", its);
More information about the wine-cvs
mailing list