Commit 881299c6 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Rearrange code to avoid forward declarations.

parent 88baa9e7
...@@ -44,86 +44,31 @@ typedef struct ...@@ -44,86 +44,31 @@ typedef struct
IFileSystemBindData IFileSystemBindData_iface; IFileSystemBindData IFileSystemBindData_iface;
LONG ref; LONG ref;
WIN32_FIND_DATAW findFile; WIN32_FIND_DATAW findFile;
} IFileSystemBindDataImpl; } FileSystemBindData;
static inline IFileSystemBindDataImpl *impl_from_IFileSystemBindData(IFileSystemBindData *iface) static inline FileSystemBindData *impl_from_IFileSystemBindData(IFileSystemBindData *iface)
{ {
return CONTAINING_RECORD(iface, IFileSystemBindDataImpl, IFileSystemBindData_iface); return CONTAINING_RECORD(iface, FileSystemBindData, IFileSystemBindData_iface);
} }
static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *, REFIID, LPVOID*); static HRESULT WINAPI FileSystemBindData_QueryInterface(
static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *); IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *);
static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *, WIN32_FIND_DATAW *);
static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *, const WIN32_FIND_DATAW *);
static const IFileSystemBindDataVtbl sbvt =
{
IFileSystemBindData_fnQueryInterface,
IFileSystemBindData_fnAddRef,
IFileSystemBindData_fnRelease,
IFileSystemBindData_fnSetFindData,
IFileSystemBindData_fnGetFindData,
};
static const WCHAR wFileSystemBindData[] = {
'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d',' ','D','a','t','a',0};
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
{ {
IFileSystemBindDataImpl *sb; FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
HRESULT ret = E_OUTOFMEMORY;
TRACE("%p, %p\n", pfd, ppV);
if (!ppV) TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppV);
return E_INVALIDARG;
*ppV = NULL; *ppV = NULL;
sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl)); if (IsEqualIID(riid, &IID_IUnknown) ||
if (!sb) IsEqualIID(riid, &IID_IFileSystemBindData))
return ret;
sb->IFileSystemBindData_iface.lpVtbl = &sbvt;
sb->ref = 1;
IFileSystemBindData_fnSetFindData(&sb->IFileSystemBindData_iface, pfd);
ret = CreateBindCtx(0, ppV);
if (SUCCEEDED(ret))
{ {
BIND_OPTS bindOpts; *ppV = &This->IFileSystemBindData_iface;
bindOpts.cbStruct = sizeof(BIND_OPTS);
bindOpts.grfFlags = 0;
bindOpts.grfMode = STGM_CREATE;
bindOpts.dwTickCountDeadline = 0;
IBindCtx_SetBindOptions(*ppV, &bindOpts);
IBindCtx_RegisterObjectParam(*ppV, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb);
IFileSystemBindData_Release(&sb->IFileSystemBindData_iface);
} }
else
HeapFree(GetProcessHeap(), 0, sb);
return ret;
}
static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(
IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
{
IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface);
TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV);
*ppV = NULL;
if (IsEqualIID(riid, &IID_IUnknown))
*ppV = This;
else if (IsEqualIID(riid, &IID_IFileSystemBindData))
*ppV = This;
if (*ppV) if (*ppV)
{ {
IUnknown_AddRef((IUnknown*)(*ppV)); IFileSystemBindData_AddRef(iface);
TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV); TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
return S_OK; return S_OK;
} }
...@@ -131,36 +76,32 @@ static HRESULT WINAPI IFileSystemBindData_fnQueryInterface( ...@@ -131,36 +76,32 @@ static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface) static ULONG WINAPI FileSystemBindData_AddRef(IFileSystemBindData *iface)
{ {
IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface); FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%u)\n", This, ref);
TRACE("(%p)->(count=%i)\n", This, refCount - 1); return ref;
return refCount;
} }
static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface) static ULONG WINAPI FileSystemBindData_Release(IFileSystemBindData *iface)
{ {
IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface); FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%i)\n", This, refCount + 1); TRACE("(%p)->(%u)\n", This, ref);
if (!refCount) if (!ref)
{
TRACE(" destroying ISFBindPidl(%p)\n",This);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
}
return refCount; return ref;
} }
static HRESULT WINAPI IFileSystemBindData_fnGetFindData( static HRESULT WINAPI FileSystemBindData_GetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
{ {
IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface); FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
TRACE("(%p), %p\n", This, pfd);
TRACE("(%p)->(%p)\n", This, pfd);
if (!pfd) if (!pfd)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -169,11 +110,11 @@ static HRESULT WINAPI IFileSystemBindData_fnGetFindData( ...@@ -169,11 +110,11 @@ static HRESULT WINAPI IFileSystemBindData_fnGetFindData(
return S_OK; return S_OK;
} }
static HRESULT WINAPI IFileSystemBindData_fnSetFindData( static HRESULT WINAPI FileSystemBindData_SetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
{ {
IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface); FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
TRACE("(%p), %p\n", This, pfd);
TRACE("(%p)->(%p)\n", This, pfd);
if (pfd) if (pfd)
This->findFile = *pfd; This->findFile = *pfd;
...@@ -181,3 +122,51 @@ static HRESULT WINAPI IFileSystemBindData_fnSetFindData( ...@@ -181,3 +122,51 @@ static HRESULT WINAPI IFileSystemBindData_fnSetFindData(
memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW)); memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
return S_OK; return S_OK;
} }
static const IFileSystemBindDataVtbl FileSystemBindDataVtbl = {
FileSystemBindData_QueryInterface,
FileSystemBindData_AddRef,
FileSystemBindData_Release,
FileSystemBindData_SetFindData,
FileSystemBindData_GetFindData,
};
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *find_data, LPBC *ppV)
{
FileSystemBindData *This;
HRESULT ret;
TRACE("(%p %p)\n", find_data, ppV);
if (!ppV)
return E_INVALIDARG;
*ppV = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IFileSystemBindData_iface.lpVtbl = &FileSystemBindDataVtbl;
This->ref = 1;
IFileSystemBindData_SetFindData(&This->IFileSystemBindData_iface, find_data);
ret = CreateBindCtx(0, ppV);
if (SUCCEEDED(ret))
{
static const WCHAR nameW[] = {
'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d',' ','D','a','t','a',0};
BIND_OPTS bindOpts;
bindOpts.cbStruct = sizeof(BIND_OPTS);
bindOpts.grfFlags = 0;
bindOpts.grfMode = STGM_CREATE;
bindOpts.dwTickCountDeadline = 0;
IBindCtx_SetBindOptions(*ppV, &bindOpts);
IBindCtx_RegisterObjectParam(*ppV, (WCHAR*)nameW, (IUnknown*)&This->IFileSystemBindData_iface);
IFileSystemBindData_Release(&This->IFileSystemBindData_iface);
}
else
HeapFree(GetProcessHeap(), 0, This);
return ret;
}
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