From 3053dfae503da065dea0cd1414ee2ee2119e0b7b Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 9 Jan 2009 12:32:09 +0000 Subject: [PATCH] 2009-01-09 13:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/classes.c * updated __objHasMsgAssigned() + accept also symbols (@methodname()) not only strings as message name (2-nd parameter) just like in __objHasMsg() or __objSendMsg() + added suport for scalar classes in __objHasMsgAssigned() + generate RT error when wrong parameters are passed * updated comments with .prg functions syntax --- harbour/ChangeLog | 9 +++++ harbour/source/vm/classes.c | 79 +++++++++++++++---------------------- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 56ca02f7b7..9114c37cfc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-09 13:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/classes.c + * updated __objHasMsgAssigned() + + accept also symbols (@methodname()) not only strings as message name + (2-nd parameter) just like in __objHasMsg() or __objSendMsg() + + added suport for scalar classes in __objHasMsgAssigned() + + generate RT error when wrong parameters are passed + * updated comments with .prg functions syntax + 2009-01-09 12:55 UTC+0100 Maurilio Longo (maurilio.longo@libero.it) * harbour/config/os2/global.cf * simplified and fixed an error in deleting files diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index e07d6bb07a..117c30603d 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -3479,7 +3479,7 @@ static PHB_ITEM hb_clsInst( USHORT uiClass ) } /* - * := __clsInst( ) + * __clsInst( ) -> * * Create a new object from class definition */ @@ -3557,7 +3557,7 @@ HB_FUNC( __CLSMODMSG ) /* - * := __objGetClsName( | ) + * __objGetClsName( | ) -> * * Returns class name of or */ @@ -3576,7 +3576,7 @@ HB_FUNC( __OBJGETCLSNAME ) /* - * := __objHasMsg( , ) + * __objHasMsg( , | ) -> * * Is a valid message for the */ @@ -3591,7 +3591,26 @@ HB_FUNC( __OBJHASMSG ) } /* - * = __objSendMsg( , , + * __objHasMsgAssigned( , | ) -> + * + * checks if function exists and is not virtual + */ +HB_FUNC( __OBJHASMSGASSIGNED ) +{ + PHB_DYNS pMessage = hb_objGetMsgSym( hb_param( 2, HB_IT_ANY ) ); + + if( pMessage ) + { + PHB_SYMB pExecSym = hb_objGetMethod( hb_param( 1, HB_IT_ANY ), + pMessage->pSymbol, NULL ); + hb_retl( pExecSym && pExecSym != &s___msgVirtual ); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* + * __objSendMsg( , | , ) -> * * Send a message to an object */ @@ -3620,7 +3639,7 @@ HB_FUNC( __OBJSENDMSG ) } /* - * := __objClone( ) + * __objClone( ) -> * * Clone an object. Note the similarity with aClone ;-) */ @@ -3641,7 +3660,7 @@ HB_FUNC( __OBJCLONE ) } /* - * := __clsInstSuper( ) + * __clsInstSuper( ) -> * * Instance super class and return class handle */ @@ -3719,7 +3738,7 @@ HB_FUNC( __CLSINSTSUPER ) } /* - * = __clsAssocType( , ) + * __clsAssocType( , ) -> * * Associate class with given basic type */ @@ -3777,7 +3796,7 @@ HB_FUNC( __CLSASSOCTYPE ) } /* - * = __ClsCntClasses() + * __ClsCntClasses() -> * * Return number of classes */ @@ -3787,7 +3806,7 @@ HB_FUNC( __CLSCNTCLASSES ) } /* - * = __cls_CntClsData( ) + * __cls_CntClsData( ) -> * * Return number of class datas */ @@ -3800,7 +3819,7 @@ HB_FUNC( __CLS_CNTCLSDATA ) } /* - * = __cls_CntShrData( ) + * __cls_CntShrData( ) -> * * Return number of class datas */ @@ -3813,7 +3832,7 @@ HB_FUNC( __CLS_CNTSHRDATA ) } /* - * = __cls_CntData( ) + * __cls_CntData( ) -> * * Return number of datas */ @@ -3826,7 +3845,7 @@ HB_FUNC( __CLS_CNTDATA ) } /* - * = __cls_DecData( ) + * __cls_DecData( ) -> * * Decrease number of datas and return new value */ @@ -3846,7 +3865,7 @@ HB_FUNC( __CLS_DECDATA ) } /* - * = __cls_IncData( ) + * __cls_IncData( ) -> * Increase number of datas and return offset to new value */ HB_FUNC( __CLS_INCDATA ) @@ -4899,37 +4918,3 @@ 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 ); -}