Commit 5905ba95 authored by Alexandre Julliard's avatar Alexandre Julliard

Implement EnumProps on top of EnumPropsEx to avoid function pointer

type mismatches.
parent 7c4b1403
...@@ -24,6 +24,8 @@ typedef struct tagPROPERTY ...@@ -24,6 +24,8 @@ typedef struct tagPROPERTY
} PROPERTY; } PROPERTY;
#define MAX_ATOM_LEN 255
/*********************************************************************** /***********************************************************************
* PROP_FindProp * PROP_FindProp
*/ */
...@@ -300,8 +302,27 @@ INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func ) ...@@ -300,8 +302,27 @@ INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
} }
#define MAX_ATOM_LEN 255 /* relay to call the EnumProps callback function from EnumPropsEx */
static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL ex ) static BOOL CALLBACK EnumPropsA_relay( HWND hwnd, LPCSTR str, HANDLE handle, ULONG_PTR lparam )
{
PROPENUMPROCA func = (PROPENUMPROCA)lparam;
return func( hwnd, str, handle );
}
/***********************************************************************
* EnumPropsA (USER32.@)
*/
INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
{
return EnumPropsExA( hwnd, EnumPropsA_relay, (LPARAM)func );
}
/***********************************************************************
* EnumPropsExA (USER32.@)
*/
INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
{ {
PROPERTY *prop, *next; PROPERTY *prop, *next;
WND *pWnd; WND *pWnd;
...@@ -309,8 +330,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL ...@@ -309,8 +330,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL
char atomStr[MAX_ATOM_LEN+1]; char atomStr[MAX_ATOM_LEN+1];
char *pStr; char *pStr;
TRACE("%04x %08x %08lx%s\n", TRACE("%04x %p %08lx\n", hwnd, func, lParam);
hwnd, (UINT)func, lParam, ex ? " [Ex]" : "" );
if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1; if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1;
for (prop = pWnd->pProp; (prop); prop = next) for (prop = pWnd->pProp; (prop); prop = next)
{ {
...@@ -323,8 +343,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL ...@@ -323,8 +343,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL
* This seems to be done for Win32 only */ * This seems to be done for Win32 only */
if (!(GlobalGetAtomNameA((ATOM)LOWORD(prop->string), atomStr, MAX_ATOM_LEN+1))) if (!(GlobalGetAtomNameA((ATOM)LOWORD(prop->string), atomStr, MAX_ATOM_LEN+1)))
{ {
ERR("huh ? Atom %04x not an atom ??\n", ERR("huh ? Atom %04x not an atom ??\n", LOWORD(prop->string));
(ATOM)LOWORD(prop->string));
atomStr[0] = '\0'; atomStr[0] = '\0';
} }
pStr = atomStr; pStr = atomStr;
...@@ -335,10 +354,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL ...@@ -335,10 +354,7 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL
TRACE(" Callback: handle=%08x str='%s'\n", TRACE(" Callback: handle=%08x str='%s'\n",
prop->handle, prop->string ); prop->handle, prop->string );
if (ex) /* EnumPropsEx has an additional lParam !! */ ret = func( hwnd, pStr, prop->handle, lParam );
ret = func( hwnd, pStr, prop->handle, lParam );
else
ret = func( hwnd, pStr, prop->handle );
if (!ret) break; if (!ret) break;
} }
WIN_ReleaseWndPtr(pWnd); WIN_ReleaseWndPtr(pWnd);
...@@ -346,25 +362,25 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL ...@@ -346,25 +362,25 @@ static INT PROPS_EnumPropsA( HWND hwnd, PROPENUMPROCA func, LPARAM lParam, BOOL
} }
/*********************************************************************** /* relay to call the EnumProps callback function from EnumPropsEx */
* EnumPropsA (USER32.@) static BOOL CALLBACK EnumPropsW_relay( HWND hwnd, LPCWSTR str, HANDLE handle, ULONG_PTR lparam )
*/
INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
{ {
return PROPS_EnumPropsA(hwnd, func, 0, FALSE); PROPENUMPROCW func = (PROPENUMPROCW)lparam;
return func( hwnd, str, handle );
} }
/*********************************************************************** /***********************************************************************
* EnumPropsExA (USER32.@) * EnumPropsW (USER32.@)
*/ */
INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam) INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
{ {
return PROPS_EnumPropsA(hwnd, (PROPENUMPROCA)func, lParam, TRUE); return EnumPropsExW( hwnd, EnumPropsW_relay, (LPARAM)func );
} }
/***********************************************************************
static INT PROPS_EnumPropsW( HWND hwnd, PROPENUMPROCW func, LPARAM lParam, BOOL ex ) * EnumPropsExW (USER32.@)
*/
INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
{ {
PROPERTY *prop, *next; PROPERTY *prop, *next;
WND *pWnd; WND *pWnd;
...@@ -373,8 +389,7 @@ static INT PROPS_EnumPropsW( HWND hwnd, PROPENUMPROCW func, LPARAM lParam, BOOL ...@@ -373,8 +389,7 @@ static INT PROPS_EnumPropsW( HWND hwnd, PROPENUMPROCW func, LPARAM lParam, BOOL
char *pStr; char *pStr;
LPWSTR strW; LPWSTR strW;
TRACE("%04x %08x %08lx%s\n", TRACE("%04x %p %08lx\n", hwnd, func, lParam);
hwnd, (UINT)func, lParam, ex ? " [Ex]" : "" );
if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1; if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1;
for (prop = pWnd->pProp; (prop); prop = next) for (prop = pWnd->pProp; (prop); prop = next)
{ {
...@@ -401,30 +416,10 @@ static INT PROPS_EnumPropsW( HWND hwnd, PROPENUMPROCW func, LPARAM lParam, BOOL ...@@ -401,30 +416,10 @@ static INT PROPS_EnumPropsW( HWND hwnd, PROPENUMPROCW func, LPARAM lParam, BOOL
strW = HEAP_strdupAtoW( GetProcessHeap(), 0, pStr ); strW = HEAP_strdupAtoW( GetProcessHeap(), 0, pStr );
if (ex) /* EnumPropsEx has an additional lParam !! */ ret = func( hwnd, strW, prop->handle, lParam );
ret = func( hwnd, strW, prop->handle, lParam );
else
ret = func( hwnd, strW, prop->handle );
HeapFree( GetProcessHeap(), 0, strW ); HeapFree( GetProcessHeap(), 0, strW );
if (!ret) break; if (!ret) break;
} }
WIN_ReleaseWndPtr(pWnd); WIN_ReleaseWndPtr(pWnd);
return ret; return ret;
} }
/***********************************************************************
* EnumPropsW (USER32.@)
*/
INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
{
return PROPS_EnumPropsW(hwnd, func, 0, FALSE);
}
/***********************************************************************
* EnumPropsExW (USER32.@)
*/
INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
{
return PROPS_EnumPropsW(hwnd, (PROPENUMPROCW)func, 0, TRUE);
}
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