diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index f61e8ebfad..1cea9c20b5 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -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( ) -> { , , ... } + * 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 diff --git a/harbour/contrib/hbct/files.c b/harbour/contrib/hbct/files.c index 2933610958..d7abf2f3e4 100644 --- a/harbour/contrib/hbct/files.c +++ b/harbour/contrib/hbct/files.c @@ -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 ); } diff --git a/harbour/include/fileio.ch b/harbour/include/fileio.ch index b391034794..a5b015ffd4 100644 --- a/harbour/include/fileio.ch +++ b/harbour/include/fileio.ch @@ -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 */ diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index a4e677a3ac..e4ca74cae2 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -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 ); diff --git a/harbour/src/rdd/dbf1.c b/harbour/src/rdd/dbf1.c index f1722de489..e12b01a00a 100644 --- a/harbour/src/rdd/dbf1.c +++ b/harbour/src/rdd/dbf1.c @@ -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; diff --git a/harbour/src/rdd/dbfntx/dbfntx1.c b/harbour/src/rdd/dbfntx/dbfntx1.c index e2bb6f9b3c..a70990f7e3 100644 --- a/harbour/src/rdd/dbfntx/dbfntx1.c +++ b/harbour/src/rdd/dbfntx/dbfntx1.c @@ -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 ) ); diff --git a/harbour/src/rdd/workarea.c b/harbour/src/rdd/workarea.c index c1eaf2e819..b19c6adf17 100644 --- a/harbour/src/rdd/workarea.c +++ b/harbour/src/rdd/workarea.c @@ -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; diff --git a/harbour/src/vm/classes.c b/harbour/src/vm/classes.c index 8066d711d7..0c722f1038 100644 --- a/harbour/src/vm/classes.c +++ b/harbour/src/vm/classes.c @@ -3616,7 +3616,7 @@ HB_FUNC( __CLSNEW ) } /* - * __clsAddFriend( , ) + * __clsAddFriend( , ) * * Add friend function */ @@ -3952,7 +3952,7 @@ HB_FUNC( __OBJCLONE ) } /* - * __clsInstSuper( | ) -> + * __clsInstSuper( | ) -> * * 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( ) -> + * __cls_DecData( ) -> * * Decrease number of datas and return new value */ @@ -4184,7 +4187,7 @@ HB_FUNC( __CLS_DECDATA ) } /* - * __cls_IncData( ) -> + * __cls_IncData( ) -> * 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( , ) -> { { , }, ... } + */ 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( , [ ] ) --> +/* __clsGetProperties( , [] ) -> * 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( ) -> { , , ... } + */ +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( , | ) -> * @@ -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( , ) --> + * __objSetClassHandle( , ) -> */ HB_FUNC( __OBJSETCLASSHANDLE ) { diff --git a/harbour/src/vm/itemapi.c b/harbour/src/vm/itemapi.c index 318d451aa3..00d505c281 100644 --- a/harbour/src/vm/itemapi.c +++ b/harbour/src/vm/itemapi.c @@ -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 ) );