2010-07-06 21:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* src/vm/hashfunc.c
  * src/vm/macro.c
  * src/vm/estack.c
  * src/vm/codebloc.c
  * src/vm/hashes.c
  * src/vm/debug.c
  * src/vm/asort.c
  * src/vm/garbage.c
  * src/vm/hvm.c
  * src/vm/cmdarg.c
  * src/vm/arrays.c
  * src/vm/fm.c
  * src/vm/arrayshb.c
  * src/vm/extend.c
  * src/vm/classes.c
    * Renamed HB_SIZE variables to have 'n' prefix.
      (verified to generate the same objects as before)
    ; TOFIX: as marked in hvm.c.
This commit is contained in:
Viktor Szakats
2010-07-06 19:45:23 +00:00
parent db1fbb5aed
commit fa8024e024
16 changed files with 1242 additions and 1222 deletions

View File

@@ -16,6 +16,26 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-07-06 21:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/vm/hashfunc.c
* src/vm/macro.c
* src/vm/estack.c
* src/vm/codebloc.c
* src/vm/hashes.c
* src/vm/debug.c
* src/vm/asort.c
* src/vm/garbage.c
* src/vm/hvm.c
* src/vm/cmdarg.c
* src/vm/arrays.c
* src/vm/fm.c
* src/vm/arrayshb.c
* src/vm/extend.c
* src/vm/classes.c
* Renamed HB_SIZE variables to have 'n' prefix.
(verified to generate the same objects as before)
; TOFIX: as marked in hvm.c.
2010-07-06 21:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbrun/hbrun.prg
! Don't search passed program in PATH and hbrun dir, if

View File

@@ -82,7 +82,7 @@ static void hb_arrayReleaseItems( PHB_BASEARRAY pBaseArray )
if( pBaseArray->nLen )
{
HB_ITEM_PTR pItems = pBaseArray->pItems;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE nLen = pBaseArray->nLen;
/*
* clear the pBaseArray->pItems to avoid infinite loop in cross
@@ -92,10 +92,10 @@ static void hb_arrayReleaseItems( PHB_BASEARRAY pBaseArray )
pBaseArray->pItems = NULL;
pBaseArray->nLen = 0;
while( ulLen-- )
while( nLen-- )
{
if( HB_IS_COMPLEX( pItems + ulLen ) )
hb_itemClear( pItems + ulLen );
if( HB_IS_COMPLEX( pItems + nLen ) )
hb_itemClear( pItems + nLen );
}
hb_xfree( pItems );
}
@@ -161,13 +161,13 @@ static HB_GARBAGE_FUNC( hb_arrayGarbageMark )
if( pBaseArray->nLen )
{
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE nLen = pBaseArray->nLen;
HB_ITEM_PTR pItems = pBaseArray->pItems;
while( ulLen-- )
while( nLen-- )
{
if( HB_IS_GCITEM( pItems + ulLen ) )
hb_gcItemRef( pItems + ulLen );
if( HB_IS_GCITEM( pItems + nLen ) )
hb_gcItemRef( pItems + nLen );
}
}
}
@@ -179,13 +179,13 @@ static const HB_GC_FUNCS s_gcArrayFuncs =
};
HB_BOOL hb_arrayNew( PHB_ITEM pItem, HB_SIZE ulLen ) /* creates a new array */
HB_BOOL hb_arrayNew( PHB_ITEM pItem, HB_SIZE nLen ) /* creates a new array */
{
PHB_BASEARRAY pBaseArray;
PHB_ITEM pItems;
HB_SIZE ulPos;
HB_SIZE nPos;
HB_TRACE(HB_TR_DEBUG, ("hb_arrayNew(%p, %" HB_PFS "u)", pItem, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_arrayNew(%p, %" HB_PFS "u)", pItem, nLen));
if( HB_IS_COMPLEX( pItem ) )
hb_itemClear( pItem );
@@ -195,52 +195,52 @@ HB_BOOL hb_arrayNew( PHB_ITEM pItem, HB_SIZE ulLen ) /* creates a new array */
* safe for automatic GC activation in hb_xgrab() without
* calling hb_gcLock()/hb_gcUnlock(). [druzus]
*/
if( ulLen > 0 )
if( nLen > 0 )
{
pItems = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) * ulLen );
for( ulPos = 0; ulPos < ulLen; ++ulPos )
( pItems + ulPos )->type = HB_IT_NIL;
pItems = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) * nLen );
for( nPos = 0; nPos < nLen; ++nPos )
( pItems + nPos )->type = HB_IT_NIL;
}
else
pItems = NULL;
pBaseArray = ( PHB_BASEARRAY ) hb_gcAllocRaw( sizeof( HB_BASEARRAY ), &s_gcArrayFuncs );
pBaseArray->pItems = pItems;
pBaseArray->nLen = ulLen;
pBaseArray->nLen = nLen;
pBaseArray->uiClass = 0;
pBaseArray->uiPrevCls = 0;
pBaseArray->nAllocated = ulLen;
pBaseArray->nAllocated = nLen;
pItem->type = HB_IT_ARRAY;
pItem->item.asArray.value = pBaseArray;
return HB_TRUE;
}
HB_BOOL hb_arraySize( PHB_ITEM pArray, HB_SIZE ulLen )
HB_BOOL hb_arraySize( PHB_ITEM pArray, HB_SIZE nLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arraySize(%p, %" HB_PFS "u)", pArray, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_arraySize(%p, %" HB_PFS "u)", pArray, nLen));
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
if( ulLen != pBaseArray->nLen )
if( nLen != pBaseArray->nLen )
{
HB_SIZE ulPos;
HB_SIZE nPos;
if( pBaseArray->nLen == 0 )
{
pBaseArray->pItems = ( PHB_ITEM ) hb_xgrab( ulLen * sizeof( HB_ITEM ) );
pBaseArray->nAllocated = ulLen;
pBaseArray->pItems = ( PHB_ITEM ) hb_xgrab( nLen * sizeof( HB_ITEM ) );
pBaseArray->nAllocated = nLen;
for( ulPos = 0; ulPos < ulLen; ulPos++ )
( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
for( nPos = 0; nPos < nLen; nPos++ )
( pBaseArray->pItems + nPos )->type = HB_IT_NIL;
}
else
{
if( pBaseArray->nLen < ulLen )
if( pBaseArray->nLen < nLen )
{
if( pBaseArray->nAllocated < ulLen )
if( pBaseArray->nAllocated < nLen )
{
/*
A common practice is to double allocation buffer size. Thus, making
@@ -253,37 +253,37 @@ HB_BOOL hb_arraySize( PHB_ITEM pArray, HB_SIZE ulLen )
size is not doubled, but multiplied by 1.5;
- adding of 1, allows reduce reallocation count for small arrays.
*/
pBaseArray->nAllocated = ( pBaseArray->nAllocated >> 1 ) + 1 + ulLen;
pBaseArray->nAllocated = ( pBaseArray->nAllocated >> 1 ) + 1 + nLen;
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * pBaseArray->nAllocated );
}
/* set value for new items */
for( ulPos = pBaseArray->nLen; ulPos < ulLen; ulPos++ )
( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
for( nPos = pBaseArray->nLen; nPos < nLen; nPos++ )
( pBaseArray->pItems + nPos )->type = HB_IT_NIL;
}
else if( pBaseArray->nLen > ulLen )
else if( pBaseArray->nLen > nLen )
{
/* release old items */
for( ulPos = ulLen; ulPos < pBaseArray->nLen; ulPos++ )
for( nPos = nLen; nPos < pBaseArray->nLen; nPos++ )
{
if( HB_IS_COMPLEX( pBaseArray->pItems + ulPos ) )
hb_itemClear( pBaseArray->pItems + ulPos );
if( HB_IS_COMPLEX( pBaseArray->pItems + nPos ) )
hb_itemClear( pBaseArray->pItems + nPos );
}
if( ulLen == 0 )
if( nLen == 0 )
{
hb_xfree( pBaseArray->pItems );
pBaseArray->pItems = NULL;
}
else if( ulLen < ( pBaseArray->nAllocated >> 1 ) )
else if( nLen < ( pBaseArray->nAllocated >> 1 ) )
{
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );
pBaseArray->nAllocated = ulLen;
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * nLen );
pBaseArray->nAllocated = nLen;
}
}
}
pBaseArray->nLen = ulLen;
pBaseArray->nLen = nLen;
}
return HB_TRUE;
@@ -369,19 +369,19 @@ HB_BOOL hb_arrayDel( PHB_ITEM pArray, HB_SIZE nIndex )
if( HB_IS_ARRAY( pArray ) )
{
HB_SIZE ulLen = pArray->item.asArray.value->nLen;
HB_SIZE nLen = pArray->item.asArray.value->nLen;
if( nIndex > 0 && nIndex <= ulLen )
if( nIndex > 0 && nIndex <= nLen )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
if( nIndex == ulLen )
if( nIndex == nLen )
{
hb_itemSetNil( pBaseArray->pItems + nIndex - 1 );
}
else
{
for( ; nIndex < ulLen; ++nIndex ) /* move items */
for( ; nIndex < nLen; ++nIndex ) /* move items */
hb_itemMoveRef( pBaseArray->pItems + nIndex - 1,
pBaseArray->pItems + nIndex );
}
@@ -399,21 +399,21 @@ HB_BOOL hb_arrayIns( PHB_ITEM pArray, HB_SIZE nIndex )
if( HB_IS_ARRAY( pArray ) )
{
HB_SIZE ulLen = pArray->item.asArray.value->nLen;
HB_SIZE nLen = pArray->item.asArray.value->nLen;
if( nIndex > 0 && nIndex <= ulLen )
if( nIndex > 0 && nIndex <= nLen )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
if( nIndex == ulLen )
if( nIndex == nLen )
{
hb_itemSetNil( pBaseArray->pItems + nIndex - 1 );
}
else
{
while( --ulLen >= nIndex ) /* move items */
hb_itemMoveRef( pBaseArray->pItems + ulLen,
pBaseArray->pItems + ulLen - 1 );
while( --nLen >= nIndex ) /* move items */
hb_itemMoveRef( pBaseArray->pItems + nLen,
pBaseArray->pItems + nLen - 1 );
}
return HB_TRUE;
@@ -626,12 +626,12 @@ double hb_arrayGetND( PHB_ITEM pArray, HB_SIZE nIndex )
return 0;
}
HB_SIZE hb_arrayCopyC( PHB_ITEM pArray, HB_SIZE nIndex, char * szBuffer, HB_SIZE ulLen )
HB_SIZE hb_arrayCopyC( PHB_ITEM pArray, HB_SIZE nIndex, char * szBuffer, HB_SIZE nLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopyC(%p, %" HB_PFS "u, %s, %" HB_PFS "u)", pArray, nIndex, szBuffer, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopyC(%p, %" HB_PFS "u, %s, %" HB_PFS "u)", pArray, nIndex, szBuffer, nLen));
if( HB_IS_ARRAY( pArray ) && nIndex > 0 && nIndex <= pArray->item.asArray.value->nLen )
return hb_itemCopyC( pArray->item.asArray.value->pItems + nIndex - 1, szBuffer, ulLen );
return hb_itemCopyC( pArray->item.asArray.value->pItems + nIndex - 1, szBuffer, nLen );
else
return 0;
}
@@ -865,26 +865,26 @@ HB_BOOL hb_arraySetC( PHB_ITEM pArray, HB_SIZE nIndex, const char * szText )
return HB_FALSE;
}
HB_BOOL hb_arraySetCL( PHB_ITEM pArray, HB_SIZE nIndex, const char * szText, HB_SIZE ulLen )
HB_BOOL hb_arraySetCL( PHB_ITEM pArray, HB_SIZE nIndex, const char * szText, HB_SIZE nLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arraySetC(%p, %" HB_PFS "u, %p, %" HB_PFS "u)", pArray, nIndex, szText, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_arraySetC(%p, %" HB_PFS "u, %p, %" HB_PFS "u)", pArray, nIndex, szText, nLen));
if( HB_IS_ARRAY( pArray ) && nIndex > 0 && nIndex <= pArray->item.asArray.value->nLen )
{
hb_itemPutCL( pArray->item.asArray.value->pItems + nIndex - 1, szText, ulLen );
hb_itemPutCL( pArray->item.asArray.value->pItems + nIndex - 1, szText, nLen );
return HB_TRUE;
}
else
return HB_FALSE;
}
HB_BOOL hb_arraySetCLPtr( PHB_ITEM pArray, HB_SIZE nIndex, char * szText, HB_SIZE ulLen )
HB_BOOL hb_arraySetCLPtr( PHB_ITEM pArray, HB_SIZE nIndex, char * szText, HB_SIZE nLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arraySetCLPtr(%p, %" HB_PFS "u, %p, %" HB_PFS "u)", pArray, nIndex, szText, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_arraySetCLPtr(%p, %" HB_PFS "u, %p, %" HB_PFS "u)", pArray, nIndex, szText, nLen));
if( HB_IS_ARRAY( pArray ) && nIndex > 0 && nIndex <= pArray->item.asArray.value->nLen )
{
hb_itemPutCLPtr( pArray->item.asArray.value->pItems + nIndex - 1, szText, ulLen );
hb_itemPutCLPtr( pArray->item.asArray.value->pItems + nIndex - 1, szText, nLen );
return HB_TRUE;
}
else
@@ -957,28 +957,28 @@ HB_BOOL hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE nLen = pBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
if( pnStart && *pnStart )
ulStart = *pnStart - 1;
nStart = *pnStart - 1;
else
ulStart = 0;
nStart = 0;
if( ulStart < ulLen )
if( nStart < nLen )
{
ulCount = ulLen - ulStart;
if( pnCount && *pnCount < ulCount )
ulCount = *pnCount;
nCount = nLen - nStart;
if( pnCount && *pnCount < nCount )
nCount = *pnCount;
if( ulCount > 0 )
if( nCount > 0 )
{
do
{
hb_itemCopy( pBaseArray->pItems + ulStart++, pValue );
hb_itemCopy( pBaseArray->pItems + nStart++, pValue );
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
}
@@ -995,22 +995,22 @@ HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE nLen = pBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
if( pnStart && *pnStart )
ulStart = *pnStart - 1;
nStart = *pnStart - 1;
else
ulStart = 0;
nStart = 0;
if( ulStart < ulLen )
if( nStart < nLen )
{
ulCount = ulLen - ulStart;
if( pnCount && *pnCount < ulCount )
ulCount = *pnCount;
nCount = nLen - nStart;
if( pnCount && *pnCount < nCount )
nCount = *pnCount;
if( ulCount > 0 )
if( nCount > 0 )
{
/* Make separate search loops for different types to find, so that
the loop can be faster. */
@@ -1022,27 +1022,27 @@ HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
{
hb_vmPushEvalSym();
hb_vmPush( pValue );
hb_vmPush( pBaseArray->pItems + ulStart );
hb_vmPushSize( ++ulStart );
hb_vmPush( pBaseArray->pItems + nStart );
hb_vmPushSize( ++nStart );
hb_vmEval( 2 );
if( HB_IS_LOGICAL( hb_stackReturnItem() ) && hb_stackReturnItem()->item.asLogical.value )
return ulStart;
return nStart;
}
while( --ulCount > 0 && ulStart < pBaseArray->nLen );
while( --nCount > 0 && nStart < pBaseArray->nLen );
}
else if( HB_IS_STRING( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
/* NOTE: The order of the pItem and pValue parameters passed to
hb_itemStrCmp() is significant, please don't change it. [vszakats] */
if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( HB_IS_NUMERIC( pValue ) )
{
@@ -1050,12 +1050,12 @@ HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( HB_IS_DATETIME( pValue ) )
{
@@ -1063,26 +1063,26 @@ HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_DATETIME( pItem ) &&
pItem->item.asDateTime.julian == pValue->item.asDateTime.julian &&
pItem->item.asDateTime.time == pValue->item.asDateTime.time )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_DATETIME( pItem ) &&
pItem->item.asDateTime.julian == pValue->item.asDateTime.julian )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
}
else if( HB_IS_LOGICAL( pValue ) )
@@ -1091,59 +1091,59 @@ HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SI
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == bValue )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( HB_IS_NIL( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_NIL( pItem ) )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( HB_IS_POINTER( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_POINTER( pItem ) &&
pItem->item.asPointer.value == pValue->item.asPointer.value )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( fExact && HB_IS_ARRAY( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_ARRAY( pItem ) &&
pItem->item.asArray.value == pValue->item.asArray.value )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
else if( fExact && HB_IS_HASH( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart++;
PHB_ITEM pItem = pBaseArray->pItems + nStart++;
if( HB_IS_HASH( pItem ) &&
pItem->item.asHash.value == pValue->item.asHash.value )
return ulStart;
return nStart;
}
while( --ulCount > 0 );
while( --nCount > 0 );
}
}
}
@@ -1159,22 +1159,22 @@ HB_SIZE hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE nLen = pBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
if( pnStart && *pnStart )
ulStart = *pnStart - 1;
nStart = *pnStart - 1;
else
ulStart = ulLen - 1;
nStart = nLen - 1;
if( ulStart < ulLen )
if( nStart < nLen )
{
ulCount = ulStart + 1;
if( pnCount && *pnCount < ulCount )
ulCount = *pnCount;
nCount = nStart + 1;
if( pnCount && *pnCount < nCount )
nCount = *pnCount;
if( ulCount > 0 )
if( nCount > 0 )
{
/* Make separate search loops for different types to find, so that
the loop can be faster. */
@@ -1186,30 +1186,30 @@ HB_SIZE hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB
{
hb_vmPushEvalSym();
hb_vmPush( pValue );
if( ulStart < pBaseArray->nLen )
hb_vmPush( pBaseArray->pItems + ulStart );
if( nStart < pBaseArray->nLen )
hb_vmPush( pBaseArray->pItems + nStart );
else
hb_vmPushNil();
hb_vmPushSize( ulStart + 1 );
hb_vmPushSize( nStart + 1 );
hb_vmEval( 2 );
if( HB_IS_LOGICAL( hb_stackReturnItem() ) && hb_stackReturnItem()->item.asLogical.value )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( HB_IS_STRING( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
/* NOTE: The order of the pItem and pValue parameters passed to
hb_itemStrCmp() is significant, please don't change it. [vszakats] */
if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( HB_IS_NUMERIC( pValue ) )
{
@@ -1217,12 +1217,12 @@ HB_SIZE hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( HB_IS_DATETIME( pValue ) )
{
@@ -1230,26 +1230,26 @@ HB_SIZE hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_DATETIME( pItem ) &&
pItem->item.asDateTime.julian == pValue->item.asDateTime.julian &&
pItem->item.asDateTime.time == pValue->item.asDateTime.time )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_DATETIME( pItem ) &&
pItem->item.asDateTime.julian == pValue->item.asDateTime.julian )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
}
else if( HB_IS_LOGICAL( pValue ) )
@@ -1258,59 +1258,59 @@ HB_SIZE hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == bValue )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( HB_IS_NIL( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_NIL( pItem ) )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( HB_IS_POINTER( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_POINTER( pItem ) &&
pItem->item.asPointer.value == pValue->item.asPointer.value )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( fExact && HB_IS_ARRAY( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_ARRAY( pItem ) &&
pItem->item.asArray.value == pValue->item.asArray.value )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
else if( fExact && HB_IS_HASH( pValue ) )
{
do
{
PHB_ITEM pItem = pBaseArray->pItems + ulStart;
PHB_ITEM pItem = pBaseArray->pItems + nStart;
if( HB_IS_HASH( pItem ) &&
pItem->item.asHash.value == pValue->item.asHash.value )
return ulStart + 1;
return nStart + 1;
}
while( --ulCount && ulStart-- );
while( --nCount && nStart-- );
}
}
}
@@ -1326,34 +1326,34 @@ HB_BOOL hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, HB_SIZE * pnStart, HB_SI
if( HB_IS_ARRAY( pArray ) && HB_IS_BLOCK( bBlock ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE nLen = pBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
if( pnStart && *pnStart )
ulStart = *pnStart - 1;
nStart = *pnStart - 1;
else
ulStart = 0;
nStart = 0;
if( ulStart < ulLen )
if( nStart < nLen )
{
ulCount = ulLen - ulStart;
if( pnCount && *pnCount < ulCount )
ulCount = *pnCount;
nCount = nLen - nStart;
if( pnCount && *pnCount < nCount )
nCount = *pnCount;
if( ulCount > 0 )
if( nCount > 0 )
{
do
{
hb_vmPushEvalSym();
hb_vmPush( bBlock );
hb_vmPush( pBaseArray->pItems + ulStart );
hb_vmPushSize( ulStart + 1 );
hb_vmPush( pBaseArray->pItems + nStart );
hb_vmPushSize( nStart + 1 );
hb_vmEval( 2 );
}
while( --ulCount > 0 && ++ulStart < pBaseArray->nLen );
while( --nCount > 0 && ++nStart < pBaseArray->nLen );
/*
* checking for ulStart < pBaseArray->nLen is fix for
* checking for nStart < pBaseArray->nLen is fix for
* possible GPF when codeblock decrease array size
*/
}
@@ -1369,61 +1369,61 @@ HB_BOOL hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, HB_SIZE * pnStart, HB_SI
is greater than the length of the array. [vszakats] */
HB_BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, HB_SIZE * pnStart,
HB_SIZE * pnCount, HB_SIZE * pulTarget )
HB_SIZE * pnCount, HB_SIZE * pnTarget )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopy(%p, %p, %p, %p, %p)", pSrcArray, pDstArray, pnStart, pnCount, pulTarget));
HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopy(%p, %p, %p, %p, %p)", pSrcArray, pDstArray, pnStart, pnCount, pnTarget));
if( HB_IS_ARRAY( pSrcArray ) && HB_IS_ARRAY( pDstArray ) )
{
PHB_BASEARRAY pSrcBaseArray = pSrcArray->item.asArray.value;
PHB_BASEARRAY pDstBaseArray = pDstArray->item.asArray.value;
HB_SIZE ulSrcLen = pSrcBaseArray->nLen;
HB_SIZE ulDstLen = pDstBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE ulTarget;
HB_SIZE nSrcLen = pSrcBaseArray->nLen;
HB_SIZE nDstLen = pDstBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
HB_SIZE nTarget;
if( pnStart && ( *pnStart >= 1 ) )
ulStart = *pnStart;
nStart = *pnStart;
else
ulStart = 1;
nStart = 1;
if( pulTarget && ( *pulTarget >= 1 ) )
ulTarget = *pulTarget;
if( pnTarget && ( *pnTarget >= 1 ) )
nTarget = *pnTarget;
else
ulTarget = 1;
nTarget = 1;
#ifdef HB_COMPAT_C53 /* From CA-Cl*pper 5.3a */
if( ulStart <= ulSrcLen )
if( nStart <= nSrcLen )
#else
if( ulSrcLen > 0 )
if( nSrcLen > 0 )
#endif
{
#ifndef HB_COMPAT_C53 /* From CA-Cl*pper 5.3a */
if( ulStart > ulSrcLen )
ulStart = ulSrcLen;
if( nStart > nSrcLen )
nStart = nSrcLen;
#endif
if( pnCount && ( *pnCount <= ulSrcLen - ulStart ) )
ulCount = *pnCount;
if( pnCount && ( *pnCount <= nSrcLen - nStart ) )
nCount = *pnCount;
else
ulCount = ulSrcLen - ulStart + 1;
nCount = nSrcLen - nStart + 1;
/* This is probably a bug, present in all versions of CA-Cl*pper. */
#if defined( HB_CLP_STRICT ) || 1
if( ulDstLen > 0 )
if( nDstLen > 0 )
{
if( ulTarget > ulDstLen )
ulTarget = ulDstLen;
if( nTarget > nDstLen )
nTarget = nDstLen;
#else
if( ulTarget <= ulDstLen )
if( nTarget <= nDstLen )
{
#endif
if( ulCount > ulDstLen - ulTarget )
ulCount = ulDstLen - ulTarget + 1;
if( nCount > nDstLen - nTarget )
nCount = nDstLen - nTarget + 1;
for( ulTarget--, ulStart--; ulCount > 0; ulCount--, ulStart++, ulTarget++ )
hb_itemCopy( pDstBaseArray->pItems + ulTarget, pSrcBaseArray->pItems + ulStart );
for( nTarget--, nStart--; nCount > 0; nCount--, nStart++, nTarget++ )
hb_itemCopy( pDstBaseArray->pItems + nTarget, pSrcBaseArray->pItems + nStart );
}
}
@@ -1436,7 +1436,7 @@ HB_BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, HB_SIZE * pnStart,
static void hb_arrayCloneBody( PHB_BASEARRAY pSrcBaseArray, PHB_BASEARRAY pDstBaseArray, PHB_NESTED_CLONED pClonedList )
{
PHB_ITEM pSrcItem, pDstItem;
HB_SIZE ulLen;
HB_SIZE nLen;
HB_TRACE(HB_TR_DEBUG, ("hb_arrayCloneBody(%p, %p, %p)", pSrcBaseArray, pDstBaseArray, pClonedList));
@@ -1445,7 +1445,7 @@ static void hb_arrayCloneBody( PHB_BASEARRAY pSrcBaseArray, PHB_BASEARRAY pDstBa
pDstBaseArray->uiClass = pSrcBaseArray->uiClass;
for( ulLen = pSrcBaseArray->nLen; ulLen; --ulLen, ++pSrcItem, ++pDstItem )
for( nLen = pSrcBaseArray->nLen; nLen; --nLen, ++pSrcItem, ++pDstItem )
hb_cloneNested( pDstItem, pSrcItem, pClonedList );
}
@@ -1518,9 +1518,9 @@ PHB_ITEM hb_arrayCloneTo( PHB_ITEM pDstArray, PHB_ITEM pSrcArray )
{
PHB_NESTED_CLONED pClonedList, pCloned;
PHB_BASEARRAY pSrcBaseArray = pSrcArray->item.asArray.value;
HB_SIZE ulSrcLen = pSrcBaseArray->nLen;
HB_SIZE nSrcLen = pSrcBaseArray->nLen;
hb_arrayNew( pDstArray, ulSrcLen );
hb_arrayNew( pDstArray, nSrcLen );
pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
pClonedList->value = ( void * ) pSrcBaseArray;
pClonedList->pDest = pDstArray;

View File

@@ -61,21 +61,21 @@
*/
static void hb_arrayNewRagged( PHB_ITEM pArray, int iDimension )
{
HB_SIZE ulElements;
HB_SIZE nElements;
HB_TRACE(HB_TR_DEBUG, ("hb_arrayNewRagged(%p, %d)", pArray, iDimension));
ulElements = hb_parns( iDimension );
nElements = hb_parns( iDimension );
/* create an array */
hb_arrayNew( pArray, ulElements );
hb_arrayNew( pArray, nElements );
if( ++iDimension <= hb_pcount() )
{
/* call self recursively to create next dimensions
*/
while( ulElements )
hb_arrayNewRagged( hb_arrayGetItemPtr( pArray, ulElements-- ), iDimension );
while( nElements )
hb_arrayNewRagged( hb_arrayGetItemPtr( pArray, nElements-- ), iDimension );
}
}
@@ -169,12 +169,12 @@ HB_FUNC( AINS )
if( pArray )
{
HB_ISIZ lPos = hb_parns( 2 );
HB_ISIZ nPos = hb_parns( 2 );
if( lPos == 0 )
lPos = 1;
if( nPos == 0 )
nPos = 1;
hb_arrayIns( pArray, lPos );
hb_arrayIns( pArray, nPos );
hb_itemReturn( pArray ); /* AIns() returns the array itself */
}
@@ -186,12 +186,12 @@ HB_FUNC( ADEL )
if( pArray )
{
HB_ISIZ lPos = hb_parns( 2 );
HB_ISIZ nPos = hb_parns( 2 );
if( lPos == 0 )
lPos = 1;
if( nPos == 0 )
nPos = 1;
hb_arrayDel( pArray, lPos );
hb_arrayDel( pArray, nPos );
hb_itemReturn( pArray ); /* ADel() returns the array itself */
}
@@ -209,7 +209,7 @@ HB_FUNC( AFILL )
if( pValue )
{
HB_SIZE ulStart, ulCount;
HB_SIZE nStart, nCount;
HB_ISIZ lStart = hb_parns( 3 ), lCount = hb_parns( 4 );
/* Explicy lCount of 0 - Nothing to do! */
@@ -225,17 +225,17 @@ HB_FUNC( AFILL )
{
/* Clipper allows the Count to be negative, if start is 1, and corrects it to maximum elements. */
if( lStart == 1 )
ulCount = 0;
nCount = 0;
/* Clipper aborts if negative count and start is not at 1. */
else
return;
}
ulStart = ( HB_SIZE ) lStart;
ulCount = ( HB_SIZE ) lCount;
nStart = ( HB_SIZE ) lStart;
nCount = ( HB_SIZE ) lCount;
hb_arrayFill( pArray,
pValue,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL );
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL );
}
}
else
@@ -256,12 +256,12 @@ HB_FUNC( ASCAN )
if( pArray && pValue )
{
HB_SIZE ulStart = hb_parns( 3 );
HB_SIZE ulCount = hb_parns( 4 );
HB_SIZE nStart = hb_parns( 3 );
HB_SIZE nCount = hb_parns( 4 );
hb_retns( hb_arrayScan( pArray, pValue,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL,
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL,
HB_FALSE ) );
}
else
@@ -276,12 +276,12 @@ HB_FUNC( HB_ASCAN )
if( pArray && pValue )
{
HB_SIZE ulStart = hb_parns( 3 );
HB_SIZE ulCount = hb_parns( 4 );
HB_SIZE nStart = hb_parns( 3 );
HB_SIZE nCount = hb_parns( 4 );
hb_retns( hb_arrayScan( pArray, pValue,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL,
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL,
hb_parl( 5 ) ) );
}
else
@@ -295,12 +295,12 @@ HB_FUNC( HB_RASCAN )
if( pArray && pValue )
{
HB_SIZE ulStart = hb_parns( 3 );
HB_SIZE ulCount = hb_parns( 4 );
HB_SIZE nStart = hb_parns( 3 );
HB_SIZE nCount = hb_parns( 4 );
hb_retns( hb_arrayRevScan( pArray, pValue,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL,
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL,
hb_parl( 5 ) ) );
}
else
@@ -313,22 +313,22 @@ HB_FUNC( HB_AINS )
if( pArray )
{
HB_ISIZ lPos = hb_parns( 2 );
HB_ISIZ nPos = hb_parns( 2 );
if( lPos == 0 )
lPos = 1;
if( nPos == 0 )
nPos = 1;
if( hb_parl( 4 ) )
{
HB_SIZE ulLen = hb_arrayLen( pArray ) + 1;
if( lPos >= 1 && ( HB_SIZE ) lPos <= ulLen )
hb_arraySize( pArray, ulLen );
HB_SIZE nLen = hb_arrayLen( pArray ) + 1;
if( nPos >= 1 && ( HB_SIZE ) nPos <= nLen )
hb_arraySize( pArray, nLen );
}
if( hb_arrayIns( pArray, lPos ) )
if( hb_arrayIns( pArray, nPos ) )
{
if( ! HB_ISNIL( 3 ) )
hb_arraySet( pArray, lPos, hb_param( 3, HB_IT_ANY ) );
hb_arraySet( pArray, nPos, hb_param( 3, HB_IT_ANY ) );
}
hb_itemReturn( pArray ); /* AIns() returns the array itself */
@@ -341,12 +341,12 @@ HB_FUNC( HB_ADEL )
if( pArray )
{
HB_ISIZ lPos = hb_parns( 2 );
HB_ISIZ nPos = hb_parns( 2 );
if( lPos == 0 )
lPos = 1;
if( nPos == 0 )
nPos = 1;
if( hb_arrayDel( pArray, lPos ) )
if( hb_arrayDel( pArray, nPos ) )
{
if( hb_parl( 3 ) )
hb_arraySize( pArray, hb_arrayLen( pArray ) - 1 );
@@ -366,13 +366,13 @@ HB_FUNC( AEVAL )
if( pArray && pBlock )
{
HB_SIZE ulStart = hb_parns( 3 );
HB_SIZE ulCount = hb_parns( 4 );
HB_SIZE nStart = hb_parns( 3 );
HB_SIZE nCount = hb_parns( 4 );
hb_arrayEval( pArray,
pBlock,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL );
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL );
hb_itemReturn( hb_stackItemFromBase( 1 ) ); /* AEval() returns the array itself */
}
@@ -390,15 +390,15 @@ HB_FUNC( ACOPY )
/* CA-Cl*pper works this way. */
if( ! hb_arrayIsObject( pSrcArray ) && ! hb_arrayIsObject( pDstArray ) )
{
HB_SIZE ulStart = hb_parns( 3 );
HB_SIZE ulCount = hb_parns( 4 );
HB_SIZE ulTarget = hb_parns( 5 );
HB_SIZE nStart = hb_parns( 3 );
HB_SIZE nCount = hb_parns( 4 );
HB_SIZE nTarget = hb_parns( 5 );
hb_arrayCopy( pSrcArray,
pDstArray,
HB_ISNUM( 3 ) ? &ulStart : NULL,
HB_ISNUM( 4 ) ? &ulCount : NULL,
HB_ISNUM( 5 ) ? &ulTarget : NULL );
HB_ISNUM( 3 ) ? &nStart : NULL,
HB_ISNUM( 4 ) ? &nCount : NULL,
HB_ISNUM( 5 ) ? &nTarget : NULL );
}
hb_itemReturn( hb_stackItemFromBase( 2 ) ); /* ACopy() returns the target array */

View File

@@ -63,7 +63,7 @@
#include "hbvm.h"
#include "hbstack.h"
static HB_BOOL hb_itemIsLess( PHB_ITEM pItem1, PHB_ITEM pItem2, PHB_ITEM pBlock, PHB_BASEARRAY pBaseArray, HB_SIZE ulLast )
static HB_BOOL hb_itemIsLess( PHB_ITEM pItem1, PHB_ITEM pItem2, PHB_ITEM pBlock, PHB_BASEARRAY pBaseArray, HB_SIZE nLast )
{
if( pBlock )
{
@@ -73,7 +73,7 @@ static HB_BOOL hb_itemIsLess( PHB_ITEM pItem1, PHB_ITEM pItem2, PHB_ITEM pBlock,
hb_vmPush( pItem2 );
hb_vmSend( 2 );
if( pBaseArray->nLen <= ulLast )
if( pBaseArray->nLen <= nLast )
return HB_FALSE;
else
{
@@ -210,38 +210,38 @@ static void hb_arraySortQuick( PHB_BASEARRAY pBaseArray, HB_ISIZ lb, HB_ISIZ ub,
}
}
HB_BOOL hb_arraySort( PHB_ITEM pArray, HB_SIZE * pulStart, HB_SIZE * pulCount, PHB_ITEM pBlock )
HB_BOOL hb_arraySort( PHB_ITEM pArray, HB_SIZE * pnStart, HB_SIZE * pnCount, PHB_ITEM pBlock )
{
HB_TRACE(HB_TR_DEBUG, ("hb_arraySort(%p, %p, %p, %p)", pArray, pulStart, pulCount, pBlock));
HB_TRACE(HB_TR_DEBUG, ("hb_arraySort(%p, %p, %p, %p)", pArray, pnStart, pnCount, pBlock));
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
HB_SIZE ulLen = pBaseArray->nLen;
HB_SIZE ulStart;
HB_SIZE ulCount;
HB_SIZE ulEnd;
HB_SIZE nLen = pBaseArray->nLen;
HB_SIZE nStart;
HB_SIZE nCount;
HB_SIZE nEnd;
if( pulStart && ( *pulStart >= 1 ) )
ulStart = *pulStart;
if( pnStart && ( *pnStart >= 1 ) )
nStart = *pnStart;
else
ulStart = 1;
nStart = 1;
if( ulStart <= ulLen )
if( nStart <= nLen )
{
if( pulCount && *pulCount >= 1 && ( *pulCount <= ulLen - ulStart ) )
ulCount = *pulCount;
if( pnCount && *pnCount >= 1 && ( *pnCount <= nLen - nStart ) )
nCount = *pnCount;
else
ulCount = ulLen - ulStart + 1;
nCount = nLen - nStart + 1;
if( ulStart + ulCount > ulLen ) /* check range */
ulCount = ulLen - ulStart + 1;
if( nStart + nCount > nLen ) /* check range */
nCount = nLen - nStart + 1;
ulEnd = ulCount + ulStart - 2;
nEnd = nCount + nStart - 2;
/* Optimize when only one or no element is to be sorted */
if( ulCount > 1 )
hb_arraySortQuick( pBaseArray, ulStart - 1, ulEnd, pBlock );
if( nCount > 1 )
hb_arraySortQuick( pBaseArray, nStart - 1, nEnd, pBlock );
}
return HB_TRUE;
@@ -256,12 +256,12 @@ HB_FUNC( ASORT )
if( pArray && ! hb_arrayIsObject( pArray ) )
{
HB_SIZE ulStart = hb_parns( 2 );
HB_SIZE ulCount = hb_parns( 3 );
HB_SIZE nStart = hb_parns( 2 );
HB_SIZE nCount = hb_parns( 3 );
hb_arraySort( pArray,
HB_ISNUM( 2 ) ? &ulStart : NULL,
HB_ISNUM( 3 ) ? &ulCount : NULL,
HB_ISNUM( 2 ) ? &nStart : NULL,
HB_ISNUM( 3 ) ? &nCount : NULL,
hb_param( 4, HB_IT_BLOCK ) );
hb_itemReturn( pArray ); /* ASort() returns the array itself */

View File

@@ -442,7 +442,7 @@ static HB_USHORT hb_clsBucketPos( PHB_DYNS pMsg, HB_USHORT uiMask )
*/
static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
{
HB_SIZE ulNewHashKey, ulLimit, ul;
HB_SIZE nNewHashKey, nLimit, n;
#ifdef HB_MSG_POOL
HB_USHORT * puiMsgIdx;
#else
@@ -451,27 +451,27 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
HB_TRACE(HB_TR_DEBUG, ("hb_clsDictRealloc(%p)", pClass));
ulNewHashKey = ( HB_SIZE ) pClass->uiHashKey + 1;
ulLimit = ulNewHashKey << BUCKETBITS;
nNewHashKey = ( HB_SIZE ) pClass->uiHashKey + 1;
nLimit = nNewHashKey << BUCKETBITS;
do
{
ulNewHashKey <<= 1;
if( ulNewHashKey > HASH_KEYMAX )
nNewHashKey <<= 1;
if( nNewHashKey > HASH_KEYMAX )
hb_errInternal( 6002, "Unable to realloc class message in __clsDictRealloc()", NULL, NULL );
#ifdef HB_MSG_POOL
puiMsgIdx = ( HB_USHORT * ) hb_xgrab( ( ulNewHashKey << BUCKETBITS ) * sizeof( HB_USHORT ) );
memset( puiMsgIdx, 0, ( ulNewHashKey << BUCKETBITS ) * sizeof( HB_USHORT ) );
puiMsgIdx = ( HB_USHORT * ) hb_xgrab( ( nNewHashKey << BUCKETBITS ) * sizeof( HB_USHORT ) );
memset( puiMsgIdx, 0, ( nNewHashKey << BUCKETBITS ) * sizeof( HB_USHORT ) );
for( ul = 0; ul < ulLimit; ul++ )
for( n = 0; n < nLimit; n++ )
{
HB_USHORT uiMsg = pClass->puiMsgIdx[ ul ];
if( pClass->puiMsgIdx[ ul ] )
HB_USHORT uiMsg = pClass->puiMsgIdx[ n ];
if( pClass->puiMsgIdx[ n ] )
{
HB_USHORT uiBucket = BUCKETSIZE;
HB_USHORT * puiIdx = puiMsgIdx + hb_clsBucketPos(
pClass->pMethods[ uiMsg ].pMessage, ulNewHashKey - 1 );
pClass->pMethods[ uiMsg ].pMessage, nNewHashKey - 1 );
do
{
if( * puiIdx == 0 ) /* this message position is empty */
@@ -491,31 +491,31 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
}
}
}
while( ul < ulLimit );
while( n < nLimit );
pClass->uiHashKey = ( HB_USHORT ) ( ulNewHashKey - 1 );
pClass->uiHashKey = ( HB_USHORT ) ( nNewHashKey - 1 );
hb_xfree( pClass->puiMsgIdx );
pClass->puiMsgIdx = puiMsgIdx;
#else
pNewMethods = ( PMETHOD ) hb_xgrab( ( ulNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );
memset( pNewMethods, 0, ( ulNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );
pNewMethods = ( PMETHOD ) hb_xgrab( ( nNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );
memset( pNewMethods, 0, ( nNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );
for( ul = 0; ul < ulLimit; ul++ )
for( n = 0; n < nLimit; n++ )
{
PHB_DYNS pMessage = ( PHB_DYNS ) pClass->pMethods[ ul ].pMessage;
PHB_DYNS pMessage = ( PHB_DYNS ) pClass->pMethods[ n ].pMessage;
if( pMessage )
{
PMETHOD pMethod = pNewMethods + hb_clsBucketPos( pMessage, ulNewHashKey - 1 );
PMETHOD pMethod = pNewMethods + hb_clsBucketPos( pMessage, nNewHashKey - 1 );
HB_USHORT uiBucket = BUCKETSIZE;
do
{
if( ! pMethod->pMessage ) /* this message position is empty */
{
memcpy( pMethod, pClass->pMethods + ul, sizeof( METHOD ) );
memcpy( pMethod, pClass->pMethods + n, sizeof( METHOD ) );
break;
}
++pMethod;
@@ -530,9 +530,9 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
}
}
}
while( ul < ulLimit );
while( n < nLimit );
pClass->uiHashKey = ( HB_USHORT ) ( ulNewHashKey - 1 );
pClass->uiHashKey = ( HB_USHORT ) ( nNewHashKey - 1 );
hb_xfree( pClass->pMethods );
pClass->pMethods = pNewMethods;
#endif
@@ -542,23 +542,23 @@ static HB_BOOL hb_clsDictRealloc( PCLASS pClass )
static void hb_clsDictInit( PCLASS pClass, HB_USHORT uiHashKey )
{
HB_SIZE ulSize;
HB_SIZE nSize;
HB_TRACE(HB_TR_DEBUG, ("hb_clsDictInit(%p,%hu)", pClass, uiHashKey));
pClass->uiHashKey = uiHashKey;
#ifdef HB_MSG_POOL
ulSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_USHORT );
pClass->puiMsgIdx = ( HB_USHORT * ) hb_xgrab( ulSize );
memset( pClass->puiMsgIdx, 0, ulSize );
nSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_USHORT );
pClass->puiMsgIdx = ( HB_USHORT * ) hb_xgrab( nSize );
memset( pClass->puiMsgIdx, 0, nSize );
pClass->uiMethodCount = 1;
pClass->pMethods = ( PMETHOD ) hb_xgrab( sizeof( METHOD ) );
memset( pClass->pMethods, 0, sizeof( METHOD ) );
#else
ulSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( METHOD );
pClass->pMethods = ( PMETHOD ) hb_xgrab( ulSize );
memset( pClass->pMethods, 0, ulSize );
nSize = ( ( ( HB_SIZE ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( METHOD );
pClass->pMethods = ( PMETHOD ) hb_xgrab( nSize );
memset( pClass->pMethods, 0, nSize );
#endif
}
@@ -820,7 +820,7 @@ static HB_USHORT hb_clsFindClassDataOffset( PCLASS pClass, PMETHOD pNewMethod )
uiData = hb_clsFindRealClassDataOffset( pNewMethod );
if( uiData )
{
HB_SIZE ulLimit = hb_clsMthNum( pClass );
HB_SIZE nLimit = hb_clsMthNum( pClass );
PMETHOD pMethod = pClass->pMethods;
do
{
@@ -834,7 +834,7 @@ static HB_USHORT hb_clsFindClassDataOffset( PCLASS pClass, PMETHOD pNewMethod )
}
++pMethod;
}
while( --ulLimit );
while( --nLimit );
}
return 0;
@@ -909,7 +909,7 @@ static HB_BOOL hb_clsUpdateHiddenMessages( PMETHOD pSrcMethod, PMETHOD pDstMetho
static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
{
PMETHOD pMethod;
HB_SIZE ulLimit;
HB_SIZE nLimit;
HB_TRACE(HB_TR_DEBUG, ("hb_clsCopyClass(%p,%p)", pClsDst, pClsSrc));
@@ -930,12 +930,12 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
if( pClsSrc->uiInitDatas )
{
HB_SIZE ulSize = ( HB_SIZE ) pClsSrc->uiInitDatas * sizeof( INITDATA );
HB_SIZE nSize = ( HB_SIZE ) pClsSrc->uiInitDatas * sizeof( INITDATA );
HB_USHORT uiData;
pClsDst->uiInitDatas = pClsSrc->uiInitDatas;
pClsDst->pInitData = ( PINITDATA ) hb_xgrab( ulSize );
memcpy( pClsDst->pInitData, pClsSrc->pInitData, ulSize );
pClsDst->pInitData = ( PINITDATA ) hb_xgrab( nSize );
memcpy( pClsDst->pInitData, pClsSrc->pInitData, nSize );
for( uiData = 0; uiData < pClsDst->uiInitDatas; ++uiData )
{
if( pClsDst->pInitData[ uiData ].uiType == HB_OO_MSG_INITIALIZED )
@@ -945,15 +945,15 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
}
}
ulLimit = hb_clsMthNum( pClsSrc );
nLimit = hb_clsMthNum( pClsSrc );
#ifdef HB_MSG_POOL
memcpy( pClsDst->puiMsgIdx, pClsSrc->puiMsgIdx,
( ( ( HB_SIZE ) pClsSrc->uiHashKey + 1 ) << BUCKETBITS ) * sizeof( HB_USHORT ) );
pClsDst->uiMethodCount = pClsSrc->uiMethodCount;
pClsDst->pMethods = ( PMETHOD ) hb_xrealloc( pClsDst->pMethods,
ulLimit * sizeof( METHOD ) );
nLimit * sizeof( METHOD ) );
#endif
memcpy( pClsDst->pMethods, pClsSrc->pMethods, ulLimit * sizeof( METHOD ) );
memcpy( pClsDst->pMethods, pClsSrc->pMethods, nLimit * sizeof( METHOD ) );
pClsDst->uiMethods = pClsSrc->uiMethods;
pMethod = pClsDst->pMethods;
@@ -966,7 +966,7 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
}
++pMethod;
}
while( --ulLimit );
while( --nLimit );
}
static HB_BOOL hb_clsIsFriendSymbol( PCLASS pClass, PHB_SYMB pSym )
@@ -2085,19 +2085,19 @@ HB_BOOL hb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage,
HB_USHORT uiObjClass = pObject->item.asArray.value->uiClass;
PCLASS pClass = s_pClasses[ pStack->uiClass ];
PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;
HB_SIZE ulIndex = pMethod->uiData;
HB_SIZE nIndex = pMethod->uiData;
if( pStack->uiClass != uiObjClass )
ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
nIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
s_pClasses[ pMethod->uiSprClass ]->pClassSym );
else
ulIndex += pMethod->uiOffset;
nIndex += pMethod->uiOffset;
/* will arise only if the class has been modified after first instance */
if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed */
hb_arraySize( pObject, ulIndex ); /* Make large enough */
if( nIndex > hb_arrayLen( pObject ) ) /* Resize needed */
hb_arraySize( pObject, nIndex ); /* Make large enough */
return hb_arrayGetItemRef( pObject, ulIndex, hb_stackReturnItem() );
return hb_arrayGetItemRef( pObject, nIndex, hb_stackReturnItem() );
}
else if( pExecSym->value.pFunPtr == HB_FUNCNAME( msgSetClsData ) )
{
@@ -2152,7 +2152,7 @@ static void hb_objSupperDestructorCall( PHB_ITEM pObject, PCLASS pClass )
{
HB_STACK_TLS_PRELOAD
PMETHOD pMethod = pClass->pMethods;
HB_SIZE ulLimit = hb_clsMthNum( pClass );
HB_SIZE nLimit = hb_clsMthNum( pClass );
char * pcClasses;
HB_USHORT uiClass;
@@ -2174,7 +2174,7 @@ static void hb_objSupperDestructorCall( PHB_ITEM pObject, PCLASS pClass )
}
++pMethod;
}
while( --ulLimit );
while( --nLimit );
for( uiClass = s_uiClasses; uiClass; --uiClass )
{
@@ -3172,11 +3172,11 @@ static HB_USHORT hb_clsNew( const char * szClassName, HB_USHORT uiDatas,
}
else if( !hb_clsHasParent( pNewCls, pSprCls->pClassSym ) )
{
HB_SIZE ul, ulLimit;
HB_SIZE n, nLimit;
HB_USHORT nLenClsDatas;
/* create class data translation tables */
nLenClsDatas = ( HB_USHORT ) hb_itemSize( pSprCls->pClassDatas );
nLenClsDatas = ( HB_USHORT ) hb_itemSize( pSprCls->pClassDatas );
if( nLenClsDatas )
{
if( nLenClsDatas > uiClassDataSize )
@@ -3193,22 +3193,22 @@ static HB_USHORT hb_clsNew( const char * szClassName, HB_USHORT uiDatas,
}
/* Copy super class handles */
ulLimit = hb_clsMthNum( pSprCls );
for( ul = 0; ul < ulLimit; ++ul )
nLimit = hb_clsMthNum( pSprCls );
for( n = 0; n < nLimit; ++n )
{
if( pSprCls->pMethods[ ul ].pMessage &&
pSprCls->pMethods[ ul ].pFuncSym == &s___msgSuper )
if( pSprCls->pMethods[ n ].pMessage &&
pSprCls->pMethods[ n ].pFuncSym == &s___msgSuper )
{
PCLASS pCls = s_pClasses[ pSprCls->pMethods[ ul ].uiSprClass ];
PCLASS pCls = s_pClasses[ pSprCls->pMethods[ n ].uiSprClass ];
pMethod = hb_clsAllocMsg( pNewCls,
pSprCls->pMethods[ ul ].pMessage );
pSprCls->pMethods[ n ].pMessage );
if( ! pMethod )
return 0;
if( pMethod->pMessage == NULL )
{
pNewCls->uiMethods++;
memcpy( pMethod, pSprCls->pMethods + ul, sizeof( METHOD ) );
memcpy( pMethod, pSprCls->pMethods + n, sizeof( METHOD ) );
pMethod->uiOffset = pNewCls->uiDatas;
pNewCls->uiDatas += pCls->uiDatas - pCls->uiDataFirst;
}
@@ -3250,12 +3250,12 @@ static HB_USHORT hb_clsNew( const char * szClassName, HB_USHORT uiDatas,
}
/* Now working on other methods */
ulLimit = hb_clsMthNum( pSprCls );
for( ul = 0; ul < ulLimit; ++ul )
nLimit = hb_clsMthNum( pSprCls );
for( n = 0; n < nLimit; ++n )
{
if( pSprCls->pMethods[ ul ].pMessage )
if( pSprCls->pMethods[ n ].pMessage )
{
pMethod = hb_clsAllocMsg( pNewCls, pSprCls->pMethods[ ul ].pMessage );
pMethod = hb_clsAllocMsg( pNewCls, pSprCls->pMethods[ n ].pMessage );
if( ! pMethod )
return 0;
@@ -3264,7 +3264,7 @@ static HB_USHORT hb_clsNew( const char * szClassName, HB_USHORT uiDatas,
{
/* Now, we can increment the msg count */
pNewCls->uiMethods++;
memcpy( pMethod, pSprCls->pMethods + ul, sizeof( METHOD ) );
memcpy( pMethod, pSprCls->pMethods + n, sizeof( METHOD ) );
if( ! hb_clsUpdateHiddenMessages( pMethod, pMethod, pNewCls ) )
{
if( pMethod->pFuncSym == &s___msgSetClsData ||
@@ -3300,11 +3300,11 @@ static HB_USHORT hb_clsNew( const char * szClassName, HB_USHORT uiDatas,
}
else
{
if( pSprCls->pMethods[ ul ].uiScope &
if( pSprCls->pMethods[ n ].uiScope &
( HB_OO_CLSTP_OVERLOADED | HB_OO_CLSTP_NONVIRTUAL ) )
pMethod->uiScope |= HB_OO_CLSTP_OVERLOADED;
hb_clsUpdateHiddenMessages( pSprCls->pMethods + ul, pMethod, pNewCls );
hb_clsUpdateHiddenMessages( pSprCls->pMethods + n, pMethod, pNewCls );
}
}
}
@@ -4018,20 +4018,20 @@ HB_FUNC( __CLASSSEL )
{
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod = pClass->pMethods;
HB_SIZE ulLimit = hb_clsMthNum( pClass ), ulPos = 0;
HB_SIZE nLimit = hb_clsMthNum( pClass ), nPos = 0;
hb_arrayNew( pReturn, pClass->uiMethods ); /* Create a transfer array */
do
{
if( pMethod->pMessage ) /* Hash Entry used ? */
hb_arraySetC( pReturn, ++ulPos, pMethod->pMessage->pSymbol->szName );
hb_arraySetC( pReturn, ++nPos, pMethod->pMessage->pSymbol->szName );
++pMethod;
}
while( --ulLimit );
while( --nLimit );
if( ulPos < ( HB_SIZE ) pClass->uiMethods )
hb_arraySize( pReturn, ulPos );
if( nPos < ( HB_SIZE ) pClass->uiMethods )
hb_arraySize( pReturn, nPos );
}
hb_itemReturnRelease( pReturn );
@@ -4232,7 +4232,7 @@ HB_FUNC_STATIC( msgClassSel )
PHB_ITEM pReturn, pItem;
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod = pClass->pMethods;
HB_SIZE ulLimit = hb_clsMthNum( pClass ), ulPos = 0;
HB_SIZE nLimit = hb_clsMthNum( pClass ), nPos = 0;
HB_USHORT nParam, nScope;
HB_BOOL lFull;
@@ -4255,7 +4255,7 @@ HB_FUNC_STATIC( msgClassSel )
{
if( lFull )
{
pItem = hb_arrayGetItemPtr( pReturn, ++ulPos );
pItem = hb_arrayGetItemPtr( pReturn, ++nPos );
hb_arrayNew( pItem, 4 );
hb_arraySetC( pItem, HB_OO_DATA_SYMBOL,
pMethod->pMessage->pSymbol->szName );
@@ -4263,17 +4263,17 @@ HB_FUNC_STATIC( msgClassSel )
hb_arraySetNI( pItem, HB_OO_DATA_SCOPE, pMethod->uiScope );
}
else
hb_arraySetC( pReturn, ++ulPos,
hb_arraySetC( pReturn, ++nPos,
pMethod->pMessage->pSymbol->szName );
}
}
}
++pMethod;
}
while( --ulLimit && ulPos < ( HB_SIZE ) pClass->uiMethods );
while( --nLimit && nPos < ( HB_SIZE ) pClass->uiMethods );
if( ulPos < ( HB_SIZE ) pClass->uiMethods )
hb_arraySize( pReturn, ulPos );
if( nPos < ( HB_SIZE ) pClass->uiMethods )
hb_arraySize( pReturn, nPos );
hb_itemReturnRelease( pReturn );
}
}
@@ -4695,19 +4695,19 @@ HB_FUNC_STATIC( msgGetData )
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
HB_SIZE ulIndex = pMethod->uiData;
HB_SIZE nIndex = pMethod->uiData;
if( uiClass != uiObjClass )
{
ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
nIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
s_pClasses[ pMethod->uiSprClass ]->pClassSym );
}
else
{
ulIndex += pMethod->uiOffset;
nIndex += pMethod->uiOffset;
}
hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() );
hb_arrayGet( pObject, nIndex, hb_stackReturnItem() );
}
}
@@ -4729,20 +4729,20 @@ HB_FUNC_STATIC( msgSetData )
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
HB_SIZE ulIndex = pMethod->uiData;
HB_SIZE nIndex = pMethod->uiData;
if( uiClass != uiObjClass )
{
ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
nIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
s_pClasses[ pMethod->uiSprClass ]->pClassSym );
}
else
{
ulIndex += pMethod->uiOffset;
nIndex += pMethod->uiOffset;
}
if( !pReturn )
hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() );
hb_arrayGet( pObject, nIndex, hb_stackReturnItem() );
else
{
@@ -4759,9 +4759,9 @@ HB_FUNC_STATIC( msgSetData )
}
/* will arise only if the class has been modified after first instance */
if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */
hb_arraySize( pObject, ulIndex ); /* Make large enough */
hb_arraySet( pObject, ulIndex, pReturn );
if( nIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */
hb_arraySize( pObject, nIndex ); /* Make large enough */
hb_arraySet( pObject, nIndex, pReturn );
hb_itemReturnForward( pReturn );
}
}
@@ -4857,53 +4857,53 @@ HB_FUNC( __CLSGETPROPERTIES )
{
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod;
HB_SIZE ulLimit, ulCount;
HB_SIZE nLimit, nCount;
HB_USHORT uiScope = HB_OO_CLSTP_PERSIST;
if( hb_parl( 2 ) )
uiScope |= HB_OO_CLSTP_EXPORTED;
ulCount = 0;
ulLimit = hb_clsMthNum( pClass );
nCount = 0;
nLimit = hb_clsMthNum( pClass );
pMethod = pClass->pMethods;
do
{
if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 )
{
if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 )
++ulCount;
++nCount;
else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' )
{
PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 );
if( pMsg && hb_clsFindMsg( pClass, pMsg ) )
++ulCount;
++nCount;
}
}
++pMethod;
}
while( --ulLimit );
while( --nLimit );
hb_arrayNew( pReturn, ulCount );
hb_arrayNew( pReturn, nCount );
ulCount = 0;
ulLimit = hb_clsMthNum( pClass );
nCount = 0;
nLimit = hb_clsMthNum( pClass );
pMethod = pClass->pMethods;
do
{
if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 )
{
if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 )
hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName );
hb_arraySetC( pReturn, ++nCount, pMethod->pMessage->pSymbol->szName );
else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' )
{
PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 );
if( pMsg && hb_clsFindMsg( pClass, pMsg ) )
hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName + 1 );
hb_arraySetC( pReturn, ++nCount, pMethod->pMessage->pSymbol->szName + 1 );
}
}
++pMethod;
}
while( --ulLimit );
while( --nLimit );
}
hb_itemReturnRelease( pReturn );

View File

@@ -348,16 +348,16 @@ static char * hb_cmdargGet( const char * pszName, HB_BOOL bRetValue )
{
if( bRetValue )
{
HB_SIZE ulLen;
HB_SIZE nLen;
pszNext += i;
/* Skip value separator colon. */
if( *pszNext == ':' )
pszNext++;
ulLen = pszEnd > pszNext ? pszEnd - pszNext : 0;
pszRetVal = ( char * ) hb_xgrab( ulLen + 1 );
hb_strncpy( pszRetVal, pszNext, ulLen );
nLen = pszEnd > pszNext ? pszEnd - pszNext : 0;
pszRetVal = ( char * ) hb_xgrab( nLen + 1 );
hb_strncpy( pszRetVal, pszNext, nLen );
}
else
pszRetVal = ( char * ) "";
@@ -483,21 +483,21 @@ HB_FUNC( HB_CMDLINE )
char** argv = hb_cmdargARGV();
int argc = hb_cmdargARGC();
char * pszBuffer, * ptr;
HB_SIZE ulLen;
HB_SIZE nLen;
int iArg;
ulLen = 0;
nLen = 0;
for( iArg = 1; iArg < argc; iArg++ )
ulLen += strlen( argv[ iArg ] ) + 1;
nLen += strlen( argv[ iArg ] ) + 1;
if( ulLen )
if( nLen )
{
ptr = pszBuffer = ( char * ) hb_xgrab( ulLen );
ptr = pszBuffer = ( char * ) hb_xgrab( nLen );
for( iArg = 1; iArg < argc; iArg++ )
{
ulLen = strlen( argv[ iArg ] );
memcpy( ptr, argv[ iArg ], ulLen );
ptr += ulLen;
nLen = strlen( argv[ iArg ] );
memcpy( ptr, argv[ iArg ], nLen );
ptr += nLen;
*ptr++ = ' ';
}
*--ptr = '\0';

View File

@@ -142,14 +142,14 @@ HB_CODEBLOCK_PTR hb_codeblockNew( const HB_BYTE * pBuffer,
HB_USHORT uiLocals,
const HB_BYTE * pLocalPosTable,
PHB_SYMB pSymbols,
HB_SIZE ulLen )
HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_CODEBLOCK_PTR pCBlock;
PHB_ITEM pLocals, pBase;
HB_BYTE * pCode;
HB_TRACE(HB_TR_DEBUG, ("hb_codeblockNew(%p, %hu, %p, %p, %" HB_PFS "u)", pBuffer, uiLocals, pLocalPosTable, pSymbols, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_codeblockNew(%p, %hu, %p, %p, %" HB_PFS "u)", pBuffer, uiLocals, pLocalPosTable, pSymbols, nLen));
/*
* allocate memory for code block body and detach items hb_gcAllocRaw()
@@ -157,15 +157,15 @@ HB_CODEBLOCK_PTR hb_codeblockNew( const HB_BYTE * pBuffer,
* calling hb_gcLock()/hb_gcUnlock(). [druzus]
*/
if( ulLen )
if( nLen )
{
/*
* The codeblock pcode is stored in dynamically allocated memory that
* can be deallocated after creation of a codeblock. We have to duplicate
* the passed buffer
*/
pCode = ( HB_BYTE * ) hb_xgrab( ulLen );
memcpy( pCode, pBuffer, ulLen );
pCode = ( HB_BYTE * ) hb_xgrab( nLen );
memcpy( pCode, pBuffer, nLen );
}
else
{
@@ -241,7 +241,7 @@ HB_CODEBLOCK_PTR hb_codeblockNew( const HB_BYTE * pBuffer,
pCBlock = ( HB_CODEBLOCK_PTR ) hb_gcAllocRaw( sizeof( HB_CODEBLOCK ), &s_gcCodeblockFuncs );
pCBlock->pCode = pCode;
pCBlock->dynBuffer = ulLen != 0;
pCBlock->dynBuffer = nLen != 0;
pCBlock->pDefSymb = pBase->item.asSymbol.stackstate->uiClass ?
hb_clsMethodSym( pBase ) : pBase->item.asSymbol.value;
pCBlock->pSymbols = pSymbols;
@@ -254,14 +254,14 @@ HB_CODEBLOCK_PTR hb_codeblockNew( const HB_BYTE * pBuffer,
return pCBlock;
}
HB_CODEBLOCK_PTR hb_codeblockMacroNew( const HB_BYTE * pBuffer, HB_SIZE ulLen )
HB_CODEBLOCK_PTR hb_codeblockMacroNew( const HB_BYTE * pBuffer, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_CODEBLOCK_PTR pCBlock;
PHB_ITEM pBase;
HB_BYTE * pCode;
HB_TRACE(HB_TR_DEBUG, ("hb_codeblockMacroNew(%p, %" HB_PFS "u)", pBuffer, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_codeblockMacroNew(%p, %" HB_PFS "u)", pBuffer, nLen));
/*
* The codeblock pcode is stored in dynamically allocated memory that
@@ -273,8 +273,8 @@ HB_CODEBLOCK_PTR hb_codeblockMacroNew( const HB_BYTE * pBuffer, HB_SIZE ulLen )
* to be safe for automatic GC activation in hb_xgrab() without
* calling hb_gcLock()/hb_gcUnlock(). [druzus]
*/
pCode = ( HB_BYTE * ) hb_xgrab( ulLen );
memcpy( pCode, pBuffer, ulLen );
pCode = ( HB_BYTE * ) hb_xgrab( nLen );
memcpy( pCode, pBuffer, nLen );
pCBlock = ( HB_CODEBLOCK_PTR ) hb_gcAllocRaw( sizeof( HB_CODEBLOCK ), &s_gcCodeblockFuncs );
pBase = hb_stackBaseItem();

View File

@@ -110,25 +110,25 @@
* $FuncName$ AddToArray( <pItem>, <pReturn>, <uiPos> )
* $Description$ Add <pItem> to array <pReturn> at pos <uiPos>
* $End$ */
static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, HB_SIZE ulPos )
static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, HB_SIZE nPos )
{
HB_TRACE(HB_TR_DEBUG, ("AddToArray(%p, %p, %" HB_PFS "u)", pItem, pReturn, ulPos));
HB_TRACE(HB_TR_DEBUG, ("AddToArray(%p, %p, %" HB_PFS "u)", pItem, pReturn, nPos));
if( HB_IS_SYMBOL( pItem ) )
{ /* Symbol is pushed as text */
PHB_ITEM pArrayItem = hb_arrayGetItemPtr( pReturn, ulPos );
PHB_ITEM pArrayItem = hb_arrayGetItemPtr( pReturn, nPos );
if( pArrayItem )
{
HB_SIZE ulLen = strlen( pItem->item.asSymbol.value->szName ) + 2;
char * szBuff = ( char * ) hb_xgrab( ulLen + 1 );
HB_SIZE nLen = strlen( pItem->item.asSymbol.value->szName ) + 2;
char * szBuff = ( char * ) hb_xgrab( nLen + 1 );
hb_snprintf( szBuff, ulLen + 1, "[%s]", pItem->item.asSymbol.value->szName );
hb_itemPutCLPtr( pArrayItem, szBuff, ulLen );
hb_snprintf( szBuff, nLen + 1, "[%s]", pItem->item.asSymbol.value->szName );
hb_itemPutCLPtr( pArrayItem, szBuff, nLen );
}
}
else /* Normal types */
hb_itemArrayPut( pReturn, ulPos, pItem );
hb_itemArrayPut( pReturn, nPos, pItem );
}
/* $Doc$
@@ -147,13 +147,13 @@ HB_FUNC( __DBGVMSTKGCOUNT )
HB_FUNC( __DBGVMSTKGLIST )
{
PHB_ITEM pReturn;
HB_ISIZ ulLen = hb_stackTopOffset();
HB_ISIZ ulPos;
HB_ISIZ nLen = hb_stackTopOffset();
HB_ISIZ nPos;
pReturn = hb_itemArrayNew( ulLen ); /* Create a transfer array */
pReturn = hb_itemArrayNew( nLen ); /* Create a transfer array */
for( ulPos = 0; ulPos < ulLen; ++ulPos )
AddToArray( hb_stackItem( ulPos ), pReturn, ulPos + 1 );
for( nPos = 0; nPos < nLen; ++nPos )
AddToArray( hb_stackItem( nPos ), pReturn, nPos + 1 );
hb_itemReturnRelease( pReturn );
}
@@ -206,16 +206,16 @@ HB_FUNC( __DBGVMSTKLCOUNT )
HB_FUNC( __DBGVMSTKLLIST )
{
PHB_ITEM pReturn;
HB_ISIZ ulLen, ul;
HB_ISIZ nLen, n;
HB_ISIZ lBaseOffset, lPrevOffset;
lBaseOffset = hb_stackBaseOffset();
lPrevOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem;
ulLen = lBaseOffset - lPrevOffset - 3;
pReturn = hb_itemArrayNew( ulLen ); /* Create a transfer array */
for( ul = 0; ul < ulLen; ++ul )
AddToArray( hb_stackItem( lPrevOffset + ul ), pReturn, ul + 1 );
nLen = lBaseOffset - lPrevOffset - 3;
pReturn = hb_itemArrayNew( nLen ); /* Create a transfer array */
for( n = 0; n < nLen; ++n )
AddToArray( hb_stackItem( lPrevOffset + n ), pReturn, n + 1 );
hb_itemReturnRelease( pReturn );
}

View File

@@ -290,15 +290,15 @@ void * hb_stackGetTSD( PHB_TSD pTSD )
#else
if( pTSD->iHandle == 0 )
{
HB_SIZE ulSize = ( hb_stack.iTSD + 2 ) * sizeof( HB_TSD_HOLDER );
HB_SIZE nSize = ( hb_stack.iTSD + 2 ) * sizeof( HB_TSD_HOLDER );
if( hb_stack.iTSD == 0 )
{
hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xgrab( ulSize );
memset( hb_stack.pTSD, 0, ulSize );
hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xgrab( nSize );
memset( hb_stack.pTSD, 0, nSize );
}
else
{
hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xrealloc( hb_stack.pTSD, ulSize );
hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xrealloc( hb_stack.pTSD, nSize );
}
pTSD->iHandle = ++hb_stack.iTSD;
#endif
@@ -583,13 +583,13 @@ void hb_stackDec( void )
}
#undef hb_stackDecrease
void hb_stackDecrease( HB_SIZE ulItems )
void hb_stackDecrease( HB_SIZE nItems )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_stackDecrease()"));
if( ( hb_stack.pPos -= ulItems ) <= hb_stack.pBase )
if( ( hb_stack.pPos -= nItems ) <= hb_stack.pBase )
hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );
}
@@ -1255,11 +1255,11 @@ static void hb_stackIsMemvarRef( PHB_STACK pStack )
{
/* 1. Mark all hidden memvars (PRIVATEs and PUBLICs) */
PHB_PRIVATE_STACK pPrivateStack = &pStack->privates;
HB_SIZE ulCount = pPrivateStack->count;
HB_SIZE nCount = pPrivateStack->count;
while( ulCount )
while( nCount )
{
PHB_ITEM pMemvar = pPrivateStack->stack[ --ulCount ].pPrevMemvar;
PHB_ITEM pMemvar = pPrivateStack->stack[ --nCount ].pPrevMemvar;
if( pMemvar && HB_IS_GCITEM( pMemvar ) )
hb_gcItemRef( pMemvar );
}

View File

@@ -145,20 +145,20 @@ HB_ULONG hb_parinfo( int iParam )
}
}
HB_SIZE hb_parinfa( int iParamNum, HB_SIZE uiArrayIndex )
HB_SIZE hb_parinfa( int iParamNum, HB_SIZE nArrayIndex )
{
PHB_ITEM pArray;
HB_TRACE(HB_TR_DEBUG, ("hb_parinfa(%d, %" HB_PFS "u)", iParamNum, uiArrayIndex));
HB_TRACE(HB_TR_DEBUG, ("hb_parinfa(%d, %" HB_PFS "u)", iParamNum, nArrayIndex));
pArray = hb_param( iParamNum, HB_IT_ARRAY );
if( pArray )
{
if( uiArrayIndex == 0 )
if( nArrayIndex == 0 )
return hb_arrayLen( pArray );
else
return ( HB_ISIZ ) hb_arrayGetType( pArray, uiArrayIndex );
return ( HB_ISIZ ) hb_arrayGetType( pArray, nArrayIndex );
}
else
return 0;
@@ -249,7 +249,7 @@ const char * hb_parcx( int iParam )
return "";
}
HB_SIZE hb_parclen( int iParam )
HB_SIZE hb_parclen( int iParam )
{
HB_STACK_TLS_PRELOAD
@@ -273,7 +273,7 @@ HB_SIZE hb_parclen( int iParam )
terminating zero byte, and it only works for parameters passed by
reference. [vszakats] */
HB_SIZE hb_parcsiz( int iParam )
HB_SIZE hb_parcsiz( int iParam )
{
HB_STACK_TLS_PRELOAD
@@ -783,13 +783,13 @@ const char * hb_parvc( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
pItem = hb_arrayGetItemPtr( pItem, ulArrayIndex );
pItem = hb_arrayGetItemPtr( pItem, nArrayIndex );
return pItem && HB_IS_STRING( pItem ) ? hb_itemGetCPtr( pItem ) : NULL;
}
}
@@ -815,20 +815,20 @@ const char * hb_parvcx( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetCPtr( pItem, ulArrayIndex );
return hb_arrayGetCPtr( pItem, nArrayIndex );
}
}
return "";
}
HB_SIZE hb_parvclen( int iParam, ... )
HB_SIZE hb_parvclen( int iParam, ... )
{
HB_STACK_TLS_PRELOAD
@@ -846,13 +846,13 @@ HB_SIZE hb_parvclen( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetCLen( pItem, ulArrayIndex );
return hb_arrayGetCLen( pItem, nArrayIndex );
}
}
@@ -863,7 +863,7 @@ HB_SIZE hb_parvclen( int iParam, ... )
terminating zero byte, and it only works for parameters passed by
reference. [vszakats] */
HB_SIZE hb_parvcsiz( int iParam, ... )
HB_SIZE hb_parvcsiz( int iParam, ... )
{
HB_STACK_TLS_PRELOAD
@@ -885,13 +885,13 @@ HB_SIZE hb_parvcsiz( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetCLen( pItem, ulArrayIndex ) + 1;
return hb_arrayGetCLen( pItem, nArrayIndex ) + 1;
}
}
}
@@ -920,13 +920,13 @@ const char * hb_parvds( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetDS( pItem, ulArrayIndex, hb_stackDateBuffer() );
return hb_arrayGetDS( pItem, nArrayIndex, hb_stackDateBuffer() );
}
}
@@ -953,13 +953,13 @@ char * hb_parvdsbuff( char * szDate, int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetDS( pItem, ulArrayIndex, szDate );
return hb_arrayGetDS( pItem, nArrayIndex, szDate );
}
}
@@ -986,13 +986,13 @@ long hb_parvdl( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetDL( pItem, ulArrayIndex );
return hb_arrayGetDL( pItem, nArrayIndex );
}
}
@@ -1018,13 +1018,13 @@ double hb_parvtd( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetTD( pItem, ulArrayIndex );
return hb_arrayGetTD( pItem, nArrayIndex );
}
}
@@ -1053,13 +1053,13 @@ HB_BOOL hb_parvtdt( long * plJulian, long * plMilliSec, int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetTDT( pItem, ulArrayIndex, plJulian, plMilliSec );
return hb_arrayGetTDT( pItem, nArrayIndex, plJulian, plMilliSec );
}
}
@@ -1091,13 +1091,13 @@ int hb_parvl( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetL( pItem, ulArrayIndex ) ? 1 : 0;
return hb_arrayGetL( pItem, nArrayIndex ) ? 1 : 0;
}
}
@@ -1126,13 +1126,13 @@ double hb_parvnd( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetND( pItem, ulArrayIndex );
return hb_arrayGetND( pItem, nArrayIndex );
}
}
@@ -1165,13 +1165,13 @@ int hb_parvni( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetNI( pItem, ulArrayIndex );
return hb_arrayGetNI( pItem, nArrayIndex );
}
}
@@ -1207,13 +1207,13 @@ long hb_parvnl( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetNL( pItem, ulArrayIndex );
return hb_arrayGetNL( pItem, nArrayIndex );
}
}
@@ -1242,13 +1242,13 @@ HB_ISIZ hb_parvns( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetNS( pItem, ulArrayIndex );
return hb_arrayGetNS( pItem, nArrayIndex );
}
}
@@ -1282,13 +1282,13 @@ HB_LONGLONG hb_parvnll( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetNLL( pItem, ulArrayIndex );
return hb_arrayGetNLL( pItem, nArrayIndex );
}
}
@@ -1322,13 +1322,13 @@ HB_MAXINT hb_parvnint( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetNInt( pItem, ulArrayIndex );
return hb_arrayGetNInt( pItem, nArrayIndex );
}
}
@@ -1353,13 +1353,13 @@ void * hb_parvptr( int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
return hb_arrayGetPtr( pItem, ulArrayIndex );
return hb_arrayGetPtr( pItem, nArrayIndex );
}
}
@@ -1388,13 +1388,13 @@ void * hb_parvptrGC( const HB_GC_FUNCS * pFuncs, int iParam, ... )
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
HB_SIZE ulArrayIndex;
HB_SIZE nArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, HB_SIZE );
nArrayIndex = va_arg( va, HB_SIZE );
va_end( va );
pItem = hb_arrayGetItemPtr( pItem, ulArrayIndex );
pItem = hb_arrayGetItemPtr( pItem, nArrayIndex );
if( pItem && HB_IS_POINTER( pItem ) &&
pItem->item.asPointer.collect &&
hb_gcFuncs( pItem->item.asPointer.value ) == pFuncs )
@@ -1416,13 +1416,13 @@ void hb_ret( void )
}
#undef hb_reta
void hb_reta( HB_SIZE ulLen ) /* undocumented hb_reta() */
void hb_reta( HB_SIZE nLen ) /* undocumented hb_reta() */
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_reta(%" HB_PFS "u)", ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_reta(%" HB_PFS "u)", nLen));
hb_arrayNew( hb_stackReturnItem(), ulLen );
hb_arrayNew( hb_stackReturnItem(), nLen );
}
#undef hb_retc
@@ -1466,33 +1466,33 @@ void hb_retc_const( const char * szText )
}
#undef hb_retclen
void hb_retclen( const char * szText, HB_SIZE ulLen )
void hb_retclen( const char * szText, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_retclen(%.*s, %" HB_PFS "u)", ( int ) ulLen, szText, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_retclen(%.*s, %" HB_PFS "u)", ( int ) nLen, szText, nLen));
hb_itemPutCL( hb_stackReturnItem(), szText, ulLen );
hb_itemPutCL( hb_stackReturnItem(), szText, nLen );
}
#undef hb_retclen_buffer
void hb_retclen_buffer( char * szText, HB_SIZE ulLen )
void hb_retclen_buffer( char * szText, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%.*s, %" HB_PFS "u)", ( int ) ulLen, szText, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%.*s, %" HB_PFS "u)", ( int ) nLen, szText, nLen));
hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen );
hb_itemPutCLPtr( hb_stackReturnItem(), szText, nLen );
}
#undef hb_retclen_const
void hb_retclen_const( const char * szText, HB_SIZE ulLen )
void hb_retclen_const( const char * szText, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_const(%.*s, %" HB_PFS "u)", ( int ) ulLen, szText, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_const(%.*s, %" HB_PFS "u)", ( int ) nLen, szText, nLen));
hb_itemPutCLConst( hb_stackReturnItem(), szText, ulLen );
hb_itemPutCLConst( hb_stackReturnItem(), szText, nLen );
}
/* szDate must have YYYYMMDD format */
@@ -1751,15 +1751,15 @@ int hb_storc( const char * szText, int iParam )
return 0;
}
int hb_storclen( const char * szText, HB_SIZE ulLen, int iParam )
int hb_storclen( const char * szText, HB_SIZE nLen, int iParam )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_storclen(%.*s, %" HB_PFS "u, %d)", ( int ) ulLen, szText, ulLen, iParam));
HB_TRACE(HB_TR_DEBUG, ("hb_storclen(%.*s, %" HB_PFS "u, %d)", ( int ) nLen, szText, nLen, iParam));
if( iParam == -1 )
{
hb_itemPutCL( hb_stackReturnItem(), szText, ulLen );
hb_itemPutCL( hb_stackReturnItem(), szText, nLen );
return 1;
}
else if( iParam >= 0 && iParam <= hb_pcount() )
@@ -1768,7 +1768,7 @@ int hb_storclen( const char * szText, HB_SIZE ulLen, int iParam )
if( HB_IS_BYREF( pItem ) )
{
hb_itemPutCL( hb_itemUnRef( pItem ), szText, ulLen );
hb_itemPutCL( hb_itemUnRef( pItem ), szText, nLen );
return 1;
}
}
@@ -1776,15 +1776,15 @@ int hb_storclen( const char * szText, HB_SIZE ulLen, int iParam )
return 0;
}
int hb_storclen_buffer( char * szText, HB_SIZE ulLen, int iParam )
int hb_storclen_buffer( char * szText, HB_SIZE nLen, int iParam )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_storclen_buffer(%.*s, %" HB_PFS "u, %d)", ( int ) ulLen, szText, ulLen, iParam));
HB_TRACE(HB_TR_DEBUG, ("hb_storclen_buffer(%.*s, %" HB_PFS "u, %d)", ( int ) nLen, szText, nLen, iParam));
if( iParam == -1 )
{
hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen );
hb_itemPutCLPtr( hb_stackReturnItem(), szText, nLen );
return 1;
}
else if( iParam >= 0 && iParam <= hb_pcount() )
@@ -1793,7 +1793,7 @@ int hb_storclen_buffer( char * szText, HB_SIZE ulLen, int iParam )
if( HB_IS_BYREF( pItem ) )
{
hb_itemPutCLPtr( hb_itemUnRef( pItem ), szText, ulLen );
hb_itemPutCLPtr( hb_itemUnRef( pItem ), szText, nLen );
return 1;
}
}
@@ -2167,11 +2167,11 @@ int hb_storvc( const char * szText, int iParam, ... )
return 0;
}
int hb_storvclen( const char * szText, HB_SIZE ulLen, int iParam, ... )
int hb_storvclen( const char * szText, HB_SIZE nLen, int iParam, ... )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_storvclen(%.*s, %" HB_PFS "u, %d, ...)", ( int ) ulLen, szText, ulLen, iParam));
HB_TRACE(HB_TR_DEBUG, ("hb_storvclen(%.*s, %" HB_PFS "u, %d, ...)", ( int ) nLen, szText, nLen, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
@@ -2186,13 +2186,13 @@ int hb_storvclen( const char * szText, HB_SIZE ulLen, int iParam, ... )
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetCL( pItem, va_arg( va, HB_SIZE ), szText, ulLen ) ? 1 : 0;
iRetVal = hb_arraySetCL( pItem, va_arg( va, HB_SIZE ), szText, nLen ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutCL( pItem, szText, ulLen );
hb_itemPutCL( pItem, szText, nLen );
return 1;
}
}
@@ -2200,11 +2200,11 @@ int hb_storvclen( const char * szText, HB_SIZE ulLen, int iParam, ... )
return 0;
}
int hb_storvclen_buffer( char * szText, HB_SIZE ulLen, int iParam, ... )
int hb_storvclen_buffer( char * szText, HB_SIZE nLen, int iParam, ... )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_storvclen_buffer(%.*s, %" HB_PFS "u, %d, ...)", ( int ) ulLen, szText, ulLen, iParam));
HB_TRACE(HB_TR_DEBUG, ("hb_storvclen_buffer(%.*s, %" HB_PFS "u, %d, ...)", ( int ) nLen, szText, nLen, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
@@ -2219,13 +2219,13 @@ int hb_storvclen_buffer( char * szText, HB_SIZE ulLen, int iParam, ... )
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetCLPtr( pItem, va_arg( va, HB_SIZE ), szText, ulLen ) ? 1 : 0;
iRetVal = hb_arraySetCLPtr( pItem, va_arg( va, HB_SIZE ), szText, nLen ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutCLPtr( pItem, szText, ulLen );
hb_itemPutCLPtr( pItem, szText, nLen );
return 1;
}
}

View File

@@ -282,7 +282,7 @@ static HB_BOOL s_fInitedFM = HB_FALSE;
typedef struct _HB_MEMINFO
{
HB_U32 u32Signature;
HB_SIZE ulSize;
HB_SIZE nSize;
HB_USHORT uiProcLine;
char szProcName[ HB_SYMBOL_NAME_LEN + 1 ];
struct _HB_MEMINFO * pPrevBlock;
@@ -306,7 +306,7 @@ typedef struct _HB_MEMINFO
#define HB_ALLOC_SIZE( n ) ( ( n ) + ( s_fStatistic ? _HB_MEMINFO_SIZE + sizeof( HB_U32 ) : HB_COUNTER_OFFSET ) )
#define HB_FM_PTR( p ) ( ( PHB_MEMINFO ) ( ( HB_BYTE * ) ( p ) - HB_MEMINFO_SIZE ) )
#define HB_FM_BLOCKSIZE( p ) ( s_fStatistic ? HB_FM_PTR( pMem )->ulSize : 0 )
#define HB_FM_BLOCKSIZE( p ) ( s_fStatistic ? HB_FM_PTR( pMem )->nSize : 0 )
/* NOTE: we cannot use here HB_TRACE because it will overwrite the
* function name/line number of code which called hb_xalloc/hb_xgrab
@@ -576,13 +576,13 @@ void hb_xsetinfo( const char * szValue )
#endif
}
void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NULL on failure */
void * hb_xalloc( HB_SIZE nSize ) /* allocates fixed memory, returns NULL on failure */
{
PHB_MEMINFO pMem;
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xalloc(%" HB_PFS "u)", ulSize));
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xalloc(%" HB_PFS "u)", nSize));
if( ulSize == 0 )
if( nSize == 0 )
hb_errInternal( HB_EI_XALLOCNULLSIZE, NULL, NULL, NULL );
#ifdef HB_FM_NEED_INIT
@@ -590,7 +590,7 @@ void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NU
hb_xinit();
#endif
pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( ulSize ) );
pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( nSize ) );
if( ! pMem )
return pMem;
@@ -617,8 +617,8 @@ void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NU
pMem->pNextBlock = NULL;
pMem->u32Signature = HB_MEMINFO_SIGNATURE;
HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
pMem->ulSize = ulSize; /* size of the memory block */
HB_FM_SETSIG( HB_MEM_PTR( pMem ), nSize );
pMem->nSize = nSize; /* size of the memory block */
pTrace = hb_traceinfo();
if( hb_tr_level() >= HB_TR_DEBUG || pTrace->level == HB_TR_FM )
@@ -640,7 +640,7 @@ void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NU
hb_stackBaseProcInfo( pMem->szProcName, &pMem->uiProcLine );
}
s_lMemoryConsumed += ulSize + sizeof( HB_COUNTER );
s_lMemoryConsumed += nSize + sizeof( HB_COUNTER );
if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
s_lMemoryMaxConsumed = s_lMemoryConsumed;
s_lMemoryBlocks++;
@@ -650,7 +650,7 @@ void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NU
HB_FM_UNLOCK
#ifdef HB_PARANOID_MEM_CHECK
memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize );
memset( HB_MEM_PTR( pMem ), HB_MEMFILER, nSize );
#endif
}
@@ -662,13 +662,13 @@ void * hb_xalloc( HB_SIZE ulSize ) /* allocates fixed memory, returns NU
return HB_MEM_PTR( pMem );
}
void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on failure */
void * hb_xgrab( HB_SIZE nSize ) /* allocates fixed memory, exits on failure */
{
PHB_MEMINFO pMem;
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xgrab(%" HB_PFS "u)", ulSize));
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xgrab(%" HB_PFS "u)", nSize));
if( ulSize == 0 )
if( nSize == 0 )
hb_errInternal( HB_EI_XGRABNULLSIZE, NULL, NULL, NULL );
#ifdef HB_FM_NEED_INIT
@@ -676,7 +676,7 @@ void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on fa
hb_xinit();
#endif
pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( ulSize ) );
pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( nSize ) );
if( ! pMem )
hb_errInternal( HB_EI_XGRABALLOC, NULL, NULL, NULL );
@@ -703,8 +703,8 @@ void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on fa
pMem->pNextBlock = NULL;
pMem->u32Signature = HB_MEMINFO_SIGNATURE;
HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
pMem->ulSize = ulSize; /* size of the memory block */
HB_FM_SETSIG( HB_MEM_PTR( pMem ), nSize );
pMem->nSize = nSize; /* size of the memory block */
pTrace = hb_traceinfo();
if( hb_tr_level() >= HB_TR_DEBUG || pTrace->level == HB_TR_FM )
@@ -726,7 +726,7 @@ void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on fa
hb_stackBaseProcInfo( pMem->szProcName, &pMem->uiProcLine );
}
s_lMemoryConsumed += ulSize + sizeof( HB_COUNTER );
s_lMemoryConsumed += nSize + sizeof( HB_COUNTER );
if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
s_lMemoryMaxConsumed = s_lMemoryConsumed;
s_lMemoryBlocks++;
@@ -736,7 +736,7 @@ void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on fa
HB_FM_UNLOCK
#ifdef HB_PARANOID_MEM_CHECK
memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize );
memset( HB_MEM_PTR( pMem ), HB_MEMFILER, nSize );
#endif
}
@@ -748,27 +748,27 @@ void * hb_xgrab( HB_SIZE ulSize ) /* allocates fixed memory, exits on fa
return HB_MEM_PTR( pMem );
}
void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) /* reallocates memory */
void * hb_xrealloc( void * pMem, HB_SIZE nSize ) /* reallocates memory */
{
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xrealloc(%p, %" HB_PFS "u)", pMem, ulSize));
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xrealloc(%p, %" HB_PFS "u)", pMem, nSize));
#if 0
/* disabled to make hb_xrealloc() ANSI-C realloc() compatible */
if( ! pMem )
hb_errInternal( HB_EI_XREALLOCNULL, NULL, NULL, NULL );
if( ulSize == 0 )
if( nSize == 0 )
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
#endif
#ifdef HB_FM_STATISTICS
if( pMem == NULL )
{
if( ulSize == 0 )
if( nSize == 0 )
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
return hb_xgrab( ulSize );
return hb_xgrab( nSize );
}
else if( ulSize == 0 )
else if( nSize == 0 )
{
hb_xfree( pMem );
return NULL;
@@ -776,49 +776,49 @@ void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) /* reallocates memory */
else if( s_fStatistic )
{
PHB_MEMINFO pMemBlock;
HB_SIZE ulMemSize;
HB_SIZE nMemSize;
pMemBlock = HB_FM_PTR( pMem );
if( pMemBlock->u32Signature != HB_MEMINFO_SIGNATURE )
hb_errInternal( HB_EI_XREALLOCINV, NULL, NULL, NULL );
ulMemSize = pMemBlock->ulSize;
nMemSize = pMemBlock->nSize;
if( HB_FM_GETSIG( pMem, ulMemSize ) != HB_MEMINFO_SIGNATURE )
if( HB_FM_GETSIG( pMem, nMemSize ) != HB_MEMINFO_SIGNATURE )
hb_errInternal( HB_EI_XMEMOVERFLOW, NULL, NULL, NULL );
HB_FM_CLRSIG( pMem, ulMemSize );
HB_FM_CLRSIG( pMem, nMemSize );
HB_FM_LOCK
#ifdef HB_PARANOID_MEM_CHECK
pMem = malloc( HB_ALLOC_SIZE( ulSize ) );
pMem = malloc( HB_ALLOC_SIZE( nSize ) );
if( pMem )
{
HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMem ) ), 1 );
if( ulSize > ulMemSize )
if( nSize > nMemSize )
{
memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( ulMemSize ) );
memset( ( HB_BYTE * ) pMem + HB_ALLOC_SIZE( ulMemSize ), HB_MEMFILER, ulSize - ulMemSize );
memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( nMemSize ) );
memset( ( HB_BYTE * ) pMem + HB_ALLOC_SIZE( nMemSize ), HB_MEMFILER, nSize - nMemSize );
}
else
memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( ulSize ) );
memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( nSize ) );
}
memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( ulMemSize ) );
memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( nMemSize ) );
free( pMemBlock );
#else
pMem = realloc( pMemBlock, HB_ALLOC_SIZE( ulSize ) );
pMem = realloc( pMemBlock, HB_ALLOC_SIZE( nSize ) );
#endif
s_lMemoryConsumed += ( ulSize - ulMemSize );
s_lMemoryConsumed += ( nSize - nMemSize );
if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
s_lMemoryMaxConsumed = s_lMemoryConsumed;
if( pMem )
{
( ( PHB_MEMINFO ) pMem )->ulSize = ulSize; /* size of the memory block */
HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
( ( PHB_MEMINFO ) pMem )->nSize = nSize; /* size of the memory block */
HB_FM_SETSIG( HB_MEM_PTR( pMem ), nSize );
if( ( ( PHB_MEMINFO ) pMem )->pPrevBlock )
( ( PHB_MEMINFO ) pMem )->pPrevBlock->pNextBlock = ( PHB_MEMINFO ) pMem;
if( ( ( PHB_MEMINFO ) pMem )->pNextBlock )
@@ -833,7 +833,7 @@ void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) /* reallocates memory */
HB_FM_UNLOCK
}
else
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( nSize ) );
if( ! pMem )
hb_errInternal( HB_EI_XREALLOC, NULL, NULL, NULL );
@@ -842,20 +842,20 @@ void * hb_xrealloc( void * pMem, HB_SIZE ulSize ) /* reallocates memory */
if( pMem == NULL )
{
if( ulSize == 0 )
if( nSize == 0 )
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
pMem = malloc( HB_ALLOC_SIZE( ulSize ) );
pMem = malloc( HB_ALLOC_SIZE( nSize ) );
if( pMem )
HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMem ) ), 1 );
}
else if( ulSize == 0 )
else if( nSize == 0 )
{
free( HB_FM_PTR( pMem ) );
return NULL;
}
else
{
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( nSize ) );
}
if( !pMem )
@@ -881,12 +881,12 @@ void hb_xfree( void * pMem ) /* frees fixed memory */
if( pMemBlock->u32Signature != HB_MEMINFO_SIGNATURE )
hb_errInternal( HB_EI_XFREEINV, NULL, NULL, NULL );
if( HB_FM_GETSIG( pMem, pMemBlock->ulSize ) != HB_MEMINFO_SIGNATURE )
if( HB_FM_GETSIG( pMem, pMemBlock->nSize ) != HB_MEMINFO_SIGNATURE )
hb_errInternal( HB_EI_XMEMOVERFLOW, NULL, NULL, NULL );
HB_FM_LOCK
s_lMemoryConsumed -= pMemBlock->ulSize + sizeof( HB_COUNTER );
s_lMemoryConsumed -= pMemBlock->nSize + sizeof( HB_COUNTER );
s_lMemoryBlocks--;
if( pMemBlock->pPrevBlock )
@@ -902,9 +902,9 @@ void hb_xfree( void * pMem ) /* frees fixed memory */
HB_FM_UNLOCK
pMemBlock->u32Signature = 0;
HB_FM_CLRSIG( pMem, pMemBlock->ulSize );
HB_FM_CLRSIG( pMem, pMemBlock->nSize );
#ifdef HB_PARANOID_MEM_CHECK
memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( pMemBlock->ulSize ) );
memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( pMemBlock->nSize ) );
#endif
}
@@ -963,48 +963,48 @@ HB_COUNTER hb_xRefCount( void * pMem )
/* reallocates memory, create copy if reference counter greater then 1 */
#undef hb_xRefResize
void * hb_xRefResize( void * pMem, HB_SIZE ulSave, HB_SIZE ulSize, HB_SIZE * pulAllocated )
void * hb_xRefResize( void * pMem, HB_SIZE nSave, HB_SIZE nSize, HB_SIZE * pnAllocated )
{
#ifdef HB_FM_STATISTICS
if( HB_ATOM_GET( HB_COUNTER_PTR( pMem ) ) > 1 )
{
void * pMemNew = memcpy( hb_xgrab( ulSize ), pMem, HB_MIN( ulSave, ulSize ) );
void * pMemNew = memcpy( hb_xgrab( nSize ), pMem, HB_MIN( nSave, nSize ) );
if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
hb_xfree( pMem );
*pulAllocated = ulSize;
*pnAllocated = nSize;
return pMemNew;
}
else if( ulSize <= *pulAllocated )
else if( nSize <= *pnAllocated )
return pMem;
*pulAllocated = ulSize;
return hb_xrealloc( pMem, ulSize );
*pnAllocated = nSize;
return hb_xrealloc( pMem, nSize );
#else
if( HB_ATOM_GET( HB_COUNTER_PTR( pMem ) ) > 1 )
{
void * pMemNew = malloc( HB_ALLOC_SIZE( ulSize ) );
void * pMemNew = malloc( HB_ALLOC_SIZE( nSize ) );
if( pMemNew )
{
HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMemNew ) ), 1 );
memcpy( HB_MEM_PTR( pMemNew ), pMem, HB_MIN( ulSave, ulSize ) );
memcpy( HB_MEM_PTR( pMemNew ), pMem, HB_MIN( nSave, nSize ) );
if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
free( HB_FM_PTR( pMem ) );
*pulAllocated = ulSize;
*pnAllocated = nSize;
return HB_MEM_PTR( pMemNew );
}
}
else if( ulSize <= *pulAllocated )
else if( nSize <= *pnAllocated )
return pMem;
else
{
*pulAllocated = ulSize;
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
*pnAllocated = nSize;
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( nSize ) );
if( pMem )
return HB_MEM_PTR( pMem );
}
@@ -1067,40 +1067,40 @@ void hb_xinit( void ) /* Initialize fixed memory subsystem */
of pMem memory block */
#ifdef HB_FM_STATISTICS
static char * hb_mem2str( char * membuffer, void * pMem, HB_SIZE uiSize )
static char * hb_mem2str( char * membuffer, void * pMem, HB_SIZE nSize )
{
HB_BYTE * cMem = ( HB_BYTE * ) pMem;
HB_SIZE uiIndex, uiPrintable;
HB_SIZE nIndex, nPrintable;
uiPrintable = 0;
for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
if( ( cMem[ uiIndex ] & 0x60 ) != 0 )
uiPrintable++;
nPrintable = 0;
for( nIndex = 0; nIndex < nSize; nIndex++ )
if( ( cMem[ nIndex ] & 0x60 ) != 0 )
nPrintable++;
if( uiPrintable * 100 / uiSize > 70 ) /* more then 70% printable chars */
if( nPrintable * 100 / nSize > 70 ) /* more then 70% printable chars */
{
/* format as string of original chars */
for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
if( cMem[ uiIndex ] >= ' ' )
membuffer[ uiIndex ] = cMem[ uiIndex ];
for( nIndex = 0; nIndex < nSize; nIndex++ )
if( cMem[ nIndex ] >= ' ' )
membuffer[ nIndex ] = cMem[ nIndex ];
else
membuffer[ uiIndex ] = '.';
membuffer[ uiIndex ] = '\0';
membuffer[ nIndex ] = '.';
membuffer[ nIndex ] = '\0';
}
else
{
/* format as hex */
for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
for( nIndex = 0; nIndex < nSize; nIndex++ )
{
int lownibble, hinibble;
hinibble = cMem[ uiIndex ] >> 4;
lownibble = cMem[ uiIndex ] & 0x0F;
membuffer[ uiIndex * 2 ] = hinibble <= 9 ?
hinibble = cMem[ nIndex ] >> 4;
lownibble = cMem[ nIndex ] & 0x0F;
membuffer[ nIndex * 2 ] = hinibble <= 9 ?
( '0' + hinibble ) : ( 'A' + hinibble - 10 );
membuffer[ uiIndex * 2 + 1 ] = lownibble <= 9 ?
membuffer[ nIndex * 2 + 1 ] = lownibble <= 9 ?
( '0' + lownibble ) : ( 'A' + lownibble - 10 );
}
membuffer[ uiIndex * 2 ] = '\0';
membuffer[ nIndex * 2 ] = '\0';
}
return membuffer;
@@ -1163,17 +1163,17 @@ void hb_xexit( void ) /* Deinitialize fixed memory subsystem */
for( ui = 1, pMemBlock = s_pFirstBlock; pMemBlock; pMemBlock = pMemBlock->pNextBlock, ++ui )
{
HB_TRACE( HB_TR_ERROR, ( "Block %i (size %lu) %s(%i), \"%s\"", ui,
pMemBlock->ulSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
pMemBlock->nSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
hb_mem2str( membuffer, ( char * ) HB_MEM_PTR( pMemBlock ),
HB_MIN( pMemBlock->ulSize, HB_MAX_MEM2STR_BLOCK ) ) ) );
HB_MIN( pMemBlock->nSize, HB_MAX_MEM2STR_BLOCK ) ) ) );
if( hLog )
{
fprintf( hLog, HB_I_("Block %i %p (size %lu) %s(%i), \"%s\"\n"), ui,
( char * ) HB_MEM_PTR( pMemBlock ),
pMemBlock->ulSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
pMemBlock->nSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
hb_mem2str( membuffer, ( char * ) HB_MEM_PTR( pMemBlock ),
HB_MIN( pMemBlock->ulSize, HB_MAX_MEM2STR_BLOCK ) ) );
HB_MIN( pMemBlock->nSize, HB_MAX_MEM2STR_BLOCK ) ) );
}
}
@@ -1216,7 +1216,7 @@ void hb_xexit( void ) /* Deinitialize fixed memory subsystem */
HB_SIZE hb_xquery( int iMode )
{
HB_SIZE ulResult;
HB_SIZE nResult;
HB_TRACE(HB_TR_DEBUG, ("hb_xquery(%d)", iMode));
@@ -1229,19 +1229,19 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = memorystatus.dwAvailPhys / 1024;
nResult = memorystatus.dwAvailPhys / 1024;
}
#elif defined( HB_OS_OS2 )
{
ULONG ulSysInfo = 0;
if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
ulResult = 0;
nResult = 0;
else
ulResult = ulSysInfo / 1024;
nResult = ulSysInfo / 1024;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
@@ -1250,19 +1250,19 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = HB_MIN( memorystatus.dwAvailPhys, ULONG_MAX ) / 1024;
nResult = HB_MIN( memorystatus.dwAvailPhys, ULONG_MAX ) / 1024;
}
#elif defined( HB_OS_OS2 )
{
ULONG ulSysInfo = 0;
if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
ulResult = 0;
nResult = 0;
else
ulResult = HB_MIN( ulSysInfo, ULONG_MAX ) / 1024;
nResult = HB_MIN( ulSysInfo, ULONG_MAX ) / 1024;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
@@ -1271,19 +1271,19 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = memorystatus.dwAvailPhys / 1024;
nResult = memorystatus.dwAvailPhys / 1024;
}
#elif defined( HB_OS_OS2 )
{
ULONG ulSysInfo = 0;
if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
ulResult = 0;
nResult = 0;
else
ulResult = ulSysInfo / 1024;
nResult = ulSysInfo / 1024;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
@@ -1292,27 +1292,27 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = memorystatus.dwAvailVirtual / 1024;
nResult = memorystatus.dwAvailVirtual / 1024;
}
#elif defined( HB_OS_OS2 )
{
ULONG ulSysInfo = 0;
if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
ulResult = 0;
nResult = 0;
else
ulResult = ulSysInfo / 1024;
nResult = ulSysInfo / 1024;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
case HB_MEM_EMS: /* UNDOCUMENTED! (Free Expanded Memory [KB]) (?) */
#if defined( HB_OS_WIN ) || defined( HB_OS_OS2 )
ulResult = 0;
nResult = 0;
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
@@ -1321,27 +1321,27 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = memorystatus.dwTotalPhys / 1024;
nResult = memorystatus.dwTotalPhys / 1024;
}
#elif defined( HB_OS_OS2 )
{
ULONG ulSysInfo = 0;
if( DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
ulResult = 0;
nResult = 0;
else
ulResult = ulSysInfo / 1024;
nResult = ulSysInfo / 1024;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
case HB_MEM_FMSEGS: /* UNDOCUMENTED! (Segments in Fixed Memory/Heap) (?) */
#if defined( HB_OS_WIN ) || defined( HB_OS_OS2 )
ulResult = 1;
nResult = 1;
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
@@ -1350,75 +1350,75 @@ HB_SIZE hb_xquery( int iMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = memorystatus.dwAvailPageFile / 1024;
nResult = memorystatus.dwAvailPageFile / 1024;
}
#elif defined( HB_OS_OS2 )
{
/* NOTE: There is no way to know how much a swap file can grow on an
OS/2 system. I think we should return free space on DASD
media which contains swap file [maurilio.longo] */
ulResult = 9999;
nResult = 9999;
}
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
case HB_MEM_CONV: /* UNDOCUMENTED! (Free Conventional [KB]) */
#if defined( HB_OS_WIN ) || defined( HB_OS_OS2 )
ulResult = 0;
nResult = 0;
#else
ulResult = 9999;
nResult = 9999;
#endif
break;
case HB_MEM_EMSUSED: /* UNDOCUMENTED! (Used Expanded Memory [KB]) (?) */
ulResult = 0;
nResult = 0;
break;
case HB_MEM_USED: /* Harbour extension (Memory used [bytes]) */
#ifdef HB_FM_STATISTICS
ulResult = s_lMemoryConsumed;
nResult = s_lMemoryConsumed;
#else
ulResult = 0;
nResult = 0;
#endif
break;
case HB_MEM_BLOCKS: /* Harbour extension (Memory blocks used) */
#ifdef HB_FM_STATISTICS
ulResult = s_lMemoryBlocks;
nResult = s_lMemoryBlocks;
#else
ulResult = 0;
nResult = 0;
#endif
break;
case HB_MEM_USEDMAX: /* Harbour extension (Maximum memory used [bytes]) */
#ifdef HB_FM_STATISTICS
ulResult = s_lMemoryMaxConsumed;
nResult = s_lMemoryMaxConsumed;
#else
ulResult = 0;
nResult = 0;
#endif
break;
case HB_MEM_STACKITEMS: /* Harbour extension (Total items allocated for the stack) */
ulResult = hb_stackTotalItems();
nResult = hb_stackTotalItems();
break;
case HB_MEM_STACK: /* Harbour extension (Total memory size used by the stack [bytes]) */
ulResult = hb_stackTotalItems() * sizeof( HB_ITEM );
nResult = hb_stackTotalItems() * sizeof( HB_ITEM );
break;
case HB_MEM_STACK_TOP : /* Harbour extension (Total items currently on the stack) */
{
HB_STACK_TLS_PRELOAD
ulResult = hb_stackTopOffset( );
nResult = hb_stackTopOffset( );
break;
}
default:
ulResult = 0;
nResult = 0;
}
return ulResult;
return nResult;
}
HB_BOOL hb_xtraced( void )

View File

@@ -121,7 +121,7 @@ typedef struct HB_GARBAGE_
#define HB_BLOCK_PTR( p ) ( ( void * ) ( ( HB_BYTE * ) ( p ) + HB_GARBAGE_SIZE ) )
/* we may use a cache later */
#define HB_GARBAGE_NEW( ulSize ) ( ( HB_GARBAGE_PTR ) hb_xgrab( HB_GARBAGE_SIZE + ( ulSize ) ) )
#define HB_GARBAGE_NEW( nSize ) ( ( HB_GARBAGE_PTR ) hb_xgrab( HB_GARBAGE_SIZE + ( nSize ) ) )
#define HB_GARBAGE_FREE( pAlloc ) hb_xfree( ( void * ) ( pAlloc ) )
/* status of memory block */
@@ -196,11 +196,11 @@ static void hb_gcUnlink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc )
}
/* allocates a memory block */
void * hb_gcAllocate( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs )
void * hb_gcAllocate( HB_SIZE nSize, const HB_GC_FUNCS * pFuncs )
{
HB_GARBAGE_PTR pAlloc;
pAlloc = HB_GARBAGE_NEW( ulSize );
pAlloc = HB_GARBAGE_NEW( nSize );
pAlloc->pFuncs = pFuncs;
pAlloc->locked = 1;
pAlloc->used = s_uUsedFlag;
@@ -212,11 +212,11 @@ void * hb_gcAllocate( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs )
}
/* allocates a memory block */
void * hb_gcAllocRaw( HB_SIZE ulSize, const HB_GC_FUNCS * pFuncs )
void * hb_gcAllocRaw( HB_SIZE nSize, const HB_GC_FUNCS * pFuncs )
{
HB_GARBAGE_PTR pAlloc;
pAlloc = HB_GARBAGE_NEW( ulSize );
pAlloc = HB_GARBAGE_NEW( nSize );
pAlloc->pFuncs = pFuncs;
pAlloc->locked = 0;
pAlloc->used = s_uUsedFlag;

View File

@@ -76,9 +76,9 @@ typedef struct _HB_BASEHASH
{
PHB_HASHPAIR pPairs; /* pointer to the array of key/value pairs */
PHB_ITEM pDefault; /* default autoadd value */
HB_SIZE * pulPos; /* the sort order for HB_HASH_KEEPORDER */
HB_SIZE ulSize; /* size of allocated pair array */
HB_SIZE ulLen; /* number of used items in pair array */
HB_SIZE * pnPos; /* the sort order for HB_HASH_KEEPORDER */
HB_SIZE nSize; /* size of allocated pair array */
HB_SIZE nLen; /* number of used items in pair array */
int iFlags; /* hash item flags */
} HB_BASEHASH, * PHB_BASEHASH, * HB_BASEHASH_PTR;
@@ -90,10 +90,10 @@ static HB_GARBAGE_FUNC( hb_hashGarbageRelease )
HB_TRACE(HB_TR_INFO, ("hb_hashGarbageRelease(%p)", pBaseHash ));
if( pBaseHash->ulSize > 0 )
if( pBaseHash->nSize > 0 )
{
PHB_HASHPAIR pPairs = pBaseHash->pPairs;
HB_SIZE ulLen = pBaseHash->ulLen;
HB_SIZE nLen = pBaseHash->nLen;
/*
* clear the pBaseHash->pPairs to avoid infinite loop in cross
@@ -101,20 +101,20 @@ static HB_GARBAGE_FUNC( hb_hashGarbageRelease )
* object destructor [druzus]
*/
pBaseHash->pPairs = NULL;
pBaseHash->ulLen = 0;
pBaseHash->nLen = 0;
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
hb_xfree( pBaseHash->pulPos );
pBaseHash->pulPos = NULL;
hb_xfree( pBaseHash->pnPos );
pBaseHash->pnPos = NULL;
}
while( ulLen-- )
while( nLen-- )
{
if( HB_IS_COMPLEX( &pPairs[ ulLen ].key ) )
hb_itemClear( &pPairs[ ulLen ].key );
if( HB_IS_COMPLEX( &pPairs[ ulLen ].value ) )
hb_itemClear( &pPairs[ ulLen ].value );
if( HB_IS_COMPLEX( &pPairs[ nLen ].key ) )
hb_itemClear( &pPairs[ nLen ].key );
if( HB_IS_COMPLEX( &pPairs[ nLen ].value ) )
hb_itemClear( &pPairs[ nLen ].value );
}
hb_xfree( pPairs );
}
@@ -132,17 +132,17 @@ static HB_GARBAGE_FUNC( hb_hashGarbageMark )
HB_TRACE(HB_TR_INFO, ("hb_hashMarkGarbage(%p)", pBaseHash ));
if( pBaseHash->ulLen > 0 )
if( pBaseHash->nLen > 0 )
{
PHB_HASHPAIR pPairs = pBaseHash->pPairs;
HB_SIZE ulLen = pBaseHash->ulLen;
HB_SIZE nLen = pBaseHash->nLen;
while( ulLen-- )
while( nLen-- )
{
if( HB_IS_GCITEM( &pPairs[ ulLen ].key ) )
hb_gcItemRef( &pPairs[ ulLen ].key );
if( HB_IS_GCITEM( &pPairs[ ulLen ].value ) )
hb_gcItemRef( &pPairs[ ulLen ].value );
if( HB_IS_GCITEM( &pPairs[ nLen ].key ) )
hb_gcItemRef( &pPairs[ nLen ].key );
if( HB_IS_GCITEM( &pPairs[ nLen ].value ) )
hb_gcItemRef( &pPairs[ nLen ].value );
}
}
if( pBaseHash->pDefault )
@@ -213,43 +213,43 @@ static int hb_hashItemCmp( PHB_ITEM pKey1, PHB_ITEM pKey2, int iFlags )
static void hb_hashResort( PHB_BASEHASH pBaseHash )
{
HB_SIZE ulPos, ulFrom;
HB_SIZE nPos, nFrom;
int iFlags = pBaseHash->iFlags;
/* The hash array is probably quite well sorted so this trivial
* algorithm is the most efficient one [druzus]
*/
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
for( ulFrom = 1; ulFrom < pBaseHash->ulLen; ++ulFrom )
for( nFrom = 1; nFrom < pBaseHash->nLen; ++nFrom )
{
ulPos = ulFrom;
while( ulPos > 0 && hb_hashItemCmp( &pBaseHash->pPairs[ pBaseHash->pulPos[ ulPos - 1 ] ].key,
&pBaseHash->pPairs[ pBaseHash->pulPos[ ulPos ] ].key,
iFlags ) > 0 )
nPos = nFrom;
while( nPos > 0 && hb_hashItemCmp( &pBaseHash->pPairs[ pBaseHash->pnPos[ nPos - 1 ] ].key,
&pBaseHash->pPairs[ pBaseHash->pnPos[ nPos ] ].key,
iFlags ) > 0 )
{
HB_SIZE ulTemp = pBaseHash->pulPos[ ulPos - 1 ];
pBaseHash->pulPos[ ulPos - 1 ] = pBaseHash->pulPos[ ulPos ];
pBaseHash->pulPos[ ulPos ] = ulTemp;
--ulPos;
HB_SIZE nTemp = pBaseHash->pnPos[ nPos - 1 ];
pBaseHash->pnPos[ nPos - 1 ] = pBaseHash->pnPos[ nPos ];
pBaseHash->pnPos[ nPos ] = nTemp;
--nPos;
}
}
}
else
{
for( ulFrom = 1; ulFrom < pBaseHash->ulLen; ++ulFrom )
for( nFrom = 1; nFrom < pBaseHash->nLen; ++nFrom )
{
ulPos = ulFrom;
while( ulPos > 0 && hb_hashItemCmp( &pBaseHash->pPairs[ ulPos - 1 ].key,
&pBaseHash->pPairs[ ulPos ].key,
iFlags ) > 0 )
nPos = nFrom;
while( nPos > 0 && hb_hashItemCmp( &pBaseHash->pPairs[ nPos - 1 ].key,
&pBaseHash->pPairs[ nPos ].key,
iFlags ) > 0 )
{
HB_HASHPAIR pair;
memcpy( &pair, pBaseHash->pPairs + ulPos - 1, sizeof( HB_HASHPAIR ) );
memcpy( pBaseHash->pPairs + ulPos - 1, pBaseHash->pPairs + ulPos, sizeof( HB_HASHPAIR ) );
memcpy( pBaseHash->pPairs + ulPos, &pair, sizeof( HB_HASHPAIR ) );
--ulPos;
memcpy( &pair, pBaseHash->pPairs + nPos - 1, sizeof( HB_HASHPAIR ) );
memcpy( pBaseHash->pPairs + nPos - 1, pBaseHash->pPairs + nPos, sizeof( HB_HASHPAIR ) );
memcpy( pBaseHash->pPairs + nPos, &pair, sizeof( HB_HASHPAIR ) );
--nPos;
}
}
}
@@ -257,86 +257,86 @@ static void hb_hashResort( PHB_BASEHASH pBaseHash )
pBaseHash->iFlags &= ~HB_HASH_RESORT;
}
static HB_BOOL hb_hashFind( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, HB_SIZE * pulPos )
static HB_BOOL hb_hashFind( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, HB_SIZE * pnPos )
{
HB_SIZE ulLeft, ulRight, ulMiddle;
HB_SIZE nLeft, nRight, nMiddle;
int iFlags = pBaseHash->iFlags;
int i;
if( iFlags & HB_HASH_RESORT )
hb_hashResort( pBaseHash );
ulLeft = 0;
ulRight = pBaseHash->ulLen;
nLeft = 0;
nRight = pBaseHash->nLen;
while( ulLeft < ulRight )
while( nLeft < nRight )
{
ulMiddle = ( ulLeft + ulRight ) >> 1;
i = hb_hashItemCmp( &pBaseHash->pPairs[ pBaseHash->pulPos ?
pBaseHash->pulPos[ ulMiddle ] : ulMiddle ].key,
nMiddle = ( nLeft + nRight ) >> 1;
i = hb_hashItemCmp( &pBaseHash->pPairs[ pBaseHash->pnPos ?
pBaseHash->pnPos[ nMiddle ] : nMiddle ].key,
pKey, iFlags );
if( i == 0 )
{
if( pulPos )
*pulPos = pBaseHash->pulPos ? pBaseHash->pulPos[ ulMiddle ] : ulMiddle;
if( pnPos )
*pnPos = pBaseHash->pnPos ? pBaseHash->pnPos[ nMiddle ] : nMiddle;
return HB_TRUE;
}
else if( i < 0 )
ulLeft = ulMiddle + 1;
nLeft = nMiddle + 1;
else
ulRight = ulMiddle;
nRight = nMiddle;
}
if( pulPos )
*pulPos = ulLeft;
if( pnPos )
*pnPos = nLeft;
return HB_FALSE;
}
static void hb_hashResize( PHB_BASEHASH pBaseHash, HB_SIZE ulNewSize )
static void hb_hashResize( PHB_BASEHASH pBaseHash, HB_SIZE nNewSize )
{
if( pBaseHash->ulSize < ulNewSize )
if( pBaseHash->nSize < nNewSize )
{
if( pBaseHash->ulSize )
if( pBaseHash->nSize )
{
pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
ulNewSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pulPos )
pBaseHash->pulPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pulPos,
ulNewSize * sizeof( HB_SIZE ) );
nNewSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pnPos )
pBaseHash->pnPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pnPos,
nNewSize * sizeof( HB_SIZE ) );
}
else
{
pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xgrab( ulNewSize * sizeof( HB_HASHPAIR ) );
pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xgrab( nNewSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->iFlags & HB_HASH_KEEPORDER )
pBaseHash->pulPos = ( HB_SIZE * ) hb_xgrab( ulNewSize * sizeof( HB_SIZE ) );
pBaseHash->pnPos = ( HB_SIZE * ) hb_xgrab( nNewSize * sizeof( HB_SIZE ) );
}
do
{
pBaseHash->pPairs[ pBaseHash->ulSize ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ pBaseHash->ulSize ].value.type = HB_IT_NIL;
pBaseHash->pPairs[ pBaseHash->nSize ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ pBaseHash->nSize ].value.type = HB_IT_NIL;
}
while( ++pBaseHash->ulSize < ulNewSize );
while( ++pBaseHash->nSize < nNewSize );
}
else if( pBaseHash->ulSize > ulNewSize && pBaseHash->ulLen <= ulNewSize )
else if( pBaseHash->nSize > nNewSize && pBaseHash->nLen <= nNewSize )
{
pBaseHash->ulSize = ulNewSize;
if( ulNewSize )
pBaseHash->nSize = nNewSize;
if( nNewSize )
{
pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
ulNewSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pulPos )
pBaseHash->pulPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pulPos,
ulNewSize * sizeof( HB_SIZE ) );
nNewSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pnPos )
pBaseHash->pnPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pnPos,
nNewSize * sizeof( HB_SIZE ) );
}
else
{
hb_xfree( pBaseHash->pPairs );
pBaseHash->pPairs = NULL;
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
hb_xfree( pBaseHash->pulPos );
pBaseHash->pulPos = NULL;
hb_xfree( pBaseHash->pnPos );
pBaseHash->pnPos = NULL;
}
}
}
@@ -344,64 +344,64 @@ static void hb_hashResize( PHB_BASEHASH pBaseHash, HB_SIZE ulNewSize )
static PHB_ITEM hb_hashValuePtr( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, HB_BOOL fAdd )
{
HB_SIZE ulPos;
HB_SIZE nPos;
if( !hb_hashFind( pBaseHash, pKey, &ulPos ) )
if( !hb_hashFind( pBaseHash, pKey, &nPos ) )
{
if( !fAdd )
return NULL;
if( pBaseHash->ulSize == pBaseHash->ulLen )
hb_hashResize( pBaseHash, pBaseHash->ulSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->nSize == pBaseHash->nLen )
hb_hashResize( pBaseHash, pBaseHash->nSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
memmove( pBaseHash->pulPos + ulPos + 1, pBaseHash->pulPos + ulPos,
( pBaseHash->ulLen - ulPos ) * sizeof( HB_SIZE ) );
ulPos = ( pBaseHash->pulPos[ ulPos ] = pBaseHash->ulLen );
memmove( pBaseHash->pnPos + nPos + 1, pBaseHash->pnPos + nPos,
( pBaseHash->nLen - nPos ) * sizeof( HB_SIZE ) );
nPos = ( pBaseHash->pnPos[ nPos ] = pBaseHash->nLen );
}
else if( ulPos < pBaseHash->ulLen )
else if( nPos < pBaseHash->nLen )
{
memmove( pBaseHash->pPairs + ulPos + 1, pBaseHash->pPairs + ulPos,
( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
pBaseHash->pPairs[ ulPos ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ ulPos ].value.type = HB_IT_NIL;
memmove( pBaseHash->pPairs + nPos + 1, pBaseHash->pPairs + nPos,
( pBaseHash->nLen - nPos ) * sizeof( HB_HASHPAIR ) );
pBaseHash->pPairs[ nPos ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ nPos ].value.type = HB_IT_NIL;
}
hb_itemCopy( &pBaseHash->pPairs[ ulPos ].key, pKey );
pBaseHash->ulLen++;
hb_itemCopy( &pBaseHash->pPairs[ nPos ].key, pKey );
pBaseHash->nLen++;
if( pBaseHash->pDefault )
hb_itemCloneTo( &pBaseHash->pPairs[ ulPos ].value, pBaseHash->pDefault );
hb_itemCloneTo( &pBaseHash->pPairs[ nPos ].value, pBaseHash->pDefault );
}
return &pBaseHash->pPairs[ ulPos ].value;
return &pBaseHash->pPairs[ nPos ].value;
}
static HB_BOOL hb_hashNewValue( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, PHB_ITEM pValue )
{
HB_SIZE ulPos;
HB_SIZE nPos;
if( !hb_hashFind( pBaseHash, pKey, &ulPos ) )
if( !hb_hashFind( pBaseHash, pKey, &nPos ) )
{
if( pBaseHash->ulSize == pBaseHash->ulLen )
hb_hashResize( pBaseHash, pBaseHash->ulSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->nSize == pBaseHash->nLen )
hb_hashResize( pBaseHash, pBaseHash->nSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
memmove( pBaseHash->pulPos + ulPos + 1, pBaseHash->pulPos + ulPos,
( pBaseHash->ulLen - ulPos ) * sizeof( HB_SIZE ) );
ulPos = ( pBaseHash->pulPos[ ulPos ] = pBaseHash->ulLen );
memmove( pBaseHash->pnPos + nPos + 1, pBaseHash->pnPos + nPos,
( pBaseHash->nLen - nPos ) * sizeof( HB_SIZE ) );
nPos = ( pBaseHash->pnPos[ nPos ] = pBaseHash->nLen );
}
else if( ulPos < pBaseHash->ulLen )
else if( nPos < pBaseHash->nLen )
{
memmove( pBaseHash->pPairs + ulPos + 1, pBaseHash->pPairs + ulPos,
( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
pBaseHash->pPairs[ ulPos ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ ulPos ].value.type = HB_IT_NIL;
memmove( pBaseHash->pPairs + nPos + 1, pBaseHash->pPairs + nPos,
( pBaseHash->nLen - nPos ) * sizeof( HB_HASHPAIR ) );
pBaseHash->pPairs[ nPos ].key.type = HB_IT_NIL;
pBaseHash->pPairs[ nPos ].value.type = HB_IT_NIL;
}
hb_itemCopy( &pBaseHash->pPairs[ ulPos ].key, pKey );
hb_itemCopyFromRef( &pBaseHash->pPairs[ ulPos ].value, pValue );
pBaseHash->ulLen++;
hb_itemCopy( &pBaseHash->pPairs[ nPos ].key, pKey );
hb_itemCopyFromRef( &pBaseHash->pPairs[ nPos ].value, pValue );
pBaseHash->nLen++;
return HB_TRUE;
}
@@ -411,29 +411,29 @@ static HB_BOOL hb_hashNewValue( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, PHB_ITEM
static void hb_hashNewPair( PHB_BASEHASH pBaseHash, PHB_ITEM * pKeyPtr, PHB_ITEM * pValPtr )
{
if( pBaseHash->ulSize == pBaseHash->ulLen )
hb_hashResize( pBaseHash, pBaseHash->ulSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->nSize == pBaseHash->nLen )
hb_hashResize( pBaseHash, pBaseHash->nSize + HB_HASH_ITEM_ALLOC );
if( pBaseHash->pulPos )
pBaseHash->pulPos[ pBaseHash->ulLen ] = pBaseHash->ulLen;
if( pBaseHash->pnPos )
pBaseHash->pnPos[ pBaseHash->nLen ] = pBaseHash->nLen;
* pKeyPtr = &pBaseHash->pPairs[ pBaseHash->ulLen ].key;
* pValPtr = &pBaseHash->pPairs[ pBaseHash->ulLen ].value;
* pKeyPtr = &pBaseHash->pPairs[ pBaseHash->nLen ].key;
* pValPtr = &pBaseHash->pPairs[ pBaseHash->nLen ].value;
pBaseHash->ulLen++;
pBaseHash->nLen++;
}
static void hb_hashDelPair( PHB_BASEHASH pBaseHash, HB_SIZE ulPos )
static void hb_hashDelPair( PHB_BASEHASH pBaseHash, HB_SIZE nPos )
{
if( --pBaseHash->ulLen == 0 )
if( --pBaseHash->nLen == 0 )
{
PHB_HASHPAIR pPairs = pBaseHash->pPairs;
pBaseHash->pPairs = NULL;
pBaseHash->ulSize = 0;
if( pBaseHash->pulPos )
pBaseHash->nSize = 0;
if( pBaseHash->pnPos )
{
hb_xfree( pBaseHash->pulPos );
pBaseHash->pulPos = NULL;
hb_xfree( pBaseHash->pnPos );
pBaseHash->pnPos = NULL;
}
if( HB_IS_COMPLEX( &pPairs->key ) )
hb_itemClear( &pPairs->key );
@@ -443,41 +443,41 @@ static void hb_hashDelPair( PHB_BASEHASH pBaseHash, HB_SIZE ulPos )
}
else
{
if( pBaseHash->pulPos )
if( pBaseHash->pnPos )
{
HB_SIZE ul = 0;
while( ul < pBaseHash->ulLen )
HB_SIZE n = 0;
while( n < pBaseHash->nLen )
{
if( pBaseHash->pulPos[ ul ] > ulPos )
pBaseHash->pulPos[ ul++ ]--;
else if( pBaseHash->pulPos[ ul ] == ulPos )
memmove( &pBaseHash->pulPos[ ul ], &pBaseHash->pulPos[ ul + 1 ],
( pBaseHash->ulLen - ul ) * sizeof( HB_SIZE ) );
if( pBaseHash->pnPos[ n ] > nPos )
pBaseHash->pnPos[ n++ ]--;
else if( pBaseHash->pnPos[ n ] == nPos )
memmove( &pBaseHash->pnPos[ n ], &pBaseHash->pnPos[ n + 1 ],
( pBaseHash->nLen - n ) * sizeof( HB_SIZE ) );
else
++ul;
++n;
}
}
if( ulPos != pBaseHash->ulLen )
if( nPos != pBaseHash->nLen )
{
HB_HASHPAIR pair;
memcpy( &pair, pBaseHash->pPairs + ulPos, sizeof( HB_HASHPAIR ) );
memmove( pBaseHash->pPairs + ulPos, pBaseHash->pPairs + ulPos + 1,
( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
ulPos = pBaseHash->ulLen;
memcpy( pBaseHash->pPairs + ulPos, &pair, sizeof( HB_HASHPAIR ) );
memcpy( &pair, pBaseHash->pPairs + nPos, sizeof( HB_HASHPAIR ) );
memmove( pBaseHash->pPairs + nPos, pBaseHash->pPairs + nPos + 1,
( pBaseHash->nLen - nPos ) * sizeof( HB_HASHPAIR ) );
nPos = pBaseHash->nLen;
memcpy( pBaseHash->pPairs + nPos, &pair, sizeof( HB_HASHPAIR ) );
}
hb_itemSetNil( &pBaseHash->pPairs[ ulPos ].key );
hb_itemSetNil( &pBaseHash->pPairs[ ulPos ].value );
if( pBaseHash->ulSize - pBaseHash->ulLen > ( HB_HASH_ITEM_ALLOC << 1 ) )
hb_itemSetNil( &pBaseHash->pPairs[ nPos ].key );
hb_itemSetNil( &pBaseHash->pPairs[ nPos ].value );
if( pBaseHash->nSize - pBaseHash->nLen > ( HB_HASH_ITEM_ALLOC << 1 ) )
{
pBaseHash->ulSize -= HB_HASH_ITEM_ALLOC;
pBaseHash->nSize -= HB_HASH_ITEM_ALLOC;
pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
pBaseHash->ulSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pulPos )
pBaseHash->pulPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pulPos,
pBaseHash->ulSize * sizeof( HB_SIZE ) );
pBaseHash->nSize * sizeof( HB_HASHPAIR ) );
if( pBaseHash->pnPos )
pBaseHash->pnPos = ( HB_SIZE * ) hb_xrealloc( pBaseHash->pnPos,
pBaseHash->nSize * sizeof( HB_SIZE ) );
}
}
}
@@ -495,9 +495,9 @@ PHB_ITEM hb_hashNew( PHB_ITEM pItem )
pBaseHash = ( PHB_BASEHASH ) hb_gcAllocRaw( sizeof( HB_BASEHASH ), &s_gcHashFuncs );
pBaseHash->pPairs = NULL;
pBaseHash->pulPos = NULL;
pBaseHash->ulSize = 0;
pBaseHash->ulLen = 0;
pBaseHash->pnPos = NULL;
pBaseHash->nSize = 0;
pBaseHash->nLen = 0;
pBaseHash->iFlags = HB_HASH_FLAG_DEFAULT;
pBaseHash->pDefault = NULL;
@@ -512,17 +512,17 @@ HB_SIZE hb_hashLen( PHB_ITEM pHash )
HB_TRACE(HB_TR_DEBUG, ("hb_hashLen(%p)", pHash));
if( HB_IS_HASH( pHash ) )
return pHash->item.asHash.value->ulLen;
return pHash->item.asHash.value->nLen;
else
return 0;
}
void hb_hashPreallocate( PHB_ITEM pHash, HB_SIZE ulNewSize )
void hb_hashPreallocate( PHB_ITEM pHash, HB_SIZE nNewSize )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashPreallocate(%p,%" HB_PFS "u)", pHash, ulNewSize));
HB_TRACE(HB_TR_DEBUG, ("hb_hashPreallocate(%p,%" HB_PFS "u)", pHash, nNewSize));
if( HB_IS_HASH( pHash ) )
hb_hashResize( pHash->item.asHash.value, ulNewSize );
hb_hashResize( pHash->item.asHash.value, nNewSize );
}
HB_BOOL hb_hashAllocNewPair( PHB_ITEM pHash, PHB_ITEM * pKeyPtr, PHB_ITEM * pValPtr )
@@ -586,7 +586,7 @@ PHB_ITEM hb_hashGetCItemPtr( PHB_ITEM pHash, const char * pszKey )
HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey )
{
HB_SIZE ulPos = 0;
HB_SIZE nPos = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_hashGetCItemPos(%p,%s)", pHash, pszKey));
@@ -598,14 +598,14 @@ HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey )
*/
PHB_ITEM pKey = hb_itemPutCConst( hb_stackAllocItem(), pszKey );
if( hb_hashFind( pHash->item.asHash.value, pKey, &ulPos ) )
ulPos++;
if( hb_hashFind( pHash->item.asHash.value, pKey, &nPos ) )
nPos++;
else
ulPos = 0;
nPos = 0;
hb_stackPop();
}
return ulPos;
return nPos;
}
PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey )
@@ -628,27 +628,27 @@ PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey )
return NULL;
}
HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pulPos )
HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pnPos )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashScan(%p,%p,%p)", pHash, pKey, pulPos));
HB_TRACE(HB_TR_DEBUG, ("hb_hashScan(%p,%p,%p)", pHash, pKey, pnPos));
if( HB_IS_HASH( pHash ) )
{
HB_SIZE ulPos;
HB_SIZE nPos;
if( HB_IS_HASHKEY( pKey ) )
{
if( hb_hashFind( pHash->item.asHash.value, pKey, &ulPos ) )
if( hb_hashFind( pHash->item.asHash.value, pKey, &nPos ) )
{
if( pulPos )
*pulPos = ulPos + 1;
if( pnPos )
*pnPos = nPos + 1;
return HB_TRUE;
}
}
else if( HB_IS_HASH( pKey ) && pKey->item.asHash.value->ulLen == 1 )
else if( HB_IS_HASH( pKey ) && pKey->item.asHash.value->nLen == 1 )
{
if( hb_hashFind( pHash->item.asHash.value, &pKey->item.asHash.value->pPairs[ 0 ].key, &ulPos ) )
if( hb_hashFind( pHash->item.asHash.value, &pKey->item.asHash.value->pPairs[ 0 ].key, &nPos ) )
{
PHB_ITEM pVal1 = &pHash->item.asHash.value->pPairs[ ulPos ].value;
PHB_ITEM pVal1 = &pHash->item.asHash.value->pPairs[ nPos ].value;
PHB_ITEM pVal2 = &pKey->item.asHash.value->pPairs[ 0 ].value;
HB_BOOL fResult = HB_FALSE;
if( HB_IS_STRING( pVal1 ) && HB_IS_STRING( pVal2 ) )
@@ -672,15 +672,15 @@ HB_BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, HB_SIZE * pulPos )
}
if( fResult )
{
if( pulPos )
*pulPos = ulPos + 1;
if( pnPos )
*pnPos = nPos + 1;
return HB_TRUE;
}
}
}
}
if( pulPos )
*pulPos = 0;
if( pnPos )
*pnPos = 0;
return HB_FALSE;
}
@@ -690,29 +690,29 @@ static HB_BOOL hb_hashClear( PHB_ITEM pHash )
if( HB_IS_HASH( pHash ) )
{
if( pHash->item.asHash.value->ulSize )
if( pHash->item.asHash.value->nSize )
{
while( pHash->item.asHash.value->ulLen )
while( pHash->item.asHash.value->nLen )
{
pHash->item.asHash.value->ulLen--;
if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].key ) )
hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].key );
if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].value ) )
hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].value );
pHash->item.asHash.value->nLen--;
if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->nLen ].key ) )
hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->nLen ].key );
if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->nLen ].value ) )
hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->nLen ].value );
}
/*
* This condition is a protection against recursive call
* from .prg object destructor [druzus]
*/
if( pHash->item.asHash.value->ulSize )
if( pHash->item.asHash.value->nSize )
{
hb_xfree( pHash->item.asHash.value->pPairs );
pHash->item.asHash.value->pPairs = NULL;
pHash->item.asHash.value->ulSize = 0;
if( pHash->item.asHash.value->pulPos )
pHash->item.asHash.value->nSize = 0;
if( pHash->item.asHash.value->pnPos )
{
hb_xfree( pHash->item.asHash.value->pulPos );
pHash->item.asHash.value->pulPos = NULL;
hb_xfree( pHash->item.asHash.value->pnPos );
pHash->item.asHash.value->pnPos = NULL;
}
}
}
@@ -729,11 +729,11 @@ HB_BOOL hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey )
if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
{
PHB_BASEHASH pBaseHash = pHash->item.asHash.value;
HB_SIZE ulPos;
HB_SIZE nPos;
if( hb_hashFind( pBaseHash, pKey, &ulPos ) )
if( hb_hashFind( pBaseHash, pKey, &nPos ) )
{
hb_hashDelPair( pBaseHash, ulPos );
hb_hashDelPair( pBaseHash, nPos );
return HB_TRUE;
}
}
@@ -754,9 +754,9 @@ HB_BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem )
}
else if( HB_IS_ARRAY( pItem ) )
{
HB_SIZE ul = 0;
HB_SIZE n = 0;
PHB_ITEM pKey;
while( ( pKey = hb_arrayGetItemPtr( pItem, ++ul ) ) != NULL )
while( ( pKey = hb_arrayGetItemPtr( pItem, ++n ) ) != NULL )
hb_hashDel( pHash, pKey );
return HB_TRUE;
}
@@ -766,9 +766,9 @@ HB_BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem )
hb_hashClear( pHash );
else
{
HB_SIZE ulLen = 0;
while( ulLen < pItem->item.asHash.value->ulLen )
hb_hashDel( pHash, &pItem->item.asHash.value->pPairs[ ulLen++ ].key );
HB_SIZE nLen = 0;
while( nLen < pItem->item.asHash.value->nLen )
hb_hashDel( pHash, &pItem->item.asHash.value->pPairs[ nLen++ ].key );
}
return HB_TRUE;
}
@@ -808,36 +808,36 @@ HB_BOOL hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue )
return HB_FALSE;
}
PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, HB_SIZE ulPos )
PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, HB_SIZE nPos )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashGetKeyAt(%p,%" HB_PFS "u)", pHash, ulPos));
HB_TRACE(HB_TR_DEBUG, ("hb_hashGetKeyAt(%p,%" HB_PFS "u)", pHash, nPos));
if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
return &pHash->item.asHash.value->pPairs[ ulPos - 1 ].key;
if( HB_IS_HASH( pHash ) && nPos > 0 && nPos <= pHash->item.asHash.value->nLen )
return &pHash->item.asHash.value->pPairs[ nPos - 1 ].key;
else
return NULL;
}
PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE ulPos )
PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE nPos )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashGetValueAt(%p,%" HB_PFS "u)", pHash, ulPos));
HB_TRACE(HB_TR_DEBUG, ("hb_hashGetValueAt(%p,%" HB_PFS "u)", pHash, nPos));
if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
if( HB_IS_HASH( pHash ) && nPos > 0 && nPos <= pHash->item.asHash.value->nLen )
{
PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value;
PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ nPos - 1 ].value;
return HB_IS_BYREF( pValue ) ? hb_itemUnRef( pValue ) : pValue;
}
else
return NULL;
}
HB_BOOL hb_hashDelAt( PHB_ITEM pHash, HB_SIZE ulPos )
HB_BOOL hb_hashDelAt( PHB_ITEM pHash, HB_SIZE nPos )
{
HB_TRACE(HB_TR_DEBUG, ("hb_hashDelAt(%p,%" HB_PFS "u)", pHash, ulPos));
HB_TRACE(HB_TR_DEBUG, ("hb_hashDelAt(%p,%" HB_PFS "u)", pHash, nPos));
if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
if( HB_IS_HASH( pHash ) && nPos > 0 && nPos <= pHash->item.asHash.value->nLen )
{
hb_hashDelPair( pHash->item.asHash.value, ulPos - 1 );
hb_hashDelPair( pHash->item.asHash.value, nPos - 1 );
return HB_TRUE;
}
else
@@ -857,32 +857,32 @@ void * hb_hashId( PHB_ITEM pHash )
void hb_hashCloneBody( PHB_ITEM pHash, PHB_ITEM pDest, PHB_NESTED_CLONED pClonedList )
{
HB_SIZE ulPos;
HB_SIZE nPos;
HB_TRACE(HB_TR_DEBUG, ("hb_hashCloneBody(%p,%p,%p)", pHash, pDest, pClonedList));
hb_hashNew( pDest );
pDest->item.asHash.value->iFlags = pHash->item.asHash.value->iFlags;
hb_hashResize( pDest->item.asHash.value, pHash->item.asHash.value->ulLen );
hb_hashResize( pDest->item.asHash.value, pHash->item.asHash.value->nLen );
if( pHash->item.asHash.value->pDefault )
{
pDest->item.asHash.value->pDefault =
hb_itemNew( pHash->item.asHash.value->pDefault );
hb_gcUnlock( pDest->item.asHash.value->pDefault );
}
if( pHash->item.asHash.value->pulPos )
memcpy( pDest->item.asHash.value->pulPos,
pHash->item.asHash.value->pulPos,
pHash->item.asHash.value->ulLen * sizeof( HB_SIZE ) );
for( ulPos = 0; ulPos < pHash->item.asHash.value->ulLen; ++ulPos )
if( pHash->item.asHash.value->pnPos )
memcpy( pDest->item.asHash.value->pnPos,
pHash->item.asHash.value->pnPos,
pHash->item.asHash.value->nLen * sizeof( HB_SIZE ) );
for( nPos = 0; nPos < pHash->item.asHash.value->nLen; ++nPos )
{
PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ ulPos ].value;
PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ nPos ].value;
if( HB_IS_BYREF( pValue ) )
pValue = hb_itemUnRef( pValue );
hb_itemCopy( &pDest->item.asHash.value->pPairs[ ulPos ].key,
&pHash->item.asHash.value->pPairs[ ulPos ].key );
pDest->item.asHash.value->ulLen++;
hb_cloneNested( &pDest->item.asHash.value->pPairs[ ulPos ].value, pValue, pClonedList );
hb_itemCopy( &pDest->item.asHash.value->pPairs[ nPos ].key,
&pHash->item.asHash.value->pPairs[ nPos ].key );
pDest->item.asHash.value->nLen++;
hb_cloneNested( &pDest->item.asHash.value->pPairs[ nPos ].value, pValue, pClonedList );
}
}
@@ -927,41 +927,41 @@ void hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType )
if( HB_IS_HASH( pDest ) && HB_IS_HASH( pSource ) )
{
PHB_BASEHASH pBaseHash;
HB_SIZE ulPos;
HB_SIZE nPos;
switch( iType )
{
case HB_HASH_UNION: /* OR */
pBaseHash = pSource->item.asHash.value;
for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
for( nPos = 0; nPos < pBaseHash->nLen; ++nPos )
{
PHB_ITEM pVal = &pBaseHash->pPairs[ ulPos ].value;
PHB_ITEM pVal = &pBaseHash->pPairs[ nPos ].value;
if( HB_IS_BYREF( pVal ) )
pVal = hb_itemUnRef( pVal );
hb_hashAdd( pDest, &pBaseHash->pPairs[ ulPos ].key, pVal );
hb_hashAdd( pDest, &pBaseHash->pPairs[ nPos ].key, pVal );
}
break;
case HB_HASH_INTERSECT: /* AND */
pBaseHash = pDest->item.asHash.value;
for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
for( nPos = 0; nPos < pBaseHash->nLen; ++nPos )
{
if( !hb_hashFind( pSource->item.asHash.value,
&pBaseHash->pPairs[ ulPos ].key, NULL ) )
hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key );
&pBaseHash->pPairs[ nPos ].key, NULL ) )
hb_hashDel( pDest, &pBaseHash->pPairs[ nPos ].key );
}
break;
case HB_HASH_DIFFERENCE: /* XOR */
pBaseHash = pSource->item.asHash.value;
for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
for( nPos = 0; nPos < pBaseHash->nLen; ++nPos )
{
if( !hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key ) )
if( !hb_hashDel( pDest, &pBaseHash->pPairs[ nPos ].key ) )
{
PHB_ITEM pVal = &pBaseHash->pPairs[ ulPos ].value;
PHB_ITEM pVal = &pBaseHash->pPairs[ nPos ].value;
if( HB_IS_BYREF( pVal ) )
pVal = hb_itemUnRef( pVal );
hb_hashAdd( pDest, &pBaseHash->pPairs[ ulPos ].key, pVal );
hb_hashAdd( pDest, &pBaseHash->pPairs[ nPos ].key, pVal );
}
}
break;
@@ -972,8 +972,8 @@ void hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType )
hb_hashClear( pDest );
else
{
for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key );
for( nPos = 0; nPos < pBaseHash->nLen; ++nPos )
hb_hashDel( pDest, &pBaseHash->pPairs[ nPos ].key );
}
break;
}
@@ -987,11 +987,11 @@ PHB_ITEM hb_hashGetKeys( PHB_ITEM pHash )
if( HB_IS_HASH( pHash ) )
{
PHB_ITEM pKeys = hb_itemArrayNew( hb_hashLen( pHash ) ), pKey;
HB_SIZE ulPos = 0;
HB_SIZE nPos = 0;
while( ( pKey = hb_hashGetKeyAt( pHash, ++ulPos ) ) != NULL )
while( ( pKey = hb_hashGetKeyAt( pHash, ++nPos ) ) != NULL )
{
PHB_ITEM pDest = hb_arrayGetItemPtr( pKeys, ulPos );
PHB_ITEM pDest = hb_arrayGetItemPtr( pKeys, nPos );
if( !pDest )
break;
hb_itemCopy( pDest, pKey );
@@ -1009,11 +1009,11 @@ PHB_ITEM hb_hashGetValues( PHB_ITEM pHash )
if( HB_IS_HASH( pHash ) )
{
PHB_ITEM pValues = hb_itemArrayNew( hb_hashLen( pHash ) ), pVal;
HB_SIZE ulPos = 0;
HB_SIZE nPos = 0;
while( ( pVal = hb_hashGetValueAt( pHash, ++ulPos ) ) != NULL )
while( ( pVal = hb_hashGetValueAt( pHash, ++nPos ) ) != NULL )
{
PHB_ITEM pDest = hb_arrayGetItemPtr( pValues, ulPos );
PHB_ITEM pDest = hb_arrayGetItemPtr( pValues, nPos );
if( !pDest )
break;
hb_itemCopy( pDest, pVal );
@@ -1062,20 +1062,20 @@ void hb_hashSetFlags( PHB_ITEM pHash, int iFlags )
if( HB_IS_HASH( pHash ) )
{
pHash->item.asHash.value->iFlags |= iFlags;
if( pHash->item.asHash.value->pulPos == NULL &&
pHash->item.asHash.value->ulSize &&
if( pHash->item.asHash.value->pnPos == NULL &&
pHash->item.asHash.value->nSize &&
( pHash->item.asHash.value->iFlags & HB_HASH_KEEPORDER ) != 0 )
{
HB_SIZE ul = pHash->item.asHash.value->ulSize;
HB_SIZE n = pHash->item.asHash.value->nSize;
pHash->item.asHash.value->pulPos = ( HB_SIZE * )
hb_xgrab( pHash->item.asHash.value->ulSize * sizeof( HB_SIZE ) );
pHash->item.asHash.value->pnPos = ( HB_SIZE * )
hb_xgrab( pHash->item.asHash.value->nSize * sizeof( HB_SIZE ) );
do
{
--ul;
pHash->item.asHash.value->pulPos[ ul ] = ul;
--n;
pHash->item.asHash.value->pnPos[ n ] = n;
}
while( ul );
while( n );
}
}
}
@@ -1087,11 +1087,11 @@ void hb_hashClearFlags( PHB_ITEM pHash, int iFlags )
if( HB_IS_HASH( pHash ) )
{
pHash->item.asHash.value->iFlags &= ~iFlags;
if( pHash->item.asHash.value->pulPos != NULL &&
if( pHash->item.asHash.value->pnPos != NULL &&
( pHash->item.asHash.value->iFlags & HB_HASH_KEEPORDER ) == 0 )
{
hb_xfree( pHash->item.asHash.value->pulPos );
pHash->item.asHash.value->pulPos = NULL;
hb_xfree( pHash->item.asHash.value->pnPos );
pHash->item.asHash.value->pnPos = NULL;
}
}
}

View File

@@ -101,9 +101,9 @@ HB_FUNC( HB_HPOS )
if( pHash && pKey )
{
HB_SIZE ulPos;
hb_hashScan( pHash, pKey, &ulPos );
hb_retns( ulPos );
HB_SIZE nPos;
hb_hashScan( pHash, pKey, &nPos );
hb_retns( nPos );
}
else
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
@@ -297,9 +297,9 @@ HB_FUNC( HB_HFILL )
if( pHash && pValue )
{
PHB_ITEM pDest;
HB_SIZE ulPos = 0;
HB_SIZE nPos = 0;
while( ( pDest = hb_hashGetValueAt( pHash, ++ulPos ) ) != NULL )
while( ( pDest = hb_hashGetValueAt( pHash, ++nPos ) ) != NULL )
hb_itemCopy( pDest, pValue );
hb_itemReturn( pHash );
@@ -325,22 +325,22 @@ HB_FUNC( HB_HCOPY )
if( pSource && pDest )
{
HB_SIZE ulLen = hb_hashLen( pSource ), ulStart, ulCount;
HB_SIZE nLen = hb_hashLen( pSource ), nStart, nCount;
ulStart = hb_parns( 3 );
if( !ulStart )
++ulStart;
ulCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : ulLen - ulStart + 1;
nStart = hb_parns( 3 );
if( !nStart )
++nStart;
nCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : nLen - nStart + 1;
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, ulStart );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, ulStart );
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nStart );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nStart );
if( pKey && pValue )
hb_hashAdd( pDest, pKey, pValue );
else
break;
++ulStart;
++nStart;
}
hb_itemReturn( pDest );
@@ -359,18 +359,18 @@ HB_FUNC( HB_HMERGE )
{
if( pAction && HB_IS_BLOCK( pAction ) )
{
HB_SIZE ulLen = hb_hashLen( pSource ), ulPos = 0;
while( ++ulPos <= ulLen )
HB_SIZE nLen = hb_hashLen( pSource ), nPos = 0;
while( ++nPos <= nLen )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, ulPos );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, ulPos );
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nPos );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nPos );
if( pKey && pValue )
{
hb_vmPushEvalSym();
hb_vmPush( pAction );
hb_vmPush( pKey );
hb_vmPush( pValue );
hb_vmPushSize( ulPos );
hb_vmPushSize( nPos );
hb_vmSend( 3 );
{
PHB_ITEM pReturn = hb_stackReturnItem();
@@ -398,29 +398,29 @@ HB_FUNC( HB_HEVAL )
if( pHash && pBlock )
{
HB_SIZE ulLen = hb_hashLen( pHash ), ulStart, ulCount;
HB_SIZE nLen = hb_hashLen( pHash ), nStart, nCount;
ulStart = hb_parns( 3 );
if( !ulStart )
++ulStart;
ulCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : ulLen - ulStart + 1;
nStart = hb_parns( 3 );
if( !nStart )
++nStart;
nCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : nLen - nStart + 1;
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pHash, ulStart );
PHB_ITEM pValue = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pKey = hb_hashGetKeyAt( pHash, nStart );
PHB_ITEM pValue = hb_hashGetValueAt( pHash, nStart );
if( pKey && pValue )
{
hb_vmPushEvalSym();
hb_vmPush( pBlock );
hb_vmPush( pKey );
hb_vmPush( pValue );
hb_vmPushSize( ulStart );
hb_vmPushSize( nStart );
hb_vmSend( 3 );
}
else
break;
++ulStart;
++nStart;
}
hb_itemReturn( pHash );
@@ -437,26 +437,26 @@ HB_FUNC( HB_HSCAN )
if( pHash && pValue )
{
HB_BOOL fExact = hb_parl( 5 ), fFound = HB_FALSE;
HB_SIZE ulLen = hb_hashLen( pHash ), ulStart, ulCount;
HB_SIZE nLen = hb_hashLen( pHash ), nStart, nCount;
ulStart = hb_parns( 3 );
if( !ulStart )
++ulStart;
ulCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : ulLen - ulStart + 1;
nStart = hb_parns( 3 );
if( !nStart )
++nStart;
nCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : nLen - nStart + 1;
if( HB_IS_BLOCK( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pHash, ulStart );
PHB_ITEM pVal = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pKey = hb_hashGetKeyAt( pHash, nStart );
PHB_ITEM pVal = hb_hashGetValueAt( pHash, nStart );
if( pKey && pValue )
{
hb_vmPushEvalSym();
hb_vmPush( pValue );
hb_vmPush( pKey );
hb_vmPush( pVal );
hb_vmPushSize( ulStart );
hb_vmPushSize( nStart );
hb_vmSend( 3 );
{
PHB_ITEM pReturn = hb_stackReturnItem();
@@ -469,14 +469,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_STRING( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
@@ -487,15 +487,15 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_NUMERIC( pValue ) )
{
double dValue = hb_itemGetND( pValue );
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
@@ -506,14 +506,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_DATETIME( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_DATETIME( pItem ) &&
@@ -526,15 +526,15 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_LOGICAL( pValue ) )
{
HB_BOOL fValue = hb_itemGetDL( pValue );
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == fValue )
@@ -545,14 +545,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_NIL( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_NIL( pItem ) )
@@ -563,14 +563,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( HB_IS_POINTER( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_POINTER( pItem ) &&
@@ -582,14 +582,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( fExact && HB_IS_ARRAY( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_ARRAY( pItem ) &&
@@ -601,14 +601,14 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
else if( fExact && HB_IS_HASH( pValue ) )
{
while( ulCount-- )
while( nCount-- )
{
PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
PHB_ITEM pItem = hb_hashGetValueAt( pHash, nStart );
if( pItem )
{
if( HB_IS_HASH( pItem ) &&
@@ -620,11 +620,11 @@ HB_FUNC( HB_HSCAN )
}
else
break;
++ulStart;
++nStart;
}
}
hb_retns( fFound ? ulStart : 0 );
hb_retns( fFound ? nStart : 0 );
}
else
hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );

View File

@@ -143,8 +143,8 @@ static void hb_vmArrayPush( void ); /* pushes an array element to the s
static void hb_vmArrayPushRef( void ); /* pushes a reference to an array element to the stack, removing the array and the index from the stack */
static void hb_vmArrayPop( void ); /* pops a value from the stack */
static void hb_vmArrayDim( HB_USHORT uiDimensions ); /* generates an uiDimensions Array and initialize those dimensions from the stack values */
static void hb_vmArrayGen( HB_SIZE ulElements ); /* generates an ulElements Array and fills it from the stack values */
static void hb_vmHashGen( HB_SIZE ulElements ); /* generates an ulElements Hash and fills it from the stack values */
static void hb_vmArrayGen( HB_SIZE nElements ); /* generates an nElements Array and fills it from the stack values */
static void hb_vmHashGen( HB_SIZE nElements ); /* generates an nElements Hash and fills it from the stack values */
/* macros */
static void hb_vmMacroDo( HB_USHORT uiArgSets ); /* execute function passing arguments set(s) on HVM stack func( &var ) */
@@ -170,9 +170,9 @@ static void hb_vmStaticsRelease( void ); /* release arrays with static va
static void hb_vmPushAlias( void ); /* pushes the current workarea number */
static void hb_vmPushAliasedField( PHB_SYMB ); /* pushes an aliased field on the eval stack */
static void hb_vmPushAliasedVar( PHB_SYMB ); /* pushes an aliased variable on the eval stack */
static void hb_vmPushBlock( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE ulLen ); /* creates a codeblock */
static void hb_vmPushBlockShort( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE ulLen ); /* creates a codeblock */
static void hb_vmPushMacroBlock( const HB_BYTE * pCode, HB_SIZE ulSize, HB_USHORT usParams ); /* creates a macro-compiled codeblock */
static void hb_vmPushBlock( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE nLen ); /* creates a codeblock */
static void hb_vmPushBlockShort( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE nLen ); /* creates a codeblock */
static void hb_vmPushMacroBlock( const HB_BYTE * pCode, HB_SIZE nSize, HB_USHORT usParams ); /* creates a macro-compiled codeblock */
static void hb_vmPushDoubleConst( double dNumber, int iWidth, int iDec ); /* Pushes a double constant (pcode) */
static void hb_vmPushLocal( int iLocal ); /* pushes the containts of a local onto the stack */
static void hb_vmPushLocalByRef( int iLocal ); /* pushes a local by refrence onto the stack */
@@ -2172,21 +2172,21 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
case HB_P_PUSHSTRLARGE:
{
HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
HB_SIZE nSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
if( bDynCode )
hb_vmPushString( ( const char * ) pCode + 4, ulSize - 1 );
hb_vmPushString( ( const char * ) pCode + 4, nSize - 1 );
else
hb_vmPushStringPcode( ( const char * ) pCode + 4, ulSize - 1 );
pCode += 4 + ulSize;
hb_vmPushStringPcode( ( const char * ) pCode + 4, nSize - 1 );
pCode += 4 + nSize;
break;
}
case HB_P_PUSHSTRHIDDEN:
{
HB_SIZE ulSize = ( HB_SIZE ) HB_PCODE_MKUSHORT( &pCode[ 2 ] );
char * szText = hb_compDecodeString( pCode[ 1 ], ( const char * ) pCode + 4, &ulSize );
hb_itemPutCLPtr( hb_stackAllocItem(), szText, ulSize );
pCode += ( 4 + ulSize );
HB_SIZE nSize = ( HB_SIZE ) HB_PCODE_MKUSHORT( &pCode[ 2 ] );
char * szText = hb_compDecodeString( pCode[ 1 ], ( const char * ) pCode + 4, &nSize );
hb_itemPutCLPtr( hb_stackAllocItem(), szText, nSize );
pCode += ( 4 + nSize );
break;
}
@@ -2222,9 +2222,9 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
* +5 +6 -> number of referenced local variables
* +7 -> start of table with referenced local variables
*/
HB_SIZE ulSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] );
hb_vmPushBlock( pCode + 3, pSymbols, bDynCode ? ulSize - 7 : 0 );
pCode += ulSize;
HB_SIZE nSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] );
hb_vmPushBlock( pCode + 3, pSymbols, bDynCode ? nSize - 7 : 0 );
pCode += nSize;
break;
}
case HB_P_PUSHBLOCKLARGE:
@@ -2235,9 +2235,9 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
* +6 +7 -> number of referenced local variables
* +8 -> start of table with referenced local variables
*/
HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
hb_vmPushBlock( pCode + 4, pSymbols, bDynCode ? ulSize - 8 : 0 );
pCode += ulSize;
HB_SIZE nSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
hb_vmPushBlock( pCode + 4, pSymbols, bDynCode ? nSize - 8 : 0 );
pCode += nSize;
break;
}
case HB_P_PUSHBLOCKSHORT:
@@ -2245,9 +2245,9 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
/* +0 -> _pushblock
* +1 -> size of codeblock
*/
HB_SIZE ulSize = pCode[ 1 ];
hb_vmPushBlockShort( pCode + 2, pSymbols, bDynCode ? ulSize - 2 : 0 );
pCode += ulSize;
HB_SIZE nSize = pCode[ 1 ];
hb_vmPushBlockShort( pCode + 2, pSymbols, bDynCode ? nSize - 2 : 0 );
pCode += nSize;
break;
}
@@ -2642,10 +2642,10 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
* +3 +4 -> number of expected parameters
* +5 -> pcode bytes
*/
HB_SIZE ulSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] );
hb_vmPushMacroBlock( pCode + 5, ulSize - 5,
HB_SIZE nSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] );
hb_vmPushMacroBlock( pCode + 5, nSize - 5,
HB_PCODE_MKUSHORT( &pCode[ 3 ] ) );
pCode += ulSize;
pCode += nSize;
break;
}
@@ -2660,10 +2660,10 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
* +4 +5 -> number of expected parameters
* +6 -> pcode bytes
*/
HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
hb_vmPushMacroBlock( pCode + 6, ulSize - 6,
HB_SIZE nSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
hb_vmPushMacroBlock( pCode + 6, nSize - 6,
HB_PCODE_MKUSHORT( &pCode[ 4 ] ) );
pCode += ulSize;
pCode += nSize;
break;
}
@@ -2723,10 +2723,10 @@ void hb_vmExecute( const HB_BYTE * pCode, PHB_SYMB pSymbols )
case HB_P_MPUSHSTRLARGE:
{
HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
HB_SIZE nSize = HB_PCODE_MKUINT24( &pCode[ 1 ] );
hb_vmPushString( ( const char * ) ( pCode + 3 ), ulSize - 1 );
pCode += 4 + ulSize;
hb_vmPushString( ( const char * ) ( pCode + 3 ), nSize - 1 );
pCode += 4 + nSize;
break;
}
@@ -3182,23 +3182,23 @@ static void hb_vmPlus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pIte
}
else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
{
HB_SIZE ulLen1 = pItem1->item.asString.length;
HB_SIZE ulLen2 = pItem2->item.asString.length;
HB_SIZE nLen1 = pItem1->item.asString.length;
HB_SIZE nLen2 = pItem2->item.asString.length;
if( ulLen2 )
if( nLen2 )
{
if( ulLen1 )
if( nLen1 )
{
if( ulLen1 < HB_SIZE_MAX - ulLen2 )
if( nLen1 < HB_SIZE_MAX - nLen2 )
{
if( pResult != pItem1 )
{
hb_itemMove( pResult, pItem1 );
pItem1 = pResult;
}
hb_itemReSizeString( pItem1, ulLen1 + ulLen2 );
hb_xmemcpy( pItem1->item.asString.value + ulLen1,
pItem2->item.asString.value, ulLen2 );
hb_itemReSizeString( pItem1, nLen1 + nLen2 );
hb_xmemcpy( pItem1->item.asString.value + nLen1,
pItem2->item.asString.value, nLen2 );
}
else
hb_errRT_BASE( EG_STROVERFLOW, 1209, NULL, "+", 2, pItem1, pItem2 );
@@ -3327,34 +3327,34 @@ static void hb_vmMinus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pIt
}
else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
{
HB_SIZE ulLen1 = pItem1->item.asString.length;
HB_SIZE ulLen2 = pItem2->item.asString.length;
HB_SIZE nLen1 = pItem1->item.asString.length;
HB_SIZE nLen2 = pItem2->item.asString.length;
if( ulLen1 == 0 )
if( nLen1 == 0 )
{
hb_itemCopy( pResult, pItem2 );
pResult->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
}
else if( ulLen2 == 0 )
else if( nLen2 == 0 )
{
if( pResult != pItem1 )
hb_itemCopy( pResult, pItem1 );
pResult->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
}
else if( ulLen1 < HB_SIZE_MAX - ulLen2 )
else if( nLen1 < HB_SIZE_MAX - nLen2 )
{
if( pResult != pItem1 )
{
hb_itemMove( pResult, pItem1 );
pItem1 = pResult;
}
hb_itemReSizeString( pItem1, ulLen1 + ulLen2 );
while( ulLen1 && pItem1->item.asString.value[ ulLen1 - 1 ] == ' ' )
ulLen1--;
hb_xmemcpy( pItem1->item.asString.value + ulLen1,
pItem2->item.asString.value, ulLen2 );
hb_xmemset( pItem1->item.asString.value + ulLen1 + ulLen2, ' ',
pItem1->item.asString.length - ulLen1 - ulLen2 );
hb_itemReSizeString( pItem1, nLen1 + nLen2 );
while( nLen1 && pItem1->item.asString.value[ nLen1 - 1 ] == ' ' )
nLen1--;
hb_xmemcpy( pItem1->item.asString.value + nLen1,
pItem2->item.asString.value, nLen2 );
hb_xmemset( pItem1->item.asString.value + nLen1 + nLen2, ' ',
pItem1->item.asString.length - nLen1 - nLen2 );
}
else
hb_errRT_BASE( EG_STROVERFLOW, 1210, NULL, "-", 2, pItem1, pItem2 );
@@ -4642,10 +4642,10 @@ static void hb_vmEnumStart( int nVars, int nDescend )
}
else if( HB_IS_HASH( pBase ) )
{
HB_SIZE ulLen = hb_hashLen( pBase );
HB_SIZE nLen = hb_hashLen( pBase );
/* the index into a hash */
pEnum->item.asEnum.offset = ( nDescend > 0 ) ? 1 : ulLen;
if( ulLen == 0 )
pEnum->item.asEnum.offset = ( nDescend > 0 ) ? 1 : nLen;
if( nLen == 0 )
fStart = HB_FALSE;
}
else if( HB_IS_STRING( pBase ) )
@@ -5041,7 +5041,7 @@ static void hb_vmArrayPush( void )
HB_STACK_TLS_PRELOAD
PHB_ITEM pIndex;
PHB_ITEM pArray;
HB_SIZE ulIndex;
HB_SIZE nIndex;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPush()"));
@@ -5064,11 +5064,11 @@ static void hb_vmArrayPush( void )
return;
}
else if( HB_IS_INTEGER( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
nIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
else if( HB_IS_LONG( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asLong.value;
nIndex = ( HB_SIZE ) pIndex->item.asLong.value;
else if( HB_IS_DOUBLE( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
nIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
else
{
if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
@@ -5095,9 +5095,9 @@ static void hb_vmArrayPush( void )
return;
}
if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->nLen ) )
if( HB_IS_VALID_INDEX( nIndex, pArray->item.asArray.value->nLen ) )
{
hb_itemCopy( pIndex, pArray->item.asArray.value->pItems + ulIndex - 1 );
hb_itemCopy( pIndex, pArray->item.asArray.value->pItems + nIndex - 1 );
hb_itemMove( pArray, pIndex );
hb_stackDec();
}
@@ -5124,7 +5124,7 @@ static void hb_vmArrayPushRef( void )
PHB_ITEM pIndex;
PHB_ITEM pArray;
PHB_ITEM pRefer;
HB_SIZE ulIndex;
HB_SIZE nIndex;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPushRef()"));
@@ -5153,11 +5153,11 @@ static void hb_vmArrayPushRef( void )
return;
}
else if( HB_IS_INTEGER( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
nIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
else if( HB_IS_LONG( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asLong.value;
nIndex = ( HB_SIZE ) pIndex->item.asLong.value;
else if( HB_IS_DOUBLE( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
nIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
else if( hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
{
/* create extended object index reference */
@@ -5187,10 +5187,10 @@ static void hb_vmArrayPushRef( void )
hb_stackPop();
return;
}
else if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->nLen ) )
else if( HB_IS_VALID_INDEX( nIndex, pArray->item.asArray.value->nLen ) )
{
/* This function is safe for overwriting passed array, [druzus] */
hb_arrayGetItemRef( pArray, ulIndex, pRefer );
hb_arrayGetItemRef( pArray, nIndex, pRefer );
hb_stackDec();
}
else if( !HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
@@ -5224,7 +5224,7 @@ static void hb_vmArrayPop( void )
PHB_ITEM pValue;
PHB_ITEM pIndex;
PHB_ITEM pArray;
HB_SIZE ulIndex;
HB_SIZE nIndex;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPop()"));
@@ -5257,11 +5257,11 @@ static void hb_vmArrayPop( void )
return;
}
else if( HB_IS_INTEGER( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
nIndex = ( HB_SIZE ) pIndex->item.asInteger.value;
else if( HB_IS_LONG( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asLong.value;
nIndex = ( HB_SIZE ) pIndex->item.asLong.value;
else if( HB_IS_DOUBLE( pIndex ) )
ulIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
nIndex = ( HB_SIZE ) pIndex->item.asDouble.value;
else
{
if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
@@ -5286,10 +5286,10 @@ static void hb_vmArrayPop( void )
return;
}
if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->nLen ) )
if( HB_IS_VALID_INDEX( nIndex, pArray->item.asArray.value->nLen ) )
{
pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
hb_itemMoveRef( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
hb_itemMoveRef( pArray->item.asArray.value->pItems + nIndex - 1, pValue );
hb_stackPop();
hb_stackPop();
hb_stackDec(); /* value was moved above hb_stackDec() is enough */
@@ -5319,32 +5319,32 @@ static void hb_vmArrayPop( void )
hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
}
static void hb_vmArrayGen( HB_SIZE ulElements ) /* generates an ulElements Array and fills it from the stack values */
static void hb_vmArrayGen( HB_SIZE nElements ) /* generates an nElements Array and fills it from the stack values */
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pArray;
HB_SIZE ulPos;
HB_SIZE nPos;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayGen(%" HB_PFS "u)", ulElements));
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayGen(%" HB_PFS "u)", nElements));
/* create new array on HVM stack */
pArray = hb_stackAllocItem();
hb_arrayNew( pArray, ulElements );
hb_arrayNew( pArray, nElements );
if( ulElements )
if( nElements )
{
/* move items from HVM stack to created array */
for( ulPos = 0; ulPos < ulElements; ulPos++ )
for( nPos = 0; nPos < nElements; nPos++ )
{
PHB_ITEM pValue = hb_stackItemFromTop( ( int ) ( ulPos - ulElements - 1 ) );
PHB_ITEM pValue = hb_stackItemFromTop( ( int ) ( nPos - nElements - 1 ) );
pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
hb_itemMove( pArray->item.asArray.value->pItems + ulPos, pValue );
hb_itemMove( pArray->item.asArray.value->pItems + nPos, pValue );
}
/* move the new array to position of first parameter */
hb_itemMove( hb_stackItemFromTop( -1 - ( int ) ulElements ), pArray );
hb_itemMove( hb_stackItemFromTop( -1 - ( int ) nElements ), pArray );
/* decrease the stack counter - all items are NIL */
hb_stackDecrease( ulElements );
hb_stackDecrease( nElements );
}
}
@@ -5354,7 +5354,7 @@ static void hb_vmArrayGen( HB_SIZE ulElements ) /* generates an ulElements Array
static void hb_vmArrayNew( HB_ITEM_PTR pArray, HB_USHORT uiDimension )
{
HB_STACK_TLS_PRELOAD
HB_SIZE ulElements;
HB_SIZE nElements;
HB_ITEM_PTR pDim;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayNew(%p, %hu)", pArray, uiDimension));
@@ -5363,27 +5363,27 @@ static void hb_vmArrayNew( HB_ITEM_PTR pArray, HB_USHORT uiDimension )
/* use the proper type of number of elements */
if( HB_IS_INTEGER( pDim ) )
ulElements = ( HB_SIZE ) pDim->item.asInteger.value;
nElements = ( HB_SIZE ) pDim->item.asInteger.value;
else if( HB_IS_LONG( pDim ) )
ulElements = ( HB_SIZE ) pDim->item.asLong.value;
nElements = ( HB_SIZE ) pDim->item.asLong.value;
else if( HB_IS_DOUBLE( pDim ) )
ulElements = ( HB_SIZE ) pDim->item.asDouble.value;
nElements = ( HB_SIZE ) pDim->item.asDouble.value;
else
/* NOTE: Clipper creates empty array if non-numeric value is
* specified as dimension and stops further processing.
* There is no runtime error generated.
*/
ulElements = 0;
nElements = 0;
/* create an array */
hb_arrayNew( pArray, ulElements );
hb_arrayNew( pArray, nElements );
if( --uiDimension )
{
/* call self recursively to create next dimensions
*/
while( ulElements-- )
hb_vmArrayNew( pArray->item.asArray.value->pItems + ulElements, uiDimension );
while( nElements-- )
hb_vmArrayNew( pArray->item.asArray.value->pItems + nElements, uiDimension );
}
}
@@ -5404,17 +5404,17 @@ static void hb_vmArrayDim( HB_USHORT uiDimensions ) /* generates an uiDimensions
while( --uiDimensions );
}
static void hb_vmHashGen( HB_SIZE ulElements ) /* generates an ulElements Hash and fills it from the stack values */
static void hb_vmHashGen( HB_SIZE nElements ) /* generates an nElements Hash and fills it from the stack values */
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pHash, pKey, pVal;
HB_TRACE(HB_TR_DEBUG, ("hb_vmHashGen(%" HB_PFS "u)", ulElements));
HB_TRACE(HB_TR_DEBUG, ("hb_vmHashGen(%" HB_PFS "u)", nElements));
/* create new hash item */
pHash = hb_hashNew( NULL );
hb_hashPreallocate( pHash, ulElements );
while( ulElements-- )
hb_hashPreallocate( pHash, nElements );
while( nElements-- )
{
pKey = hb_stackItemFromTop( -2 );
pVal = hb_stackItemFromTop( -1 );
@@ -5442,7 +5442,7 @@ static void hb_vmHashGen( HB_SIZE ulElements ) /* generates an ulElements Hash a
static void hb_vmMacroPushIndex( void )
{
HB_STACK_TLS_PRELOAD
HB_SIZE ulIndexes;
HB_SIZE nIndexes;
HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroPushIndex()"));
@@ -5450,15 +5450,15 @@ static void hb_vmMacroPushIndex( void )
* Now the top most element on the stack points to number of
* additional indexes to generated array
*/
ulIndexes = hb_itemGetNL( hb_stackItemFromTop( -1 ) );
nIndexes = hb_itemGetNL( hb_stackItemFromTop( -1 ) ); /* TOFIX!!! */
hb_stackDec();
if( ulIndexes > 1 )
if( nIndexes > 1 )
{
PHB_ITEM pIndexArray;
HB_SIZE ul = 1;
HB_SIZE n = 1;
hb_vmArrayGen( ulIndexes - 1 );
hb_vmArrayGen( nIndexes - 1 );
pIndexArray = hb_itemNew( hb_stackItemFromTop( -1 ) );
hb_stackPop();
@@ -5473,13 +5473,13 @@ static void hb_vmMacroPushIndex( void )
/* RT error? */
if( hb_stackGetActionRequest() != 0 )
break;
hb_vmPush( hb_arrayGetItemPtr( pIndexArray, ul ) );
hb_vmPush( hb_arrayGetItemPtr( pIndexArray, n ) );
}
while( ++ul < ulIndexes );
while( ++n < nIndexes );
hb_itemRelease( pIndexArray );
}
else if( ulIndexes == 0 )
else if( nIndexes == 0 )
hb_vmPushNil(); /* It will force RT error later in array push or pop */
}
@@ -5605,16 +5605,16 @@ static void hb_vmPushAParams( void )
pArray = hb_stackItemFromTop( -1 );
if( HB_IS_ARRAY( pArray ) )
{
HB_SIZE ulLen = pArray->item.asArray.value->nLen, ul;
HB_SIZE nLen = pArray->item.asArray.value->nLen, ul;
if( ulLen )
if( nLen )
{
for( ul = 1; ul < ulLen; ++ul )
for( ul = 1; ul < nLen; ++ul )
hb_vmPush( pArray->item.asArray.value->pItems + ul );
pCount = hb_stackAllocItem();
hb_itemCopy( pCount, pArray->item.asArray.value->pItems );
hb_itemMove( pArray, pCount );
hb_itemPutNS( pCount, ulLen );
hb_itemPutNS( pCount, nLen );
}
else
hb_itemPutNL( pArray, 0 );
@@ -6779,24 +6779,24 @@ void hb_vmPushPointer( void * pPointer )
pItem->item.asPointer.single = HB_FALSE;
}
void hb_vmPushString( const char * szText, HB_SIZE length )
void hb_vmPushString( const char * szText, HB_SIZE nLength )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushString(%s, %" HB_PFS "u)", szText, length));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushString(%s, %" HB_PFS "u)", szText, nLength));
hb_itemPutCL( hb_stackAllocItem(), szText, length );
hb_itemPutCL( hb_stackAllocItem(), szText, nLength );
}
void hb_vmPushStringPcode( const char * szText, HB_SIZE length )
void hb_vmPushStringPcode( const char * szText, HB_SIZE nLength )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushStringPcode(%s, %" HB_PFS "u)", szText, length));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushStringPcode(%s, %" HB_PFS "u)", szText, nLength));
pItem->type = HB_IT_STRING;
pItem->item.asString.length = length;
pItem->item.asString.length = nLength;
pItem->item.asString.allocated = 0;
pItem->item.asString.value = ( char * ) szText;
}
@@ -6845,25 +6845,25 @@ void hb_vmPushEvalSym( void )
*
* NOTE: pCode points to static memory
*/
static void hb_vmPushBlock( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE ulLen )
static void hb_vmPushBlock( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
HB_USHORT uiLocals;
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlock(%p,%p,%" HB_PFS "u)", pCode, pSymbols, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlock(%p,%p,%" HB_PFS "u)", pCode, pSymbols, nLen));
uiLocals = HB_PCODE_MKUSHORT( &pCode[ 2 ] );
if( ulLen )
ulLen -= uiLocals << 1;
if( nLen )
nLen -= uiLocals << 1;
pItem->item.asBlock.value =
hb_codeblockNew( pCode + 4 + ( uiLocals << 1 ),/* pcode buffer */
uiLocals, /* number of referenced local variables */
pCode + 4, /* table with referenced local variables */
pSymbols,
ulLen );
nLen );
pItem->type = HB_IT_BLOCK;
/* store the number of expected parameters
@@ -6882,19 +6882,19 @@ static void hb_vmPushBlock( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE ul
*
* NOTE: pCode points to static memory
*/
static void hb_vmPushBlockShort( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE ulLen )
static void hb_vmPushBlockShort( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SIZE nLen )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlockShort(%p,%p,%" HB_PFS "u)", pCode, pSymbols, ulLen));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlockShort(%p,%p,%" HB_PFS "u)", pCode, pSymbols, nLen));
pItem->item.asBlock.value =
hb_codeblockNew( pCode, /* pcode buffer */
0, /* number of referenced local variables */
NULL, /* table with referenced local variables */
pSymbols,
ulLen );
nLen );
pItem->type = HB_IT_BLOCK;
@@ -6915,14 +6915,14 @@ static void hb_vmPushBlockShort( const HB_BYTE * pCode, PHB_SYMB pSymbols, HB_SI
*
* NOTE: pCode points to dynamically allocated memory
*/
static void hb_vmPushMacroBlock( const HB_BYTE * pCode, HB_SIZE ulSize, HB_USHORT usParams )
static void hb_vmPushMacroBlock( const HB_BYTE * pCode, HB_SIZE nSize, HB_USHORT usParams )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushMacroBlock(%p,%" HB_PFS "u,%hu)", pCode, ulSize, usParams));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushMacroBlock(%p,%" HB_PFS "u,%hu)", pCode, nSize, usParams));
pItem->item.asBlock.value = hb_codeblockMacroNew( pCode, ulSize );
pItem->item.asBlock.value = hb_codeblockMacroNew( pCode, nSize );
pItem->type = HB_IT_BLOCK;
/* store the number of expected parameters
@@ -7488,9 +7488,9 @@ static void hb_vmStaticsClear( void )
PHB_ITEM pStatics = HB_SYM_STATICSBASE( pSym );
if( pStatics )
{
HB_SIZE ulLen = hb_arrayLen( pStatics ), ul;
HB_SIZE nLen = hb_arrayLen( pStatics ), ul;
for( ul = 1; ul <= ulLen; ++ul )
for( ul = 1; ul <= nLen; ++ul )
{
PHB_ITEM pItem = hb_arrayGetItemPtr( pStatics, ul );
if( HB_IS_COMPLEX( pItem ) )
@@ -7524,7 +7524,7 @@ static void hb_vmStaticsRelease( void )
static HB_SIZE hb_vmStaticsCount( void )
{
HB_SIZE ulStatics = 0;
HB_SIZE nStatics = 0;
if( hb_vmLockModuleSymbols() )
{
@@ -7536,14 +7536,14 @@ static HB_SIZE hb_vmStaticsCount( void )
PHB_SYMB pSym = pLastSymbols->pModuleSymbols + pLastSymbols->uiStaticsOffset;
PHB_ITEM pStatics = HB_SYM_STATICSBASE( pSym );
if( pStatics )
ulStatics += hb_arrayLen( pStatics );
nStatics += hb_arrayLen( pStatics );
}
pLastSymbols = pLastSymbols->pNext;
}
hb_vmUnlockModuleSymbols();
}
return ulStatics;
return nStatics;
}
static PHB_ITEM hb_vmStaticsArray( void )
@@ -7553,11 +7553,11 @@ static PHB_ITEM hb_vmStaticsArray( void )
if( hb_vmLockModuleSymbols() )
{
PHB_SYMBOLS pLastSymbols = s_pSymbols;
HB_SIZE ulOffset, ulCount;
HB_SIZE nOffset, nCount;
ulCount = hb_vmStaticsCount();
pArray = hb_itemArrayNew( ulCount );
ulOffset = 0;
nCount = hb_vmStaticsCount();
pArray = hb_itemArrayNew( nCount );
nOffset = 0;
while( pLastSymbols )
{
@@ -7567,10 +7567,10 @@ static PHB_ITEM hb_vmStaticsArray( void )
PHB_ITEM pStatics = HB_SYM_STATICSBASE( pSym );
if( pStatics )
{
HB_SIZE ulLen = hb_arrayLen( pStatics ), ul;
HB_SIZE nLen = hb_arrayLen( pStatics ), n;
for( ul = 1; ul <= ulLen; ++ul )
hb_arraySet( pArray, ++ulOffset, hb_arrayGetItemPtr( pStatics, ul ) );
for( n = 1; n <= nLen; ++n )
hb_arraySet( pArray, ++nOffset, hb_arrayGetItemPtr( pStatics, n ) );
}
}
pLastSymbols = pLastSymbols->pNext;
@@ -7828,19 +7828,19 @@ PHB_SYMBOLS hb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, HB_USHORT uiSymbols,
if( fClone )
{
HB_SIZE ulSymSize = ( HB_ULONG ) uiSymbols * sizeof( HB_SYMB ), ulSize;
HB_SIZE nSymSize = ( HB_ULONG ) uiSymbols * sizeof( HB_SYMB ), nSize; /* TOFIX !!! */
char * buffer;
ulSize = ulSymSize;
nSize = nSymSize;
for( ui = 0; ui < uiSymbols; ui++ )
ulSize += strlen( pModuleSymbols[ ui ].szName ) + 1;
buffer = ( char * ) memcpy( hb_xgrab( ulSize ), pModuleSymbols, ulSymSize );
nSize += strlen( pModuleSymbols[ ui ].szName ) + 1;
buffer = ( char * ) memcpy( hb_xgrab( nSize ), pModuleSymbols, nSymSize );
pModuleSymbols = ( PHB_SYMB ) buffer;
for( ui = 0; ui < uiSymbols; ui++ )
{
buffer += ulSymSize;
ulSymSize = strlen( pModuleSymbols[ ui ].szName ) + 1;
memcpy( buffer, pModuleSymbols[ ui ].szName, ulSymSize );
buffer += nSymSize;
nSymSize = strlen( pModuleSymbols[ ui ].szName ) + 1;
memcpy( buffer, pModuleSymbols[ ui ].szName, nSymSize );
pModuleSymbols[ ui ].szName = buffer;
}
}
@@ -10945,26 +10945,26 @@ void hb_xvmArrayDim( HB_USHORT uiDimensions )
hb_vmArrayDim( uiDimensions );
}
void hb_xvmArrayGen( HB_SIZE ulElements )
void hb_xvmArrayGen( HB_SIZE nElements )
{
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayGen(%" HB_PFS "u)", ulElements));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayGen(%" HB_PFS "u)", nElements));
hb_vmArrayGen( ulElements );
hb_vmArrayGen( nElements );
}
void hb_xvmHashGen( HB_SIZE ulElements )
void hb_xvmHashGen( HB_SIZE nElements )
{
HB_TRACE(HB_TR_DEBUG, ("hb_xvmHashGen(%" HB_PFS "u)", ulElements));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmHashGen(%" HB_PFS "u)", nElements));
hb_vmHashGen( ulElements );
hb_vmHashGen( nElements );
}
static void hb_vmArrayItemPush( HB_SIZE ulIndex )
static void hb_vmArrayItemPush( HB_SIZE nIndex )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pArray;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPush(%" HB_PFS "u)", ulIndex));
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPush(%" HB_PFS "u)", nIndex));
pArray = hb_stackItemFromTop( -1 );
@@ -10972,24 +10972,24 @@ static void hb_vmArrayItemPush( HB_SIZE ulIndex )
{
if( HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), NULL );
hb_stackPop();
return;
}
if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->nLen ) )
if( HB_IS_VALID_INDEX( nIndex, pArray->item.asArray.value->nLen ) )
{
PHB_ITEM pItem = hb_stackAllocItem();
hb_itemCopy( pItem, pArray->item.asArray.value->pItems + ulIndex - 1 );
hb_itemCopy( pItem, pArray->item.asArray.value->pItems + nIndex - 1 );
hb_itemMove( pArray, pItem );
hb_stackDec();
}
else
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
if( !HB_IS_OBJECT( pArray ) &&
hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), NULL ) )
@@ -11007,7 +11007,7 @@ static void hb_vmArrayItemPush( HB_SIZE ulIndex )
{
PHB_ITEM pValue, pIndex;
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
pIndex = hb_stackItemFromTop( -1 );
pValue = hb_hashGetItemPtr( pArray, pIndex, HB_HASH_AUTOADD_ACCESS );
@@ -11025,7 +11025,7 @@ static void hb_vmArrayItemPush( HB_SIZE ulIndex )
}
else
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), NULL ) )
hb_stackPop();
@@ -11034,13 +11034,13 @@ static void hb_vmArrayItemPush( HB_SIZE ulIndex )
}
}
static void hb_vmArrayItemPop( HB_SIZE ulIndex )
static void hb_vmArrayItemPop( HB_SIZE nIndex )
{
HB_STACK_TLS_PRELOAD
PHB_ITEM pValue;
PHB_ITEM pArray;
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPop(%" HB_PFS "u)", ulIndex));
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPop(%" HB_PFS "u)", nIndex));
pValue = hb_stackItemFromTop( -2 );
pArray = hb_stackItemFromTop( -1 );
@@ -11052,7 +11052,7 @@ static void hb_vmArrayItemPop( HB_SIZE ulIndex )
{
if( HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), pValue );
hb_stackPop();
@@ -11061,16 +11061,16 @@ static void hb_vmArrayItemPop( HB_SIZE ulIndex )
return;
}
if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->nLen ) )
if( HB_IS_VALID_INDEX( nIndex, pArray->item.asArray.value->nLen ) )
{
pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
hb_itemMoveRef( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
hb_itemMoveRef( pArray->item.asArray.value->pItems + nIndex - 1, pValue );
hb_stackPop();
hb_stackDec(); /* value was moved above hb_stackDec() is enough */
}
else
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
if( !HB_IS_OBJECT( pArray ) &&
hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), pValue ) )
@@ -11092,7 +11092,7 @@ static void hb_vmArrayItemPop( HB_SIZE ulIndex )
{
PHB_ITEM pDest;
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
pDest = hb_hashGetItemPtr( pArray, hb_stackItemFromTop( -1 ), HB_HASH_AUTOADD_ASSIGN );
if( pDest )
@@ -11115,7 +11115,7 @@ static void hb_vmArrayItemPop( HB_SIZE ulIndex )
}
else
{
hb_vmPushNumInt( ulIndex );
hb_vmPushNumInt( nIndex );
if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
hb_stackItemFromTop( -1 ), pValue ) )
{
@@ -11152,13 +11152,13 @@ HB_BOOL hb_xvmArrayPushRef( void )
HB_XVM_RETURN
}
HB_BOOL hb_xvmArrayItemPush( HB_SIZE ulIndex )
HB_BOOL hb_xvmArrayItemPush( HB_SIZE nIndex )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPush(%" HB_PFS "u)", ulIndex));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPush(%" HB_PFS "u)", nIndex));
hb_vmArrayItemPush( ulIndex );
hb_vmArrayItemPush( nIndex );
HB_XVM_RETURN
}
@@ -11174,13 +11174,13 @@ HB_BOOL hb_xvmArrayPop( void )
HB_XVM_RETURN
}
HB_BOOL hb_xvmArrayItemPop( HB_SIZE ulIndex )
HB_BOOL hb_xvmArrayItemPop( HB_SIZE nIndex )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPop(%" HB_PFS "u)", ulIndex));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPop(%" HB_PFS "u)", nIndex));
hb_vmArrayItemPop( ulIndex );
hb_vmArrayItemPop( nIndex );
HB_XVM_RETURN
}
@@ -11208,15 +11208,15 @@ void hb_xvmPushLongLong( HB_LONGLONG llNumber )
}
#endif
void hb_xvmPushStringHidden( int iMethod, const char * szText, HB_SIZE ulSize )
void hb_xvmPushStringHidden( int iMethod, const char * szText, HB_SIZE nSize )
{
HB_STACK_TLS_PRELOAD
char * szString;
HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushStringHidden(%d, %s, %" HB_PFS "u)", iMethod, szText, ulSize));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushStringHidden(%d, %s, %" HB_PFS "u)", iMethod, szText, nSize));
szString = hb_compDecodeString( iMethod, szText, &ulSize );
hb_itemPutCLPtr( hb_stackAllocItem(), szString, ulSize );
szString = hb_compDecodeString( iMethod, szText, &nSize );
hb_itemPutCLPtr( hb_stackAllocItem(), szString, nSize );
}
void hb_xvmLocalName( HB_USHORT uiLocal, const char * szLocalName )

View File

@@ -254,29 +254,29 @@ static void hb_macroSyntaxError( HB_MACRO_PTR pMacro )
* PRIVATE &a&b //this will cause syntax error '&'
*
*/
static char * hb_macroTextSubst( const char * szString, HB_SIZE * pulStringLen )
static char * hb_macroTextSubst( const char * szString, HB_SIZE * pnStringLen )
{
char * szResult;
HB_SIZE ulResStrLen;
HB_SIZE ulResBufLen;
HB_SIZE ulCharsLeft;
HB_SIZE nResStrLen;
HB_SIZE nResBufLen;
HB_SIZE nCharsLeft;
char * pHead;
char * pTail;
HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSubst(%s, %" HB_PFS "u)", szString, *pulStringLen));
HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSubst(%s, %" HB_PFS "u)", szString, *pnStringLen));
pHead = ( char * ) memchr( szString, '&', *pulStringLen );
pHead = ( char * ) memchr( szString, '&', *pnStringLen );
if( pHead == NULL )
return ( char * ) szString; /* no more processing is required */
/* initial length of the string and the result buffer (it can contain null bytes) */
ulResBufLen = ulResStrLen = *pulStringLen;
nResBufLen = nResStrLen = *pnStringLen;
/* initial buffer for return value */
szResult = ( char * ) hb_xgrab( ulResBufLen + 1 );
szResult = ( char * ) hb_xgrab( nResBufLen + 1 );
/* copy the input string with trailing zero byte
*/
memcpy( szResult, szString, ulResStrLen + 1 );
memcpy( szResult, szString, nResStrLen + 1 );
/* switch the pointer so it will point into the result buffer
*/
pHead = szResult + ( pHead - szString );
@@ -300,7 +300,7 @@ static char * hb_macroTextSubst( const char * szString, HB_SIZE * pulStringLen )
* length of identifiers (HB_SYMBOL_NAME_LEN) - only the max allowed
* are used for name lookup however the whole string is replaced
*/
HB_SIZE ulNameLen = 1;
HB_SIZE nNameLen = 1;
char * pName = pHead;
while( *++pHead && ( *pHead == '_' ||
@@ -308,17 +308,17 @@ static char * hb_macroTextSubst( const char * szString, HB_SIZE * pulStringLen )
( *pHead >= 'a' && *pHead <= 'z' ) ||
( *pHead >= '0' && *pHead <= '9' ) ) )
{
++ulNameLen;
++nNameLen;
}
/* pHead points now at the character that terminated a variable name */
/* NOTE: '_' is invalid variable name
*/
if( ulNameLen > 1 || *pName != '_' )
if( nNameLen > 1 || *pName != '_' )
{
/* this is not the "&_" string */
char * szValPtr;
HB_SIZE ulValLen;
HB_SIZE nValLen;
/* Get a pointer to the string value stored in this variable
* or NULL if variable doesn't exist or doesn't contain a string
@@ -326,47 +326,47 @@ static char * hb_macroTextSubst( const char * szString, HB_SIZE * pulStringLen )
* NOTE: This doesn't create a copy of the value then it
* shouldn't be released here.
*/
ulValLen = ulNameLen; /* the length of name */
szValPtr = hb_memvarGetStrValuePtr( pName, &ulValLen );
nValLen = nNameLen; /* the length of name */
szValPtr = hb_memvarGetStrValuePtr( pName, &nValLen );
if( szValPtr )
{
if( *pHead == '.' )
{
/* we have stopped at the macro terminator '.' - skip it */
++pHead;
++ulNameLen;
++nNameLen;
}
++ulNameLen; /* count also the '&' character */
++nNameLen; /* count also the '&' character */
/* number of characters left on the right side of a variable name */
ulCharsLeft = ulResStrLen - ( pHead - szResult );
nCharsLeft = nResStrLen - ( pHead - szResult );
/* NOTE:
* if a replacement string is shorter then the variable
* name then we don't have to reallocate the result buffer:
* 'ulResStrLen' stores the current length of a string in the buffer
* 'ulResBufLen' stores the length of the buffer
* 'nResStrLen' stores the current length of a string in the buffer
* 'nResBufLen' stores the length of the buffer
*/
if( ulValLen > ulNameLen )
if( nValLen > nNameLen )
{
ulResStrLen += ( ulValLen - ulNameLen );
if( ulResStrLen > ulResBufLen )
nResStrLen += ( nValLen - nNameLen );
if( nResStrLen > nResBufLen )
{
HB_SIZE ulHead = pHead - szResult;
HB_SIZE ulTail = pTail - szResult;
ulResBufLen = ulResStrLen;
szResult = ( char * ) hb_xrealloc( szResult, ulResBufLen + 1 );
pHead = szResult + ulHead;
pTail = szResult + ulTail;
HB_SIZE nHead = pHead - szResult;
HB_SIZE nTail = pTail - szResult;
nResBufLen = nResStrLen;
szResult = ( char * ) hb_xrealloc( szResult, nResBufLen + 1 );
pHead = szResult + nHead;
pTail = szResult + nTail;
}
}
else
ulResStrLen -= ( ulNameLen - ulValLen );
nResStrLen -= ( nNameLen - nValLen );
/* move bytes located on the right side of a variable name */
memmove( pTail + ulValLen, pHead, ulCharsLeft + 1 );
memmove( pTail + nValLen, pHead, nCharsLeft + 1 );
/* copy substituted value */
memcpy( pTail, szValPtr, ulValLen );
memcpy( pTail, szValPtr, nValLen );
/* restart scanning from the beginning of replaced string */
/* NOTE: This causes that the following code:
* a := '&a'
@@ -378,20 +378,20 @@ static char * hb_macroTextSubst( const char * szString, HB_SIZE * pulStringLen )
}
}
}
ulCharsLeft = ulResStrLen - ( pHead - szResult );
nCharsLeft = nResStrLen - ( pHead - szResult );
}
while( ulCharsLeft && ( pHead = ( char * ) memchr( pHead, '&', ulCharsLeft ) ) != NULL );
while( nCharsLeft && ( pHead = ( char * ) memchr( pHead, '&', nCharsLeft ) ) != NULL );
if( ulResStrLen < ulResBufLen )
if( nResStrLen < nResBufLen )
{
/* result string is shorter then allocated buffer -
* cut it to a required length
*/
szResult = ( char * ) hb_xrealloc( szResult, ulResStrLen + 1 );
szResult = ( char * ) hb_xrealloc( szResult, nResStrLen + 1 );
}
szResult[ ulResStrLen ] = 0; /* place terminating null character */
szResult[ nResStrLen ] = 0; /* place terminating null character */
/* return a length of result string */
*pulStringLen = ulResStrLen;
*pnStringLen = nResStrLen;
return szResult; /* a new memory buffer was allocated */
}
@@ -594,8 +594,8 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag,
{
/* grab memory for "alias->var"
*/
HB_SIZE ulLen = pAlias->item.asString.length + pVar->item.asString.length + 2;
char * szString = ( char * ) hb_xgrab( ulLen + 1 );
HB_SIZE nLen = pAlias->item.asString.length + pVar->item.asString.length + 2;
char * szString = ( char * ) hb_xgrab( nLen + 1 );
HB_MACRO struMacro;
int iStatus;
@@ -603,7 +603,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag,
szString[ pAlias->item.asString.length ] = '-';
szString[ pAlias->item.asString.length + 1 ] = '>';
memcpy( szString + pAlias->item.asString.length + 2, pVar->item.asString.value, pVar->item.asString.length );
szString[ ulLen ] = '\0';
szString[ nLen ] = '\0';
struMacro.mode = HB_MODE_MACRO;
struMacro.supported = (iSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : iSupported;
@@ -611,7 +611,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag,
struMacro.uiNameLen = HB_SYMBOL_NAME_LEN;
struMacro.status = HB_MACRO_CONT;
struMacro.string = szString;
struMacro.length = ulLen;
struMacro.length = nLen;
iStatus = hb_macroParse( &struMacro );
@@ -624,7 +624,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag,
}
else
{
hb_vmPushString( szString, ulLen );
hb_vmPushString( szString, nLen );
hb_macroSyntaxError( &struMacro );
}
@@ -690,78 +690,78 @@ void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int flags )
* new string if a valid macro text substitution was found (and sets
* pbNewString to TRUE)
*/
char * hb_macroExpandString( const char *szString, HB_SIZE ulLength, HB_BOOL *pfNewString )
char * hb_macroExpandString( const char *szString, HB_SIZE nLength, HB_BOOL *pfNewString )
{
char *szResultString;
HB_TRACE(HB_TR_DEBUG, ("hb_macroExpandString(%s,%" HB_PFS "u,%p)", szString, ulLength, pfNewString));
HB_TRACE(HB_TR_DEBUG, ("hb_macroExpandString(%s,%" HB_PFS "u,%p)", szString, nLength, pfNewString));
if( szString )
szResultString = hb_macroTextSubst( szString, &ulLength );
szResultString = hb_macroTextSubst( szString, &nLength );
else
szResultString = ( char * ) szString;
*pfNewString = ( szString != szResultString );
return szResultString;
}
char * hb_macroTextSymbol( const char *szString, HB_SIZE ulLength, HB_BOOL *pfNewString )
char * hb_macroTextSymbol( const char *szString, HB_SIZE nLength, HB_BOOL *pfNewString )
{
char *szResult = NULL;
HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSymbol(%s,%" HB_PFS "u,%p)", szString, ulLength, pfNewString));
HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSymbol(%s,%" HB_PFS "u,%p)", szString, nLength, pfNewString));
if( szString )
{
HB_SIZE ulLen = 0;
HB_SIZE nLen = 0;
szResult = hb_macroTextSubst( szString, &ulLength );
szResult = hb_macroTextSubst( szString, &nLength );
while( ulLength && ( szResult[ 0 ] == ' ' || szResult[ 0 ] == '\t' ) )
while( nLength && ( szResult[ 0 ] == ' ' || szResult[ 0 ] == '\t' ) )
{
++szResult;
++szString;
--ulLength;
--nLength;
}
while( ulLength && ( szResult[ ulLength - 1 ] == ' ' ||
szResult[ ulLength - 1 ] == '\t' ) )
--ulLength;
while( nLength && ( szResult[ nLength - 1 ] == ' ' ||
szResult[ nLength - 1 ] == '\t' ) )
--nLength;
/* NOTE: This uses _a-zA-Z0-9 pattern to check for a valid name
* "_" is not valid macro string
*/
while( ulLen < ulLength )
while( nLen < nLength )
{
char c = szResult[ ulLen ];
char c = szResult[ nLen ];
if( c >= 'a' && c <= 'z' )
{
if( szResult == szString )
{
szResult = ( char * ) hb_xgrab( ulLength + 1 );
memcpy( szResult, szString, ulLength );
szResult[ ulLength ] = '\0';
szResult = ( char * ) hb_xgrab( nLength + 1 );
memcpy( szResult, szString, nLength );
szResult[ nLength ] = '\0';
}
szResult[ ulLen ] = c - ( 'a' - 'A' );
szResult[ nLen ] = c - ( 'a' - 'A' );
}
else if( ! ( c == '_' || ( c >= 'A' && c <= 'Z' ) ||
( ulLen && ( c >= '0' && c <= '9' ) ) ) )
( nLen && ( c >= '0' && c <= '9' ) ) ) )
{
break;
}
++ulLen;
++nLen;
}
if( ulLen == ulLength && ulLen > ( HB_SIZE ) ( szResult[ 0 ] == '_' ? 1 : 0 ) )
if( nLen == nLength && nLen > ( HB_SIZE ) ( szResult[ 0 ] == '_' ? 1 : 0 ) )
{
if( ulLen > HB_SYMBOL_NAME_LEN )
ulLen = HB_SYMBOL_NAME_LEN;
if( szResult[ ulLen ] )
if( nLen > HB_SYMBOL_NAME_LEN )
nLen = HB_SYMBOL_NAME_LEN;
if( szResult[ nLen ] )
{
if( szResult == szString )
{
szResult = ( char * ) hb_xgrab( ulLen + 1 );
memcpy( szResult, szString, ulLen );
szResult = ( char * ) hb_xgrab( nLen + 1 );
memcpy( szResult, szString, nLen );
}
szResult[ ulLen ] = '\0';
szResult[ nLen ] = '\0';
}
}
else
@@ -897,15 +897,15 @@ void hb_macroTextValue( HB_ITEM_PTR pItem )
if( hb_macroCheckParam( pItem ) )
{
char * szString;
HB_SIZE ulLength = pItem->item.asString.length;
HB_SIZE nLength = pItem->item.asString.length;
szString = hb_macroTextSubst( pItem->item.asString.value, &ulLength );
szString = hb_macroTextSubst( pItem->item.asString.value, &nLength );
if( szString != pItem->item.asString.value )
{
/* replace the old value on the eval stack with the new one
*/
hb_itemPutCLPtr( pItem, szString, ulLength );
hb_itemPutCLPtr( pItem, szString, nLength );
}
/*
* else
@@ -1089,11 +1089,11 @@ int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL )
return 0;
}
HB_BOOL hb_macroIsValidMacroText( const char * szText, HB_SIZE ulLen )
HB_BOOL hb_macroIsValidMacroText( const char * szText, HB_SIZE nLen )
{
if( ulLen )
if( nLen )
{
while( --ulLen )
while( --nLen )
{
if( *szText++ == '&' )
{
@@ -1156,20 +1156,20 @@ HB_SIZE hb_macroGenJumpTrue( HB_ISIZ lOffset, HB_COMP_DECL )
return HB_PCODE_DATA->lPCodePos - 3;
}
void hb_macroGenJumpThere( HB_SIZE ulFrom, HB_SIZE ulTo, HB_COMP_DECL )
void hb_macroGenJumpThere( HB_SIZE nFrom, HB_SIZE nTo, HB_COMP_DECL )
{
HB_BYTE * pCode = HB_PCODE_DATA->pCode;
HB_ISIZ lOffset = ulTo - ulFrom + 1;
HB_ISIZ lOffset = nTo - nFrom + 1;
if( HB_LIM_INT24( lOffset ) )
HB_PUT_LE_UINT24( &pCode[ ulFrom ], lOffset );
HB_PUT_LE_UINT24( &pCode[ nFrom ], lOffset );
else
hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );
}
void hb_macroGenJumpHere( HB_SIZE ulOffset, HB_COMP_DECL )
void hb_macroGenJumpHere( HB_SIZE nOffset, HB_COMP_DECL )
{
hb_macroGenJumpThere( ulOffset, HB_PCODE_DATA->lPCodePos, HB_COMP_PARAM );
hb_macroGenJumpThere( nOffset, HB_PCODE_DATA->lPCodePos, HB_COMP_PARAM );
}
/*
@@ -1542,15 +1542,15 @@ void hb_macroGenPushFunRef( const char * szFunName, HB_COMP_DECL )
}
/* generates the pcode to push a string on the virtual machine stack */
void hb_macroGenPushString( const char * szText, HB_SIZE ulStrLen, HB_COMP_DECL )
void hb_macroGenPushString( const char * szText, HB_SIZE nStrLen, HB_COMP_DECL )
{
if( ulStrLen <= UINT24_MAX )
if( nStrLen <= UINT24_MAX )
{
if( ulStrLen <= USHRT_MAX )
hb_macroGenPCode3( HB_P_MPUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_COMP_PARAM );
if( nStrLen <= USHRT_MAX )
hb_macroGenPCode3( HB_P_MPUSHSTR, HB_LOBYTE( nStrLen ), HB_HIBYTE( nStrLen ), HB_COMP_PARAM );
else
hb_macroGenPCode4( HB_P_MPUSHSTRLARGE, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_ULBYTE( ulStrLen ), HB_COMP_PARAM );
hb_macroGenPCodeN( ( HB_BYTE * ) szText, ulStrLen, HB_COMP_PARAM );
hb_macroGenPCode4( HB_P_MPUSHSTRLARGE, HB_LOBYTE( nStrLen ), HB_HIBYTE( nStrLen ), HB_ULBYTE( nStrLen ), HB_COMP_PARAM );
hb_macroGenPCodeN( ( HB_BYTE * ) szText, nStrLen, HB_COMP_PARAM );
}
else
hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );
@@ -1602,19 +1602,19 @@ void hb_macroGenPCode4( HB_BYTE byte1, HB_BYTE byte2, HB_BYTE byte3, HB_BYTE byt
pFunc->pCode[ pFunc->lPCodePos++ ] = byte4;
}
void hb_macroGenPCodeN( HB_BYTE * pBuffer, HB_SIZE ulSize, HB_COMP_DECL )
void hb_macroGenPCodeN( HB_BYTE * pBuffer, HB_SIZE nSize, HB_COMP_DECL )
{
HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;
if( pFunc->lPCodePos + ulSize > pFunc->lPCodeSize )
if( pFunc->lPCodePos + nSize > pFunc->lPCodeSize )
{
/* not enough free space in pcode buffer - increase it */
pFunc->lPCodeSize += ( ( ( ulSize / HB_PCODE_SIZE ) + 1 ) * HB_PCODE_SIZE );
pFunc->lPCodeSize += ( ( ( nSize / HB_PCODE_SIZE ) + 1 ) * HB_PCODE_SIZE );
pFunc->pCode = ( HB_BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize );
}
memcpy( pFunc->pCode + pFunc->lPCodePos, pBuffer, ulSize );
pFunc->lPCodePos += ulSize;
memcpy( pFunc->pCode + pFunc->lPCodePos, pBuffer, nSize );
pFunc->lPCodePos += nSize;
}
/* ************************************************************************* */
@@ -1651,8 +1651,8 @@ void hb_macroCodeBlockStart( HB_COMP_DECL )
void hb_macroCodeBlockEnd( HB_COMP_DECL )
{
HB_PCODE_INFO_PTR pCodeblock; /* pointer to the current codeblock */
HB_SIZE ulSize;
HB_USHORT wParms = 0; /* number of codeblock parameters */
HB_SIZE nSize;
HB_USHORT usParms = 0; /* number of codeblock parameters */
HB_CBVAR_PTR pVar;
HB_TRACE(HB_TR_DEBUG, ("hb_macroCodeBlockEnd(%p)", HB_COMP_PARAM));
@@ -1674,26 +1674,26 @@ void hb_macroCodeBlockEnd( HB_COMP_DECL )
while( pVar )
{
pVar = pVar->pNext;
++wParms;
++usParms;
}
/* NOTE: 6 = HB_P_MPUSHBLOCK + HB_USHORT( size ) + HB_USHORT( wParams ) + _ENDBLOCK
* runtime compiled codeblock cannot reference local variables defined in a
* function
*/
ulSize = pCodeblock->lPCodePos + 6;
nSize = pCodeblock->lPCodePos + 6;
/* NOTE: HB_P_MPUSHBLOCK differs from HB_P_PUSHBLOCK - the pcode
* is stored in dynamic memory pool instead of static memory
*/
if( ulSize <= USHRT_MAX )
hb_macroGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_COMP_PARAM );
if( nSize <= USHRT_MAX )
hb_macroGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( nSize ), HB_HIBYTE( nSize ), HB_COMP_PARAM );
else
{
++ulSize;
hb_macroGenPCode4( HB_P_MPUSHBLOCKLARGE, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_ULBYTE( ulSize ), HB_COMP_PARAM );
++nSize;
hb_macroGenPCode4( HB_P_MPUSHBLOCKLARGE, HB_LOBYTE( nSize ), HB_HIBYTE( nSize ), HB_ULBYTE( nSize ), HB_COMP_PARAM );
}
hb_macroGenPCode2( HB_LOBYTE( wParms ), HB_HIBYTE( wParms ), HB_COMP_PARAM );
hb_macroGenPCode2( HB_LOBYTE( usParms ), HB_HIBYTE( usParms ), HB_COMP_PARAM );
/* copy a codeblock pcode buffer */
hb_macroGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, HB_COMP_PARAM );