How to get address of a class method?
I wonder a way like getting function address (@MyFunc()):
@TMyClass:MyMethod()
Is this possible?
Thx,
Roberto Parisi
#include "hbclass.ch"
function Main()
MsgInfo( ValType( @Test_One() ) )
return nil
CLASS Test
METHOD One
ENDCLASS
METHOD One CLASS Test
return nil
#include "hbapi.h"
#include "hboo.ch"
#include "classes.h"
HB_FUNC(__GETMETHODPOINTER) {
PMETHOD pMethod = hb_objGetpMthd(hb_dynsymGet(hb_parc(2)), hb_parnl(1));
if (pMethod && pMethod->uiType == HB_OO_MSG_METHOD) hb_retptr(pMethod->pFunction);
}
HB_FUNC( __GETMETHODPOINTER )
{
USHORT uiClass = ( USHORT ) hb_parni( 1 );
PHB_ITEM pString = hb_param( 2, HB_IT_STRING );
if( uiClass && uiClass <= s_uiClasses && pString &&
! s_pClasses[ uiClass ]->fLocked )
{
PHB_DYNS pMsg = hb_dynsymFindName( pString->item.asString.value );
if( pMsg )
{
PCLASS pClass = s_pClasses[ uiClass ];
PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );
if( pMethod )
{
if (pMethod->itemType == HB_OO_MSG_METHOD) {
if (pMethod->pFuncSym->value.pFunPtr) {
hb_itemPutSymbol( hb_stackReturnItem(), pMethod->pFuncSym );
}
}
}
}
}
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 98 guests