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

shell32: COM cleanup in autocomplete.c.

parent 2317815d
...@@ -64,8 +64,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); ...@@ -64,8 +64,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
typedef struct typedef struct
{ {
const IAutoComplete2Vtbl *lpVtbl; IAutoComplete2 IAutoComplete2_iface;
const IAutoCompleteDropDownVtbl *lpDropDownVtbl; IAutoCompleteDropDown IAutoCompleteDropDown_iface;
LONG ref; LONG ref;
BOOL initialized; BOOL initialized;
BOOL enabled; BOOL enabled;
...@@ -85,16 +85,15 @@ static const IAutoCompleteDropDownVtbl acdropdownvt; ...@@ -85,16 +85,15 @@ static const IAutoCompleteDropDownVtbl acdropdownvt;
static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o', static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o',
'c','o','m','p','l','e','t','e',' ', 'c','o','m','p','l','e','t','e',' ',
'c','o','n','t','r','o','l',0}; 'c','o','n','t','r','o','l',0};
/*
converts This to an interface pointer static inline IAutoCompleteImpl *impl_from_IAutoComplete2(IAutoComplete2 *iface)
*/ {
#define _IUnknown_(This) ((IUnknown*)&(This)->lpVtbl) return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoComplete2_iface);
#define _IAutoComplete2_(This) ((IAutoComplete2*)&(This)->lpVtbl) }
#define _IAutoCompleteDropDown_(This) (&(This)->lpDropDownVtbl)
static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDropDown *iface) static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDropDown *iface)
{ {
return (IAutoCompleteImpl *)((char *)iface - FIELD_OFFSET(IAutoCompleteImpl, lpDropDownVtbl)); return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
} }
static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
...@@ -134,13 +133,13 @@ HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVO ...@@ -134,13 +133,13 @@ HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVO
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
lpac->ref = 1; lpac->ref = 1;
lpac->lpVtbl = &acvt; lpac->IAutoComplete2_iface.lpVtbl = &acvt;
lpac->lpDropDownVtbl = &acdropdownvt; lpac->IAutoCompleteDropDown_iface.lpVtbl = &acdropdownvt;
lpac->enabled = TRUE; lpac->enabled = TRUE;
lpac->options = ACO_AUTOAPPEND; lpac->options = ACO_AUTOAPPEND;
hr = IUnknown_QueryInterface(_IUnknown_ (lpac), riid, ppv); hr = IAutoComplete2_QueryInterface(&lpac->IAutoComplete2_iface, riid, ppv);
IUnknown_Release(_IUnknown_ (lpac)); IAutoComplete2_Release(&lpac->IAutoComplete2_iface);
TRACE("-- (%p)->\n",lpac); TRACE("-- (%p)->\n",lpac);
...@@ -155,8 +154,8 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface( ...@@ -155,8 +154,8 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
REFIID riid, REFIID riid,
LPVOID *ppvObj) LPVOID *ppvObj)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
TRACE("(%p)->(IID:%s,%p)\n", This, shdebugstr_guid(riid), ppvObj); TRACE("(%p)->(IID:%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
*ppvObj = NULL; *ppvObj = NULL;
...@@ -168,7 +167,7 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface( ...@@ -168,7 +167,7 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
} }
else if (IsEqualIID(riid, &IID_IAutoCompleteDropDown)) else if (IsEqualIID(riid, &IID_IAutoCompleteDropDown))
{ {
*ppvObj = _IAutoCompleteDropDown_(This); *ppvObj = &This->IAutoCompleteDropDown_iface;
} }
if (*ppvObj) if (*ppvObj)
...@@ -187,9 +186,9 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface( ...@@ -187,9 +186,9 @@ static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
static ULONG WINAPI IAutoComplete2_fnAddRef( static ULONG WINAPI IAutoComplete2_fnAddRef(
IAutoComplete2 * iface) IAutoComplete2 * iface)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%u)\n", This, refCount - 1); TRACE("(%p)->(%u)\n", This, refCount - 1);
return refCount; return refCount;
...@@ -201,7 +200,7 @@ static ULONG WINAPI IAutoComplete2_fnAddRef( ...@@ -201,7 +200,7 @@ static ULONG WINAPI IAutoComplete2_fnAddRef(
static ULONG WINAPI IAutoComplete2_fnRelease( static ULONG WINAPI IAutoComplete2_fnRelease(
IAutoComplete2 * iface) IAutoComplete2 * iface)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%u)\n", This, refCount + 1); TRACE("(%p)->(%u)\n", This, refCount + 1);
...@@ -224,8 +223,7 @@ static HRESULT WINAPI IAutoComplete2_fnEnable( ...@@ -224,8 +223,7 @@ static HRESULT WINAPI IAutoComplete2_fnEnable(
IAutoComplete2 * iface, IAutoComplete2 * iface,
BOOL fEnable) BOOL fEnable)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false"); TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
...@@ -245,7 +243,7 @@ static HRESULT WINAPI IAutoComplete2_fnInit( ...@@ -245,7 +243,7 @@ static HRESULT WINAPI IAutoComplete2_fnInit(
LPCOLESTR pwzsRegKeyPath, LPCOLESTR pwzsRegKeyPath,
LPCOLESTR pwszQuickComplete) LPCOLESTR pwszQuickComplete)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
TRACE("(%p)->(%p, %p, %s, %s)\n", TRACE("(%p)->(%p, %p, %s, %s)\n",
This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete)); This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
...@@ -274,7 +272,7 @@ static HRESULT WINAPI IAutoComplete2_fnInit( ...@@ -274,7 +272,7 @@ static HRESULT WINAPI IAutoComplete2_fnInit(
This->hwndEdit = hwndEdit; This->hwndEdit = hwndEdit;
This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc); This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
/* Keep at least one reference to the object until the edit window is destroyed. */ /* Keep at least one reference to the object until the edit window is destroyed. */
IAutoComplete2_AddRef((IAutoComplete2 *)This); IAutoComplete2_AddRef(&This->IAutoComplete2_iface);
SetPropW( hwndEdit, autocomplete_propertyW, This ); SetPropW( hwndEdit, autocomplete_propertyW, This );
if (This->options & ACO_AUTOSUGGEST) if (This->options & ACO_AUTOSUGGEST)
...@@ -326,10 +324,9 @@ static HRESULT WINAPI IAutoComplete2_fnGetOptions( ...@@ -326,10 +324,9 @@ static HRESULT WINAPI IAutoComplete2_fnGetOptions(
IAutoComplete2 * iface, IAutoComplete2 * iface,
DWORD *pdwFlag) DWORD *pdwFlag)
{ {
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
HRESULT hr = S_OK; HRESULT hr = S_OK;
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
TRACE("(%p) -> (%p)\n", This, pdwFlag); TRACE("(%p) -> (%p)\n", This, pdwFlag);
*pdwFlag = This->options; *pdwFlag = This->options;
...@@ -344,10 +341,9 @@ static HRESULT WINAPI IAutoComplete2_fnSetOptions( ...@@ -344,10 +341,9 @@ static HRESULT WINAPI IAutoComplete2_fnSetOptions(
IAutoComplete2 * iface, IAutoComplete2 * iface,
DWORD dwFlag) DWORD dwFlag)
{ {
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
HRESULT hr = S_OK; HRESULT hr = S_OK;
IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
TRACE("(%p) -> (0x%x)\n", This, dwFlag); TRACE("(%p) -> (0x%x)\n", This, dwFlag);
This->options = dwFlag; This->options = dwFlag;
...@@ -434,19 +430,19 @@ static HRESULT WINAPI IAutoCompleteDropDown_fnQueryInterface(IAutoCompleteDropDo ...@@ -434,19 +430,19 @@ static HRESULT WINAPI IAutoCompleteDropDown_fnQueryInterface(IAutoCompleteDropDo
REFIID riid, LPVOID *ppvObj) REFIID riid, LPVOID *ppvObj)
{ {
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface); IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
return IAutoComplete2_fnQueryInterface(_IAutoComplete2_(This), riid, ppvObj); return IAutoComplete2_fnQueryInterface(&This->IAutoComplete2_iface, riid, ppvObj);
} }
static ULONG WINAPI IAutoCompleteDropDown_fnAddRef(IAutoCompleteDropDown *iface) static ULONG WINAPI IAutoCompleteDropDown_fnAddRef(IAutoCompleteDropDown *iface)
{ {
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface); IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
return IAutoComplete2_fnAddRef(_IAutoComplete2_(This)); return IAutoComplete2_fnAddRef(&This->IAutoComplete2_iface);
} }
static ULONG WINAPI IAutoCompleteDropDown_fnRelease(IAutoCompleteDropDown *iface) static ULONG WINAPI IAutoCompleteDropDown_fnRelease(IAutoCompleteDropDown *iface)
{ {
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface); IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
return IAutoComplete2_fnRelease(_IAutoComplete2_(This)); return IAutoComplete2_fnRelease(&This->IAutoComplete2_iface);
} }
/************************************************************************** /**************************************************************************
...@@ -636,7 +632,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, ...@@ -636,7 +632,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
This->hwndEdit = NULL; This->hwndEdit = NULL;
if (This->hwndListBox) if (This->hwndListBox)
DestroyWindow(This->hwndListBox); DestroyWindow(This->hwndListBox);
IAutoComplete2_Release((IAutoComplete2 *)This); IAutoComplete2_Release(&This->IAutoComplete2_iface);
return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam); return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam);
} }
default: default:
......
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