typedef struct
{
- const IHlinkVtbl *lpVtbl;
+ IHlink IHlink_iface;
LONG ref;
- const IPersistStreamVtbl *lpPSVtbl;
- const IDataObjectVtbl *lpDOVtbl;
+ IPersistStream IPersistStream_iface;
+ IDataObject IDataObject_iface;
LPWSTR FriendlyName;
LPWSTR Location;
BOOL absolute;
} HlinkImpl;
+static inline HlinkImpl *impl_from_IHlink(IHlink *iface)
+{
+ return CONTAINING_RECORD(iface, HlinkImpl, IHlink_iface);
+}
+
-static inline HlinkImpl* HlinkImpl_from_IPersistStream( IPersistStream* iface)
+static inline HlinkImpl* impl_from_IPersistStream( IPersistStream* iface)
{
- return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpPSVtbl));
+ return CONTAINING_RECORD(iface, HlinkImpl, IPersistStream_iface);
}
-static inline HlinkImpl* HlinkImpl_from_IDataObject( IDataObject* iface)
+static inline HlinkImpl* impl_from_IDataObject( IDataObject* iface)
{
- return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpDOVtbl));
+ return CONTAINING_RECORD(iface, HlinkImpl, IDataObject_iface);
}
static HRESULT __GetMoniker(HlinkImpl* This, IMoniker** moniker,
return E_OUTOFMEMORY;
hl->ref = 1;
- hl->lpVtbl = &hlvt;
- hl->lpPSVtbl = &psvt;
- hl->lpDOVtbl = &dovt;
+ hl->IHlink_iface.lpVtbl = &hlvt;
+ hl->IPersistStream_iface.lpVtbl = &psvt;
+ hl->IDataObject_iface.lpVtbl = &dovt;
*ppv = hl;
return S_OK;
static HRESULT WINAPI IHlink_fnQueryInterface(IHlink* iface, REFIID riid,
LPVOID *ppvObj)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
if (IsEqualIID(riid, &IID_IUnknown) || (IsEqualIID(riid, &IID_IHlink)))
*ppvObj = This;
else if (IsEqualIID(riid, &IID_IPersistStream))
- *ppvObj = &(This->lpPSVtbl);
+ *ppvObj = &This->IPersistStream_iface;
else if (IsEqualIID(riid, &IID_IDataObject))
- *ppvObj = &(This->lpDOVtbl);
+ *ppvObj = &This->IDataObject_iface;
if (*ppvObj)
{
static ULONG WINAPI IHlink_fnAddRef (IHlink* iface)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
static ULONG WINAPI IHlink_fnRelease (IHlink* iface)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount + 1);
static HRESULT WINAPI IHlink_fnSetHlinkSite( IHlink* iface,
IHlinkSite* pihlSite, DWORD dwSiteData)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%p %i)\n", This, pihlSite, dwSiteData);
static HRESULT WINAPI IHlink_fnGetHlinkSite( IHlink* iface,
IHlinkSite** ppihlSite, DWORD *pdwSiteData)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%p %p)\n", This, ppihlSite, pdwSiteData);
static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
DWORD rfHLSETF, IMoniker *pmkTarget, LPCWSTR pwzLocation)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget,
debugstr_w(pwzLocation));
static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
DWORD grfHLSETF, LPCWSTR pwzTarget, LPCWSTR pwzLocation)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
debugstr_w(pwzLocation));
static HRESULT WINAPI IHlink_fnGetMonikerReference(IHlink* iface,
DWORD dwWhichRef, IMoniker **ppimkTarget, LPWSTR *ppwzLocation)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppimkTarget,
ppwzLocation);
static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
DWORD dwWhichRef, LPWSTR *ppwzTarget, LPWSTR *ppwzLocation)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
LPCWSTR pwzFriendlyName)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface,
DWORD grfHLFNAMEF, LPWSTR* ppwzFriendlyName)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p) -> (%i %p)\n", This, grfHLFNAMEF, ppwzFriendlyName);
static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
LPCWSTR pwzTargetFramename)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
heap_free(This->TargetFrameName);
static HRESULT WINAPI IHlink_fnGetTargetFrameName(IHlink* iface,
LPWSTR *ppwzTargetFrameName)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName);
*ppwzTargetFrameName = hlink_co_strdupW( This->TargetFrameName );
static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
IBindStatusCallback *pbsc, IHlinkBrowseContext *phbc)
{
- HlinkImpl *This = (HlinkImpl*)iface;
+ HlinkImpl *This = impl_from_IHlink(iface);
IMoniker *mon = NULL;
HRESULT r;
static HRESULT WINAPI IDataObject_fnQueryInterface(IDataObject* iface,
REFIID riid, LPVOID *ppvObj)
{
- HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
+ HlinkImpl *This = impl_from_IDataObject(iface);
TRACE("%p\n", This);
- return IHlink_QueryInterface((IHlink*)This, riid, ppvObj);
+ return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
}
static ULONG WINAPI IDataObject_fnAddRef (IDataObject* iface)
{
- HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
+ HlinkImpl *This = impl_from_IDataObject(iface);
TRACE("%p\n", This);
- return IHlink_AddRef((IHlink*)This);
+ return IHlink_AddRef(&This->IHlink_iface);
}
static ULONG WINAPI IDataObject_fnRelease (IDataObject* iface)
{
- HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
+ HlinkImpl *This = impl_from_IDataObject(iface);
TRACE("%p\n", This);
- return IHlink_Release((IHlink*)This);
+ return IHlink_Release(&This->IHlink_iface);
}
static HRESULT WINAPI IDataObject_fnGetData(IDataObject* iface,
static HRESULT WINAPI IPersistStream_fnQueryInterface(IPersistStream* iface,
REFIID riid, LPVOID *ppvObj)
{
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
TRACE("(%p)\n", This);
- return IHlink_QueryInterface((IHlink*)This, riid, ppvObj);
+ return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
}
static ULONG WINAPI IPersistStream_fnAddRef (IPersistStream* iface)
{
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
TRACE("(%p)\n", This);
- return IHlink_AddRef((IHlink*)This);
+ return IHlink_AddRef(&This->IHlink_iface);
}
static ULONG WINAPI IPersistStream_fnRelease (IPersistStream* iface)
{
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
TRACE("(%p)\n", This);
- return IHlink_Release((IHlink*)This);
+ return IHlink_Release(&This->IHlink_iface);
}
static HRESULT WINAPI IPersistStream_fnGetClassID(IPersistStream* iface,
CLSID* pClassID)
{
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
TRACE("(%p)\n", This);
*pClassID = CLSID_StdHlink;
return S_OK;
HRESULT r;
DWORD hdr[2];
DWORD read;
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
r = IStream_Read(pStm, hdr, sizeof(hdr), &read);
if (read != sizeof(hdr) || (hdr[0] != HLINK_SAVE_MAGIC))
IStream* pStm, BOOL fClearDirty)
{
HRESULT r;
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
DWORD hdr[2];
IMoniker *moniker;
ULARGE_INTEGER* pcbSize)
{
HRESULT r;
- HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
+ HlinkImpl *This = impl_from_IPersistStream(iface);
IMoniker *moniker;
TRACE("(%p) Moniker(%p)\n", This, This->Moniker);