2008-09-20 05:37 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/common.mak
  * harbour/source/rdd/Makefile
    ! restored dbdetach.* in makefiles

  + harbour/source/rdd/dbdetach.c
    + added file I forgot to add in previous commit

  * harbour/source/vm/thread.c
    + added support for using function name as string in HB_THREADSTART()
    + added support for thread attributes. They will be used in the future.
This commit is contained in:
Przemyslaw Czerpak
2008-09-20 03:37:41 +00:00
parent 0705a60aeb
commit 2f2dc484a8
5 changed files with 225 additions and 6 deletions

View File

@@ -8,6 +8,18 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-09-20 05:37 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/common.mak
* harbour/source/rdd/Makefile
! restored dbdetach.* in makefiles
+ harbour/source/rdd/dbdetach.c
+ added file I forgot to add in previous commit
* harbour/source/vm/thread.c
+ added support for using function name as string in HB_THREADSTART()
+ added support for thread attributes. They will be used in the future.
2008-09-19 21:28 UTC-0500 Teo Fonrouge (teo/at/windtelsoft/dot/com)
* common.mak
* source/rdd/Makefile

View File

@@ -890,6 +890,7 @@ RDD_LIB_OBJS = \
$(OBJ_DIR)\dbcmd53$(OBJEXT) \
$(OBJ_DIR)\dbcmdhb$(OBJEXT) \
$(OBJ_DIR)\dbcmdx$(OBJEXT) \
$(OBJ_DIR)\dbdetach$(OBJEXT) \
$(OBJ_DIR)\dbdrop$(OBJEXT) \
$(OBJ_DIR)\dbexists$(OBJEXT) \
$(OBJ_DIR)\fieldhb$(OBJEXT) \

View File

@@ -9,6 +9,7 @@ C_SOURCES=\
dbcmd53.c \
dbcmdhb.c \
dbcmdx.c \
dbdetach.c \
dbdrop.c \
dbexists.c \
fieldhb.c \

View File

@@ -0,0 +1,141 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* .prg functions for workarea detaching
*
* Copyright 2008 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* 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.
*
*/
#include "hbapi.h"
#include "hbapirdd.h"
#include "hbapiitm.h"
#include "hbapierr.h"
/*
* hb_dbDetach( [<nWorkArea>|<cAlias>], [<xCargo>] ) -> <lSuccess>
*/
HB_FUNC( HB_DBDETACH )
{
PHB_ITEM pAlias = hb_param( 1, HB_IT_ANY );
PHB_ITEM pCargo = hb_param( 2, HB_IT_ANY ); /* HB_IT_BLOCK in xBase++ */
AREAP pArea = NULL;
int iArea;
if( !pAlias || HB_IS_NIL( pAlias ) )
{
pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
}
else if( HB_IS_STRING( pAlias ) )
{
char * szAlias = hb_itemGetCPtr( pAlias );
hb_rddGetAliasNumber( szAlias, &iArea );
if( iArea > 0 )
pArea = ( AREAP ) hb_rddGetWorkAreaPointer( iArea );
}
else if( HB_IS_NUMBER( pAlias ) )
{
iArea = hb_itemGetNI( pAlias );
if( iArea > 0 )
pArea = ( AREAP ) hb_rddGetWorkAreaPointer( iArea );
}
else
{
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, HB_ERR_FUNCNAME );
return;
}
if( pArea )
hb_retl( hb_rddDetachArea( pArea, pCargo ) == SUCCESS );
else
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, HB_ERR_FUNCNAME );
}
/*
* DbRequest( [<cAlias>], [<lFreeArea>], [<@xCargo>], [<lWait>] )
* -> <lSuccess>
*/
HB_FUNC( HB_DBREQUEST )
{
char * szAlias;
PHB_ITEM pCargo;
BOOL fNewArea, fWait;
AREAP pArea;
if( ISNIL( 1 ) || ISCHAR( 1 ) )
{
szAlias = hb_parc( 1 );
fNewArea = ISLOG( 2 ) && hb_parl( 2 );
fWait = ISLOG( 4 ) && hb_parl( 4 );
pCargo = ISBYREF( 3 ) ? hb_itemNew( NULL ) : NULL;
pArea = hb_rddRequestArea( szAlias, pCargo, fNewArea, fWait );
if( pArea )
hb_rddSelectWorkAreaNumber( pArea->uiArea );
if( pCargo )
{
hb_itemParamStoreForward( 3, pCargo );
hb_itemRelease( pCargo );
}
hb_retl( pArea != NULL );
}
else
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, HB_ERR_FUNCNAME );
}
#ifdef HB_COMPAT_XPP
HB_FUNC( DBRELEASE )
{
HB_FUNC_EXEC( HB_DBDETACH );
}
HB_FUNC( DBREQUEST )
{
HB_FUNC_EXEC( HB_DBREQUEST );
}
#endif

View File

@@ -458,6 +458,11 @@ static HB_THREAD_STARTFUNC( hb_threadStartVM )
hb_vmPushSymbol( hb_itemGetSymbol( pStart ) );
hb_vmPushNil();
}
else if( HB_IS_STRING( pStart ) )
{
hb_vmPushDynSym( hb_dynsymGet( hb_itemGetCPtr( pStart ) ) );
hb_vmPushNil();
}
else
ulPCount = 0;
}
@@ -506,8 +511,44 @@ static PHB_THREADSTATE hb_thParam( int iParam )
HB_FUNC( HB_THREADSTART )
{
PHB_ITEM pStart = hb_param( 1, HB_IT_ANY );
if( pStart && ( HB_IS_BLOCK( pStart ) || HB_IS_SYMBOL( pStart ) ) )
ULONG ulAttr = 0, ulStart = 1;
const char * szFuncName = NULL;
PHB_SYMB pSymbol = NULL;
PHB_ITEM pStart;
pStart = hb_param( ulStart, HB_IT_ANY );
while( pStart && HB_IS_NUMERIC( pStart ) )
{
ulAttr |= ( ULONG ) hb_itemGetNL( pStart );
pStart = hb_param( ++ulStart, HB_IT_ANY );
}
if( pStart )
{
if( HB_IS_STRING( pStart ) )
{
PHB_DYNS pDynSym;
szFuncName = hb_itemGetCPtr( pStart );
pDynSym = hb_dynsymFindName( szFuncName );
if( pDynSym )
pSymbol = pDynSym->pSymbol;
if( !pSymbol || !pSymbol->value.pFunPtr )
pStart = NULL;
}
else if( HB_IS_SYMBOL( pStart ) )
{
pSymbol = hb_itemGetSymbol( pStart );
if( !pSymbol->value.pFunPtr )
{
szFuncName = pSymbol->szName;
pStart = NULL;
}
}
else if( !HB_IS_BLOCK( pStart ) )
pStart = NULL;
}
if( pStart )
{
PHB_ITEM pReturn;
PHB_THREADSTATE pThread;
@@ -525,14 +566,32 @@ HB_FUNC( HB_THREADSTART )
pThread->pSet = hb_setClone( hb_stackSetStruct() );
pThread->pParams = hb_arrayBaseParams();
/* detach LOCAL variables passed by reference */
ulPCount = hb_arrayLen( pThread->pParams );
for( ulParam = 2; ulParam <= ulPCount; ++ulParam )
/* remove thread attributes */
if( ulStart > 1 )
{
for( ulParam = 1; ulParam < ulStart; ++ulParam )
hb_arrayDel( pThread->pParams, 1 );
ulPCount -= ulStart - 1;
hb_arraySize( pThread->pParams, ulPCount );
}
if( HB_IS_STRING( pStart ) && pSymbol )
hb_itemPutSymbol( hb_arrayGetItemPtr( pThread->pParams, 1 ), pSymbol );
/* detach LOCAL variables passed by reference */
for( ulParam = 1; ulParam <= ulPCount; ++ulParam )
{
PHB_ITEM pParam = hb_arrayGetItemPtr( pThread->pParams, ulParam );
if( HB_IS_BYREF( pParam ) )
hb_memvarDetachLocal( pParam );
{
if( ulParam == 1 )
hb_itemCopy( pParam, hb_itemUnRef( pParam ) );
else
hb_memvarDetachLocal( pParam );
}
}
/* TODO: use thread attributes in thread initialization,
* f.e. to copy visible memvars if user request about it.
*/
/* make copy of thread pointer item before we pass it to new thread
* to avoid race condition
@@ -549,7 +608,12 @@ HB_FUNC( HB_THREADSTART )
}
}
else
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
{
if( szFuncName )
hb_errRT_BASE_SubstR( EG_NOFUNC, 1001, NULL, szFuncName, 0 );
else
hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( HB_THREADJOIN )