From 5d696539858f7950e3a5fe8ea51fe4982376c1e8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sun, 12 Oct 2008 11:19:42 +0000 Subject: [PATCH] 2008-10-12 13:19 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbthread.h * casting cleanup * harbour/include/hbapigt.h * harbour/source/rtl/gtapi.c * harbour/source/rtl/scroll.c * harbour/source/rtl/console.c * harbour/source/rtl/box.c * changed hb_gtDrawBox() and hb_gtPutText() to operate on color number (index in some GTs) instead of color string * use int as color number (index) in hb_gtScrollEx() hb_gtBoxEx() * harbour/source/rtl/box.c % changed DISPBOX() with color and frame string to work as one GT atomic operation * harbour/source/vm/classes.c ! fixed profiler usage --- harbour/ChangeLog | 20 ++++++++++ harbour/include/hbapigt.h | 8 ++-- harbour/include/hbthread.h | 4 +- harbour/source/rtl/box.c | 75 +++++++++++++++++++++++------------- harbour/source/rtl/console.c | 10 ++++- harbour/source/rtl/gtapi.c | 48 +++++++++-------------- harbour/source/rtl/scroll.c | 12 ++---- harbour/source/vm/classes.c | 30 ++++++++++++--- 8 files changed, 131 insertions(+), 76 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index aa6d8301a1..65b6dadfbd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,26 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-12 13:19 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbthread.h + * casting cleanup + + * harbour/include/hbapigt.h + * harbour/source/rtl/gtapi.c + * harbour/source/rtl/scroll.c + * harbour/source/rtl/console.c + * harbour/source/rtl/box.c + * changed hb_gtDrawBox() and hb_gtPutText() to operate on color + number (index in some GTs) instead of color string + * use int as color number (index) in hb_gtScrollEx() hb_gtBoxEx() + + * harbour/source/rtl/box.c + % changed DISPBOX() with color and frame string to work as one + GT atomic operation + + * harbour/source/vm/classes.c + ! fixed profiler usage + 2008-10-11 21:49 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * bin/bld.bat * bin/bld_os2.cmd diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index a277dad02f..d02ba4fe1f 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -147,7 +147,7 @@ extern HB_EXPORT ERRCODE hb_gtUnlock( void ); extern HB_EXPORT ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame ); extern HB_EXPORT ERRCODE hb_gtBoxD( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); extern HB_EXPORT ERRCODE hb_gtBoxS( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); -extern HB_EXPORT ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame, const char * pszColor ); +extern HB_EXPORT ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame, int iColor ); extern HB_EXPORT ERRCODE hb_gtColorSelect( USHORT uiColorIndex ); extern HB_EXPORT int hb_gtColorToN( const char * szColorString ); extern HB_EXPORT ERRCODE hb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize ); @@ -189,7 +189,7 @@ extern HB_EXPORT ERRCODE hb_gtTone( double dFrequency, double dDuration ); extern HB_EXPORT ERRCODE hb_gtWrite( BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen ); -extern HB_EXPORT ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength, const char * pszColor ); +extern HB_EXPORT ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength, int iColor ); extern HB_EXPORT const char * hb_gtVersion( int iType ); extern HB_EXPORT ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen ); @@ -207,8 +207,8 @@ extern HB_EXPORT ERRCODE hb_gtGetScrChar( int iRow, int iCol, BYTE * pbColor, BY extern HB_EXPORT ERRCODE hb_gtPutScrChar( int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar ); extern HB_EXPORT ERRCODE hb_gtFlush( void ); extern HB_EXPORT ERRCODE hb_gtGetPosEx( int * piRow, int * piCol ); -extern HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols ); -extern HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor ); +extern HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, int iColor, int iChar, int iRows, int iCols ); +extern HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, int iColor ); extern HB_EXPORT int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor ); extern HB_EXPORT ERRCODE hb_gtGfxText( int iTop, int iLeft, const char * szText, int iColor, int iSize, int iWidth ); diff --git a/harbour/include/hbthread.h b/harbour/include/hbthread.h index 7918518536..c57f3713a2 100644 --- a/harbour/include/hbthread.h +++ b/harbour/include/hbthread.h @@ -103,7 +103,7 @@ HB_EXTERN_BEGIN # define HB_CRITICAL_NEED_INIT # endif # define HB_CRITICAL_GET(v) ( &( (v)->critical ) ) -# define HB_CRITICAL_INITVAL { ( HB_RAWCRITICAL_T ) 0 } +# define HB_CRITICAL_INITVAL { } # endif # if defined( PTHREAD_COND_INITIALIZER ) && !defined( HB_COND_NEED_INIT ) @@ -116,7 +116,7 @@ HB_EXTERN_BEGIN # define HB_COND_NEED_INIT # endif # define HB_COND_GET(v) ( &( (v)->cond ) ) -# define HB_COND_INITVAL ( ( HB_RAWCOND_T ) 0 ) +# define HB_COND_INITVAL { } # endif #elif defined( HB_OS_WIN_32 ) && ! defined( HB_WINCE ) diff --git a/harbour/source/rtl/box.c b/harbour/source/rtl/box.c index 021478a7f1..7e7d443e63 100644 --- a/harbour/source/rtl/box.c +++ b/harbour/source/rtl/box.c @@ -65,35 +65,49 @@ HB_FUNC( DISPBOX ) { const char * pszBox = hb_parc( 5 ); const char * pszColor = hb_parc( 6 ); - char szOldColor[ HB_CLRSTR_LEN ]; - - if( pszColor ) - { - hb_gtGetColorStr( szOldColor ); - hb_gtSetColorStr( pszColor ); - } if( pszBox ) - hb_gtBox( ( SHORT ) hb_itemGetNI( pTop ), - ( SHORT ) hb_itemGetNI( pLeft), - ( SHORT ) hb_itemGetNI( pBottom ), - ( SHORT ) hb_itemGetNI( pRight ), - ( BYTE * ) ( *pszBox ? pszBox : " " ) ); - - else if( hb_parni( 5 ) == 2 ) - hb_gtBoxD( ( SHORT ) hb_itemGetNI( pTop ), - ( SHORT ) hb_itemGetNI( pLeft), - ( SHORT ) hb_itemGetNI( pBottom ), - ( SHORT ) hb_itemGetNI( pRight ) ); + { + int iColor; + if( pszColor ) + iColor = hb_gtColorToN( pszColor ); + else if( ISNUM( 6 ) ) + iColor = hb_parni( 6 ); + else + iColor = -1; + hb_gtDrawBox( ( SHORT ) hb_itemGetNI( pTop ), + ( SHORT ) hb_itemGetNI( pLeft), + ( SHORT ) hb_itemGetNI( pBottom ), + ( SHORT ) hb_itemGetNI( pRight ), + ( BYTE * ) ( *pszBox ? pszBox : " " ), + iColor ); + } else - hb_gtBoxS( ( SHORT ) hb_itemGetNI( pTop ), - ( SHORT ) hb_itemGetNI( pLeft), - ( SHORT ) hb_itemGetNI( pBottom ), - ( SHORT ) hb_itemGetNI( pRight ) ); + { + char szOldColor[ HB_CLRSTR_LEN ]; - if( pszColor ) - hb_gtSetColorStr( szOldColor ); + if( pszColor ) + { + hb_gtGetColorStr( szOldColor ); + hb_gtSetColorStr( pszColor ); + } + + if( hb_parni( 5 ) == 2 ) + hb_gtBoxD( ( SHORT ) hb_itemGetNI( pTop ), + ( SHORT ) hb_itemGetNI( pLeft), + ( SHORT ) hb_itemGetNI( pBottom ), + ( SHORT ) hb_itemGetNI( pRight ) ); + + else + hb_gtBoxS( ( SHORT ) hb_itemGetNI( pTop ), + ( SHORT ) hb_itemGetNI( pLeft), + ( SHORT ) hb_itemGetNI( pBottom ), + ( SHORT ) hb_itemGetNI( pRight ) ); + + if( pszColor ) + hb_gtSetColorStr( szOldColor ); + } } } @@ -106,14 +120,23 @@ HB_FUNC( HB_DISPBOX ) if( pTop && pLeft && pBottom && pRight ) { - const char * pszColor = hb_parc( 6 ); const char * pszBox = hb_parc( 5 ); + const char * pszColor = hb_parc( 6 ); + int iColor; + + + if( pszColor ) + iColor = hb_gtColorToN( pszColor ); + else if( ISNUM( 6 ) ) + iColor = hb_parni( 6 ); + else + iColor = -1; hb_gtDrawBox( ( SHORT ) hb_itemGetNI( pTop ), ( SHORT ) hb_itemGetNI( pLeft), ( SHORT ) hb_itemGetNI( pBottom ), ( SHORT ) hb_itemGetNI( pRight ), ( BYTE * ) ( *pszBox ? pszBox : " " ), - pszColor ); + iColor ); } } diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 3775bbb759..a6b1176a7c 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -579,10 +579,18 @@ HB_FUNC( HB_DISPOUTAT ) char * pszString; ULONG ulLen; BOOL bFreeReq; + int iColor; pszString = hb_itemStringCon( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq ); - hb_gtPutText( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen, hb_parc( 4 ) ); + if( ISCHAR( 4 ) ) + iColor = hb_gtColorToN( hb_parc( 4 ) ); + else if( ISNUM( 6 ) ) + iColor = hb_parni( 6 ); + else + iColor = -1; + + hb_gtPutText( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen, iColor ); if( bFreeReq ) hb_xfree( pszString ); diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index bc60b4f0fd..97c0d9ed0b 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -243,24 +243,16 @@ HB_EXPORT ERRCODE hb_gtBoxS( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right ) return FAILURE; } -HB_EXPORT ERRCODE hb_gtDrawBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame, const char * pszColor ) +HB_EXPORT ERRCODE hb_gtDrawBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame, int iColor ) { PHB_GT pGT; - HB_TRACE(HB_TR_DEBUG, ("hb_gtBox(%hd, %hd, %hd, %hd, %p, %s)", Top, Left, Bottom, Right, pbyFrame, pszColor)); + HB_TRACE(HB_TR_DEBUG, ("hb_gtDrawBox(%hd, %hd, %hd, %hd, %p, %d)", Top, Left, Bottom, Right, pbyFrame, iColor)); pGT = hb_gt_Base(); if( pGT ) { - int iColor; - - if( pszColor ) - { - iColor = HB_GTSELF_COLORNUM( pGT, pszColor ); - if( iColor == -1 ) - iColor = HB_GTSELF_COLORNUM( pGT, "W/N" ); - } - else + if( iColor == -1 ) iColor = HB_GTSELF_GETCOLOR( pGT ); HB_GTSELF_BOX( pGT, Top, Left, Bottom, Right, pbyFrame, iColor ); @@ -781,27 +773,19 @@ HB_EXPORT ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols ) HB_EXPORT ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength, - const char * pszColor ) + int iColor ) { PHB_GT pGT; - HB_TRACE(HB_TR_DEBUG, ("hb_gtPutText(%hu, %hu, %p, %lu, %s)", uiRow, uiCol, pStr, ulLength, pszColor)); + HB_TRACE(HB_TR_DEBUG, ("hb_gtPutText(%hu, %hu, %p, %lu, %d)", uiRow, uiCol, pStr, ulLength, iColor)); pGT = hb_gt_Base(); if( pGT ) { - int iColor; - - if( pszColor ) - { - iColor = HB_GTSELF_COLORNUM( pGT, pszColor ); - if( iColor == -1 ) - iColor = HB_GTSELF_COLORNUM( pGT, "W/N" ); - } - else + if( iColor == -1 ) iColor = HB_GTSELF_GETCOLOR( pGT ); - HB_GTSELF_PUTTEXT( pGT, uiRow, uiCol, ( BYTE ) iColor, pStr, ulLength ); + HB_GTSELF_PUTTEXT( pGT, uiRow, uiCol, iColor, pStr, ulLength ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); @@ -1267,17 +1251,21 @@ HB_EXPORT ERRCODE hb_gtGetPosEx( int * piRow, int * piCol ) return FAILURE; } -HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols ) +HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, int iColor, int iChar, int iRows, int iCols ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gtScrollEx(%d, %d, %d, %d, %d, %hd, %d, %d)", iTop, iLeft, iBottom, iRight, bColor, bChar, iRows, iCols)); + HB_TRACE(HB_TR_DEBUG, ("hb_gtScrollEx(%d, %d, %d, %d, %d, %hd, %d, %d)", iTop, iLeft, iBottom, iRight, iColor, iChar, iRows, iCols)); if( iTop <= iBottom && iLeft <= iRight ) { PHB_GT pGT = hb_gt_Base(); if( pGT ) { + if( iColor == -1 ) + iColor = HB_GTSELF_GETCOLOR( pGT ); + if( iChar < 0 ) + iChar = HB_GTSELF_GETCLEARCHAR( pGT ); HB_GTSELF_SCROLL( pGT, iTop, iLeft, iBottom, iRight, - bColor, bChar, iRows, iCols ); + iColor, iChar, iRows, iCols ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); return SUCCESS; @@ -1286,16 +1274,18 @@ HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, B return FAILURE; } -HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor ) +HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, int iColor ) { PHB_GT pGT; - HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxEx(%d, %d, %d, %d, %p, %d)", iTop, iLeft, iBottom, iRight, pbyFrame, bColor)); + HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxEx(%d, %d, %d, %d, %p, %d)", iTop, iLeft, iBottom, iRight, pbyFrame, iColor)); pGT = hb_gt_Base(); if( pGT ) { - HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight, pbyFrame, bColor ); + if( iColor == -1 ) + iColor = HB_GTSELF_GETCOLOR( pGT ); + HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight, pbyFrame, iColor ); HB_GTSELF_SETPOS( pGT, iTop + 1, iLeft + 1 ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); diff --git a/harbour/source/rtl/scroll.c b/harbour/source/rtl/scroll.c index 2b41fea859..405370fbd2 100644 --- a/harbour/source/rtl/scroll.c +++ b/harbour/source/rtl/scroll.c @@ -160,27 +160,23 @@ HB_FUNC( HB_SCROLL ) if( ISNUM( 7 ) ) iColor = hb_parni( 7 ); else if( ISCHAR( 7 ) ) - { iColor = hb_gtColorToN( hb_parc( 7 ) ); - if( iColor == -1 ) - iColor = hb_gtColorToN( "W/N" ); - } else - iColor = hb_gtGetClearColor(); + iColor = -1; if( ISNUM( 8 ) ) iChar = hb_parni( 8 ); else if( ISCHAR( 8 ) ) iChar = ( UCHAR ) hb_parc( 8 )[0]; else - iChar = hb_gtGetClearChar(); + iChar = -1; hb_gtScrollEx( iTop, iLeft, iBottom, iRight, - ( BYTE ) iColor, - ( BYTE ) iChar, + iColor, + iChar, hb_parni( 5 ), /* Defaults to zero on bad type */ hb_parni( 6 ) ); /* Defaults to zero on bad type */ } diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 7a54d8a131..90bf38c99c 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -4505,13 +4505,31 @@ static HARBOUR hb___msgNull( void ) #ifndef HB_NO_PROFILER void hb_mthAddTime( ULONG ulClockTicks ) { - PMETHOD pMethod = s_pClasses[ hb_objGetClassH( hb_stackSelfItem() ) ]-> - pMethods; - if( pMethod ) + PHB_ITEM pObject = hb_stackSelfItem(); + PCLASS pClass = s_pClasses[ hb_objGetClassH( pObject ) ]; + + if( pClass ) { - pMethod += hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod; - pMethod->ulCalls++; - pMethod->ulTime += ulClockTicks; + PMETHOD pMethod = pClass->pMethods; + if( pMethod ) + { + pMethod += hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod; + pMethod->ulCalls++; + pMethod->ulTime += ulClockTicks; + return; + } + } + + if( HB_IS_BLOCK( pObject ) ) + { + PHB_SYMB pSym = hb_stackBaseItem()->item.asSymbol.value; + + if( pSym == &hb_symEval || pSym->pDynSym == hb_symEval.pDynSym ) + { + pSym->pDynSym->ulCalls++; + if( --pSym->pDynSym->ulRecurse == 0 ) + pSym->pDynSym->ulTime += ulClockTicks; + } } } #endif