diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 672ee77ced..a6daae7f14 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,20 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-07-31 17:41 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/classes.c + + adding 2-nd parameter to __clsGetProperties() + When it's TRUE then __clsGetProperties() returns also exported + messages which have corresponding assign messages (with "_" prefix) + + * harbour/source/rtl/objfunc.prg + + added __objGetProperties( oObject, [ lAllExported = .F. ] ) -> + aMsgAndValues + This function returns list of PROPERTY message with their values, + when 2-nd parameter is true it also returns exported messages which + which have corresponding assign messages (with "_" prefix) + This function is designed to use in object inspectors. + 2008-07-31 14:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbmzip/hbmzip.c * harbour/contrib/hbmzip/readme.txt diff --git a/harbour/source/rtl/objfunc.prg b/harbour/source/rtl/objfunc.prg index e23ca20a0b..2942db6256 100644 --- a/harbour/source/rtl/objfunc.prg +++ b/harbour/source/rtl/objfunc.prg @@ -279,3 +279,14 @@ FUNCTION __objDerivedFrom( oObject, xSuper ) RETURN __clsParent( oObject:ClassH, cClassName ) + +FUNCTION __objGetProperties( oObject, lAllExported ) + LOCAL msg, aMsgList + + aMsgList := __clsGetProperties( oObject:classH, lAllExported ) + + FOR EACH msg IN aMsgList + msg := { msg, __objSendMsg( oObject, msg ) } + NEXT + + RETURN aMsgList diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index c7ca9223d7..95aa0592d2 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -4383,10 +4383,13 @@ HB_FUNC( __GETMSGPRF ) /* profiler: returns a method called and consumed times * hb_stornl( 0, -1, 2 ); } -/* __ClsGetProperties( nClassHandle ) --> aPropertiesNames +/* __ClsGetProperties( nClassHandle, [ lAllExported ] ) --> aPropertiesNames * 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 (or PERSISTENT) */ + * that have been declared as PROPERTY (PERSISTENT) or also EXPORTED + * if second parameter is true and message has corresponding + * assign message (with "_" prefix) + */ HB_FUNC( __CLSGETPROPERTIES ) { @@ -4398,14 +4401,27 @@ HB_FUNC( __CLSGETPROPERTIES ) PCLASS pClass = &s_pClasses[ uiClass ]; PMETHOD pMethod; ULONG ulLimit, ulCount; + USHORT uiScope = HB_OO_CLSTP_PERSIST; + + if( ISLOG( 2 ) && hb_parl( 2 ) ) + uiScope |= HB_OO_CLSTP_EXPORTED; ulCount = 0; ulLimit = hb_clsMthNum( pClass ); pMethod = pClass->pMethods; do { - if( pMethod->pMessage && ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) ) - ++ulCount; + if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 ) + { + if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 ) + ++ulCount; + else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' ) + { + PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 ); + if( pMsg && hb_clsFindMsg( pClass, pMsg ) ) + ++ulCount; + } + } ++pMethod; } while( --ulLimit ); @@ -4417,8 +4433,17 @@ HB_FUNC( __CLSGETPROPERTIES ) pMethod = pClass->pMethods; do { - if( pMethod->pMessage && ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) ) - hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName ); + if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 ) + { + if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 ) + hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName ); + else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' ) + { + PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 ); + if( pMsg && hb_clsFindMsg( pClass, pMsg ) ) + hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName + 1 ); + } + } ++pMethod; } while( --ulLimit );