diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9fefc44b33..85ac92e93c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,33 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-19 13:41 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * include/hbapi.h + * include/hbapiitm.h + * src/vm/itemapi.c + * src/vm/arrays.c + * src/vm/extend.c + + Added hb_storvns(). + + Added hb_parvns(). + ; TOFIX: hb_itemPutNS() gives these (not quite unexpected) mingw warnings: + --- + itemapi.c:993:8: warning: comparison between signed and unsigned integer expressions + itemapi.c:998:38: warning: comparison between signed and unsigned integer expressions + itemapi.c:1004:35: warning: comparison between signed and unsigned integer expressions + itemapi.c:1004:7: warning: comparison is always false due to limited range of data type + --- + + * src/rtl/philes.c + * src/rtl/mlcfunc.c + * src/rtl/rat.c + + Using size APIs. + % Also deleting '( HB_SIZE )' casts along the way. + + * src/rtl/oemansi.c + ! Cast to make Win64 happy. Quite interesting that almost no + Windows API don't support proper 64-bit strings, so here + Windows will be the limitation, not Harbour. + 2010-06-19 13:26 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/vm/extend.c ! Fixed another miss for prev rename. diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index b9c1f4b358..ab8be840bc 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -639,10 +639,10 @@ extern HB_EXPORT int hb_parni( int iParam ); /* retrieve a numeric para extern HB_EXPORT int hb_parnidef( int iParam, int iDefValue ); /* retrieve a numeric parameter as a integer, return default value if parameter isn't numeric */ extern HB_EXPORT long hb_parnl( int iParam ); /* retrieve a numeric parameter as a long */ extern HB_EXPORT long hb_parnldef( int iParam, long lDefValue ); /* retrieve a numeric parameter as a long, return default value if parameter isn't numeric */ -extern HB_EXPORT HB_MAXINT hb_parnint( int iParam ); /* retrieve a numeric parameter as a HB_MAXINT */ -extern HB_EXPORT HB_MAXINT hb_parnintdef( int iParam, HB_MAXINT lDefValue ); /* retrieve a numeric parameter as a HB_MAXINT, return default value if parameter isn't numeric */ extern HB_EXPORT HB_SIZE hb_parns( int iParam ); /* retrieve a numeric parameter as a HB_SIZE */ extern HB_EXPORT HB_SIZE hb_parnsdef( int iParam, HB_SIZE nDefValue ); /* retrieve a numeric parameter as a HB_SIZE, return default value if parameter isn't numeric */ +extern HB_EXPORT HB_MAXINT hb_parnint( int iParam ); /* retrieve a numeric parameter as a HB_MAXINT */ +extern HB_EXPORT HB_MAXINT hb_parnintdef( int iParam, HB_MAXINT lDefValue ); /* retrieve a numeric parameter as a HB_MAXINT, return default value if parameter isn't numeric */ extern HB_EXPORT void * hb_parptr( int iParam ); /* retrieve a parameter as a pointer */ extern HB_EXPORT void * hb_parptrGC( const HB_GC_FUNCS * pFuncs, int iParam ); /* retrieve a parameter as a pointer if it's a pointer to GC allocated block */ #ifndef HB_LONG_LONG_OFF @@ -662,6 +662,7 @@ extern HB_EXPORT int hb_parvl( int iParam, ... ); /* retrieve a logical extern HB_EXPORT double hb_parvnd( int iParam, ... ); /* retrieve a numeric parameter as a double */ extern HB_EXPORT int hb_parvni( int iParam, ... ); /* retrieve a numeric parameter as a integer */ extern HB_EXPORT long hb_parvnl( int iParam, ... ); /* retrieve a numeric parameter as a long */ +extern HB_EXPORT HB_SIZE hb_parvns( int iParam, ... ); /* retrieve a numeric parameter as a HB_SIZE */ extern HB_EXPORT HB_MAXINT hb_parvnint( int iParam, ... ); /* retrieve a numeric parameter as a HB_MAXINT */ extern HB_EXPORT void * hb_parvptr( int iParam, ... ); /* retrieve a parameter as a pointer */ extern HB_EXPORT void * hb_parvptrGC( const HB_GC_FUNCS * pFuncs, int iParam, ... ); /* retrieve a parameter as a pointer if it's a pointer to GC allocated block */ @@ -686,8 +687,8 @@ extern HB_EXPORT void hb_retl( int iTrueFalse ); /* returns a logical integer extern HB_EXPORT void hb_retnd( double dNumber ); /* returns a double */ extern HB_EXPORT void hb_retni( int iNumber ); /* returns a integer number */ extern HB_EXPORT void hb_retnl( long lNumber );/* returns a long number */ -extern HB_EXPORT void hb_retnint( HB_MAXINT lNumber );/* returns a long number */ extern HB_EXPORT void hb_retns( HB_SIZE nNumber );/* returns a size */ +extern HB_EXPORT void hb_retnint( HB_MAXINT lNumber );/* returns a long number */ extern HB_EXPORT void hb_retnlen( double dNumber, int iWidth, int iDec ); /* returns a double, with specific width and decimals */ extern HB_EXPORT void hb_retndlen( double dNumber, int iWidth, int iDec ); /* returns a double, with specific width and decimals */ extern HB_EXPORT void hb_retnilen( int iNumber, int iWidth ); /* returns a integer number, with specific width */ @@ -724,6 +725,7 @@ extern HB_EXPORT void hb_retnlllen( HB_LONGLONG lNumber, int iWidth ); /* retu #define hb_retnd( dNumber ) hb_itemPutND( hb_stackReturnItem(), dNumber ) #define hb_retni( iNumber ) hb_itemPutNI( hb_stackReturnItem(), iNumber ) #define hb_retnl( lNumber ) hb_itemPutNL( hb_stackReturnItem(), lNumber ) +#define hb_retns( nNumber ) hb_itemPutNS( hb_stackReturnItem(), nNumber ) #define hb_retnll( lNumber ) hb_itemPutNLL( hb_stackReturnItem(), lNumber ) #define hb_retnlen( dNumber, iWidth, iDec ) hb_itemPutNLen( hb_stackReturnItem(), dNumber, iWidth, iDec ) #define hb_retndlen( dNumber, iWidth, iDec ) hb_itemPutNDLen( hb_stackReturnItem(), dNumber, iWidth, iDec ) @@ -731,7 +733,6 @@ extern HB_EXPORT void hb_retnlllen( HB_LONGLONG lNumber, int iWidth ); /* retu #define hb_retnllen( lNumber, iWidth ) hb_itemPutNLLen( hb_stackReturnItem(), lNumber, iWidth ) #define hb_retnlllen( lNumber, iWidth ) hb_itemPutNLLLen( hb_stackReturnItem(), lNumber, iWidth ) #define hb_retnint( iNumber ) hb_itemPutNInt( hb_stackReturnItem(), iNumber ) -#define hb_retns( nNumber ) hb_itemPutNS( hb_stackReturnItem(), nNumber ) #define hb_retnintlen( lNumber, iWidth ) hb_itemPutNIntLen( hb_stackReturnItem(), lNumber, iWidth ) #define hb_retptr( pointer ) hb_itemPutPtr( hb_stackReturnItem(), pointer ) #define hb_retptrGC( pointer ) hb_itemPutPtrGC( hb_stackReturnItem(), pointer ) @@ -750,9 +751,9 @@ extern HB_EXPORT int hb_stortdt( long lJulian, long lMilliSec, int iParam ); extern HB_EXPORT int hb_storl( int iLogical, int iParam ); /* stores a logical integer on a variable by reference */ extern HB_EXPORT int hb_storni( int iValue, int iParam ); /* stores an integer on a variable by reference */ extern HB_EXPORT int hb_stornl( long lValue, int iParam ); /* stores a long on a variable by reference */ +extern HB_EXPORT int hb_storns( HB_SIZE nValue, int iParam ); /* stores a HB_SIZE on a variable by reference */ extern HB_EXPORT int hb_stornd( double dValue, int iParam ); /* stores a double on a variable by reference */ extern HB_EXPORT int hb_stornint( HB_MAXINT lValue, int iParam ); /* stores a HB_MAXINT on a variable by reference */ -extern HB_EXPORT int hb_storns( HB_SIZE nValue, int iParam ); /* stores a HB_SIZE on a variable by reference */ extern HB_EXPORT int hb_storptr( void * pointer, int iParam ); /* stores a pointer on a variable by reference */ extern HB_EXPORT int hb_storptrGC( void * pointer, int iParam ); /* stores a pointer to GC block on a variable by reference */ #ifndef HB_LONG_LONG_OFF @@ -769,6 +770,7 @@ extern HB_EXPORT int hb_storvtdt( long lJulian, long lMilliSec, int iParam, . extern HB_EXPORT int hb_storvl( int iLogical, int iParam, ... ); /* stores a logical integer on a variable by reference */ extern HB_EXPORT int hb_storvni( int iValue, int iParam, ... ); /* stores an integer on a variable by reference */ extern HB_EXPORT int hb_storvnl( long lValue, int iParam, ... ); /* stores a long on a variable by reference */ +extern HB_EXPORT int hb_storvns( HB_SIZE lValue, int iParam, ... ); /* stores a HB_SIZE on a variable by reference */ extern HB_EXPORT int hb_storvnd( double dValue, int iParam, ... ); /* stores a double on a variable by reference */ extern HB_EXPORT int hb_storvnint( HB_MAXINT lValue, int iParam, ... ); /* stores a HB_MAXINT on a variable by reference */ extern HB_EXPORT int hb_storvptr( void * pointer, int iParam, ... ); /* stores a pointer on a variable by reference */ @@ -802,8 +804,8 @@ extern HB_EXPORT PHB_SYMB hb_arrayGetSymbol( PHB_ITEM pArray, HB_SIZE ulInde extern HB_EXPORT HB_BOOL hb_arrayGetL( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the logical value contained on an array element */ extern HB_EXPORT int hb_arrayGetNI( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the int value contained on an array element */ extern HB_EXPORT long hb_arrayGetNL( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the long numeric value contained on an array element */ -extern HB_EXPORT HB_MAXINT hb_arrayGetNInt( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the HB_MAXINT value contained on an array element */ extern HB_EXPORT HB_SIZE hb_arrayGetNS( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the HB_SIZE value contained on an array element */ +extern HB_EXPORT HB_MAXINT hb_arrayGetNInt( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the HB_MAXINT value contained on an array element */ extern HB_EXPORT double hb_arrayGetND( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the double value contained on an array element */ extern HB_EXPORT char * hb_arrayGetDS( PHB_ITEM pArray, HB_SIZE ulIndex, char * szDate ); /* retrieves the date value contained in an array element */ extern HB_EXPORT long hb_arrayGetDL( PHB_ITEM pArray, HB_SIZE ulIndex ); /* retrieves the date value contained in an array element, as a long integer */ @@ -819,11 +821,11 @@ extern HB_EXPORT HB_BOOL hb_arraySetTDT( PHB_ITEM pArray, HB_SIZE ulIndex, extern HB_EXPORT HB_BOOL hb_arraySetL( PHB_ITEM pArray, HB_SIZE ulIndex, HB_BOOL fValue ); extern HB_EXPORT HB_BOOL hb_arraySetNI( PHB_ITEM pArray, HB_SIZE ulIndex, int iNumber ); extern HB_EXPORT HB_BOOL hb_arraySetNL( PHB_ITEM pArray, HB_SIZE ulIndex, long lNumber ); +extern HB_EXPORT HB_BOOL hb_arraySetNS( PHB_ITEM pArray, HB_SIZE ulIndex, HB_SIZE nNumber ); #ifndef HB_LONG_LONG_OFF extern HB_EXPORT HB_BOOL hb_arraySetNLL( PHB_ITEM pArray, HB_SIZE ulIndex, HB_LONGLONG llNumber ); #endif extern HB_EXPORT HB_BOOL hb_arraySetNInt( PHB_ITEM pArray, HB_SIZE ulIndex, HB_MAXINT lNumber ); -extern HB_EXPORT HB_BOOL hb_arraySetNS( PHB_ITEM pArray, HB_SIZE ulIndex, HB_SIZE nNumber ); extern HB_EXPORT HB_BOOL hb_arraySetND( PHB_ITEM pArray, HB_SIZE ulIndex, double dNumber ); extern HB_EXPORT HB_BOOL hb_arraySetC( PHB_ITEM pArray, HB_SIZE ulIndex, const char * szText ); extern HB_EXPORT HB_BOOL hb_arraySetCL( PHB_ITEM pArray, HB_SIZE ulIndex, const char * szText, HB_SIZE ulLen ); diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index 098693c6f2..65dc64e5bd 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -97,8 +97,8 @@ extern HB_EXPORT double hb_itemGetND ( PHB_ITEM pItem ); extern HB_EXPORT double hb_itemGetNDDec ( PHB_ITEM pItem, int * piDec ); extern HB_EXPORT int hb_itemGetNI ( PHB_ITEM pItem ); extern HB_EXPORT long hb_itemGetNL ( PHB_ITEM pItem ); -extern HB_EXPORT HB_MAXINT hb_itemGetNInt ( PHB_ITEM pItem ); extern HB_EXPORT HB_SIZE hb_itemGetNS ( PHB_ITEM pItem ); +extern HB_EXPORT HB_MAXINT hb_itemGetNInt ( PHB_ITEM pItem ); extern HB_EXPORT void hb_itemGetNLen ( PHB_ITEM pItem, int * piWidth, int * piDec ); extern HB_EXPORT void * hb_itemGetPtr ( PHB_ITEM pItem ); extern HB_EXPORT void * hb_itemGetPtrGC ( PHB_ITEM pItem, const HB_GC_FUNCS * pFuncs ); @@ -124,9 +124,9 @@ extern HB_EXPORT PHB_ITEM hb_itemPutL ( PHB_ITEM pItem, HB_BOOL bValue extern HB_EXPORT PHB_ITEM hb_itemPutND ( PHB_ITEM pItem, double dNumber ); extern HB_EXPORT PHB_ITEM hb_itemPutNI ( PHB_ITEM pItem, int iNumber ); extern HB_EXPORT PHB_ITEM hb_itemPutNL ( PHB_ITEM pItem, long lNumber ); +extern HB_EXPORT PHB_ITEM hb_itemPutNS ( PHB_ITEM pItem, HB_SIZE nNumber ); extern HB_EXPORT PHB_ITEM hb_itemPutNInt ( PHB_ITEM pItem, HB_MAXINT lNumber ); extern HB_EXPORT PHB_ITEM hb_itemPutNIntLen( PHB_ITEM pItem, HB_MAXINT lNumber, int iWidth ); -extern HB_EXPORT PHB_ITEM hb_itemPutNS ( PHB_ITEM pItem, HB_SIZE nNumber ); extern HB_EXPORT PHB_ITEM hb_itemPutNLen ( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ); extern HB_EXPORT PHB_ITEM hb_itemPutNDLen ( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ); extern HB_EXPORT PHB_ITEM hb_itemPutNDDec ( PHB_ITEM pItem, double dNumber, int iDec ); diff --git a/harbour/src/rtl/mlcfunc.c b/harbour/src/rtl/mlcfunc.c index 356217238e..c1542abbd9 100644 --- a/harbour/src/rtl/mlcfunc.c +++ b/harbour/src/rtl/mlcfunc.c @@ -227,7 +227,7 @@ static const char * hb_mlGetParams( int iParAdd, HB_SIZE * pulLen, { if( hb_parnd( 2 ) <= 0 ) return NULL; - * pulLineLength = hb_parnl( 2 ); + * pulLineLength = hb_parns( 2 ); } else * pulLineLength = 79; @@ -257,7 +257,7 @@ HB_FUNC( MEMOLINE ) &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); char * szLine; - HB_SIZE ulLine = hb_parnl( 3 ); + HB_SIZE ulLine = hb_parns( 3 ); HB_SIZE ulOffset = 0; HB_SIZE ulCols = 0; @@ -333,7 +333,7 @@ HB_FUNC( MLCOUNT ) } hb_xfree( pEOLs ); } - hb_retnl( ulLines ); + hb_retns( ulLines ); } HB_FUNC( MLPOS ) @@ -345,7 +345,7 @@ HB_FUNC( MLPOS ) const char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); - HB_SIZE ulLine = hb_parnl( 3 ); + HB_SIZE ulLine = hb_parns( 3 ); HB_SIZE ulOffset = 0; HB_SIZE ulCols = 0; @@ -361,7 +361,7 @@ HB_FUNC( MLPOS ) ++ulOffset; hb_xfree( pEOLs ); } - hb_retnl( ulOffset ); + hb_retns( ulOffset ); } HB_FUNC( MLCTOPOS ) @@ -373,8 +373,8 @@ HB_FUNC( MLCTOPOS ) const char * pszString = hb_mlGetParams( 2, &ulLen, &ulLineLength, &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); - HB_SIZE ulLine = hb_parnl( 3 ); - HB_SIZE ulCol = hb_parnl( 4 ); + HB_SIZE ulLine = hb_parns( 3 ); + HB_SIZE ulCol = hb_parns( 4 ); HB_SIZE ulOffset = 0; HB_SIZE ulCols = 0; @@ -394,7 +394,7 @@ HB_FUNC( MLCTOPOS ) hb_xfree( pEOLs ); } ++ulOffset; - hb_retnl( ulOffset ); + hb_retns( ulOffset ); } HB_FUNC( MPOSTOLC ) @@ -406,7 +406,7 @@ HB_FUNC( MPOSTOLC ) const char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); - HB_SIZE ulPos = hb_parnl( 3 ); + HB_SIZE ulPos = hb_parns( 3 ); HB_SIZE ulOffset = 0; HB_SIZE ulLine = 0; HB_SIZE ulCol = 0; @@ -456,6 +456,6 @@ HB_FUNC( MPOSTOLC ) hb_xfree( pEOLs ); } hb_reta( 2 ); - hb_storvnl( ulLine, -1, 1 ); - hb_storvnl( ulCol, -1, 2 ); + hb_storvns( ulLine, -1, 1 ); + hb_storvns( ulCol, -1, 2 ); } diff --git a/harbour/src/rtl/oemansi.c b/harbour/src/rtl/oemansi.c index 4001467e03..53727025bf 100644 --- a/harbour/src/rtl/oemansi.c +++ b/harbour/src/rtl/oemansi.c @@ -67,7 +67,7 @@ HB_FUNC( HB_ANSITOOEM ) if( pString ) #if defined( HB_OS_WIN ) { - int nLen = hb_itemGetCLen( pString ); + int nLen = ( int ) hb_itemGetCLen( pString ); const char * pszSrc = hb_itemGetCPtr( pString ); int nWideLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 ); @@ -99,7 +99,7 @@ HB_FUNC( HB_OEMTOANSI ) if( pString ) #if defined( HB_OS_WIN ) { - int nLen = hb_itemGetCLen( pString ); + int nLen = ( int ) hb_itemGetCLen( pString ); const char * pszSrc = hb_itemGetCPtr( pString ); int nWideLen = MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED, pszSrc, nLen, NULL, 0 ); diff --git a/harbour/src/rtl/philes.c b/harbour/src/rtl/philes.c index fd7d729130..3b07b48682 100644 --- a/harbour/src/rtl/philes.c +++ b/harbour/src/rtl/philes.c @@ -120,7 +120,7 @@ HB_FUNC( FREAD ) char * buffer; HB_SIZE ulSize; - ulRead = hb_parnl( 3 ); + ulRead = hb_parns( 3 ); /* NOTE: CA-Cl*pper determines the maximum size by calling _parcsiz() instead of _parclen(), this means that the maximum read length @@ -151,12 +151,12 @@ HB_FUNC( FWRITE ) if( HB_ISNUM( 3 ) ) { - HB_SIZE nWrite = ( HB_SIZE ) hb_parnl( 3 ); + HB_SIZE nWrite = hb_parns( 3 ); if( nWrite < nLen ) nLen = nWrite; } - hb_retnl( hb_fsWriteLarge( hb_numToHandle( hb_parnint( 1 ) ), hb_parc( 2 ), nLen ) ); + hb_retns( hb_fsWriteLarge( hb_numToHandle( hb_parnint( 1 ) ), hb_parc( 2 ), nLen ) ); uiError = hb_fsError(); } else @@ -237,7 +237,7 @@ HB_FUNC( FREADSTR ) if( HB_ISNUM( 1 ) && HB_ISNUM( 2 ) ) { - HB_SIZE ulToRead = ( HB_SIZE ) hb_parnl( 2 ); + HB_SIZE ulToRead = hb_parns( 2 ); if( ulToRead > 0 ) { diff --git a/harbour/src/rtl/rat.c b/harbour/src/rtl/rat.c index beae592c1c..eb90b83067 100644 --- a/harbour/src/rtl/rat.c +++ b/harbour/src/rtl/rat.c @@ -73,14 +73,14 @@ HB_FUNC( RAT ) lPos--; } - hb_retnl( bFound ? lPos + 2 : 0 ); + hb_retns( bFound ? lPos + 2 : 0 ); } else - hb_retnl( 0 ); + hb_retns( 0 ); } else /* This function never seems to raise an error */ - hb_retnl( 0 ); + hb_retns( 0 ); } HB_FUNC( HB_RAT ) @@ -100,7 +100,7 @@ HB_FUNC( HB_RAT ) if( HB_ISNUM( 3 ) ) { - lStart = hb_parnl( 3 ); + lStart = hb_parns( 3 ); if( lStart >= 1 ) --lStart; else @@ -111,7 +111,7 @@ HB_FUNC( HB_RAT ) if( HB_ISNUM( 4 ) ) { - HB_ISIZ lEnd = hb_parnl( 4 ) - 1; + HB_ISIZ lEnd = hb_parns( 4 ) - 1; if( lEnd < lPos ) lPos = lEnd; @@ -124,12 +124,12 @@ HB_FUNC( HB_RAT ) lPos--; } - hb_retnl( bFound ? lPos + 2 : 0 ); + hb_retns( bFound ? lPos + 2 : 0 ); } else - hb_retnl( 0 ); + hb_retns( 0 ); } else /* This function never seems to raise an error */ - hb_retnl( 0 ); + hb_retns( 0 ); } diff --git a/harbour/src/vm/arrays.c b/harbour/src/vm/arrays.c index 317d77cdb3..c6417c839a 100644 --- a/harbour/src/vm/arrays.c +++ b/harbour/src/vm/arrays.c @@ -584,6 +584,16 @@ long hb_arrayGetNL( PHB_ITEM pArray, HB_SIZE ulIndex ) return 0; } +HB_SIZE hb_arrayGetNS( PHB_ITEM pArray, HB_SIZE ulIndex ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNS(%p, %lu)", pArray, ulIndex)); + + if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) + return hb_itemGetNS( pArray->item.asArray.value->pItems + ulIndex - 1 ); + else + return 0; +} + #ifndef HB_LONG_LONG_OFF HB_LONGLONG hb_arrayGetNLL( PHB_ITEM pArray, HB_SIZE ulIndex ) { @@ -606,16 +616,6 @@ HB_MAXINT hb_arrayGetNInt( PHB_ITEM pArray, HB_SIZE ulIndex ) return 0; } -HB_SIZE hb_arrayGetNS( PHB_ITEM pArray, HB_SIZE ulIndex ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNS(%p, %lu)", pArray, ulIndex)); - - if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) - return hb_itemGetNS( pArray->item.asArray.value->pItems + ulIndex - 1 ); - else - return 0; -} - double hb_arrayGetND( PHB_ITEM pArray, HB_SIZE ulIndex ) { HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetND(%p, %lu)", pArray, ulIndex)); @@ -798,6 +798,19 @@ HB_BOOL hb_arraySetNL( PHB_ITEM pArray, HB_SIZE ulIndex, long lNumber ) return HB_FALSE; } +HB_BOOL hb_arraySetNS( PHB_ITEM pArray, HB_SIZE ulIndex, HB_SIZE nNumber ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNS(%p, %lu, %" HB_PFS "d)", pArray, ulIndex, nNumber)); + + if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) + { + hb_itemPutNS( pArray->item.asArray.value->pItems + ulIndex - 1, nNumber ); + return HB_TRUE; + } + else + return HB_FALSE; +} + #ifndef HB_LONG_LONG_OFF HB_BOOL hb_arraySetNLL( PHB_ITEM pArray, HB_SIZE ulIndex, HB_LONGLONG llNumber ) { @@ -826,19 +839,6 @@ HB_BOOL hb_arraySetNInt( PHB_ITEM pArray, HB_SIZE ulIndex, HB_MAXINT lNumber ) return HB_FALSE; } -HB_BOOL hb_arraySetNS( PHB_ITEM pArray, HB_SIZE ulIndex, HB_SIZE nNumber ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNS(%p, %lu, %" HB_PFS "d)", pArray, ulIndex, nNumber)); - - if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) - { - hb_itemPutNS( pArray->item.asArray.value->pItems + ulIndex - 1, nNumber ); - return HB_TRUE; - } - else - return HB_FALSE; -} - HB_BOOL hb_arraySetND( PHB_ITEM pArray, HB_SIZE ulIndex, double dNumber ) { HB_TRACE(HB_TR_DEBUG, ("hb_arraySetND(%p, %lu, %lf)", pArray, ulIndex, dNumber)); diff --git a/harbour/src/vm/extend.c b/harbour/src/vm/extend.c index 4d875ff161..b600da1dd6 100644 --- a/harbour/src/vm/extend.c +++ b/harbour/src/vm/extend.c @@ -587,6 +587,54 @@ long hb_parnldef( int iParam, long lDefValue ) return lDefValue; } +HB_SIZE hb_parns( int iParam ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_parns(%d)", iParam)); + + if( iParam >= -1 && iParam <= hb_pcount() ) + { + PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); + + if( HB_IS_BYREF( pItem ) ) + pItem = hb_itemUnRef( pItem ); + + if( HB_IS_LONG( pItem ) ) + return ( HB_SIZE ) pItem->item.asLong.value; + else if( HB_IS_INTEGER( pItem ) ) + return ( HB_SIZE ) pItem->item.asInteger.value; + else if( HB_IS_DOUBLE( pItem ) ) + return ( HB_SIZE ) pItem->item.asDouble.value; + } + + return 0; +} + +HB_SIZE hb_parnsdef( int iParam, HB_SIZE nDefValue ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_parnsdef(%d, %" HB_PFS "d)", iParam, nDefValue)); + + if( iParam >= -1 && iParam <= hb_pcount() ) + { + PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); + + if( HB_IS_BYREF( pItem ) ) + pItem = hb_itemUnRef( pItem ); + + if( HB_IS_LONG( pItem ) ) + return ( HB_SIZE ) pItem->item.asLong.value; + else if( HB_IS_INTEGER( pItem ) ) + return ( HB_SIZE ) pItem->item.asInteger.value; + else if( HB_IS_DOUBLE( pItem ) ) + return ( HB_SIZE ) pItem->item.asDouble.value; + } + + return nDefValue; +} + #ifndef HB_LONG_LONG_OFF HB_LONGLONG hb_parnll( int iParam ) { @@ -673,54 +721,6 @@ HB_MAXINT hb_parnintdef( int iParam, HB_MAXINT lDefValue ) return lDefValue; } -HB_SIZE hb_parns( int iParam ) -{ - HB_STACK_TLS_PRELOAD - - HB_TRACE(HB_TR_DEBUG, ("hb_parns(%d)", iParam)); - - if( iParam >= -1 && iParam <= hb_pcount() ) - { - PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); - - if( HB_IS_BYREF( pItem ) ) - pItem = hb_itemUnRef( pItem ); - - if( HB_IS_LONG( pItem ) ) - return ( HB_SIZE ) pItem->item.asLong.value; - else if( HB_IS_INTEGER( pItem ) ) - return ( HB_SIZE ) pItem->item.asInteger.value; - else if( HB_IS_DOUBLE( pItem ) ) - return ( HB_SIZE ) pItem->item.asDouble.value; - } - - return 0; -} - -HB_SIZE hb_parnsdef( int iParam, HB_SIZE nDefValue ) -{ - HB_STACK_TLS_PRELOAD - - HB_TRACE(HB_TR_DEBUG, ("hb_parnsdef(%d, %" HB_PFS "d)", iParam, nDefValue)); - - if( iParam >= -1 && iParam <= hb_pcount() ) - { - PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); - - if( HB_IS_BYREF( pItem ) ) - pItem = hb_itemUnRef( pItem ); - - if( HB_IS_LONG( pItem ) ) - return ( HB_SIZE ) pItem->item.asLong.value; - else if( HB_IS_INTEGER( pItem ) ) - return ( HB_SIZE ) pItem->item.asInteger.value; - else if( HB_IS_DOUBLE( pItem ) ) - return ( HB_SIZE ) pItem->item.asDouble.value; - } - - return nDefValue; -} - void * hb_parptr( int iParam ) { HB_STACK_TLS_PRELOAD @@ -1220,6 +1220,41 @@ long hb_parvnl( int iParam, ... ) return 0; } +HB_SIZE hb_parvns( int iParam, ... ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_parvns(%d, ...)", iParam)); + + if( iParam >= -1 && iParam <= hb_pcount() ) + { + PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); + + if( HB_IS_BYREF( pItem ) ) + pItem = hb_itemUnRef( pItem ); + + if( HB_IS_LONG( pItem ) ) + return ( HB_SIZE ) pItem->item.asLong.value; + else if( HB_IS_INTEGER( pItem ) ) + return ( HB_SIZE ) pItem->item.asInteger.value; + else if( HB_IS_DOUBLE( pItem ) ) + return ( HB_SIZE ) pItem->item.asDouble.value; + else if( HB_IS_ARRAY( pItem ) ) + { + va_list va; + HB_SIZE ulArrayIndex; + + va_start( va, iParam ); + ulArrayIndex = va_arg( va, HB_SIZE ); + va_end( va ); + + return hb_arrayGetNS( pItem, ulArrayIndex ); + } + } + + return 0; +} + #ifndef HB_LONG_LONG_OFF HB_LONGLONG hb_parvnll( int iParam, ... ) { @@ -1542,6 +1577,16 @@ void hb_retnl( long lNumber ) hb_itemPutNL( hb_stackReturnItem(), lNumber ); } +#undef hb_retns +void hb_retns( HB_SIZE nNumber ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_retns(%" HB_PFS "d )", nNumber)); + + hb_itemPutNInt( hb_stackReturnItem(), nNumber ); +} + #ifndef HB_LONG_LONG_OFF #undef hb_retnll void hb_retnll( HB_LONGLONG llNumber ) @@ -1564,16 +1609,6 @@ void hb_retnint( HB_MAXINT lNumber ) hb_itemPutNInt( hb_stackReturnItem(), lNumber ); } -#undef hb_retns -void hb_retns( HB_SIZE nNumber ) -{ - HB_STACK_TLS_PRELOAD - - HB_TRACE(HB_TR_DEBUG, ("hb_retns(%" HB_PFS "d )", nNumber)); - - hb_itemPutNInt( hb_stackReturnItem(), nNumber ); -} - #undef hb_retnlen void hb_retnlen( double dNumber, int iWidth, int iDec ) { @@ -1933,6 +1968,31 @@ int hb_stornl( long lValue, int iParam ) return 0; } +int hb_storns( HB_SIZE nValue, int iParam ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_storns(%" HB_PFS "d, %d)", nValue, iParam)); + + if( iParam == -1 ) + { + hb_itemPutNS( hb_stackReturnItem(), nValue ); + return 1; + } + else if( iParam >= 0 && iParam <= hb_pcount() ) + { + PHB_ITEM pItem = hb_stackItemFromBase( iParam ); + + if( HB_IS_BYREF( pItem ) ) + { + hb_itemPutNS( hb_itemUnRef( pItem ), nValue ); + return 1; + } + } + + return 0; +} + #ifndef HB_LONG_LONG_OFF int hb_stornll( HB_LONGLONG llValue, int iParam ) { @@ -1985,31 +2045,6 @@ int hb_stornint( HB_MAXINT lValue, int iParam ) return 0; } -int hb_storns( HB_SIZE nValue, int iParam ) -{ - HB_STACK_TLS_PRELOAD - - HB_TRACE(HB_TR_DEBUG, ("hb_storns(%" HB_PFS "d, %d)", nValue, iParam)); - - if( iParam == -1 ) - { - hb_itemPutNS( hb_stackReturnItem(), nValue ); - return 1; - } - else if( iParam >= 0 && iParam <= hb_pcount() ) - { - PHB_ITEM pItem = hb_stackItemFromBase( iParam ); - - if( HB_IS_BYREF( pItem ) ) - { - hb_itemPutNS( hb_itemUnRef( pItem ), nValue ); - return 1; - } - } - - return 0; -} - int hb_stornd( double dNumber, int iParam ) { HB_STACK_TLS_PRELOAD @@ -2421,6 +2456,39 @@ int hb_storvnl( long lValue, int iParam, ... ) return 0; } +int hb_storvns( HB_SIZE nValue, int iParam, ... ) +{ + HB_STACK_TLS_PRELOAD + + HB_TRACE(HB_TR_DEBUG, ("hb_storvns(%" HB_PFS "d, %d, ...)", nValue, iParam)); + + if( iParam >= -1 && iParam <= hb_pcount() ) + { + PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam ); + HB_BOOL bByRef = HB_IS_BYREF( pItem ); + + if( bByRef ) + pItem = hb_itemUnRef( pItem ); + + if( HB_IS_ARRAY( pItem ) ) + { + int iRetVal; + va_list va; + va_start( va, iParam ); + iRetVal = hb_arraySetNS( pItem, va_arg( va, HB_SIZE ), nValue ) ? 1 : 0; + va_end( va ); + return iRetVal; + } + else if( bByRef || iParam == -1 ) + { + hb_itemPutNS( pItem, nValue ); + return 1; + } + } + + return 0; +} + #ifndef HB_LONG_LONG_OFF int hb_storvnll( HB_LONGLONG llValue, int iParam, ... ) { diff --git a/harbour/src/vm/itemapi.c b/harbour/src/vm/itemapi.c index 81b89fece0..506f751173 100644 --- a/harbour/src/vm/itemapi.c +++ b/harbour/src/vm/itemapi.c @@ -647,6 +647,25 @@ long hb_itemGetNL( PHB_ITEM pItem ) return 0; } +HB_SIZE hb_itemGetNS( PHB_ITEM pItem ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNS(%p)", pItem)); + + if( pItem ) + { + if( HB_IS_LONG( pItem ) ) + return ( HB_SIZE ) pItem->item.asLong.value; + + else if( HB_IS_INTEGER( pItem ) ) + return ( HB_SIZE ) pItem->item.asInteger.value; + + else if( HB_IS_DOUBLE( pItem ) ) + return ( HB_SIZE ) pItem->item.asDouble.value; + } + + return 0; +} + HB_MAXINT hb_itemGetNInt( PHB_ITEM pItem ) { HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNL(%p)", pItem)); @@ -670,25 +689,6 @@ HB_MAXINT hb_itemGetNInt( PHB_ITEM pItem ) return 0; } -HB_SIZE hb_itemGetNS( PHB_ITEM pItem ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNS(%p)", pItem)); - - if( pItem ) - { - if( HB_IS_LONG( pItem ) ) - return ( HB_SIZE ) pItem->item.asLong.value; - - else if( HB_IS_INTEGER( pItem ) ) - return ( HB_SIZE ) pItem->item.asInteger.value; - - else if( HB_IS_DOUBLE( pItem ) ) - return ( HB_SIZE ) pItem->item.asDouble.value; - } - - return 0; -} - #ifndef HB_LONG_LONG_OFF HB_LONGLONG hb_itemGetNLL( PHB_ITEM pItem ) { @@ -978,6 +978,35 @@ PHB_ITEM hb_itemPutNL( PHB_ITEM pItem, long lNumber ) return pItem; } +PHB_ITEM hb_itemPutNS( PHB_ITEM pItem, HB_SIZE nNumber ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNS(%p, %" HB_PFS "d)", pItem, nNumber)); + + if( pItem ) + { + if( HB_IS_COMPLEX( pItem ) ) + hb_itemClear( pItem ); + } + else + pItem = hb_itemNew( NULL ); + + if( HB_LIM_INT( nNumber ) ) + { + pItem->type = HB_IT_INTEGER; + pItem->item.asInteger.value = ( int ) nNumber; + /* EXP limit used intentionally */ + pItem->item.asInteger.length = HB_INT_EXPLENGTH( nNumber ); + } + else + { + pItem->type = HB_IT_LONG; + pItem->item.asLong.value = nNumber; + pItem->item.asLong.length = HB_LONG_LENGTH( nNumber ); + } + + return pItem; +} + #ifndef HB_LONG_LONG_OFF PHB_ITEM hb_itemPutNLL( PHB_ITEM pItem, HB_LONGLONG llNumber ) { @@ -1052,35 +1081,6 @@ PHB_ITEM hb_itemPutNIntLen( PHB_ITEM pItem, HB_MAXINT lNumber, int iWidth ) } } -PHB_ITEM hb_itemPutNS( PHB_ITEM pItem, HB_SIZE nNumber ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNS(%p, %" HB_PFS "d)", pItem, nNumber)); - - if( pItem ) - { - if( HB_IS_COMPLEX( pItem ) ) - hb_itemClear( pItem ); - } - else - pItem = hb_itemNew( NULL ); - - if( HB_LIM_INT( nNumber ) ) - { - pItem->type = HB_IT_INTEGER; - pItem->item.asInteger.value = ( int ) nNumber; - /* EXP limit used intentionally */ - pItem->item.asInteger.length = HB_INT_EXPLENGTH( nNumber ); - } - else - { - pItem->type = HB_IT_LONG; - pItem->item.asLong.value = nNumber; - pItem->item.asLong.length = HB_LONG_LENGTH( nNumber ); - } - - return pItem; -} - PHB_ITEM hb_itemPutNLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec ) { HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNLen(%p, %lf, %d, %d)", pItem, dNumber, iWidth, iDec));