2006-08-23 23:12 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbrdddbf.h
  * harbour/source/rdd/dbf1.c
  * harbour/contrib/rdd_ads/ads1.c
    * synced with xHarbour

  * harbour/include/hbapi.h
    + added uiClass and uiMethod to HB_STACK_STATE structure
    - removed puiClsTree from HB_BASEARRAY structure

  * harbour/include/hbvmpub.h
    ! fixed typo in HB_ARRAY_OBJ() declaration

  * harbour/source/vm/arrays.c
    - removed puiClsTree from HB_BASEARRAY structure

  * harbour/source/vm/classes.c
    - removed static variable s_pMethod to make classes code MT safe
    * store information about current method index and supercasting on
      HVM stack in HB_STACK_STATE structure
    ! changed hb_objGetRealClsName() to not use puiClsTree - this functions
      was never working as it should when object was supercasted.
      Now it simply returns name of class where method was defined and
      inherited.
    - removed hb_objPopSuperCast() and changed last parameter in
      hb_objGetMethod() from BOOL * to PHB_STACK_STATE
      hb_objPopSuperCast() is not longer necessary
    - removed hb_mthRequested() and first parameter from hb_mthAddTime()
    + added char * hb_clsName( USHORT uiClass );
    + added TOFIX notes in hb___msgGetData() and hb___msgSetData()

  * harbour/source/vm/estack.c
    + added uiClass and uiMethod to HB_STACK_STATE structure

  * harbour/source/vm/hvm.c
    * updated for above modifications

  * harbour/source/vm/proc.c
    ! do not use hb_objGetRealClsName() anymore but retrieve information
       about _REAL_ class form HVM stack
This commit is contained in:
Przemyslaw Czerpak
2006-08-23 21:13:42 +00:00
parent 8bef490815
commit d4af3b201b
12 changed files with 179 additions and 217 deletions

View File

@@ -8,6 +8,47 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2006-08-23 23:12 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbrdddbf.h
* harbour/source/rdd/dbf1.c
* harbour/contrib/rdd_ads/ads1.c
* synced with xHarbour
* harbour/include/hbapi.h
+ added uiClass and uiMethod to HB_STACK_STATE structure
- removed puiClsTree from HB_BASEARRAY structure
* harbour/include/hbvmpub.h
! fixed typo in HB_ARRAY_OBJ() declaration
* harbour/source/vm/arrays.c
- removed puiClsTree from HB_BASEARRAY structure
* harbour/source/vm/classes.c
- removed static variable s_pMethod to make classes code MT safe
* store information about current method index and supercasting on
HVM stack in HB_STACK_STATE structure
! changed hb_objGetRealClsName() to not use puiClsTree - this functions
was never working as it should when object was supercasted.
Now it simply returns name of class where method was defined and
inherited.
- removed hb_objPopSuperCast() and changed last parameter in
hb_objGetMethod() from BOOL * to PHB_STACK_STATE
hb_objPopSuperCast() is not longer necessary
- removed hb_mthRequested() and first parameter from hb_mthAddTime()
+ added char * hb_clsName( USHORT uiClass );
+ added TOFIX notes in hb___msgGetData() and hb___msgSetData()
* harbour/source/vm/estack.c
+ added uiClass and uiMethod to HB_STACK_STATE structure
* harbour/source/vm/hvm.c
* updated for above modifications
* harbour/source/vm/proc.c
! do not use hb_objGetRealClsName() anymore but retrieve information
about _REAL_ class form HVM stack
2006-08-19 01:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* moved HB_STACK_STATE declaration from hbstack.h to hbapi.h

View File

@@ -952,7 +952,7 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin
if( u16Found )
{
/* remeber the record number for faster checking if we should update
/* remember the record number for faster checking if we should update
fFound after SKIPFILTER */
AdsGetRecordNum( pArea->hTable, ADS_IGNOREFILTERS, &u32RecNo );
}
@@ -1068,10 +1068,10 @@ static ERRCODE adsSkip( ADSAREAP pArea, LONG lToSkip )
pArea->fTop = pArea->fBottom = FALSE;
/*
* This causes that skip id done on the server side but it
* This causes that skip is done on the server side but it
* may cause bad side effect - in multiple skip ADS respects
* only index keys and bitmap filter so it may skip differ
* number of records then we asked, [druzus]
* number of records than we asked, [druzus]
*/
if( pArea->dbfi.itmCobExpr == NULL || pArea->dbfi.fOptimized )
{

View File

@@ -229,6 +229,8 @@ typedef struct _HB_STACK_STATE
LONG lBaseItem; /* stack base offset of previous func/proc */
LONG lStatics; /* statics offset of previous func/proc */
ULONG ulPrivateBase; /* memvars base offset of previous func/proc */
USHORT uiClass; /* class when message is sent */
USHORT uiMethod; /* number of class method */
} HB_STACK_STATE, * PHB_STACK_STATE; /* used to save/restore stack state in hb_vmDo)_ */
@@ -348,7 +350,6 @@ typedef struct _HB_BASEARRAY
{
PHB_ITEM pItems; /* pointer to the array items */
ULONG ulLen; /* number of items in the array */
USHORT * puiClsTree; /* remember array of super called ID Tree */
USHORT uiClass; /* offset to the classes base if it is an object */
USHORT uiPrevCls; /* for fixing after access super */
} HB_BASEARRAY, * PHB_BASEARRAY, * HB_BASEARRAY_PTR;

View File

@@ -90,13 +90,13 @@ HB_EXTERN_BEGIN
extern void hb_clsInit( void ); /* initialize Classy/OO system at HVM startup */
extern void hb_clsReleaseAll( void ); /* releases all defined classes */
extern void hb_clsIsClassRef( void ); /* classes.c - mark all class internals as used */
extern char * hb_clsName( USHORT uiClass );
/* has this function to be public? */
extern BOOL hb_clsIsParent( USHORT uiClass, char * szParentName ); /* is a class handle inherited from szParentName Class ? */
/* object management */
#ifdef _HB_API_INTERNAL_
extern PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pSymMsg, BOOL * pfPopSuper ); /* returns the method pointer of an object class */
extern void hb_objPopSuperCast( PHB_ITEM pObject ); /* clean super casting if necessary */
extern PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pSymMsg, PHB_STACK_STATE pStack ); /* returns the method pointer of an object class */
#endif
extern BOOL hb_objHasOperator( PHB_ITEM pObject, USHORT uiOperator );
@@ -113,9 +113,8 @@ extern void hb_objSendMessage( PHB_ITEM pObj, PHB_DYNS pMessage, ULONG ulA
#ifndef HB_NO_PROFILER
/* profiler for object management */
extern BOOL hb_bProfiler; /* profiler activity status */
extern void * hb_mthRequested( void ); /* profiler from classes.c */
extern void hb_mthAddTime( void *, ULONG ); /* profiler from classes.c */
extern BOOL hb_bProfiler; /* profiler activity status */
extern void hb_mthAddTime( ULONG ); /* profiler from classes.c */
#endif
HB_EXTERN_END

View File

@@ -340,7 +340,7 @@ extern HB_EXPORT BOOL hb_dbfLockIdxFile( FHANDLE hFile, BYTE bScheme, USHORT
extern HB_EXPORT BOOL hb_dbfLockIdxGetData( BYTE bScheme, HB_FOFFSET *ulPos, HB_FOFFSET *ulPool );
#ifndef HB_CDP_SUPPORT_OFF
extern void hb_dbfTranslateRec( DBFAREAP pArea, BYTE * pBuffer, PHB_CODEPAGE cdp_src, PHB_CODEPAGE cdp_dest );
extern HB_EXPORT void hb_dbfTranslateRec( DBFAREAP pArea, BYTE * pBuffer, PHB_CODEPAGE cdp_src, PHB_CODEPAGE cdp_dest );
#endif
HB_EXTERN_END

View File

@@ -123,7 +123,7 @@ struct _HB_SYMB;
/* # define HB_ITEM_TYPE( p ) ( hb_itemType( p ) ) */
# define HB_OBJ_CLASS( p ) ( hb_objGetClass( p ) )
# define HB_ARRAY_OBJ( p ) ( hb_arrayIsObject( pSrcArray ) )
# define HB_ARRAY_OBJ( p ) ( hb_arrayIsObject( p ) )
/* basic types */
typedef void * PHB_ITEM;

View File

@@ -3385,7 +3385,7 @@ static ERRCODE hb_dbfPack( DBFAREAP pArea )
}
#ifndef HB_CDP_SUPPORT_OFF
void hb_dbfTranslateRec( DBFAREAP pArea, BYTE * pBuffer, PHB_CODEPAGE cdp_src, PHB_CODEPAGE cdp_dest )
HB_EXPORT void hb_dbfTranslateRec( DBFAREAP pArea, BYTE * pBuffer, PHB_CODEPAGE cdp_src, PHB_CODEPAGE cdp_dest )
{
USHORT uiIndex;
LPFIELD pField;

View File

@@ -81,13 +81,6 @@ static HB_GARBAGE_FUNC( hb_arrayReleaseGarbage )
{
PHB_BASEARRAY pBaseArray = ( PHB_BASEARRAY ) Cargo;
/* clear object tree as needed */
if( pBaseArray->uiClass && pBaseArray->puiClsTree )
{
hb_xfree( pBaseArray->puiClsTree );
pBaseArray->puiClsTree = NULL;
}
if( pBaseArray->pItems )
{
HB_ITEM_PTR pItems = pBaseArray->pItems;
@@ -138,7 +131,6 @@ HB_EXPORT BOOL hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array
pBaseArray->ulLen = ulLen;
pBaseArray->uiClass = 0;
pBaseArray->uiPrevCls = 0;
pBaseArray->puiClsTree = NULL;
pItem->type = HB_IT_ARRAY;
pItem->item.asArray.value = pBaseArray;

View File

@@ -270,14 +270,11 @@ static HB_SYMB s___msgWithObjectPop = { "___WITHOBJECT", {HB_FS_MESSAGE}, {hb__
static PCLASS s_pClasses = NULL;
static USHORT s_uiClasses = 0;
static PMETHOD s_pMethod = NULL; /* TOFIX: The object engine is not thread safe because of this. [vszakats] */
/* All functions contained in classes.c */
static PHB_ITEM hb_clsInst( USHORT uiClass );
static ULONG hb_cls_MsgToNum( PHB_DYNS pMsg );
static void hb_clsDictRealloc( PCLASS pClass );
static void hb_clsRelease( PCLASS );
#ifdef HB_CLS_ENFORCERO
static PMETHOD hb_objGetpMethod( PHB_ITEM, PHB_SYMB );
@@ -663,6 +660,14 @@ ULONG hb_cls_MsgToNum( PHB_DYNS pMsg )
return nRetVal;
}
char * hb_clsName( USHORT uiClass )
{
if( uiClass && uiClass <= s_uiClasses )
return ( s_pClasses + ( uiClass - 1 ) )->szName;
else
return NULL;
}
BOOL hb_clsIsParent( USHORT uiClass, char * szParentName )
{
USHORT uiAt, uiLimit;
@@ -754,6 +759,10 @@ char * hb_objGetClsName( PHB_ITEM pObject )
szClassName = "LOGICAL";
break;
case HB_IT_POINTER:
szClassName = "POINTER";
break;
default:
szClassName = "UNKNOWN";
break;
@@ -779,46 +788,25 @@ char * hb_objGetRealClsName( PHB_ITEM pObject, char * szName )
{
PHB_DYNS pMsg = hb_dynsymFindName( szName );
USHORT uiClass;
USHORT uiCurCls;
USHORT uiClsTree;
uiClass = pObject->item.asArray.value->uiClass;
if( uiClass && uiClass <= uiClass )
{
PCLASS pClass = s_pClasses + ( uiClass - 1 );
USHORT uiAt = ( USHORT ) ( ( ( hb_cls_MsgToNum( pMsg ) ) % pClass->uiHashKey ) * BUCKET );
USHORT uiMask = ( USHORT ) ( pClass->uiHashKey * BUCKET );
USHORT uiLimit = ( USHORT ) ( uiAt ? ( uiAt - 1 ) : ( uiMask - 1 ) );
/* default value to current class object */
if (pObject->item.asArray.value->puiClsTree && pObject->item.asArray.value->puiClsTree[0])
{
uiClsTree = pObject->item.asArray.value->puiClsTree[0] ;
uiCurCls = pObject->item.asArray.value->puiClsTree[uiClsTree] ;
}
else
{
uiClsTree = 1; /* Flag value */
uiCurCls = uiClass;
}
while (uiClsTree)
{
if( uiCurCls && uiCurCls <= s_uiClasses )
while( uiAt != uiLimit )
{
PCLASS pClass = s_pClasses + ( uiCurCls - 1 );
USHORT uiAt = ( USHORT ) ( ( ( hb_cls_MsgToNum( pMsg ) ) % pClass->uiHashKey ) * BUCKET );
USHORT uiMask = ( USHORT ) ( pClass->uiHashKey * BUCKET );
USHORT uiLimit = ( USHORT ) ( uiAt ? ( uiAt - 1 ) : ( uiMask - 1 ) );
while( uiAt != uiLimit )
if( pClass->pMethods[ uiAt ].pMessage == pMsg )
{
if( pClass->pMethods[ uiAt ].pMessage == pMsg )
{
uiClass = (pClass->pMethods + uiAt)->uiSprClass;
uiClsTree=1; /* Flag Value */
break;
}
if( ++uiAt == uiMask )
uiAt = 0;
uiClass = ( pClass->pMethods + uiAt )->uiSprClass;
break;
}
if( ++uiAt == uiMask )
uiAt = 0;
}
if (-- uiClsTree)
uiCurCls = pObject->item.asArray.value->puiClsTree[uiClsTree] ;
}
if( uiClass && uiClass <= s_uiClasses )
@@ -828,16 +816,12 @@ char * hb_objGetRealClsName( PHB_ITEM pObject, char * szName )
return hb_objGetClsName( pObject );
}
static void hb_objPushSuperCast( PHB_ITEM pObject )
static void hb_objRevertSuperCast( PHB_ITEM pObject )
{
PHB_BASEARRAY pObjBase;
PHB_ITEM pRealObj;
USHORT uiClass;
USHORT nPos;
pObjBase = pObject->item.asArray.value;
uiClass = pObjBase->uiClass;
pRealObj = hb_itemNew( pObjBase->pItems );
/* and take back the good pObjBase */
pObjBase = pRealObj->item.asArray.value;
@@ -845,42 +829,6 @@ static void hb_objPushSuperCast( PHB_ITEM pObject )
hb_itemSwap( pObject, pRealObj );
/* and release the fake one */
hb_itemRelease( pRealObj );
/* Push current SuperClass handle */
if ( ! pObjBase->puiClsTree )
{
pObjBase->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) );
pObjBase->puiClsTree[ 0 ] = 0;
}
nPos = pObjBase->puiClsTree[ 0 ] + 1;
pObjBase->puiClsTree = ( USHORT * ) hb_xrealloc( pObjBase->puiClsTree, sizeof( USHORT ) * ( nPos + 1 ) );
pObjBase->puiClsTree[ 0 ] = nPos ;
pObjBase->puiClsTree[ nPos ] = uiClass;
}
void hb_objPopSuperCast( PHB_ITEM pObject )
{
if( HB_IS_OBJECT( pObject ) )
{
PHB_BASEARRAY pObjBase = pObject->item.asArray.value;
if( pObjBase->puiClsTree )
{
USHORT nPos = pObjBase->puiClsTree[ 0 ] - 1;
/* POP SuperClass handle */
if( nPos )
{
pObjBase->puiClsTree = ( USHORT * ) hb_xrealloc( pObjBase->puiClsTree, sizeof( USHORT ) * ( nPos + 1 ) );
pObjBase->puiClsTree[ 0 ] = nPos;
}
else
{
hb_xfree(pObjBase->puiClsTree);
pObjBase->puiClsTree = NULL ;
}
}
}
}
/*
@@ -888,16 +836,12 @@ void hb_objPopSuperCast( PHB_ITEM pObject )
*
* Internal function to the function pointer of a message of an object
*/
PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, BOOL * pfPopSuper )
PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, PHB_STACK_STATE pStack )
{
PCLASS pClass = NULL;
PHB_DYNS pMsg;
HB_TRACE(HB_TR_DEBUG, ("hb_objGetMethod(%p, %p, %p)", pObject, pMessage, pfPopSuper));
s_pMethod = NULL;
if( pfPopSuper )
*pfPopSuper = FALSE;
HB_TRACE(HB_TR_DEBUG, ("hb_objGetMethod(%p, %p, %p)", pObject, pMessage, pStack));
pMsg = pMessage->pDynSym;
@@ -905,10 +849,11 @@ PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, BOOL * pfPopSuper
{
USHORT uiClass = pObject->item.asArray.value->uiClass;
if( pfPopSuper && pObject->item.asArray.value->uiPrevCls )
if( pStack )
{
hb_objPushSuperCast( pObject );
*pfPopSuper = TRUE;
pStack->uiClass = uiClass;
if( pObject->item.asArray.value->uiPrevCls )
hb_objRevertSuperCast( pObject );
}
if( uiClass && uiClass <= s_uiClasses )
@@ -924,10 +869,10 @@ PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, BOOL * pfPopSuper
{
if( pClass->pMethods[ uiAt ].pMessage == pMsg )
{
PMETHOD pMethod = pClass->pMethods + uiAt;
/* hb_clsScope( pObject, pMethod ); */ /* debug */
s_pMethod = pMethod ;
return pMethod->pFuncSym;
/* hb_clsScope( pObject, pClass->pMethods + uiAt ); */
if( pStack )
pStack->uiMethod = uiAt;
return ( pClass->pMethods + uiAt )->pFuncSym;
}
uiAt++;
if( uiAt == uiMask )
@@ -1017,7 +962,7 @@ PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, BOOL * pfPopSuper
else if( pMsg == s___msgClass.pDynSym )
return &s___msgClass;
*/
if( pfPopSuper )
if( pStack )
{
if( pClass && pClass->pFunError )
return pClass->pFunError;
@@ -1786,8 +1731,6 @@ static PHB_ITEM hb_clsInst( USHORT uiClass )
pSelf->item.asArray.value->uiClass = uiClass;
pSelf->item.asArray.value->uiPrevCls = 0;
pSelf->item.asArray.value->puiClsTree = NULL;
/* Initialise value if initialisation was requested */
pMeth = pClass->pMethods;
for( uiAt = 0; uiAt < uiLimit; uiAt++, pMeth++ )
@@ -1963,12 +1906,7 @@ HB_FUNC( __OBJCLONE )
if( pSrcObject )
{
pDstObject= hb_arrayClone( pSrcObject );
/* pDstObject->item.asArray.value->puiClsTree = NULL; */
/* pDstObject->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); */
/* pDstObject->item.asArray.value->puiClsTree[0]=0; */
pDstObject = hb_arrayClone( pSrcObject );
hb_itemRelease( hb_itemReturn( pDstObject ) );
}
else
@@ -2458,21 +2396,23 @@ static HARBOUR hb___msgClsParent( void )
*/
static HARBOUR hb___msgEvalInline( void )
{
USHORT uiClass = ( hb_stackSelfItem() )->item.asArray.value->uiClass;
USHORT uiParam;
PCLASS pClass = s_pClasses +
hb_stackSelfItem()->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
USHORT uiPCount = hb_pcount();
USHORT uiParam;
hb_vmPushSymbol( &hb_symEval );
hb_vmPush( hb_arrayGetItemPtr( s_pClasses[ uiClass - 1 ].pInlines,
s_pMethod->uiData ) );
hb_vmPush( hb_stackSelfItem() ); /* Push self */
hb_vmPush( hb_arrayGetItemPtr( pClass->pInlines, pMethod->uiData ) );
hb_vmPush( hb_stackSelfItem() ); /* Push self */
for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
{
hb_vmPush( hb_stackItemFromBase( uiParam ) );
}
hb_vmDo( ( USHORT ) ( uiPCount + 1 ) ); /* Self is also an argument */
hb_vmDo( uiPCount + 1 ); /* Self is also an argument */
}
/*
@@ -2535,34 +2475,21 @@ static HARBOUR hb___msgNoMethod( void )
*
* Internal function to return a superobject
*/
/*
static HARBOUR hb___msgSuper( void )
{
PHB_ITEM pObject = hb_stackSelfItem();
pObject->item.asArray.value->uiPrevCls = pObject->item.asArray.value->uiClass; / * backup of actual handel * /
pObject->item.asArray.value->uiClass = s_pMethod->uiSprClass; / * superclass handel casting * /
hb_itemReturn( pObject );
}
*/
static HARBOUR hb___msgSuper( void )
{
PHB_ITEM pObject = hb_stackSelfItem();
/*ULONG ulLen = pObject->item.asArray.value->ulLen; */
PHB_ITEM pCopy = hb_itemArrayNew(1);
USHORT uiClass = pObject->item.asArray.value->uiClass;
/* Now save the Self object as the 1st elem. */
hb_itemArrayPut( pCopy, 1 , pObject );
/* Or Store original object as 1st elem */
/* hb_itemCopy( pCopy->item.asArray.value->pItems , pObject) ; */
hb_arraySet( pCopy, 1, pObject );
/* And transform it into a fake object */
pCopy->item.asArray.value->uiPrevCls = pObject->item.asArray.value->uiClass; /* backup of actual handel */
pCopy->item.asArray.value->uiClass = s_pMethod->uiSprClass; /* superclass handel casting */
pCopy->item.asArray.value->puiClsTree = NULL ;
/* backup of actual handel */
pCopy->item.asArray.value->uiPrevCls = uiClass;
/* superclass handel casting */
pCopy->item.asArray.value->uiClass = ( ( s_pClasses + uiClass - 1 )->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod )->uiSprClass;
hb_itemRelease( hb_itemReturn( pCopy ) );
}
@@ -2574,10 +2501,12 @@ static HARBOUR hb___msgSuper( void )
*/
static HARBOUR hb___msgGetClsData( void )
{
USHORT uiClass = ( hb_stackSelfItem() )->item.asArray.value->uiClass;
PCLASS pClass = s_pClasses +
hb_stackSelfItem()->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
if( uiClass && uiClass <= s_uiClasses )
hb_arrayGet( s_pClasses[ uiClass - 1 ].pClassDatas, s_pMethod->uiData, hb_stackReturnItem() );
hb_arrayGet( pClass->pClassDatas, pMethod->uiData, hb_stackReturnItem() );
}
@@ -2588,15 +2517,13 @@ static HARBOUR hb___msgGetClsData( void )
*/
static HARBOUR hb___msgSetClsData( void )
{
USHORT uiClass = ( hb_stackSelfItem() )->item.asArray.value->uiClass;
PCLASS pClass = s_pClasses +
hb_stackSelfItem()->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
PHB_ITEM pReturn = hb_stackItemFromBase( 1 );
if( uiClass && uiClass <= s_uiClasses )
{
hb_arraySet( s_pClasses[ uiClass - 1 ].pClassDatas, s_pMethod->uiData, pReturn );
}
hb_arraySet( pClass->pClassDatas, pMethod->uiData, pReturn );
hb_itemReturn( pReturn );
}
@@ -2607,10 +2534,17 @@ static HARBOUR hb___msgSetClsData( void )
*/
static HARBOUR hb___msgGetShrData( void )
{
USHORT uiSprCls = s_pMethod->uiSprClass;
PCLASS pClass = s_pClasses +
hb_stackSelfItem()->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
USHORT uiSprCls = pMethod->uiSprClass;
if( uiSprCls && uiSprCls <= s_uiClasses )
hb_arrayGet( s_pClasses[ uiSprCls - 1 ].pClassDatas, s_pMethod->uiDataShared, hb_stackReturnItem() );
{
hb_arrayGet( s_pClasses[ uiSprCls - 1 ].pClassDatas,
pMethod->uiDataShared, hb_stackReturnItem() );
}
}
/*
@@ -2620,13 +2554,18 @@ static HARBOUR hb___msgGetShrData( void )
*/
static HARBOUR hb___msgSetShrData( void )
{
USHORT uiSprCls = s_pMethod->uiSprClass;
PCLASS pClass = s_pClasses +
hb_stackSelfItem()->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
USHORT uiSprCls = pMethod->uiSprClass;
PHB_ITEM pReturn = hb_stackItemFromBase( 1 );
if( uiSprCls && uiSprCls <= s_uiClasses )
{
hb_arraySet( s_pClasses[ uiSprCls - 1 ].pClassDatas, s_pMethod->uiDataShared, pReturn );
hb_arraySet( s_pClasses[ uiSprCls - 1 ].pClassDatas,
pMethod->uiDataShared, pReturn );
}
hb_itemReturn( pReturn );
@@ -2640,13 +2579,21 @@ static HARBOUR hb___msgSetShrData( void )
static HARBOUR hb___msgGetData( void )
{
PHB_ITEM pObject = hb_stackSelfItem();
USHORT uiIndex = s_pMethod->uiData;
PCLASS pClass = s_pClasses +
pObject->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
ULONG ulIndex = pMethod->uiData;
/* TOFIX: this code does not work correctly when super casting is used
for classes with multiinheritance - to ulIndex we should add additional
variable uiSuperInstantOffset, [druzus] */
/* will arise only if the class has been modified after first instance */
if( uiIndex > ( USHORT ) hb_arrayLen( pObject ) ) /* Resize needed */
hb_arraySize( pObject, uiIndex ); /* Make large enough */
if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed */
hb_arraySize( pObject, ulIndex ); /* Make large enough */
hb_arrayGet( pObject, uiIndex, hb_stackReturnItem() );
hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() );
}
/*
@@ -2656,17 +2603,23 @@ static HARBOUR hb___msgGetData( void )
*/
static HARBOUR hb___msgSetData( void )
{
PHB_ITEM pObject = hb_stackSelfItem();
PHB_ITEM pReturn = hb_stackItemFromBase( 1 );
USHORT uiIndex = s_pMethod->uiData;
PHB_ITEM pObject = hb_stackSelfItem();
PCLASS pClass = s_pClasses +
pObject->item.asArray.value->uiClass - 1;
PMETHOD pMethod = pClass->pMethods +
hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
ULONG ulIndex = pMethod->uiData;
/* TOFIX: this code does not work correctly when super casting is used
for classes with multiinheritance - to ulIndex we should add additional
variable uiSuperInstantOffset, [druzus] */
/* will arise only if the class has been modified after first instance */
if( uiIndex > ( USHORT ) hb_arrayLen( pObject ) ) /* Resize needed ? */
{
hb_arraySize( pObject, uiIndex ); /* Make large enough */
}
if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */
hb_arraySize( pObject, ulIndex ); /* Make large enough */
hb_arraySet( pObject, uiIndex, pReturn );
hb_arraySet( pObject, ulIndex, pReturn );
hb_itemReturn( pReturn );
}
@@ -2736,19 +2689,14 @@ HB_FUNC( __CLS_PAR00 )
}
#ifndef HB_NO_PROFILER
/* profiler: It provides to the HVM the just requested method pointer */
void * hb_mthRequested( void )
void hb_mthAddTime( ULONG ulClockTicks )
{
return ( void * ) s_pMethod;
}
PMETHOD pMethod =
( s_pClasses + hb_stackSelfItem()->item.asArray.value->uiClass - 1 )->
pMethods + hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
void hb_mthAddTime( void * pMethod, ULONG ulClockTicks )
{
if( pMethod != NULL )
{
( ( PMETHOD ) pMethod )->ulCalls++; /* Profiler */
( ( PMETHOD ) pMethod )->ulTime += ulClockTicks;
}
pMethod->ulCalls++;
pMethod->ulTime += ulClockTicks;
}
#endif
@@ -2774,7 +2722,7 @@ HB_FUNC( __GETMSGPRF ) /* profiler: returns a method called and consumed times *
while( uiAt != uiLimit )
{
if( pClass->pMethods[ uiAt ].pMessage->pSymbol->pDynSym = pMsg )
if( pClass->pMethods[ uiAt ].pMessage->pSymbol->pDynSym == pMsg )
{
pMethod = pClass->pMethods + uiAt;
hb_stornl( pMethod->ulCalls, -1, 1 );

View File

@@ -244,6 +244,8 @@ HB_ITEM_PTR hb_stackNewFrame( HB_STACK_STATE * pStack, USHORT uiParams )
pStack->lBaseItem = hb_stack.pBase - hb_stack.pItems;
pStack->lStatics = hb_stack.lStatics;
pStack->ulPrivateBase = hb_memvarGetPrivatesBase();
pStack->uiClass = pStack->uiMethod = 0;
pItem->item.asSymbol.stackstate = pStack;
pItem->item.asSymbol.lineno = 0;
pItem->item.asSymbol.paramcnt = uiParams;

View File

@@ -3905,7 +3905,6 @@ HB_EXPORT void hb_vmDo( USHORT uiParams )
#ifndef HB_NO_PROFILER
ULONG ulClock = 0;
void * pMethod = NULL;
BOOL bProfiler = hb_bProfiler; /* because profiler state may change */
#endif
@@ -3930,15 +3929,10 @@ HB_EXPORT void hb_vmDo( USHORT uiParams )
if( ! HB_IS_NIL( pSelf ) ) /* are we sending a message ? */
{
PHB_SYMB pExecSym;
BOOL lPopSuper;
pExecSym = hb_objGetMethod( pSelf, pSym, &lPopSuper );
pExecSym = hb_objGetMethod( pSelf, pSym, &sStackState );
if( pExecSym && pExecSym->value.pFunPtr )
{
#ifndef HB_NO_PROFILER
if( bProfiler )
pMethod = hb_mthRequested();
#endif
if( hb_bTracePrgCalls )
HB_TRACE(HB_TR_ALWAYS, ("Calling: %s:%s", hb_objGetClsName( pSelf ), pSym->szName));
@@ -3951,16 +3945,13 @@ HB_EXPORT void hb_vmDo( USHORT uiParams )
#ifndef HB_NO_PROFILER
if( bProfiler )
hb_mthAddTime( pMethod, clock() - ulClock );
hb_mthAddTime( clock() - ulClock );
#endif
}
else if( pSym->szName[ 0 ] == '_' )
hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1, HB_ERR_ARGS_SELFPARAMS );
else
hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, pSym->szName, HB_ERR_ARGS_SELFPARAMS );
if( lPopSuper )
hb_objPopSuperCast( pSelf );
}
else /* it is a function */
{
@@ -4009,10 +4000,8 @@ HB_EXPORT void hb_vmSend( USHORT uiParams )
HB_STACK_STATE sStackState;
PHB_ITEM pSelf;
BOOL bDebugPrevState;
BOOL lPopSuper;
#ifndef HB_NO_PROFILER
ULONG ulClock = 0;
void * pMethod = NULL;
BOOL bProfiler = hb_bProfiler; /* because profiler state may change */
#endif
@@ -4035,13 +4024,9 @@ HB_EXPORT void hb_vmSend( USHORT uiParams )
bDebugPrevState = s_bDebugging;
s_bDebugging = FALSE;
pExecSym = hb_objGetMethod( pSelf, pSym, &lPopSuper );
pExecSym = hb_objGetMethod( pSelf, pSym, &sStackState );
if( pExecSym && pExecSym->value.pFunPtr )
{
#ifndef HB_NO_PROFILER
if( bProfiler )
pMethod = hb_mthRequested();
#endif
if( hb_bTracePrgCalls )
HB_TRACE(HB_TR_ALWAYS, ("Calling: %s:%s", hb_objGetClsName( pSelf ), pSym->szName));
@@ -4054,7 +4039,7 @@ HB_EXPORT void hb_vmSend( USHORT uiParams )
#ifndef HB_NO_PROFILER
if( bProfiler )
hb_mthAddTime( pMethod, clock() - ulClock );
hb_mthAddTime( clock() - ulClock );
#endif
}
else if( pSym->szName[ 0 ] == '_' )
@@ -4062,9 +4047,6 @@ HB_EXPORT void hb_vmSend( USHORT uiParams )
else
hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, pSym->szName, HB_ERR_ARGS_SELFPARAMS );
if( lPopSuper )
hb_objPopSuperCast( pSelf );
if( s_bDebugging )
hb_vmDebuggerEndProc();

View File

@@ -59,7 +59,6 @@
*
* Copyright 2001 JFL (Mafact) <jfl@mafact.com>
* Adding the MethodName() just calling Procname()
* call to hb_objGetRealClsName in case of object
* Special treatment in case of Object and __Eval (only for methodname)
* skipping block and adding (b) before the method name
*
@@ -160,22 +159,20 @@ char * hb_procname( int iLevel, char * szName, BOOL bSkipBlock )
{
PHB_ITEM pBase, pSelf;
if( bSkipBlock && lOffset > 0 )
if( bSkipBlock && lOffset > 0 &&
hb_stackItem( lOffset )->item.asSymbol.value == &hb_symEval )
{
char * szTstName = hb_stackItem( lOffset )->item.asSymbol.value->szName ;
/* Is it an inline method ? if so back one more ... */
if( strcmp( szTstName, "__EVAL" ) == 0 )
{
lPrevOffset = lOffset;
lOffset = hb_stackItem( lOffset )->item.asSymbol.stackstate->lBaseItem;
}
/* it's an inline method - back one more ... */
lPrevOffset = lOffset;
lOffset = hb_stackItem( lOffset )->item.asSymbol.stackstate->lBaseItem;
}
pBase = hb_stackItem( lOffset );
pSelf = hb_stackItem( lOffset + 1 );
if( HB_IS_OBJECT( pSelf ) ) /* it is a method name */
if( pBase->item.asSymbol.stackstate->uiClass ) /* it is a method name */
{
strcpy( szName, hb_objGetRealClsName( pSelf, pBase->item.asSymbol.value->szName ) );
strcpy( szName, hb_clsName( pBase->item.asSymbol.stackstate->uiClass ) );
if( lPrevOffset )
strcat( szName, ":(b)" );
@@ -234,9 +231,9 @@ BOOL hb_procinfo( int iLevel, char * szName, USHORT * puiLine, char * szFile )
if( szName )
{
if( HB_IS_OBJECT( pSelf ) ) /* it is a method name */
if( pBase->item.asSymbol.stackstate->uiClass ) /* it is a method name */
{
strcpy( szName, hb_objGetRealClsName( pSelf, pSym->szName ) );
strcpy( szName, hb_clsName( pBase->item.asSymbol.stackstate->uiClass ) );
strcat( szName, ":" );
strcat( szName, pSym->szName );
}