2008-05-26 12:13 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* include/hbapi.h
   * source/vm/extend.c
     + Added hb_retc_null() which is equivalent to 
       hb_retc( NULL ) and will return an empty string.
       I opted for this because hb_retc( NULL ) usage is not 
       compatible with CA-Cl*pper _retc(), so it might create 
       problems when writing C code intended for both Clipper 
       and Harbour.

   * contrib/hbclipsm/stack.c
   * contrib/hbclipsm/environ.c
   * contrib/hbclipsm/status.c
   * contrib/hbclipsm/gauge.c
     % Optimizations.
     ; TOFIX: GAUGE*() still leaks and doesn't seem to function.

   * contrib/rddads/adsmgmnt.c
     % Optimizations (using hb_arraySet*()).
     ! Fixed typo in ADSMGGETOPENTABLES2().
This commit is contained in:
Viktor Szakats
2008-05-26 10:15:27 +00:00
parent 2940317c15
commit b5d578680c
8 changed files with 89 additions and 122 deletions

View File

@@ -8,6 +8,27 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-05-26 12:13 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* include/hbapi.h
* source/vm/extend.c
+ Added hb_retc_null() which is equivalent to
hb_retc( NULL ) and will return an empty string.
I opted for this because hb_retc( NULL ) usage is not
compatible with CA-Cl*pper _retc(), so it might create
problems when writing C code intended for both Clipper
and Harbour.
* contrib/hbclipsm/stack.c
* contrib/hbclipsm/environ.c
* contrib/hbclipsm/status.c
* contrib/hbclipsm/gauge.c
% Optimizations.
; TOFIX: GAUGE*() still leaks and doesn't seem to function.
* contrib/rddads/adsmgmnt.c
% Optimizations (using hb_arraySet*()).
! Fixed typo in ADSMGGETOPENTABLES2().
2008-05-26 11:26 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbmsql/make_b32.bat
* contrib/hbmsql/make_vc.bat

View File

@@ -66,7 +66,7 @@ HB_FUNC( FILEPATH )
hb_xfree( pFileName );
}
else
hb_retc( "" );
hb_retc( NULL );
}
/* FileBase( <cFile> ) --> cFileBase
@@ -80,7 +80,7 @@ HB_FUNC( FILEBASE )
hb_xfree( pFileName );
}
else
hb_retc( "" );
hb_retc( NULL );
}
/* FileExt( <cFile> ) --> cFileExt
@@ -93,11 +93,11 @@ HB_FUNC( FILEEXT )
if( pFileName->szExtension != NULL )
hb_retc( ( pFileName->szExtension ) + 1 ); /* Skip the dot */
else
hb_retc( "" );
hb_retc( NULL );
hb_xfree( pFileName );
}
else
hb_retc( "" );
hb_retc( NULL );
}
/* FileDrive( <cFile> ) --> cFileDrive
@@ -111,5 +111,5 @@ HB_FUNC( FILEDRIVE )
hb_xfree( pFileName );
}
else
hb_retc( "" );
hb_retc( NULL );
}

View File

@@ -78,54 +78,27 @@ static void hb_gaugeUpdate( PHB_ITEM pArray, float fPercent );
HB_FUNC( GAUGENEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( B_LEN ); /* Create array */
PHB_ITEM pItem;
pItem = hb_itemPutNL( NULL, ( ISNUM( B_TOP ) ? hb_parni( B_TOP ) : 0 ) );
hb_itemArrayPut( pReturn, B_TOP, pItem );
hb_itemRelease( pItem );
hb_arraySetNL( pReturn, B_TOP, hb_parni( B_TOP ) );
hb_arraySetNL( pReturn, B_LEFT, hb_parni( B_LEFT ) );
hb_arraySetNL( pReturn, B_BOTTOM,
ISNUM( B_BOTTOM ) ?
( hb_parni( B_BOTTOM ) < hb_parni( B_TOP ) + 2 ?
hb_parni( B_TOP ) + 2 : hb_parni( B_BOTTOM ) ) : 0 );
hb_arraySetNL( pReturn, B_RIGHT,
ISNUM( B_RIGHT ) ?
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 4 ?
hb_parni( B_LEFT ) + 4 : hb_parni( B_RIGHT ) ) : 0 );
hb_arraySetC( pReturn, B_BACKCOLOR, ISCHAR( B_BACKCOLOR ) ? hb_parc( B_BACKCOLOR ) : "W/N" );
hb_arraySetC( pReturn, B_BARCOLOR, ISCHAR( B_BARCOLOR ) ? hb_parc( B_BARCOLOR ) : "W+/N" );
hb_arraySetL( pReturn, B_DISPLAYNUM,
!( ISNUM( B_RIGHT ) &&
ISNUM( B_LEFT ) &&
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 9 ) ) );
hb_arraySetC( pReturn, B_BARCHAR, ISCHAR( B_BARCHAR ) ? hb_parc( B_BARCHAR ) : ( char * ) '\xdb' );
hb_arraySetNL( pReturn, B_PERCENT, 0 );
pItem = hb_itemPutNL( NULL, ( ISNUM( B_LEFT ) ? hb_parni( B_LEFT ) : 0 ) );
hb_itemArrayPut( pReturn, B_LEFT, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL,
( ISNUM( B_BOTTOM ) ?
( hb_parni( B_BOTTOM ) < hb_parni( B_TOP ) + 2 ?
hb_parni( B_TOP ) + 2 : hb_parni( B_BOTTOM ) ) : 0 ) );
hb_itemArrayPut( pReturn, B_BOTTOM, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL,
( ISNUM( B_RIGHT ) ?
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 4 ?
hb_parni( B_LEFT ) + 4 : hb_parni( B_RIGHT ) ) : 0 ) );
hb_itemArrayPut( pReturn, B_RIGHT, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BACKCOLOR ) ? hb_parc( B_BACKCOLOR ) : "W/N" ) );
hb_itemArrayPut( pReturn, B_BACKCOLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BARCOLOR ) ? hb_parc( B_BARCOLOR ) : "W+/N" ) );
hb_itemArrayPut( pReturn, B_BARCOLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutL( NULL, !( ISNUM( B_RIGHT ) &&
ISNUM( B_LEFT ) &&
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 9 ) ) );
hb_itemArrayPut( pReturn, B_DISPLAYNUM, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BARCHAR ) ? hb_parc( B_BARCHAR ) : ( char * ) '\xdb') );
hb_itemArrayPut( pReturn, B_BARCHAR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, 0 );
hb_itemArrayPut( pReturn, B_PERCENT, pItem );
hb_itemRelease( pItem );
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
hb_itemReturnRelease( pReturn );
}
/* GaugeDisplay( aGauge ) --> aGauge

View File

@@ -57,20 +57,15 @@
*/
HB_FUNC( STACKNEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( 0 ); /* Create array */
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
hb_itemReturnRelease( hb_itemArrayNew( 0 ) ); /* Create array */
}
/* StackPush( <aStack>, <xValue> ) --> <aStack>
*/
HB_FUNC( STACKPUSH )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
PHB_ITEM pAny = hb_param( 2, HB_IT_ANY );
hb_arrayAdd( pArray, pAny );
hb_arrayAdd( hb_param( 1, HB_IT_ARRAY ),
hb_param( 2, HB_IT_ANY ) );
}
/* StackPop( <aStack> ) --> <xValue>
@@ -90,17 +85,14 @@ HB_FUNC( STACKPOP )
hb_arraySize( pArray, HB_MAX( ulLen, 0 ) );
}
hb_itemReturn( pLast );
hb_itemRelease( pLast );
hb_itemReturnRelease( pLast );
}
/* StackIsEmpty( <aStack> ) --> <lEmpty>
*/
HB_FUNC( STACKISEMPTY )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
hb_retl( hb_arrayLen( pArray ) == 0 );
hb_retl( hb_arrayLen( hb_param( 1, HB_IT_ARRAY ) ) == 0 );
}
/* StackTop( <aStack> ) --> <xValue>
@@ -108,11 +100,9 @@ HB_FUNC( STACKISEMPTY )
*/
HB_FUNC( STACKTOP )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
PHB_ITEM pLast = hb_itemNew( NULL );
hb_arrayLast( pArray, pLast );
hb_arrayLast( hb_param( 1, HB_IT_ARRAY ), pLast );
hb_itemReturn( pLast );
hb_itemRelease( pLast );
hb_itemReturnRelease( pLast );
}

View File

@@ -68,26 +68,13 @@
HB_FUNC( STATUSNEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( ST_LEN ); /* Create array */
PHB_ITEM pItem;
pItem = hb_itemPutNL( NULL, ( ISNUM( ST_ROW ) ? hb_parni( ST_ROW ) : 0 ) );
hb_itemArrayPut( pReturn, ST_ROW, pItem );
hb_itemRelease( pItem );
hb_arraySetNL( pReturn, ST_ROW, hb_parni( ST_ROW ) );
hb_arraySetNL( pReturn, ST_COL, hb_parni( ST_COL ) );
hb_arraySetC( pReturn, ST_COLOR, ISCHAR( ST_COLOR ) ? hb_parc( ST_COLOR ) : "W+/N" );
hb_arraySetNL( pReturn, ST_CURRENT, 1 );
pItem = hb_itemPutNL( NULL, ( ISNUM( ST_COL ) ? hb_parni( ST_COL ) : 0 ) );
hb_itemArrayPut( pReturn, ST_COL, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( ST_COLOR ) ? hb_parc( ST_COLOR ) : "W+/N" ) );
hb_itemArrayPut( pReturn, ST_COLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, 1 );
hb_itemArrayPut( pReturn, ST_CURRENT, pItem );
hb_itemRelease( pItem );
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
hb_itemReturnRelease( pReturn );
}
/* StatusUpdate( <aStat> ) --> nil

View File

@@ -387,30 +387,24 @@ HB_FUNC( ADSMGGETUSERNAMES )
PHB_ITEM pArrayItm = hb_arrayGetItemPtr( pArray, ulCount );
hb_arrayNew( pArrayItm, 6 );
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 1 ),
( char * ) pastUserInfo[ ulCount ].aucUserName );
hb_itemPutNL( hb_arrayGetItemPtr( pArrayItm, 2 ),
pastUserInfo[ ulCount ].usConnNumber );
hb_arraySetC( pArrayItm, 1, ( char * ) pastUserInfo[ ulCount ].aucUserName );
hb_arraySetNL( pArrayItm, 2, pastUserInfo[ ulCount ].usConnNumber );
#if ADS_LIB_VERSION >= 600
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ),
( char * ) pastUserInfo[ ulCount ].aucAddress );
hb_arraySetC( pArrayItm, 3, ( char * ) pastUserInfo[ ulCount ].aucAddress );
#else
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ), NULL );
hb_arraySetC( pArrayItm, 3, NULL );
#endif
#if ADS_LIB_VERSION >= 800
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 4 ),
( char * ) pastUserInfo[ ulCount ].aucAuthUserName );
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 5 ),
( char * ) pastUserInfo[ ulCount ].aucOSUserLoginName );
hb_arraySetC( pArrayItm, 4, ( char * ) pastUserInfo[ ulCount ].aucAuthUserName );
hb_arraySetC( pArrayItm, 5, ( char * ) pastUserInfo[ ulCount ].aucOSUserLoginName );
#else
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 4 ), NULL );
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 5 ), NULL );
hb_arraySetC( pArrayItm, 4, NULL );
hb_arraySetC( pArrayItm, 5, NULL );
#endif
#if ADS_LIB_VERSION >= 810
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ),
( char * ) pastUserInfo[ ulCount ].aucTSAddress );
hb_arraySetC( pArrayItm, 6, ( char * ) pastUserInfo[ ulCount ].aucTSAddress );
#else
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ), NULL );
hb_arraySetC( pArrayItm, 6, NULL );
#endif
}
hb_itemReturnRelease( pArray );
@@ -496,7 +490,7 @@ HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnecti
UNSIGNED16 ulCount;
for( ulCount = 1; ulCount <= usArrayLen; ulCount++ )
hb_itemPutC( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), ( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName );
hb_arraySetC( pArray, ( ULONG ) ulCount, ( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName );
hb_itemReturnRelease( pArray );
}
@@ -534,10 +528,8 @@ HB_FUNC( ADSMGGETOPENTABLES2 ) /* nMaxNumberOfFilesToReturn, cUserName, nConnect
PHB_ITEM pArrayItm = hb_arrayGetItemPtr( pArray, ulCount );
hb_arrayNew( pArrayItm, 2 );
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ),
( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName );
hb_itemPutNI( hb_arrayGetItemPtr( pArrayItm, 2 ),
astOpenTableInfo[ ulCount - 1 ].usLockType ); /* Advantage locking mode */
hb_arraySetC( pArrayItm, 1, ( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName );
hb_arraySetNI( pArrayItm, 2, astOpenTableInfo[ ulCount - 1 ].usLockType ); /* Advantage locking mode */
}
hb_itemReturnRelease( pArray );
@@ -573,7 +565,7 @@ HB_FUNC( ADSMGGETOPENINDEXES ) /* nMaxNumberOfFilesToReturn, cTableName, cUserNa
UNSIGNED16 ulCount;
for( ulCount = 1; ulCount <= usArrayLen; ulCount++ )
hb_itemPutC( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), ( char * ) astOpenIndexInfo[ ulCount - 1 ].aucIndexName );
hb_arraySetC( pArray, ( ULONG ) ulCount, ( char * ) astOpenIndexInfo[ ulCount - 1 ].aucIndexName );
hb_itemReturnRelease( pArray );
}
@@ -608,7 +600,7 @@ HB_FUNC( ADSMGGETLOCKS )
UNSIGNED16 ulCount;
for( ulCount = 1; ulCount <= usArrayLen; ulCount++ )
hb_itemPutNL( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), astRecordInfo[ ulCount - 1 ].ulRecordNumber );
hb_arraySetNL( pArray, ( ULONG ) ulCount, astRecordInfo[ ulCount - 1 ].ulRecordNumber );
hb_itemReturnRelease( pArray );
}
@@ -644,21 +636,15 @@ HB_FUNC( ADSMGGETWORKERTHREADACTIVITY )
PHB_ITEM pArrayItm = hb_arrayGetItemPtr( pArray, ulCount );
hb_arrayNew( pArrayItm, 6 );
hb_itemPutNL( hb_arrayGetItemPtr( pArrayItm, 1 ),
astWorkerThreadActivity[ ulCount ].ulThreadNumber );
hb_itemPutNI( hb_arrayGetItemPtr( pArrayItm, 2 ),
astWorkerThreadActivity[ ulCount ].usOpCode );
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ),
( char * ) astWorkerThreadActivity[ ulCount ].aucUserName );
hb_itemPutNI( hb_arrayGetItemPtr( pArrayItm, 4 ),
astWorkerThreadActivity[ ulCount ].usConnNumber );
hb_itemPutNI( hb_arrayGetItemPtr( pArrayItm, 5 ),
astWorkerThreadActivity[ ulCount ].usReserved1 );
hb_arraySetNL( pArrayItm, 1, astWorkerThreadActivity[ ulCount ].ulThreadNumber );
hb_arraySetNI( pArrayItm, 2, astWorkerThreadActivity[ ulCount ].usOpCode );
hb_arraySetC( pArrayItm, 3, ( char * ) astWorkerThreadActivity[ ulCount ].aucUserName );
hb_arraySetNI( pArrayItm, 4, astWorkerThreadActivity[ ulCount ].usConnNumber );
hb_arraySetNI( pArrayItm, 5, astWorkerThreadActivity[ ulCount ].usReserved1 );
#if ADS_LIB_VERSION >= 800
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ),
( char * ) astWorkerThreadActivity[ ulCount ].aucOSUserLoginName );
hb_arraySetC( pArrayItm, 6, ( char * ) astWorkerThreadActivity[ ulCount ].aucOSUserLoginName );
#else
hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ), NULL );
hb_arraySetC( pArrayItm, 6, NULL );
#endif
}
hb_itemReturnRelease( pArray );

View File

@@ -603,6 +603,7 @@ extern HB_EXPORT LONGLONG hb_parnll( int iParam, ... ); /* retrieve a numeric
extern HB_EXPORT int hb_pcount( void ); /* returns the number of suplied parameters */
extern HB_EXPORT void hb_ret( void ); /* post a NIL return value */
extern HB_EXPORT void hb_retc( const char * szText ); /* returns a string */
extern HB_EXPORT void hb_retc_null( void ); /* returns an empty string */
extern HB_EXPORT void hb_retc_buffer( char * szText ); /* sames as above, but accepts an allocated buffer */
extern HB_EXPORT void hb_retc_const( const char * szText ); /* returns a string as a pcode based string */
extern HB_EXPORT void hb_retclen( const char * szText, ULONG ulLen ); /* returns a string with a specific length */
@@ -644,6 +645,7 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns
#define hb_ret() hb_itemClear( hb_stackReturnItem() )
#define hb_reta( ulLen ) hb_arrayNew( hb_stackReturnItem(), ulLen )
#define hb_retc( szText ) hb_itemPutC( hb_stackReturnItem(), szText )
#define hb_retc_null() hb_itemPutC( hb_stackReturnItem(), NULL )
#define hb_retc_buffer( szText ) hb_itemPutCPtr( hb_stackReturnItem(), szText, strlen( szText ) )
#define hb_retc_const( szText ) hb_itemPutCConst( hb_stackReturnItem(), szText )
#define hb_retclen( szText, ulLen ) hb_itemPutCL( hb_stackReturnItem(), szText, ulLen )

View File

@@ -734,6 +734,14 @@ HB_EXPORT void hb_retc( const char * szText )
hb_itemPutC( hb_stackReturnItem(), szText );
}
#undef hb_retc_null
HB_EXPORT void hb_retc_null( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retc_null()"));
hb_itemPutC( hb_stackReturnItem(), NULL );
}
#undef hb_retc_buffer
HB_EXPORT void hb_retc_buffer( char * szText )
{