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

oleaut32: Standardize the COM usage in connpt.c.

parent 47446593
...@@ -48,7 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); ...@@ -48,7 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
*/ */
typedef struct ConnectionPointImpl { typedef struct ConnectionPointImpl {
const IConnectionPointVtbl *lpvtbl; IConnectionPoint IConnectionPoint_iface;
/* IUnknown of our main object*/ /* IUnknown of our main object*/
IUnknown *Obj; IUnknown *Obj;
...@@ -74,7 +74,7 @@ static const IConnectionPointVtbl ConnectionPointImpl_VTable; ...@@ -74,7 +74,7 @@ static const IConnectionPointVtbl ConnectionPointImpl_VTable;
*/ */
typedef struct EnumConnectionsImpl { typedef struct EnumConnectionsImpl {
const IEnumConnectionsVtbl *lpvtbl; IEnumConnections IEnumConnections_iface;
LONG ref; LONG ref;
...@@ -94,6 +94,15 @@ static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk, ...@@ -94,6 +94,15 @@ static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk,
DWORD nSinks, DWORD nSinks,
CONNECTDATA *pCD); CONNECTDATA *pCD);
static inline ConnectionPointImpl *impl_from_IConnectionPoint(IConnectionPoint *iface)
{
return CONTAINING_RECORD(iface, ConnectionPointImpl, IConnectionPoint_iface);
}
static inline EnumConnectionsImpl *impl_from_IEnumConnections(IEnumConnections *iface)
{
return CONTAINING_RECORD(iface, EnumConnectionsImpl, IEnumConnections_iface);
}
/************************************************************************ /************************************************************************
* ConnectionPointImpl_Construct * ConnectionPointImpl_Construct
...@@ -104,7 +113,7 @@ static ConnectionPointImpl *ConnectionPointImpl_Construct(IUnknown *pUnk, ...@@ -104,7 +113,7 @@ static ConnectionPointImpl *ConnectionPointImpl_Construct(IUnknown *pUnk,
ConnectionPointImpl *Obj; ConnectionPointImpl *Obj;
Obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*Obj)); Obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*Obj));
Obj->lpvtbl = &ConnectionPointImpl_VTable; Obj->IConnectionPoint_iface.lpVtbl = &ConnectionPointImpl_VTable;
Obj->Obj = pUnk; Obj->Obj = pUnk;
Obj->ref = 1; Obj->ref = 1;
Obj->iid = *riid; Obj->iid = *riid;
...@@ -143,7 +152,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface( ...@@ -143,7 +152,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface(
REFIID riid, REFIID riid,
void** ppvObject) void** ppvObject)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject); TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
/* /*
...@@ -178,7 +187,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface( ...@@ -178,7 +187,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface(
* Query Interface always increases the reference count by one when it is * Query Interface always increases the reference count by one when it is
* successful * successful
*/ */
ConnectionPointImpl_AddRef((IConnectionPoint*)This); ConnectionPointImpl_AddRef(&This->IConnectionPoint_iface);
return S_OK; return S_OK;
} }
...@@ -191,7 +200,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface( ...@@ -191,7 +200,7 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface(
*/ */
static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface) static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%d)\n", This, refCount - 1); TRACE("(%p)->(ref before=%d)\n", This, refCount - 1);
...@@ -207,7 +216,7 @@ static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface) ...@@ -207,7 +216,7 @@ static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface)
static ULONG WINAPI ConnectionPointImpl_Release( static ULONG WINAPI ConnectionPointImpl_Release(
IConnectionPoint* iface) IConnectionPoint* iface)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%d)\n", This, refCount + 1); TRACE("(%p)->(ref before=%d)\n", This, refCount + 1);
...@@ -228,7 +237,7 @@ static HRESULT WINAPI ConnectionPointImpl_GetConnectionInterface( ...@@ -228,7 +237,7 @@ static HRESULT WINAPI ConnectionPointImpl_GetConnectionInterface(
IConnectionPoint *iface, IConnectionPoint *iface,
IID *piid) IID *piid)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
TRACE("(%p)->(%p) returning %s\n", This, piid, debugstr_guid(&(This->iid))); TRACE("(%p)->(%p) returning %s\n", This, piid, debugstr_guid(&(This->iid)));
*piid = This->iid; *piid = This->iid;
return S_OK; return S_OK;
...@@ -242,7 +251,7 @@ static HRESULT WINAPI ConnectionPointImpl_GetConnectionPointContainer( ...@@ -242,7 +251,7 @@ static HRESULT WINAPI ConnectionPointImpl_GetConnectionPointContainer(
IConnectionPoint *iface, IConnectionPoint *iface,
IConnectionPointContainer **ppCPC) IConnectionPointContainer **ppCPC)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
TRACE("(%p)->(%p)\n", This, ppCPC); TRACE("(%p)->(%p)\n", This, ppCPC);
return IUnknown_QueryInterface(This->Obj, return IUnknown_QueryInterface(This->Obj,
...@@ -259,7 +268,7 @@ static HRESULT WINAPI ConnectionPointImpl_Advise(IConnectionPoint *iface, ...@@ -259,7 +268,7 @@ static HRESULT WINAPI ConnectionPointImpl_Advise(IConnectionPoint *iface,
DWORD *pdwCookie) DWORD *pdwCookie)
{ {
DWORD i; DWORD i;
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
IUnknown *lpSink; IUnknown *lpSink;
TRACE("(%p)->(%p, %p)\n", This, lpUnk, pdwCookie); TRACE("(%p)->(%p, %p)\n", This, lpUnk, pdwCookie);
...@@ -290,7 +299,7 @@ static HRESULT WINAPI ConnectionPointImpl_Advise(IConnectionPoint *iface, ...@@ -290,7 +299,7 @@ static HRESULT WINAPI ConnectionPointImpl_Advise(IConnectionPoint *iface,
static HRESULT WINAPI ConnectionPointImpl_Unadvise(IConnectionPoint *iface, static HRESULT WINAPI ConnectionPointImpl_Unadvise(IConnectionPoint *iface,
DWORD dwCookie) DWORD dwCookie)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
TRACE("(%p)->(%d)\n", This, dwCookie); TRACE("(%p)->(%d)\n", This, dwCookie);
if(dwCookie == 0 || dwCookie > This->maxSinks) return E_INVALIDARG; if(dwCookie == 0 || dwCookie > This->maxSinks) return E_INVALIDARG;
...@@ -311,7 +320,7 @@ static HRESULT WINAPI ConnectionPointImpl_EnumConnections( ...@@ -311,7 +320,7 @@ static HRESULT WINAPI ConnectionPointImpl_EnumConnections(
IConnectionPoint *iface, IConnectionPoint *iface,
LPENUMCONNECTIONS *ppEnum) LPENUMCONNECTIONS *ppEnum)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = impl_from_IConnectionPoint(iface);
CONNECTDATA *pCD; CONNECTDATA *pCD;
DWORD i, nextslot; DWORD i, nextslot;
EnumConnectionsImpl *EnumObj; EnumConnectionsImpl *EnumObj;
...@@ -339,9 +348,9 @@ static HRESULT WINAPI ConnectionPointImpl_EnumConnections( ...@@ -339,9 +348,9 @@ static HRESULT WINAPI ConnectionPointImpl_EnumConnections(
IUnknown_AddRef((IUnknown*)This); IUnknown_AddRef((IUnknown*)This);
EnumObj = EnumConnectionsImpl_Construct((IUnknown*)This, This->nSinks, pCD); EnumObj = EnumConnectionsImpl_Construct((IUnknown*)This, This->nSinks, pCD);
hr = IEnumConnections_QueryInterface((IEnumConnections*)EnumObj, hr = IEnumConnections_QueryInterface(&EnumObj->IEnumConnections_iface,
&IID_IEnumConnections, (LPVOID)ppEnum); &IID_IEnumConnections, (LPVOID)ppEnum);
IEnumConnections_Release((IEnumConnections*)EnumObj); IEnumConnections_Release(&EnumObj->IEnumConnections_iface);
HeapFree(GetProcessHeap(), 0, pCD); HeapFree(GetProcessHeap(), 0, pCD);
return hr; return hr;
...@@ -373,7 +382,7 @@ static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk, ...@@ -373,7 +382,7 @@ static EnumConnectionsImpl *EnumConnectionsImpl_Construct(IUnknown *pUnk,
EnumConnectionsImpl *Obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*Obj)); EnumConnectionsImpl *Obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*Obj));
DWORD i; DWORD i;
Obj->lpvtbl = &EnumConnectionsImpl_VTable; Obj->IEnumConnections_iface.lpVtbl = &EnumConnectionsImpl_VTable;
Obj->ref = 1; Obj->ref = 1;
Obj->pUnk = pUnk; Obj->pUnk = pUnk;
Obj->pCD = HeapAlloc(GetProcessHeap(), 0, nSinks * sizeof(CONNECTDATA)); Obj->pCD = HeapAlloc(GetProcessHeap(), 0, nSinks * sizeof(CONNECTDATA));
...@@ -460,7 +469,7 @@ static HRESULT WINAPI EnumConnectionsImpl_QueryInterface( ...@@ -460,7 +469,7 @@ static HRESULT WINAPI EnumConnectionsImpl_QueryInterface(
*/ */
static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%d)\n", This, refCount - 1); TRACE("(%p)->(ref before=%d)\n", This, refCount - 1);
...@@ -476,7 +485,7 @@ static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) ...@@ -476,7 +485,7 @@ static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
*/ */
static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface) static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%d)\n", This, refCount + 1); TRACE("(%p)->(ref before=%d)\n", This, refCount + 1);
...@@ -499,7 +508,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Next(IEnumConnections* iface, ...@@ -499,7 +508,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Next(IEnumConnections* iface,
ULONG cConn, LPCONNECTDATA pCD, ULONG cConn, LPCONNECTDATA pCD,
ULONG *pEnum) ULONG *pEnum)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
DWORD nRet = 0; DWORD nRet = 0;
TRACE("(%p)->(%d, %p, %p)\n", This, cConn, pCD, pEnum); TRACE("(%p)->(%d, %p, %p)\n", This, cConn, pCD, pEnum);
...@@ -534,7 +543,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Next(IEnumConnections* iface, ...@@ -534,7 +543,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Next(IEnumConnections* iface,
static HRESULT WINAPI EnumConnectionsImpl_Skip(IEnumConnections* iface, static HRESULT WINAPI EnumConnectionsImpl_Skip(IEnumConnections* iface,
ULONG cSkip) ULONG cSkip)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
TRACE("(%p)->(%d)\n", This, cSkip); TRACE("(%p)->(%d)\n", This, cSkip);
if(This->nCur + cSkip >= This->nConns) if(This->nCur + cSkip >= This->nConns)
...@@ -552,7 +561,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Skip(IEnumConnections* iface, ...@@ -552,7 +561,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Skip(IEnumConnections* iface,
*/ */
static HRESULT WINAPI EnumConnectionsImpl_Reset(IEnumConnections* iface) static HRESULT WINAPI EnumConnectionsImpl_Reset(IEnumConnections* iface)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
This->nCur = 0; This->nCur = 0;
...@@ -568,7 +577,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Reset(IEnumConnections* iface) ...@@ -568,7 +577,7 @@ static HRESULT WINAPI EnumConnectionsImpl_Reset(IEnumConnections* iface)
static HRESULT WINAPI EnumConnectionsImpl_Clone(IEnumConnections* iface, static HRESULT WINAPI EnumConnectionsImpl_Clone(IEnumConnections* iface,
LPENUMCONNECTIONS *ppEnum) LPENUMCONNECTIONS *ppEnum)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = impl_from_IEnumConnections(iface);
EnumConnectionsImpl *newObj; EnumConnectionsImpl *newObj;
TRACE("(%p)->(%p)\n", This, ppEnum); TRACE("(%p)->(%p)\n", This, ppEnum);
...@@ -613,8 +622,8 @@ HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid, ...@@ -613,8 +622,8 @@ HRESULT CreateConnectionPoint(IUnknown *pUnk, REFIID riid,
Obj = ConnectionPointImpl_Construct(pUnk, riid); Obj = ConnectionPointImpl_Construct(pUnk, riid);
if(!Obj) return E_OUTOFMEMORY; if(!Obj) return E_OUTOFMEMORY;
hr = IConnectionPoint_QueryInterface((IConnectionPoint *)Obj, hr = IConnectionPoint_QueryInterface(&Obj->IConnectionPoint_iface,
&IID_IConnectionPoint, (LPVOID)pCP); &IID_IConnectionPoint, (LPVOID)pCP);
IConnectionPoint_Release((IConnectionPoint *)Obj); IConnectionPoint_Release(&Obj->IConnectionPoint_iface);
return hr; return hr;
} }
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