2012-01-02 21:38 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* harbour/include/hbapistr.h
  * harbour/src/vm/strapi.c
    + added new C functions:
         const char * hb_parastr( int iParam, HB_SIZE nIndex,
                                  void * cdp,
                                  void ** phString, HB_SIZE * pnLen );
         const char * hb_parastr_utf8( int iParam, HB_SIZE nIndex,
                                       void ** phString, HB_SIZE * pnLen );
         const HB_WCHAR * hb_parastr_u16( int iParam, HB_SIZE nIndex,
                                          int iEndian,
                                          void ** phString, HB_SIZE * pnLen );

  * harbour/include/hbwinuni.h
    + added new C macros for windows builds:
         HB_PARASTR( nItem, nIndex, phStr, pnLen )
         HB_PARASTRDEF( nItem, nIndex, phStr, pnLen )

  * harbour/src/vm/hashes.c
    + added optional code for deleting items from hash arrays with
      strict order. This code can be enabled by Harbour compile time
      macro: HB_FAST_HASH_DEL.
      I added it for testing only.
This commit is contained in:
Przemyslaw Czerpak
2012-01-02 20:38:17 +00:00
parent fc7ea4f146
commit 35fbd4f189
5 changed files with 151 additions and 0 deletions

View File

@@ -16,6 +16,30 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-01-02 21:38 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbapistr.h
* harbour/src/vm/strapi.c
+ added new C functions:
const char * hb_parastr( int iParam, HB_SIZE nIndex,
void * cdp,
void ** phString, HB_SIZE * pnLen );
const char * hb_parastr_utf8( int iParam, HB_SIZE nIndex,
void ** phString, HB_SIZE * pnLen );
const HB_WCHAR * hb_parastr_u16( int iParam, HB_SIZE nIndex,
int iEndian,
void ** phString, HB_SIZE * pnLen );
* harbour/include/hbwinuni.h
+ added new C macros for windows builds:
HB_PARASTR( nItem, nIndex, phStr, pnLen )
HB_PARASTRDEF( nItem, nIndex, phStr, pnLen )
* harbour/src/vm/hashes.c
+ added optional code for deleting items from hash arrays with
strict order. This code can be enabled by Harbour compile time
macro: HB_FAST_HASH_DEL.
I added it for testing only.
2012-01-01 14:05 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/gtwvg/wvgcore.c
* contrib/gtwvg/wvgcuig.c

View File

@@ -109,6 +109,10 @@ extern HB_EXPORT const char * hb_parstr( int iParam, void * cdp, void ** phStrin
extern HB_EXPORT const char * hb_parstr_utf8( int iParam, void ** phString, HB_SIZE * pnLen );
extern HB_EXPORT const HB_WCHAR * hb_parstr_u16( int iParam, int iEndian, void ** phString, HB_SIZE * pnLen );
extern HB_EXPORT const char * hb_parastr( int iParam, HB_SIZE nIndex, void * cdp, void ** phString, HB_SIZE * pnLen );
extern HB_EXPORT const char * hb_parastr_utf8( int iParam, HB_SIZE nIndex, void ** phString, HB_SIZE * pnLen );
extern HB_EXPORT const HB_WCHAR * hb_parastr_u16( int iParam, HB_SIZE nIndex, int iEndian, void ** phString, HB_SIZE * pnLen );
extern HB_EXPORT void hb_retstr( void * cdp, const char * szText );
extern HB_EXPORT void hb_retstr_utf8( const char * szText );
extern HB_EXPORT void hb_retstr_u16( int iEndian, const HB_WCHAR * szText );

View File

@@ -62,6 +62,8 @@
#if defined( UNICODE )
#define HB_PARSTR( n, h, len ) hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len )
#define HB_PARSTRDEF( n, h, len ) hb_wstrnull( hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len ) )
#define HB_PARASTR( n, i, h, len ) hb_parastr_u16( n, i, HB_CDP_ENDIAN_NATIVE, h, len )
#define HB_PARASTRDEF( n, i, h, len ) hb_wstrnull( hb_parastr_u16( n, i, HB_CDP_ENDIAN_NATIVE, h, len ) )
#define HB_RETSTR( str ) hb_retstr_u16( HB_CDP_ENDIAN_NATIVE, str )
#define HB_RETSTRLEN( str, len ) hb_retstrlen_u16( HB_CDP_ENDIAN_NATIVE, str, len )
#define HB_STORSTR( str, n ) hb_storstr_u16( HB_CDP_ENDIAN_NATIVE, str, n )
@@ -85,6 +87,8 @@
#else
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
#define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
#define HB_PARASTR( n, i, h, len ) hb_parastr( n, i, hb_setGetOSCP(), h, len )
#define HB_PARASTRDEF( n, i, h, len ) hb_strnull( hb_parastr( n, i, hb_setGetOSCP(), h, len ) )
#define HB_RETSTR( str ) hb_retstr( hb_setGetOSCP(), str )
#define HB_RETSTRLEN( str, len ) hb_retstrlen( hb_setGetOSCP(), str, len )
#define HB_STORSTR( str, n ) hb_storstr( hb_setGetOSCP(), str, n )

View File

@@ -443,6 +443,42 @@ static void hb_hashDelPair( PHB_BASEHASH pBaseHash, HB_SIZE nPos )
{
if( pBaseHash->pnPos )
{
#ifdef HB_FAST_HASH_DEL
HB_SIZE * pnPos, * pnDel, * pnLast;
pnPos = pBaseHash->pnPos + pBaseHash->nLen;
pnDel = pnLast = NULL;
for( ;; )
{
if( *pnPos == nPos )
{
pnDel = pnPos;
if( pnLast != NULL )
break;
}
if( *pnPos == pBaseHash->nLen )
{
pnLast = pnPos;
if( pnDel != NULL )
break;
}
if( pnPos-- == pBaseHash->pnPos )
hb_errInternal( HB_EI_ERRUNRECOV, "HB_HDEL(): corrupted hash index", NULL, NULL );
}
*pnLast = *pnDel;
if( pnDel < pBaseHash->pnPos + pBaseHash->nLen )
memmove( pnDel, pnDel + 1,
( pBaseHash->pnPos + pBaseHash->nLen - pnDel ) * sizeof( HB_SIZE ) );
if( nPos != pBaseHash->nLen )
{
HB_HASHPAIR pair;
memcpy( &pair, pBaseHash->pPairs + nPos, sizeof( HB_HASHPAIR ) );
memcpy( pBaseHash->pPairs + nPos, pBaseHash->pPairs + pBaseHash->nLen,
sizeof( HB_HASHPAIR ) );
nPos = pBaseHash->nLen;
memcpy( pBaseHash->pPairs + nPos, &pair, sizeof( HB_HASHPAIR ) );
}
#else
HB_SIZE n = 0;
while( n < pBaseHash->nLen )
{
@@ -454,6 +490,7 @@ static void hb_hashDelPair( PHB_BASEHASH pBaseHash, HB_SIZE nPos )
else
++n;
}
#endif
}
if( nPos != pBaseHash->nLen )

View File

@@ -770,6 +770,88 @@ const HB_WCHAR * hb_parstr_u16( int iParam, int iEndian,
}
const char * hb_parastr( int iParam, HB_SIZE nIndex,
void * cdp, void ** phString, HB_SIZE * pnLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_parastr(%d,%" HB_PFS "u,%p,%p,%p)", iParam, nIndex, cdp, phString, pnLen));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
return hb_arrayGetStr( pItem, nIndex, cdp, phString, pnLen );
else
return hb_itemGetStr( pItem, cdp, phString, pnLen );
}
if( pnLen )
* pnLen = 0;
* phString = NULL;
return NULL;
}
const char * hb_parastr_utf8( int iParam, HB_SIZE nIndex,
void ** phString, HB_SIZE * pnLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_parastr_utf8(%d,%" HB_PFS "u,%p,%p)", iParam, nIndex, phString, pnLen));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
return hb_arrayGetStrUTF8( pItem, nIndex, phString, pnLen );
else
return hb_itemGetStrUTF8( pItem, phString, pnLen );
}
if( pnLen )
* pnLen = 0;
* phString = NULL;
return NULL;
}
const HB_WCHAR * hb_parastr_u16( int iParam, HB_SIZE nIndex, int iEndian,
void ** phString, HB_SIZE * pnLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_parastr_u16(%d,%" HB_PFS "u,%d,%p,%p)", iParam, nIndex, iEndian, phString, pnLen));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
return hb_arrayGetStrU16( pItem, nIndex, iEndian, phString, pnLen );
else
return hb_itemGetStrU16( pItem, iEndian, phString, pnLen );
}
if( pnLen )
* pnLen = 0;
* phString = NULL;
return NULL;
}
void hb_retstr( void * cdp, const char * szText )
{
HB_STACK_TLS_PRELOAD