Nikolay Sivov : shell32: Rearrange code to avoid forward declarations.

Alexandre Julliard julliard at winehq.org
Fri Jan 13 11:44:29 CST 2012


Module: wine
Branch: master
Commit: 881299c6a8e806577d639970c5cc4ffc9c6bfbce
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=881299c6a8e806577d639970c5cc4ffc9c6bfbce

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Jan 13 00:14:14 2012 +0300

shell32: Rearrange code to avoid forward declarations.

---

 dlls/shell32/shlfsbind.c |  169 +++++++++++++++++++++------------------------
 1 files changed, 79 insertions(+), 90 deletions(-)

diff --git a/dlls/shell32/shlfsbind.c b/dlls/shell32/shlfsbind.c
index 5988290..53a1d3b 100644
--- a/dlls/shell32/shlfsbind.c
+++ b/dlls/shell32/shlfsbind.c
@@ -44,86 +44,31 @@ typedef struct
     IFileSystemBindData IFileSystemBindData_iface;
     LONG ref;
     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 ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *);
-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)
+static HRESULT WINAPI FileSystemBindData_QueryInterface(
+                IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
 {
-    IFileSystemBindDataImpl *sb;
-    HRESULT ret = E_OUTOFMEMORY;
-
-    TRACE("%p, %p\n", pfd, ppV);
+    FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
 
-    if (!ppV)
-       return E_INVALIDARG;
+    TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppV);
 
     *ppV = NULL;
 
-    sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl));
-    if (!sb)
-        return ret;
-
-    sb->IFileSystemBindData_iface.lpVtbl = &sbvt;
-    sb->ref = 1;
-    IFileSystemBindData_fnSetFindData(&sb->IFileSystemBindData_iface, pfd);
-
-    ret = CreateBindCtx(0, ppV);
-    if (SUCCEEDED(ret))
+    if (IsEqualIID(riid, &IID_IUnknown) ||
+        IsEqualIID(riid, &IID_IFileSystemBindData))
     {
-        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, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb);
-
-        IFileSystemBindData_Release(&sb->IFileSystemBindData_iface);
+        *ppV = &This->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)
     {
-        IUnknown_AddRef((IUnknown*)(*ppV));
+        IFileSystemBindData_AddRef(iface);
         TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
         return S_OK;
     }
@@ -131,36 +76,32 @@ static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(
     return E_NOINTERFACE;
 }
 
-static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface)
+static ULONG WINAPI FileSystemBindData_AddRef(IFileSystemBindData *iface)
 {
-    IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface);
-    ULONG refCount = InterlockedIncrement(&This->ref);
-
-    TRACE("(%p)->(count=%i)\n", This, refCount - 1);
-
-    return refCount;
+    FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+    TRACE("(%p)->(%u)\n", This, ref);
+    return ref;
 }
 
-static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface)
+static ULONG WINAPI FileSystemBindData_Release(IFileSystemBindData *iface)
 {
-    IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface);
-    ULONG refCount = InterlockedDecrement(&This->ref);
+    FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p)->(count=%i)\n", This, refCount + 1);
+    TRACE("(%p)->(%u)\n", This, ref);
 
-    if (!refCount)
-    {
-        TRACE(" destroying ISFBindPidl(%p)\n",This);
+    if (!ref)
         HeapFree(GetProcessHeap(), 0, This);
-    }
-    return refCount;
+
+    return ref;
 }
 
-static HRESULT WINAPI IFileSystemBindData_fnGetFindData(
-               IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
+static HRESULT WINAPI FileSystemBindData_GetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
 {
-    IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface);
-    TRACE("(%p), %p\n", This, pfd);
+    FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
+
+    TRACE("(%p)->(%p)\n", This, pfd);
 
     if (!pfd)
         return E_INVALIDARG;
@@ -169,11 +110,11 @@ static HRESULT WINAPI IFileSystemBindData_fnGetFindData(
     return S_OK;
 }
 
-static HRESULT WINAPI IFileSystemBindData_fnSetFindData(
-               IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
+static HRESULT WINAPI FileSystemBindData_SetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
 {
-    IFileSystemBindDataImpl *This = impl_from_IFileSystemBindData(iface);
-    TRACE("(%p), %p\n", This, pfd);
+    FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
+
+    TRACE("(%p)->(%p)\n", This, pfd);
 
     if (pfd)
         This->findFile = *pfd;
@@ -181,3 +122,51 @@ static HRESULT WINAPI IFileSystemBindData_fnSetFindData(
         memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
     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;
+}




More information about the wine-cvs mailing list