diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e20db186ad..a90f0c5c74 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,32 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + * fixed handling of sweeper functions + * there is no need to call hb_UnregisterSweep - this + is done automatically inside hb_gcFree and during + garbage collecting + +2006-06-26 15:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtgui/Makefile + * harbour/source/rtl/gtgui/gtgui.c + + harbour/source/rtl/gtgui/gtdef.c + + added GT version info + * modified the hack which overwrite the default GT name + Now original GTGUI is always present and only separate + file add linker bindings. It will be cleaner solution which + will allow to use REQUEST HB_GT_GUI in valid programs and + libraries. + + * harbour/source/rtl/gtwin/gtwin.c + * indenting + + * harbour/source/vm/garbage.c + * minor modification: use HB_GC_PTR() to take HB_GRABAGE pointer + + added alternate code for sweep function execution - disabled by + default, maybe it will be used when we agree the sweep function + behavior + + * harbour/contrib/rdd_ads/ads1.c * BCC warnings clean-up - synced with xHarbour * harbour/source/rtl/empty.c diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 9b427f3c45..3ccf2d83f8 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -833,7 +833,7 @@ static ERRCODE adsGoTop( ADSAREAP pArea ) static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLast ) { - UNSIGNED32 u32Result, u32RecNo = 0, u32NewRec; + UNSIGNED32 u32RecNo = 0, u32NewRec; UNSIGNED16 u16SeekType = ( bSoftSeek ) ? ADS_SOFTSEEK : ADS_HARDSEEK, u16KeyType, u16Found, u16KeyLen; UNSIGNED8 *pszKey; @@ -897,8 +897,8 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin if( bFindLast ) { - u32Result = AdsSeekLast( pArea->hOrdCurrent, - pszKey, u16KeyLen, u16KeyType, &u16Found ); + AdsSeekLast( pArea->hOrdCurrent, + pszKey, u16KeyLen, u16KeyType, &u16Found ); if( bSoftSeek && ! u16Found ) { UNSIGNED16 u16Eof; @@ -906,8 +906,8 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin /* in such case ADS set record at EOF position so we should make normal soft seek and then skip -1 to emulate Clipper behavior, Druzus */ - u32Result = AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, - u16KeyType, u16SeekType, &u16Found ); + AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, + u16KeyType, u16SeekType, &u16Found ); AdsAtEOF( pArea->hTable, &u16Eof ); if( !u16Eof ) @@ -918,8 +918,8 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin } else { - u32Result = AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, - u16KeyType, u16SeekType, &u16Found ); + AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, + u16KeyType, u16SeekType, &u16Found ); } hb_adsUpdateAreaFlags( pArea ); @@ -2063,7 +2063,7 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else { ulRetVal = AdsSetBinary( pArea->hTable, ADSFIELD( uiIndex ), - ADS_BINARY, ulLen, 0, + ADS_BINARY, ulLen, 0, (UNSIGNED8*) szRet, ulLen ); } hb_adsOemAnsiFree( szRet ); diff --git a/harbour/source/rtl/empty.c b/harbour/source/rtl/empty.c index 25447f5bbf..d8e3e2e55a 100644 --- a/harbour/source/rtl/empty.c +++ b/harbour/source/rtl/empty.c @@ -96,6 +96,10 @@ HB_FUNC( EMPTY ) hb_retl( hb_itemGetPtr( pItem ) == NULL ); break; + case HB_IT_SYMBOL: + hb_retl( hb_itemGetSymbol( pItem ) == NULL ); + break; + default: hb_retl( TRUE ); break; diff --git a/harbour/source/rtl/gtgui/Makefile b/harbour/source/rtl/gtgui/Makefile index a89ac9541a..46378b0d45 100644 --- a/harbour/source/rtl/gtgui/Makefile +++ b/harbour/source/rtl/gtgui/Makefile @@ -6,6 +6,7 @@ ROOT = ../../../ C_SOURCES=\ gtgui.c \ + gtdef.c \ LIBNAME=gtgui diff --git a/harbour/source/rtl/gtgui/gtdef.c b/harbour/source/rtl/gtgui/gtdef.c new file mode 100644 index 0000000000..62b3e75ecd --- /dev/null +++ b/harbour/source/rtl/gtgui/gtdef.c @@ -0,0 +1,91 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Mini GT for GUI programs. + * Now it supports only low level TONE and CLIPBOARD code for W32 + * + * Copyright 2006 Przemyslaw Czerpak + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + + +/* NOTE: User programs should never call this layer directly! */ + + +#include "hbapi.h" + +/* + * This GT is called GUI but we introduce a hack to make + * Windows users happy ;-) and we will add aliased name equal + * to the default GT REQUESTed by our RTL library, [druzus] + */ + +#if defined( HB_OS_WIN_32 ) + +#if defined(HB_GT_DEFAULT) +# define HB_GT_NAME HB_GT_DEFAULT +#elif defined(HB_GT_LIB) +# define HB_GT_NAME HB_GT_LIB +#else +# define HB_GT_NAME WIN +#endif + +/* Small trick to check if the default GT is not already set to GUI */ +#define GUI 1 +#define gui 1 + +#if HB_GT_NAME + 1 == 1 + +#undef GUI +#undef gui + +#include "hbgtcore.h" + +HB_GT_REQUEST( GUI ); +HB_GT_ANNOUNCE( HB_GT_NAME ); +#endif + +#endif diff --git a/harbour/source/rtl/gtgui/gtgui.c b/harbour/source/rtl/gtgui/gtgui.c index d088a94b7b..7982c9e656 100644 --- a/harbour/source/rtl/gtgui/gtgui.c +++ b/harbour/source/rtl/gtgui/gtgui.c @@ -54,33 +54,9 @@ /* NOTE: User programs should never call this layer directly! */ - -#define HB_OS_WIN_32_USED -#include "hbapi.h" - - -/* - * This GT should be called GUI but we introduce a hack to make - * Windows users happy ;-) and we will change its name to the - * one used by default GT REQUESTed by our RTL library, [druzus] - */ - -#if defined( HB_OS_WIN_32 ) - -#if defined(HB_GT_DEFAULT) -# define HB_GT_NAME HB_GT_DEFAULT -#elif defined(HB_GT_LIB) -# define HB_GT_NAME HB_GT_LIB -#else -# define HB_GT_NAME WIN -#endif - -#else - #define HB_GT_NAME GUI -#endif - +#define HB_OS_WIN_32_USED #include "hbgtcore.h" #include "hbinit.h" #include "hbapiitm.h" @@ -90,6 +66,18 @@ static HB_GT_FUNCS SuperTable; #define HB_GTSUPER (&SuperTable) +/* *********************************************************************** */ + +static char * hb_gt_gui_Version( int iType ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_gui_Version(%d)", iType ) ); + + if ( iType == 0 ) + return HB_GT_DRVNAME( HB_GT_NAME ); + + return "Harbour Terminal: Strep GT driver for W32 GUI programs"; +} + /* *********************************************************************** */ /* dDuration is in 'Ticks' (18.2 per second) */ static void hb_gt_gui_Tone( double dFrequency, double dDuration ) @@ -148,6 +136,7 @@ static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable)); + pFuncTable->Version = hb_gt_gui_Version; pFuncTable->Tone = hb_gt_gui_Tone; pFuncTable->Info = hb_gt_gui_Info; diff --git a/harbour/source/rtl/gtwin/gtwin.c b/harbour/source/rtl/gtwin/gtwin.c index e991f2aee5..a1bbe964a9 100644 --- a/harbour/source/rtl/gtwin/gtwin.c +++ b/harbour/source/rtl/gtwin/gtwin.c @@ -840,7 +840,7 @@ static char * hb_gt_win_Version( int iType ) if ( iType == 0 ) return HB_GT_DRVNAME( HB_GT_NAME ); - return "Harbour Terminal: Win32 buffered console"; + return "Harbour Terminal: Win32 buffered console"; } /* *********************************************************************** */ diff --git a/harbour/source/vm/garbage.c b/harbour/source/vm/garbage.c index 6ec395bfd1..b6fc283ac4 100644 --- a/harbour/source/vm/garbage.c +++ b/harbour/source/vm/garbage.c @@ -416,27 +416,15 @@ void hb_gcItemRef( HB_ITEM_PTR pItem ) void hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ) { HB_GARBAGE_EXTERN_PTR pExt; - HB_GARBAGE_PTR pAlloc; - + pExt = ( HB_GARBAGE_EXTERN_PTR ) hb_xgrab( sizeof( HB_GARBAGE_EXTERN ) ); pExt->pFunc = pSweep; pExt->pBlock = Cargo; - pExt->pNext = NULL; - - /* set user sweep flag */ - pAlloc = ( HB_GARBAGE_PTR ) ( ( BYTE * ) Cargo - HB_GARBAGE_SIZE ); - pAlloc->used ^= HB_GC_USERSWEEP; + pExt->pNext = s_pSweepExtern; + s_pSweepExtern = pExt; - if( s_pSweepExtern == NULL ) - { - s_pSweepExtern = pExt; - } - else - { - pExt->pNext = s_pSweepExtern; - s_pSweepExtern = pExt; - } - + /* set user sweep flag */ + HB_GC_PTR( Cargo )->used ^= HB_GC_USERSWEEP; } void hb_gcUnregisterSweep( void * Cargo ) @@ -449,12 +437,11 @@ void hb_gcUnregisterSweep( void * Cargo ) { if( pExt->pBlock == Cargo ) { - HB_GARBAGE_PTR pAlloc; - + HB_GARBAGE_PTR pAlloc = HB_GC_PTR( Cargo ); + /* clear user sweep flag */ - pAlloc = ( HB_GARBAGE_PTR ) ( ( BYTE * ) Cargo - HB_GARBAGE_SIZE ); pAlloc->used &= ~ HB_GC_USERSWEEP; - + if( pExt == s_pSweepExtern ) { s_pSweepExtern = pExt->pNext; @@ -463,7 +450,7 @@ void hb_gcUnregisterSweep( void * Cargo ) { pPrev->pNext = pExt->pNext; } - + hb_xfree( (void *) pExt ); pExt = NULL; } @@ -503,27 +490,55 @@ void hb_gcCollectAll( void ) hb_memvarsIsMemvarRef(); hb_gcItemRef( hb_stackReturnItem() ); hb_clsIsClassRef(); - + +#if 1 if( s_pSweepExtern ) { HB_GARBAGE_EXTERN_PTR pExt = s_pSweepExtern; - + do { if( ( pExt->pFunc )( pExt->pBlock ) ) { /* block is still used */ - pAlloc = ( HB_GARBAGE_PTR ) ( ( BYTE * ) pExt->pBlock - HB_GARBAGE_SIZE ); + pAlloc = HB_GC_PTR( pExt->pBlock ); pAlloc->used ^= HB_GC_USED_FLAG; } pExt = pExt->pNext; } while( pExt ); } +#else + /* alternate version which unregister sweep functions in one pass */ + if( s_pSweepExtern ) + { + HB_GARBAGE_EXTERN_PTR * pExtPtr = &s_pSweepExtern; + + do + { + pAlloc = HB_GC_PTR( ( * pExtPtr )->pBlock ); + + if( ( ( * pExtPtr )->pFunc )( ( * pExtPtr )->pBlock ) ) + { + /* block is still used */ + pAlloc->used ^= HB_GC_USED_FLAG; + pExtPtr = &( * pExtPtr )->pNext; + } + else + { + HB_GARBAGE_EXTERN_PTR pFree = * pExtPtr; + pAlloc->used &= ~HB_GC_USERSWEEP; + * pExtPtr = ( * pExtPtr )->pNext; + hb_xfree( pFree ); + } + } + while( * pExtPtr ); + } +#endif /* check list of locked block for blocks referenced from * locked block - */ + */ if( s_pLockedBlock ) { pAlloc = s_pLockedBlock;