Commit ee56fbb9 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

ole32: Use ifaces instead of vtbl pointers in FTMarshalImpl.

parent 24ad5cb6
...@@ -39,19 +39,21 @@ ...@@ -39,19 +39,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole); WINE_DEFAULT_DEBUG_CHANNEL(ole);
typedef struct _FTMarshalImpl { typedef struct _FTMarshalImpl {
const IUnknownVtbl *lpVtbl; IUnknown IUnknown_iface;
LONG ref; LONG ref;
const IMarshalVtbl *lpvtblFTM; IMarshal IMarshal_iface;
IUnknown *pUnkOuter; IUnknown *pUnkOuter;
} FTMarshalImpl; } FTMarshalImpl;
#define _IFTMUnknown_(This) ((IUnknown*)&(This)->lpVtbl) static inline FTMarshalImpl *impl_from_IUnknown(IUnknown *iface)
#define _IFTMarshal_(This) (&(This)->lpvtblFTM) {
return CONTAINING_RECORD(iface, FTMarshalImpl, IUnknown_iface);
}
static inline FTMarshalImpl *impl_from_IMarshal( IMarshal *iface ) static inline FTMarshalImpl *impl_from_IMarshal( IMarshal *iface )
{ {
return (FTMarshalImpl *)((char*)iface - FIELD_OFFSET(FTMarshalImpl, lpvtblFTM)); return CONTAINING_RECORD(iface, FTMarshalImpl, IMarshal_iface);
} }
/* inner IUnknown to handle aggregation */ /* inner IUnknown to handle aggregation */
...@@ -59,15 +61,15 @@ static HRESULT WINAPI ...@@ -59,15 +61,15 @@ static HRESULT WINAPI
IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv) IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv)
{ {
FTMarshalImpl *This = (FTMarshalImpl *)iface; FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n"); TRACE ("\n");
*ppv = NULL; *ppv = NULL;
if (IsEqualIID (&IID_IUnknown, riid)) if (IsEqualIID (&IID_IUnknown, riid))
*ppv = _IFTMUnknown_ (This); *ppv = &This->IUnknown_iface;
else if (IsEqualIID (&IID_IMarshal, riid)) else if (IsEqualIID (&IID_IMarshal, riid))
*ppv = _IFTMarshal_ (This); *ppv = &This->IMarshal_iface;
else { else {
FIXME ("No interface for %s.\n", debugstr_guid (riid)); FIXME ("No interface for %s.\n", debugstr_guid (riid));
return E_NOINTERFACE; return E_NOINTERFACE;
...@@ -79,7 +81,7 @@ IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv) ...@@ -79,7 +81,7 @@ IiFTMUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppv)
static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface) static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface)
{ {
FTMarshalImpl *This = (FTMarshalImpl *)iface; FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n"); TRACE ("\n");
return InterlockedIncrement (&This->ref); return InterlockedIncrement (&This->ref);
...@@ -88,7 +90,7 @@ static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface) ...@@ -88,7 +90,7 @@ static ULONG WINAPI IiFTMUnknown_fnAddRef (IUnknown * iface)
static ULONG WINAPI IiFTMUnknown_fnRelease (IUnknown * iface) static ULONG WINAPI IiFTMUnknown_fnRelease (IUnknown * iface)
{ {
FTMarshalImpl *This = (FTMarshalImpl *)iface; FTMarshalImpl *This = impl_from_IUnknown(iface);
TRACE ("\n"); TRACE ("\n");
if (InterlockedDecrement (&This->ref)) if (InterlockedDecrement (&This->ref))
...@@ -340,12 +342,12 @@ HRESULT WINAPI CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter, LPUNKNOWN * p ...@@ -340,12 +342,12 @@ HRESULT WINAPI CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter, LPUNKNOWN * p
if (!ftm) if (!ftm)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
ftm->lpVtbl = &iunkvt; ftm->IUnknown_iface.lpVtbl = &iunkvt;
ftm->lpvtblFTM = &ftmvtbl; ftm->IMarshal_iface.lpVtbl = &ftmvtbl;
ftm->ref = 1; ftm->ref = 1;
ftm->pUnkOuter = punkOuter ? punkOuter : _IFTMUnknown_(ftm); ftm->pUnkOuter = punkOuter ? punkOuter : &ftm->IUnknown_iface;
*ppunkMarshal = _IFTMUnknown_ (ftm); *ppunkMarshal = &ftm->IUnknown_iface;
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment