2013-01-28 17:44 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* harbour/src/vm/classes.c
    + added new PRG function:
         __clsGetAncestors( <nClass> ) -> { <nSupper1>, <nSupper2>, ... }
    * generate RTE if someone tries to register scalar class with instance
      variables.
    * updated some comments

  * harbour/include/hbapiitm.h
  * harbour/src/vm/itemapi.c
    + added new C function hb_itemGetLX()
      It's similar to hb_itemGetL() but returns HB_TRUE for
      some non logical items to mimic Cl*pper behavior.

  * harbour/src/rdd/workarea.c
  * harbour/src/rdd/dbf1.c
    ! use hb_itemGetLX() instead of hb_itemGetL() in DBEVAL(),
      COPY TO ..., APPEND FROM ..., SORT TO ... functions and
      commands - Cl*pper compatible behavior.

  * harbour/src/rdd/dbfntx/dbfntx1.c
    * minor indenting

  * harbour/include/fileio.ch
    + added HB_FA_ANY macro value - it's attribute mask for hb_fsFindFirst()
      which includes all directory entries regardless of their attributes.

  * harbour/contrib/hbct/files.c
    ! fixed FILEATTR() to accept by default directories, hidden and system
      files when called with file name in first parameter - it's standard
      CT3 behavior.
    ! limit attributes in mask used by FILE*() functions to standard DOS
      ones - without it existing code is not portable to * nixes.
This commit is contained in:
Przemyslaw Czerpak
2013-01-28 16:44:47 +00:00
parent 706cc6fb51
commit eb438ad976
9 changed files with 133 additions and 33 deletions

View File

@@ -10,6 +10,40 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2013-01-28 17:44 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/src/vm/classes.c
+ added new PRG function:
__clsGetAncestors( <nClass> ) -> { <nSupper1>, <nSupper2>, ... }
* generate RTE if someone tries to register scalar class with instance
variables.
* updated some comments
* harbour/include/hbapiitm.h
* harbour/src/vm/itemapi.c
+ added new C function hb_itemGetLX()
It's similar to hb_itemGetL() but returns HB_TRUE for
some non logical items to mimic Cl*pper behavior.
* harbour/src/rdd/workarea.c
* harbour/src/rdd/dbf1.c
! use hb_itemGetLX() instead of hb_itemGetL() in DBEVAL(),
COPY TO ..., APPEND FROM ..., SORT TO ... functions and
commands - Cl*pper compatible behavior.
* harbour/src/rdd/dbfntx/dbfntx1.c
* minor indenting
* harbour/include/fileio.ch
+ added HB_FA_ANY macro value - it's attribute mask for hb_fsFindFirst()
which includes all directory entries regardless of their attributes.
* harbour/contrib/hbct/files.c
! fixed FILEATTR() to accept by default directories, hidden and system
files when called with file name in first parameter - it's standard
CT3 behavior.
! limit attributes in mask used by FILE*() functions to standard DOS
ones - without it existing code is not portable to * nixes.
2013-01-26 15:06 UTC+0100 Viktor Szakats (harbour syenar.net)
* src/rdd/usrrdd/rdds/arrayrdd.prg
! another formatting error in just added continued line

View File

@@ -102,7 +102,11 @@ static HB_TSD_NEW( s_FFData, sizeof( HB_FFDATA ), NULL, hb_fileFindRelease );
#define HB_GET_FFDATA() ( ( PHB_FFDATA ) hb_stackGetTSD( &s_FFData ) )
static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
/* limit attributes to DOS ones for code portability */
#define HB_FF_ATTR( ff ) ( ( ff )->attr & 0xFF )
static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_BOOL fAny )
{
PHB_FFDATA pFFData = HB_GET_FFDATA();
@@ -118,12 +122,13 @@ static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
if( szFile )
{
if( HB_ISNUM( 2 ) )
ulAttr = ( HB_FATTR ) hb_parnl( 2 );
pFFData->ulAttr = hb_parl( 3 ) ? ulAttr : HB_FA_ALL;
HB_FATTR ulAttr;
ulAttr = ( HB_FATTR ) hb_parnldef( 2, fAny ? HB_FA_ANY : HB_FA_ALL );
pFFData->ulAttr = hb_parl( 3 ) ? ulAttr : 0;
pFFData->ffind = hb_fsFindFirst( szFile, ulAttr );
while( pFFData->ffind && pFFData->ulAttr &&
pFFData->ffind->attr != pFFData->ulAttr )
HB_FF_ATTR( pFFData->ffind ) != pFFData->ulAttr )
{
if( ! hb_fsFindNext( pFFData->ffind ) )
{
@@ -144,7 +149,7 @@ static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
break;
}
}
while( pFFData->ulAttr && pFFData->ffind->attr != pFFData->ulAttr );
while( pFFData->ulAttr && HB_FF_ATTR( pFFData->ffind ) != pFFData->ulAttr );
}
return pFFData->ffind;
@@ -152,35 +157,35 @@ static PHB_FFIND _hb_fileStart( HB_BOOL fNext, HB_FATTR ulAttr )
HB_FUNC( FILESEEK )
{
PHB_FFIND ffind = _hb_fileStart( HB_TRUE, HB_FA_ALL );
PHB_FFIND ffind = _hb_fileStart( HB_TRUE, HB_FALSE );
hb_retc( ffind ? ffind->szName : NULL );
}
HB_FUNC( FILEATTR )
{
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FA_ALL );
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_TRUE );
hb_retni( ffind ? ffind->attr : 0 );
hb_retni( ffind ? HB_FF_ATTR( ffind ) : 0 );
}
HB_FUNC( FILESIZE )
{
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FA_ALL );
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FALSE );
hb_retnint( ffind ? ffind->size : -1 );
}
HB_FUNC( FILEDATE )
{
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FA_ALL );
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FALSE );
hb_retdl( ffind ? ffind->lDate : 0 );
}
HB_FUNC( FILETIME )
{
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FA_ALL );
PHB_FFIND ffind = _hb_fileStart( HB_FALSE, HB_FALSE );
hb_retc( ffind ? ffind->szTime : NULL );
}

View File

@@ -64,6 +64,8 @@
/* File attributes flags */
#define HB_FA_ALL 0x00000000
#define HB_FA_ANY ( HB_FA_READONLY | HB_FA_HIDDEN | HB_FA_SYSTEM | HB_FA_DIRECTORY | HB_FA_ARCHIVE )
#define HB_FA_READONLY 0x00000001 /* R */
#define HB_FA_HIDDEN 0x00000002 /* H */
#define HB_FA_SYSTEM 0x00000004 /* S */

View File

@@ -93,6 +93,7 @@ extern HB_EXPORT long hb_itemGetDL ( PHB_ITEM pItem );
extern HB_EXPORT double hb_itemGetTD ( PHB_ITEM pItem );
extern HB_EXPORT HB_BOOL hb_itemGetTDT ( PHB_ITEM pItem, long * plJulian, long * plMilliSec );
extern HB_EXPORT HB_BOOL hb_itemGetL ( PHB_ITEM pItem );
extern HB_EXPORT HB_BOOL hb_itemGetLX ( PHB_ITEM pItem );
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 );

View File

@@ -4734,7 +4734,7 @@ static HB_ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo )
{
if( ! pSortInfo->dbtri.dbsci.itmCobWhile &&
( ! pSortInfo->dbtri.dbsci.fRest ||
! hb_itemGetL( pSortInfo->dbtri.dbsci.fRest ) ) )
! hb_itemGetLX( pSortInfo->dbtri.dbsci.fRest ) ) )
errCode = SELF_GOTOP( ( AREAP ) pArea );
bMoreRecords = HB_TRUE;
bLimited = HB_FALSE;
@@ -4749,7 +4749,7 @@ static HB_ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo )
hb_dbQSortExit( &dbQuickSort );
return HB_FAILURE;
}
bMoreRecords = hb_itemGetL( pArea->area.valResult );
bMoreRecords = hb_itemGetLX( pArea->area.valResult );
}
if( bMoreRecords && pSortInfo->dbtri.dbsci.itmCobFor )
@@ -4759,7 +4759,7 @@ static HB_ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo )
hb_dbQSortExit( &dbQuickSort );
return HB_FAILURE;
}
bValidRecord = hb_itemGetL( pArea->area.valResult );
bValidRecord = hb_itemGetLX( pArea->area.valResult );
}
else
bValidRecord = bMoreRecords;

View File

@@ -6235,7 +6235,8 @@ static HB_ERRCODE hb_ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderI
HB_ERRCODE errCode;
HB_ULONG ulRecNo;
HB_BOOL fCompound, fTagName, fBagName, fProd, fLocked = HB_FALSE,
fAscend = HB_TRUE, fCustom = HB_FALSE, fTemporary = HB_FALSE, fExclusive = HB_FALSE;
fAscend = HB_TRUE, fCustom = HB_FALSE, fTemporary = HB_FALSE,
fExclusive = HB_FALSE;
HB_BYTE bType;
HB_TRACE( HB_TR_DEBUG, ( "hb_ntxOrderCreate(%p, %p)", pArea, pOrderInfo ) );

View File

@@ -973,7 +973,7 @@ static HB_ERRCODE hb_waEval( AREAP pArea, LPDBEVALINFO pEvalInfo )
lNext = hb_itemGetNL( pEvalInfo->dbsci.lNext );
}
else if( ! pEvalInfo->dbsci.itmCobWhile &&
! hb_itemGetL( pEvalInfo->dbsci.fRest ) )
! hb_itemGetLX( pEvalInfo->dbsci.fRest ) )
{
if( SELF_GOTOP( pArea ) != HB_SUCCESS )
return HB_FAILURE;
@@ -995,7 +995,7 @@ static HB_ERRCODE hb_waEval( AREAP pArea, LPDBEVALINFO pEvalInfo )
{
if( SELF_EVALBLOCK( pArea, pEvalInfo->dbsci.itmCobWhile ) != HB_SUCCESS )
return HB_FAILURE;
if( ! hb_itemGetL( pArea->valResult ) )
if( ! hb_itemGetLX( pArea->valResult ) )
break;
}
@@ -1003,7 +1003,7 @@ static HB_ERRCODE hb_waEval( AREAP pArea, LPDBEVALINFO pEvalInfo )
{
if( SELF_EVALBLOCK( pArea, pEvalInfo->dbsci.itmCobFor ) != HB_SUCCESS )
return HB_FAILURE;
fFor = hb_itemGetL( pArea->valResult );
fFor = hb_itemGetLX( pArea->valResult );
}
else
fFor = HB_TRUE;
@@ -1053,7 +1053,7 @@ static HB_ERRCODE hb_waLocate( AREAP pArea, HB_BOOL fContinue )
lNext = hb_itemGetNL( pArea->dbsi.lNext );
}
else if( ! pArea->dbsi.itmCobWhile &&
! hb_itemGetL( pArea->dbsi.fRest ) )
! hb_itemGetLX( pArea->dbsi.fRest ) )
{
if( SELF_GOTOP( pArea ) != HB_SUCCESS )
return HB_FAILURE;
@@ -1077,7 +1077,7 @@ static HB_ERRCODE hb_waLocate( AREAP pArea, HB_BOOL fContinue )
{
if( SELF_EVALBLOCK( pArea, pArea->dbsi.itmCobWhile ) != HB_SUCCESS )
return HB_FAILURE;
if( ! hb_itemGetL( pArea->valResult ) )
if( ! hb_itemGetLX( pArea->valResult ) )
break;
}
@@ -1091,7 +1091,7 @@ static HB_ERRCODE hb_waLocate( AREAP pArea, HB_BOOL fContinue )
if( SELF_EVALBLOCK( pArea, pArea->dbsi.itmCobFor ) != HB_SUCCESS )
return HB_FAILURE;
if( hb_itemGetL( pArea->valResult ) )
if( hb_itemGetLX( pArea->valResult ) )
{
pArea->fFound = HB_TRUE;
break;
@@ -1130,7 +1130,7 @@ static HB_ERRCODE hb_waTrans( AREAP pArea, LPDBTRANSINFO pTransInfo )
lNext = hb_itemGetNL( pTransInfo->dbsci.lNext );
}
else if( ! pTransInfo->dbsci.itmCobWhile &&
! hb_itemGetL( pTransInfo->dbsci.fRest ) )
! hb_itemGetLX( pTransInfo->dbsci.fRest ) )
{
if( SELF_GOTOP( pArea ) != HB_SUCCESS )
return HB_FAILURE;
@@ -1152,7 +1152,7 @@ static HB_ERRCODE hb_waTrans( AREAP pArea, LPDBTRANSINFO pTransInfo )
{
if( SELF_EVALBLOCK( pArea, pTransInfo->dbsci.itmCobWhile ) != HB_SUCCESS )
return HB_FAILURE;
if( ! hb_itemGetL( pArea->valResult ) )
if( ! hb_itemGetLX( pArea->valResult ) )
break;
}
@@ -1160,7 +1160,7 @@ static HB_ERRCODE hb_waTrans( AREAP pArea, LPDBTRANSINFO pTransInfo )
{
if( SELF_EVALBLOCK( pArea, pTransInfo->dbsci.itmCobFor ) != HB_SUCCESS )
return HB_FAILURE;
fFor = hb_itemGetL( pArea->valResult );
fFor = hb_itemGetLX( pArea->valResult );
}
else
fFor = HB_TRUE;

View File

@@ -3616,7 +3616,7 @@ HB_FUNC( __CLSNEW )
}
/*
* __clsAddFriend( <hClass>, <pFyncSym> )
* __clsAddFriend( <hClass>, <sFuncSym> )
*
* Add friend function
*/
@@ -3952,7 +3952,7 @@ HB_FUNC( __OBJCLONE )
}
/*
* __clsInstSuper( <cName> | <sName> ) -> <hClass>
* __clsInstSuper( <cClassName> | <sClassFunc> ) -> <hClass>
*
* Instance super class and return class handle
*/
@@ -4062,7 +4062,10 @@ HB_FUNC( __CLSASSOCTYPE )
if( uiClass && uiClass <= s_uiClasses && pType )
{
HB_TYPE nType = hb_clsGetItemType( pType, HB_IT_ANY );
if( nType != HB_IT_ANY )
if( s_pClasses[ uiClass ]->uiDatas )
hb_errRT_BASE( EG_ARG, 3005, "Scalar class can not contain instance variables", HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
else if( nType != HB_IT_ANY )
{
switch( nType )
{
@@ -4163,7 +4166,7 @@ HB_FUNC( __CLS_CNTDATA )
}
/*
* __cls_DecData( <hClass> ) -> <nSeq>
* __cls_DecData( <hClass> ) -> <nCount>
*
* Decrease number of datas and return new value
*/
@@ -4184,7 +4187,7 @@ HB_FUNC( __CLS_DECDATA )
}
/*
* __cls_IncData( <hClass> ) -> <nSeq>
* __cls_IncData( <hClass> ) -> <nCount>
* Increase number of datas and return offset to new value
*/
HB_FUNC( __CLS_INCDATA )
@@ -5033,7 +5036,8 @@ void hb_mthAddTime( HB_ULONG ulClockTicks )
}
#endif
/* __getMsgPrf( nClass, cMsg ) --> aMethodInfo { nTimes, nTime } */
/* __getMsgPrf( <hClass>, <cMsg> ) -> <aMethodInfo> { { <nTimes>, <nTime> }, ... }
*/
HB_FUNC( __GETMSGPRF ) /* profiler: returns a method called and consumed times */
{
HB_STACK_TLS_PRELOAD
@@ -5065,7 +5069,7 @@ HB_FUNC( __GETMSGPRF ) /* profiler: returns a method called and consumed times *
hb_storvnl( 0, -1, 2 );
}
/* __clsGetProperties( <nClassHandle>, [ <lAllExported> ] ) --> <acProperties>
/* __clsGetProperties( <nClassHandle>, [<lAllExported>] ) -> <acProperties>
* Notice that this function works quite similar to __CLASSSEL()
* except that just returns the name of the datas and methods
* that have been declared as PROPERTY (PERSISTENT) or also EXPORTED
@@ -5135,6 +5139,30 @@ HB_FUNC( __CLSGETPROPERTIES )
hb_itemReturnRelease( pReturn );
}
/* __clsGetAncestors( <nClass> ) -> { <nSupper1>, <nSupper2>, ... }
*/
HB_FUNC( __CLSGETANCESTORS )
{
HB_USHORT uiClass = ( HB_USHORT ) hb_parni( 1 ), uiCount;
if( uiClass && uiClass <= s_uiClasses )
{
PHB_ITEM pReturn = hb_stackReturnItem();
PCLASS pClass = s_pClasses[ uiClass ];
HB_SIZE nPos = 0;
uiCount = pClass->uiSuperClasses;
hb_arrayNew( pReturn, uiCount );
while( uiCount-- )
{
HB_USHORT uiSuperCls = pClass->pSuperClasses[ uiCount ].uiClass;
if( uiSuperCls != uiClass )
hb_arraySetNI( pReturn, ++nPos, uiSuperCls );
}
hb_arraySize( pReturn, nPos );
}
}
/*
* __clsMsgType( <hClass>, <cMsgName> | <sMsgName> ) -> <nType>
*
@@ -5252,7 +5280,7 @@ HB_FUNC( __OBJSETCLASS )
* It allows to change the class handle of an object into another class handle,
* so the object behaves like a different Class of object.
* Based on objects.lib SetClsHandle()
* __objSetClassHandle( <oObject>, <nClassHandle> ) --> <nPrevClassHandle>
* __objSetClassHandle( <oObject>, <nClassHandle> ) -> <nPrevClassHandle>
*/
HB_FUNC( __OBJSETCLASSHANDLE )
{

View File

@@ -614,6 +614,35 @@ HB_BOOL hb_itemGetL( PHB_ITEM pItem )
return HB_FALSE;
}
HB_BOOL hb_itemGetLX( PHB_ITEM pItem )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_itemGetLX(%p)", pItem ) );
if( pItem )
{
if( HB_IS_LOGICAL( pItem ) )
return pItem->item.asLogical.value;
else if( HB_IS_INTEGER( pItem ) )
return pItem->item.asInteger.value != 0;
else if( HB_IS_LONG( pItem ) )
return pItem->item.asLong.value != 0;
else if( HB_IS_DOUBLE( pItem ) )
return pItem->item.asDouble.value != 0.0;
else if( HB_IS_DATETIME( pItem ) )
return pItem->item.asDateTime.julian != 0 ||
pItem->item.asDateTime.time != 0;
else
return HB_TRUE;
}
return HB_FALSE;
}
double hb_itemGetND( PHB_ITEM pItem )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_itemGetND(%p)", pItem ) );