From cc64a7d5f0ea0271386be913848bb7d60353e8d9 Mon Sep 17 00:00:00 2001 From: Teo Fonrouge Date: Wed, 7 Jan 2009 19:57:52 +0000 Subject: [PATCH] 2009-01-07 13:56 UTC-0600 Teo Fonrouge (teo/at/windtelsoft/dot/com) * source/vm/classes.c + addded __objHasMsgAssigned( object, "msgName" ) ; this is similar to xHarbour __clsMsgAssigned() and checks ; if a VIRTUAL message has been overrided in a sub-class. ; TODO: Please check this implementation, I'm sure it can be optimized. --- harbour/ChangeLog | 7 ++++++ harbour/source/vm/classes.c | 50 +++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ce406cd0e7..6d028e92c0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-07 13:56 UTC-0600 Teo Fonrouge (teo/at/windtelsoft/dot/com) + * source/vm/classes.c + + addded __objHasMsgAssigned( object, "msgName" ) + ; this is similar to xHarbour __clsMsgAssigned() and checks + ; if a VIRTUAL message has been overrided in a sub-class. + ; TODO: Please check this implementation, I'm sure it can be optimized. + 2009-01-05 18:20 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/dbsql.c * harbour/source/rdd/dbfntx/dbfntx1.c diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index a81b5c8e18..e07d6bb07a 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -424,7 +424,7 @@ static USHORT hb_clsBucketPos( PHB_DYNS pMsg, USHORT uiMask ) /* Safely divide it by 16 - it's minimum memory allocated for single * HB_DYNS structure */ - /* + /* return ( ( USHORT ) ( ( HB_PTRDIFF ) pMsg >> 4 ) & uiMask ) << BUCKETBITS; */ @@ -1004,7 +1004,7 @@ static void hb_clsAddFriendSymbol( PCLASS pClass, PHB_SYMB pSym ) pClass->pFriendSyms[ 0 ] = pSym; pClass->uiFriendSyms++; } - else + else { pClass->pFriendSyms = ( PHB_SYMB * ) hb_xrealloc( pClass->pFriendSyms, ( pClass->uiFriendSyms + 1 ) * sizeof( PHB_SYMB ) ); @@ -1069,7 +1069,7 @@ void hb_clsInit( void ) */ void hb_clsDoInit( void ) { - static const char * s_pszFuncNames[] = + static const char * s_pszFuncNames[] = { "HBARRAY", "HBBLOCK", "HBCHARACTER", "HBDATE", "HBHASH", "HBLOGICAL", "HBNIL", "HBNUMERIC", "HBSYMBOL", "HBPOINTER" }; @@ -1356,7 +1356,7 @@ const char * hb_objGetClsName( PHB_ITEM pObject ) else if( HB_IS_SYMBOL( pObject ) ) return "SYMBOL"; - else + else return "UNKNOWN"; } @@ -2962,7 +2962,7 @@ static BOOL hb_clsAddMsg( USHORT uiClass, const char * szMessage, } } - return TRUE; + return TRUE; } /* @@ -3351,8 +3351,8 @@ HB_FUNC( __CLSNEW ) pModFriend = hb_param( 5, HB_IT_ANY ); if( pModFriend && HB_IS_NIL( pModFriend ) ) pModFriend = NULL; - - if( szClassName && + + if( szClassName && ( ! pDatas || HB_IS_NUMERIC( pDatas ) ) && ( ! pSuperArray || HB_IS_ARRAY( pSuperArray ) ) && ( ! pClassFunc || HB_IS_SYMBOL( pClassFunc ) ) && @@ -3524,7 +3524,7 @@ HB_FUNC( __CLSMODMSG ) PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg ); if( pMethod ) - { + { PHB_SYMB pFuncSym = pMethod->pFuncSym; if( pFuncSym == &s___msgSetData || pFuncSym == &s___msgGetData ) @@ -4899,3 +4899,37 @@ const char * hb_clsRealMethodName( void ) return szName; } #endif + +/* checks if function exists and is not virtual */ +HB_FUNC( __OBJHASMSGASSIGNED ) +{ + PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); + PHB_ITEM pString = hb_param( 2, HB_IT_STRING ); + USHORT uiClass; + BOOL fResult = FALSE; + + if( pObject ) + { + uiClass = pObject->item.asArray.value->uiClass; + } + else + { + uiClass = 0; + } + + if( uiClass && pString ) + { + PHB_DYNS pMsg = hb_dynsymFindName( pString->item.asString.value ); + + if( pMsg ) + { + PMETHOD pMethod = hb_clsFindMsg( s_pClasses[ uiClass ], pMsg ); + + if( pMethod && pMethod->pFuncSym != &s___msgVirtual ) /* NON Virtual method */ + { + fResult = TRUE; + } + } + } + hb_retl( fResult ); +}