2010-02-14 15:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbwince.h
    * redirect GetProcAddress() to GetProcAddressA() in WinCE builds.
      ASCII version of GetProcAddress() is supported by WinCE 3.0 and
      later versions.

  * harbour/include/hbdefs.h
    - removed HBTEXT() macro

  * harbour/src/common/hbver.c
  * harbour/src/rtl/diskspac.c
  * harbour/src/rtl/disksphb.c
  * harbour/src/rtl/gtwvt/gtwvt.c
  * harbour/src/vm/extrap.c
  * harbour/src/vm/maindllp/dllpcode.c
  * harbour/contrib/gtwvg/gtwvg.c
  * harbour/contrib/gtwvg/gtwvg.h
  * harbour/contrib/gtwvg/wvgwin.c
  * harbour/contrib/hbwin/wapi_winbase.c
  * harbour/contrib/hbwin/axcore.c
  * harbour/contrib/hbwin/mapi.c
  * harbour/contrib/hbwin/win_prn2.c
  * harbour/contrib/hbwin/win_prn3.c
  * harbour/contrib/hbwin/wapi_shellapi.c
    * eliminated HBTEXT() macro

  * harbour/src/rtl/diskspac.c
  * harbour/src/rtl/disksphb.c
  * harbour/contrib/hbwin/wapi_winbase.c
    % optimized GetProcAddress() calls to store function addresses
      in static variables
This commit is contained in:
Przemyslaw Czerpak
2010-02-14 14:18:13 +00:00
parent 28df65d9b9
commit cdd7cd30db
18 changed files with 124 additions and 95 deletions

View File

@@ -17,6 +17,38 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-02-14 15:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbwince.h
* redirect GetProcAddress() to GetProcAddressA() in WinCE builds.
ASCII version of GetProcAddress() is supported by WinCE 3.0 and
later versions.
* harbour/include/hbdefs.h
- removed HBTEXT() macro
* harbour/src/common/hbver.c
* harbour/src/rtl/diskspac.c
* harbour/src/rtl/disksphb.c
* harbour/src/rtl/gtwvt/gtwvt.c
* harbour/src/vm/extrap.c
* harbour/src/vm/maindllp/dllpcode.c
* harbour/contrib/gtwvg/gtwvg.c
* harbour/contrib/gtwvg/gtwvg.h
* harbour/contrib/gtwvg/wvgwin.c
* harbour/contrib/hbwin/wapi_winbase.c
* harbour/contrib/hbwin/axcore.c
* harbour/contrib/hbwin/mapi.c
* harbour/contrib/hbwin/win_prn2.c
* harbour/contrib/hbwin/win_prn3.c
* harbour/contrib/hbwin/wapi_shellapi.c
* eliminated HBTEXT() macro
* harbour/src/rtl/diskspac.c
* harbour/src/rtl/disksphb.c
* harbour/contrib/hbwin/wapi_winbase.c
% optimized GetProcAddress() calls to store function addresses
in static variables
2010-02-14 15:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/hbdyn.c
! Fixed handling of HB_DYN_ENC_RAW and HB_DYN_CTYPE_CHAR_UNSIGNED

View File

@@ -2556,15 +2556,9 @@ static HB_BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT )
{
typedef BOOL ( WINAPI * P_SLWA )( HWND, COLORREF, BYTE, DWORD );
#if defined( UNICODE ) && defined( GetProcAddress )
P_SLWA pSetLayeredWindowAttributes = ( P_SLWA )
GetProcAddress( GetModuleHandle( TEXT( "user32.dll" ) ),
HBTEXT( "SetLayeredWindowAttributes" ) );
#else
P_SLWA pSetLayeredWindowAttributes = ( P_SLWA )
GetProcAddress( GetModuleHandle( TEXT( "user32.dll" ) ),
HBTEXT( "SetLayeredWindowAttributes" ) );
#endif
"SetLayeredWindowAttributes" );
if( pSetLayeredWindowAttributes )
{
@@ -4188,11 +4182,7 @@ static void hb_wvt_gtLoadGuiData( void )
if( h )
{
/* workaround for wrong declarations in some old C compilers */
#if defined( UNICODE ) && defined( GetProcAddress )
s_guiData->pfnGF = ( wvtGradientFill ) GetProcAddressW( h, HBTEXT( "GradientFill" ) );
#else
s_guiData->pfnGF = ( wvtGradientFill ) GetProcAddress( h, HBTEXT( "GradientFill" ) );
#endif
s_guiData->pfnGF = ( wvtGradientFill ) GetProcAddress( h, "GradientFill" );
if( s_guiData->pfnGF )
{
s_guiData->hMSImg32 = h;
@@ -4202,12 +4192,7 @@ static void hb_wvt_gtLoadGuiData( void )
h = LoadLibraryEx( TEXT( "user32.dll" ), NULL, 0 );
if( h )
{
/* workaround for wrong declarations in some old C compilers */
#if defined( UNICODE ) && defined( GetProcAddress )
s_guiData->pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddressW( h, HBTEXT( "SetLayeredWindowAttributes" ) );
#else
s_guiData->pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddress( h, HBTEXT( "SetLayeredWindowAttributes" ) );
#endif
s_guiData->pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddress( h, "SetLayeredWindowAttributes" );
if( s_guiData->pfnLayered )
{
s_guiData->hUser32 = h;

View File

@@ -100,6 +100,10 @@
#include "hbgtwvg.ch"
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
HB_EXTERN_BEGIN
/*----------------------------------------------------------------------*/

View File

@@ -1158,11 +1158,7 @@ HB_FUNC( WVG_SETLAYEREDWINDOWATTRIBUTES )
h = LoadLibraryEx( TEXT( "user32.dll" ), NULL, 0 );
if( h )
{
#if defined( UNICODE ) && defined( GetProcAddress )
pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddressW( h, HBTEXT( "SetLayeredWindowAttributes" ) );
#else
pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddress( h, HBTEXT( "SetLayeredWindowAttributes" ) );
#endif
pfnLayered = ( wvtSetLayeredWindowAttributes ) GetProcAddress( h, "SetLayeredWindowAttributes" );
if( pfnLayered )
{
HWND hWnd = wapi_par_HWND( 1 );

View File

@@ -51,6 +51,9 @@
*/
#include "hbwinole.h"
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
typedef BOOL ( CALLBACK * PHB_AX_WININIT )( void );
typedef HRESULT ( CALLBACK * PHB_AX_GETCTRL )( HWND, IUnknown** );
@@ -103,8 +106,8 @@ HB_BOOL hb_oleAxInit( void )
s_hLib = NULL;
return HB_FALSE;
}
pAtlAxWinInit = ( PHB_AX_WININIT ) GetProcAddress( s_hLib, HBTEXT( "AtlAxWinInit" ) );
s_pAtlAxGetControl = ( PHB_AX_GETCTRL ) GetProcAddress( s_hLib, HBTEXT( "AtlAxGetControl" ) );
pAtlAxWinInit = ( PHB_AX_WININIT ) GetProcAddress( s_hLib, "AtlAxWinInit" );
s_pAtlAxGetControl = ( PHB_AX_GETCTRL ) GetProcAddress( s_hLib, "AtlAxGetControl" );
if( pAtlAxWinInit )
( *pAtlAxWinInit )();

View File

@@ -52,6 +52,9 @@
*/
#include "hbwin.h"
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
#include <mapi.h>
@@ -80,7 +83,7 @@ HB_FUNC( WIN_MAPISENDMAIL )
if( ( hMapiDll = LoadLibrary( TEXT( "mapi32.dll" ) ) ) >= ( HINSTANCE ) 32 )
{
LPMAPISENDMAIL MAPISendMail = ( LPMAPISENDMAIL ) GetProcAddress( hMapiDll, HBTEXT( "MAPISendMail" ) );
LPMAPISENDMAIL MAPISendMail = ( LPMAPISENDMAIL ) GetProcAddress( hMapiDll, "MAPISendMail" );
if( MAPISendMail )
{

View File

@@ -51,6 +51,9 @@
*/
#include "hbwapi.h"
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
HB_FUNC( WAPI_SHELLEXECUTE )
{
@@ -85,7 +88,8 @@ HB_FUNC( WAPI_ISUSERANADMIN )
if( hLib )
{
typedef int ( WINAPI * ISUSERANADMIN )( void );
ISUSERANADMIN pIsUserAnAdmin = ( ISUSERANADMIN ) GetProcAddress( hLib, HBTEXT( "IsUserAnAdmin" ) );
ISUSERANADMIN pIsUserAnAdmin = ( ISUSERANADMIN )
GetProcAddress( hLib, "IsUserAnAdmin" );
if( pIsUserAnAdmin )
bResult = ( pIsUserAnAdmin )();

View File

@@ -225,19 +225,9 @@ HB_FUNC( WAPI_GETPROCADDRESS )
{
FARPROC pProc;
DWORD dwLastError;
#if defined( HB_OS_WIN_CE )
void * hProcName;
pProc = GetProcAddress( ( HMODULE ) hb_parptr( 1 ), HB_ISCHAR( 2 ) ?
hb_parstr_u16( 2, HB_CDP_ENDIAN_NATIVE, &hProcName, NULL ) :
( LPCTSTR ) ( HB_PTRDIFF ) hb_parnint( 2 ) );
dwLastError = GetLastError();
hb_strfree( hProcName );
#else
pProc = GetProcAddress( ( HMODULE ) hb_parptr( 1 ), HB_ISCHAR( 2 ) ?
hb_parc( 2 ) : ( LPCSTR ) ( HB_PTRDIFF ) hb_parnint( 2 ) );
dwLastError = GetLastError();
#endif
hbwapi_SetLastError( dwLastError );
hb_retptr( ( void * ) pProc );
}
@@ -370,20 +360,17 @@ HB_FUNC( WAPI_GETSHORTPATHNAME )
HB_FUNC( WAPI_GETLONGPATHNAME )
{
_HB_GETPATHNAME getPathName = NULL;
HMODULE hLib = LoadLibrary( TEXT( "kernel32.dll" ) );
static _HB_GETPATHNAME s_getPathNameAddr = NULL;
if( hLib )
getPathName = ( _HB_GETPATHNAME )
GetProcAddress( hLib, HBTEXT( "GetLongPathName" ) );
if( !getPathName )
getPathName = GetShortPathName;
s_getPathName( getPathName );
if( hLib )
FreeLibrary( hLib );
if( !s_getPathNameAddr )
{
s_getPathNameAddr = ( _HB_GETPATHNAME )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
"GetLongPathName" );
if( !s_getPathNameAddr )
s_getPathNameAddr = GetShortPathName;
}
s_getPathName( s_getPathNameAddr );
}
#endif

View File

@@ -135,9 +135,9 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName )
{
fnGetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool,
#if defined( UNICODE )
HBTEXT( "GetDefaultPrinterW" ) );
"GetDefaultPrinterW" );
#else
HBTEXT( "GetDefaultPrinterA" ) );
"GetDefaultPrinterA" );
#endif
if( fnGetDefaultPrinter )

View File

@@ -165,9 +165,9 @@ static HB_BOOL hb_SetDefaultPrinter( LPCTSTR lpPrinterName )
return HB_FALSE;
fnSetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool,
#if defined( UNICODE )
HBTEXT( "SetDefaultPrinterW" ) );
"SetDefaultPrinterW" );
#else
HBTEXT( "SetDefaultPrinterA" ) );
"SetDefaultPrinterA" );
#endif
if( ! fnSetDefaultPrinter )
{

View File

@@ -1583,11 +1583,6 @@ typedef HB_U32 HB_FATTR;
extern HB_EXPORT void hb_wctombget( char * dstA, const wchar_t * srcW, HB_SIZE ulLen );
HB_EXTERN_END
#if defined( HB_OS_WIN_CE )
#define HBTEXT( x ) TEXT( x )
#else
#define HBTEXT( x ) x
#endif
#endif
#if defined( HB_OS_WIN ) && defined( UNICODE )

View File

@@ -58,6 +58,12 @@
#include <windows.h>
/* use ASCII version of GetProcAddress() to keep the same code for desktop
* windows and WinCE/Mobile. It's supported by WinCE 3.0 and later versions.
*/
#undef GetProcAddress
#define GetProcAddress GetProcAddressA
HB_EXTERN_BEGIN
#if defined( _MSC_VER )

View File

@@ -80,6 +80,9 @@
#if defined( HB_OS_WIN )
#include <windows.h>
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
#ifndef VER_PLATFORM_WIN32_WINDOWS
#define VER_PLATFORM_WIN32_WINDOWS 1
@@ -269,7 +272,7 @@ char * hb_verPlatform( void )
const char * pszWine = "";
const char * pszName = "";
if( hntdll && GetProcAddress( hntdll, HBTEXT( "wine_get_version" ) ) )
if( hntdll && GetProcAddress( hntdll, "wine_get_version" ) )
pszWine = " (Wine)";
switch( osVer.dwPlatformId )

View File

@@ -154,20 +154,28 @@ HB_FUNC( DISKSPACE )
{
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
HBTEXT( "GetDiskFreeSpaceExW" ) );
#else
HBTEXT( "GetDiskFreeSpaceExA" ) );
#endif
if( pGetDiskFreeSpaceEx )
static P_GDFSE s_pGetDiskFreeSpaceEx = NULL;
static HB_BOOL s_fInit = HB_FALSE;
if( !s_fInit )
{
bError = pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes ) ? HB_FALSE : HB_TRUE;
s_fInit = HB_TRUE;
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
"GetDiskFreeSpaceExW" );
#else
"GetDiskFreeSpaceExA" );
#endif
}
if( s_pGetDiskFreeSpaceEx )
{
bError = s_pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes ) ? HB_FALSE : HB_TRUE;
if( ! bError )
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
}

View File

@@ -210,24 +210,29 @@ HB_FUNC( HB_DISKSPACE )
}
#else
{
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
HBTEXT( "GetDiskFreeSpaceExW" ) );
#else
HBTEXT( "GetDiskFreeSpaceExA" ) );
#endif
static P_GDFSE s_pGetDiskFreeSpaceEx = NULL;
static HB_BOOL s_fInit = HB_FALSE;
if( pGetDiskFreeSpaceEx )
if( !s_fInit )
{
fResult = pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes ) ? HB_TRUE : HB_FALSE;
s_fInit = HB_TRUE;
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
"GetDiskFreeSpaceExW" );
#else
"GetDiskFreeSpaceExA" );
#endif
}
if( s_pGetDiskFreeSpaceEx )
{
fResult = s_pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes ) ? HB_TRUE : HB_FALSE;
hb_fsSetIOError( fResult, 0 );
if( fResult )
{

View File

@@ -1860,7 +1860,7 @@ static HB_BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT )
P_SLWA pSetLayeredWindowAttributes = ( P_SLWA )
GetProcAddress( GetModuleHandle( TEXT( "user32.dll" ) ),
HBTEXT( "SetLayeredWindowAttributes" ) );
"SetLayeredWindowAttributes" );
if( pSetLayeredWindowAttributes )
{

View File

@@ -234,9 +234,9 @@ static LONG WINAPI hb_winExceptionHandler( struct _EXCEPTION_POINTERS * pExcepti
typedef BOOL ( WINAPI * P_M32F )( HANDLE, LPMODULEENTRY32 ); /* Module32First() */
typedef BOOL ( WINAPI * P_M32N )( HANDLE, LPMODULEENTRY32 ); /* Module32Next() */
P_CTH32SSH pCreateToolhelp32Snapshot = ( P_CTH32SSH ) GetProcAddress( hKernel32, HBTEXT( "CreateToolhelp32Snapshot" ) );
P_M32F pModule32First = ( P_M32F ) GetProcAddress( hKernel32, HBTEXT( "Module32First" ) );
P_M32N pModule32Next = ( P_M32N ) GetProcAddress( hKernel32, HBTEXT( "Module32Next" ) );
P_CTH32SSH pCreateToolhelp32Snapshot = ( P_CTH32SSH ) GetProcAddress( hKernel32, "CreateToolhelp32Snapshot" );
P_M32F pModule32First = ( P_M32F ) GetProcAddress( hKernel32, "Module32First" );
P_M32N pModule32Next = ( P_M32N ) GetProcAddress( hKernel32, "Module32Next" );
if( pCreateToolhelp32Snapshot &&
pModule32First &&

View File

@@ -58,6 +58,9 @@
#if defined( HB_OS_WIN )
#include <windows.h>
#if defined( HB_OS_WIN_CE )
#include "hbwince.h"
#endif
#endif
#define HB_DLL_PREF TEXT( "harbour" )
@@ -146,12 +149,7 @@ PHB_FUNC hb_dllGetProcAddress( const char * szProcName )
if( s_hModule != NULL )
{
#if defined( HB_OS_WIN_CE )
# define HBTEXTSTR LPCTSTR
#else
# define HBTEXTSTR LPCSTR
#endif
static HBTEXTSTR s_szGetProcAddr = HBTEXT( "_dll_hb_vmProcAddress" );
static const char * s_szGetProcAddr = "_dll_hb_vmProcAddress";
int i = 6;
do