itss: Standardize the COM usage in moniker.c.

This commit is contained in:
Michael Stefaniuc 2010-12-05 15:14:46 +01:00 committed by Alexandre Julliard
parent 577f202d25
commit 72f3765a5b
1 changed files with 25 additions and 15 deletions

View File

@ -43,19 +43,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss);
/*****************************************************************************/ /*****************************************************************************/
typedef struct { typedef struct {
const IMonikerVtbl *vtbl_ITS_IMoniker; IMoniker IMoniker_iface;
LONG ref; LONG ref;
LPWSTR szHtml; LPWSTR szHtml;
WCHAR szFile[1]; WCHAR szFile[1];
} ITS_IMonikerImpl; } ITS_IMonikerImpl;
static inline ITS_IMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return CONTAINING_RECORD(iface, ITS_IMonikerImpl, IMoniker_iface);
}
/*** IUnknown methods ***/ /*** IUnknown methods ***/
static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface( static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface(
IMoniker* iface, IMoniker* iface,
REFIID riid, REFIID riid,
void** ppvObject) void** ppvObject)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IParseDisplayName)) || IsEqualGUID(riid, &IID_IParseDisplayName))
@ -72,7 +77,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface(
static ULONG WINAPI ITS_IMonikerImpl_AddRef( static ULONG WINAPI ITS_IMonikerImpl_AddRef(
IMoniker* iface) IMoniker* iface)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("%p\n", This); TRACE("%p\n", This);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
@ -80,7 +85,7 @@ static ULONG WINAPI ITS_IMonikerImpl_AddRef(
static ULONG WINAPI ITS_IMonikerImpl_Release( static ULONG WINAPI ITS_IMonikerImpl_Release(
IMoniker* iface) IMoniker* iface)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) { if (ref == 0) {
@ -96,7 +101,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetClassID(
IMoniker* iface, IMoniker* iface,
CLSID* pClassID) CLSID* pClassID)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
TRACE("%p %p\n", This, pClassID); TRACE("%p %p\n", This, pClassID);
*pClassID = CLSID_ITStorage; *pClassID = CLSID_ITStorage;
@ -155,7 +160,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_BindToStorage(
REFIID riid, REFIID riid,
void** ppvObj) void** ppvObj)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE; DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE;
HRESULT r; HRESULT r;
IStorage *stg = NULL; IStorage *stg = NULL;
@ -279,7 +284,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName(
IMoniker* pmkToLeft, IMoniker* pmkToLeft,
LPOLESTR* ppszDisplayName) LPOLESTR* ppszDisplayName)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
static const WCHAR szFormat[] = { static const WCHAR szFormat[] = {
'm','s','-','i','t','s',':','%','s',':',':','%','s',0 }; 'm','s','-','i','t','s',':','%','s',':',':','%','s',0 };
DWORD len = sizeof szFormat / sizeof(WCHAR); 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); sz = sizeof(ITS_IMonikerImpl) + strlenW( name )*sizeof(WCHAR);
itsmon = HeapAlloc( GetProcessHeap(), 0, sz ); itsmon = HeapAlloc( GetProcessHeap(), 0, sz );
itsmon->vtbl_ITS_IMoniker = &ITS_IMonikerImpl_Vtbl; itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl;
itsmon->ref = 1; itsmon->ref = 1;
strcpyW( itsmon->szFile, name ); strcpyW( itsmon->szFile, name );
itsmon->szHtml = &itsmon->szFile[n]; 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, TRACE("-> %p %s %s\n", itsmon,
debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) ); debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) );
*ppObj = (IMoniker*) itsmon; *ppObj = &itsmon->IMoniker_iface;
ITSS_LockModule(); ITSS_LockModule();
return S_OK; return S_OK;
@ -371,16 +376,21 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n )
/*****************************************************************************/ /*****************************************************************************/
typedef struct { typedef struct {
const IParseDisplayNameVtbl *vtbl_ITS_IParseDisplayName; IParseDisplayName IParseDisplayName_iface;
LONG ref; LONG ref;
} ITS_IParseDisplayNameImpl; } 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( static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface(
IParseDisplayName* iface, IParseDisplayName* iface,
REFIID riid, REFIID riid,
void** ppvObject) void** ppvObject)
{ {
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IParseDisplayName)) || IsEqualGUID(riid, &IID_IParseDisplayName))
@ -397,7 +407,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface(
static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef( static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
IParseDisplayName* iface) IParseDisplayName* iface)
{ {
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
TRACE("%p\n", This); TRACE("%p\n", This);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
@ -405,7 +415,7 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
static ULONG WINAPI ITS_IParseDisplayNameImpl_Release( static ULONG WINAPI ITS_IParseDisplayNameImpl_Release(
IParseDisplayName* iface) IParseDisplayName* iface)
{ {
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) { if (ref == 0) {
@ -428,7 +438,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName(
const DWORD prefix_len = (sizeof szPrefix/sizeof szPrefix[0])-1; const DWORD prefix_len = (sizeof szPrefix/sizeof szPrefix[0])-1;
DWORD n; DWORD n;
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface);
TRACE("%p %s %p %p\n", This, TRACE("%p %s %p %p\n", This,
debugstr_w( pszDisplayName ), pchEaten, ppmkOut ); debugstr_w( pszDisplayName ), pchEaten, ppmkOut );
@ -469,7 +479,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITS_IParseDisplayNameImpl) ); its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITS_IParseDisplayNameImpl) );
its->vtbl_ITS_IParseDisplayName = &ITS_IParseDisplayNameImpl_Vtbl; its->IParseDisplayName_iface.lpVtbl = &ITS_IParseDisplayNameImpl_Vtbl;
its->ref = 1; its->ref = 1;
TRACE("-> %p\n", its); TRACE("-> %p\n", its);