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

shlwapi: Use iface instead of vtbl pointers in ISHFileStream.

parent 7363b0e9
...@@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); ...@@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
/* Layout of ISHFileStream object */ /* Layout of ISHFileStream object */
typedef struct typedef struct
{ {
const IStreamVtbl *lpVtbl; IStream IStream_iface;
LONG ref; LONG ref;
HANDLE hFile; HANDLE hFile;
DWORD dwMode; DWORD dwMode;
...@@ -51,6 +51,11 @@ typedef struct ...@@ -51,6 +51,11 @@ typedef struct
DWORD grfStateBits; DWORD grfStateBits;
} ISHFileStream; } ISHFileStream;
static inline ISHFileStream *impl_from_IStream(IStream *iface)
{
return CONTAINING_RECORD(iface, ISHFileStream, IStream_iface);
}
static HRESULT WINAPI IStream_fnCommit(IStream*,DWORD); static HRESULT WINAPI IStream_fnCommit(IStream*,DWORD);
...@@ -59,7 +64,7 @@ static HRESULT WINAPI IStream_fnCommit(IStream*,DWORD); ...@@ -59,7 +64,7 @@ static HRESULT WINAPI IStream_fnCommit(IStream*,DWORD);
*/ */
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj) static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppvObj); TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppvObj);
...@@ -80,7 +85,7 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO ...@@ -80,7 +85,7 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO
*/ */
static ULONG WINAPI IStream_fnAddRef(IStream *iface) static ULONG WINAPI IStream_fnAddRef(IStream *iface)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1); TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
...@@ -93,7 +98,7 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface) ...@@ -93,7 +98,7 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface)
*/ */
static ULONG WINAPI IStream_fnRelease(IStream *iface) static ULONG WINAPI IStream_fnRelease(IStream *iface)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1); TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
...@@ -114,7 +119,7 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface) ...@@ -114,7 +119,7 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
*/ */
static HRESULT WINAPI IStream_fnRead(IStream *iface, void* pv, ULONG cb, ULONG* pcbRead) static HRESULT WINAPI IStream_fnRead(IStream *iface, void* pv, ULONG cb, ULONG* pcbRead)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
DWORD dwRead = 0; DWORD dwRead = 0;
TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbRead); TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbRead);
...@@ -134,7 +139,7 @@ static HRESULT WINAPI IStream_fnRead(IStream *iface, void* pv, ULONG cb, ULONG* ...@@ -134,7 +139,7 @@ static HRESULT WINAPI IStream_fnRead(IStream *iface, void* pv, ULONG cb, ULONG*
*/ */
static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void* pv, ULONG cb, ULONG* pcbWritten) static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void* pv, ULONG cb, ULONG* pcbWritten)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
DWORD dwWritten = 0; DWORD dwWritten = 0;
TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbWritten); TRACE("(%p,%p,0x%08x,%p)\n", This, pv, cb, pcbWritten);
...@@ -162,7 +167,7 @@ static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void* pv, ULONG cb, ...@@ -162,7 +167,7 @@ static HRESULT WINAPI IStream_fnWrite(IStream *iface, const void* pv, ULONG cb,
static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove, static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER* pNewPos) DWORD dwOrigin, ULARGE_INTEGER* pNewPos)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
DWORD dwPos; DWORD dwPos;
TRACE("(%p,%d,%d,%p)\n", This, dlibMove.u.LowPart, dwOrigin, pNewPos); TRACE("(%p,%d,%d,%p)\n", This, dlibMove.u.LowPart, dwOrigin, pNewPos);
...@@ -185,7 +190,7 @@ static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove, ...@@ -185,7 +190,7 @@ static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove,
*/ */
static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSize) static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSize)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p,%d)\n", This, libNewSize.u.LowPart); TRACE("(%p,%d)\n", This, libNewSize.u.LowPart);
...@@ -205,7 +210,7 @@ static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSiz ...@@ -205,7 +210,7 @@ static HRESULT WINAPI IStream_fnSetSize(IStream *iface, ULARGE_INTEGER libNewSiz
static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream* pstm, ULARGE_INTEGER cb, static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream* pstm, ULARGE_INTEGER cb,
ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
char copyBuff[1024]; char copyBuff[1024];
ULONGLONG ulSize; ULONGLONG ulSize;
HRESULT hRet = S_OK; HRESULT hRet = S_OK;
...@@ -254,7 +259,7 @@ static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream* pstm, ULARGE_INT ...@@ -254,7 +259,7 @@ static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream* pstm, ULARGE_INT
*/ */
static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags) static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p,%d)\n", This, grfCommitFlags); TRACE("(%p,%d)\n", This, grfCommitFlags);
/* Currently unbuffered: This function is not needed */ /* Currently unbuffered: This function is not needed */
...@@ -266,7 +271,7 @@ static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags) ...@@ -266,7 +271,7 @@ static HRESULT WINAPI IStream_fnCommit(IStream *iface, DWORD grfCommitFlags)
*/ */
static HRESULT WINAPI IStream_fnRevert(IStream *iface) static HRESULT WINAPI IStream_fnRevert(IStream *iface)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
return E_NOTIMPL; return E_NOTIMPL;
...@@ -278,7 +283,7 @@ static HRESULT WINAPI IStream_fnRevert(IStream *iface) ...@@ -278,7 +283,7 @@ static HRESULT WINAPI IStream_fnRevert(IStream *iface)
static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType) ULARGE_INTEGER cb, DWORD dwLockType)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p,%d,%d,%d)\n", This, libOffset.u.LowPart, cb.u.LowPart, dwLockType); TRACE("(%p,%d,%d,%d)\n", This, libOffset.u.LowPart, cb.u.LowPart, dwLockType);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -289,7 +294,7 @@ static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER ...@@ -289,7 +294,7 @@ static HRESULT WINAPI IStream_fnLockUnlockRegion(IStream *iface, ULARGE_INTEGER
static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG* lpStat, static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG* lpStat,
DWORD grfStatFlag) DWORD grfStatFlag)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
BY_HANDLE_FILE_INFORMATION fi; BY_HANDLE_FILE_INFORMATION fi;
HRESULT hRet = S_OK; HRESULT hRet = S_OK;
...@@ -326,7 +331,7 @@ static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG* lpStat, ...@@ -326,7 +331,7 @@ static HRESULT WINAPI IStream_fnStat(IStream *iface, STATSTG* lpStat,
*/ */
static HRESULT WINAPI IStream_fnClone(IStream *iface, IStream** ppstm) static HRESULT WINAPI IStream_fnClone(IStream *iface, IStream** ppstm)
{ {
ISHFileStream *This = (ISHFileStream *)iface; ISHFileStream *This = impl_from_IStream(iface);
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
if (ppstm) if (ppstm)
...@@ -365,7 +370,7 @@ static IStream *IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode) ...@@ -365,7 +370,7 @@ static IStream *IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode)
if (fileStream) if (fileStream)
{ {
fileStream->lpVtbl = &SHLWAPI_fsVTable; fileStream->IStream_iface.lpVtbl = &SHLWAPI_fsVTable;
fileStream->ref = 1; fileStream->ref = 1;
fileStream->hFile = hFile; fileStream->hFile = hFile;
fileStream->dwMode = dwMode; fileStream->dwMode = dwMode;
...@@ -374,7 +379,7 @@ static IStream *IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode) ...@@ -374,7 +379,7 @@ static IStream *IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode)
fileStream->grfStateBits = 0; /* FIXME */ fileStream->grfStateBits = 0; /* FIXME */
} }
TRACE ("Returning %p\n", fileStream); TRACE ("Returning %p\n", fileStream);
return (IStream *)fileStream; return &fileStream->IStream_iface;
} }
/************************************************************************* /*************************************************************************
......
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