2001-11-26 22:55 GMT+1 JFL (mafact) <jfl@mafact.com>

This commit is contained in:
Jean-Francois Lefebvre
2001-11-26 21:55:26 +00:00
parent 02547acfae
commit ce2eb47611
3 changed files with 86 additions and 37 deletions

View File

@@ -1,3 +1,12 @@
2001-11-26 22:55 GMT+1 JFL (mafact) <jfl@mafact.com>
* harbour/source/vm/classes.c
* Freezed ('remed') scoping due to a small bug wich could always
create a false scoping error ...
* harbour/source/vm/hvm.c
* Changed the way a super call is done so now
Super:Init(::nX) is allowed and ::nX is correctly seen
befor ethat it was see as ::Super:nX ...
2001-11-23 17:57 GMT-3 Horacio Roldan <harbour_ar@yahoo.com.ar>
* source/rdd/dbfcdx/dbfcdx1.c
! fixed gpf with autoopen

View File

@@ -202,7 +202,7 @@ static PHB_DYNS s_msgClsParent = NULL;
static PHB_ITEM hb_clsInst( USHORT uiClass );
static void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod );
static ULONG hb_cls_MsgToNum( PHB_DYNS pMsg );
static BOOL hb_clsIsParent( PCLASS pClass, char * szParentName );
static BOOL hb_clsIsParent( USHORT uiClass, char * szParentName );
static void hb_clsDictRealloc( PCLASS pClass );
static void hb_clsRelease( PCLASS );
void hb_clsReleaseAll( void );
@@ -401,7 +401,7 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod )
char * szCallerNameMsg;
char * szCallerNameObject;
char * szSelfNameMsg;
/* char * szSelfNameObject; */
char * szSelfNameObject; /* debug */
char * szSelfNameRealClass;
if ( (( uiScope & HB_OO_CLSTP_PROTECTED ) ) ||
@@ -410,7 +410,7 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod )
)
{
/*szSelfNameObject = hb_objGetClsName( pObject );*/
szSelfNameObject = hb_objGetClsName( pObject ); /* debug */
szSelfNameMsg = pMessage->pSymbol->szName ;
szSelfNameRealClass = hb_objGetRealClsName( pObject, pMessage->pSymbol->szName );
@@ -446,20 +446,20 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod )
pCaller = * (pBase+1 ) ;
szCallerNameObject = hb_objGetRealClsName( pCaller, szCallerNameMsg ) ;
/*strcpy( szName, szCallerNameObject ); */
/*strcat( szName, ":" ); */
/*strcat( szName, szCallerNameMsg ); */
/*strcat( szName, ">" ); */
/*strcat( szName, szSelfNameRealClass ); */
/*strcat( szName, ">" ); */
/*strcat( szName, szSelfNameObject ); */
/*strcat( szName, ":" ); */
/*strcat( szName, szSelfNameMsg ); */
strcpy( szName, szSelfNameRealClass );
strcpy( szName, szCallerNameObject );
strcat( szName, ":" );
strcat( szName, szCallerNameMsg );
strcat( szName, ">" );
strcat( szName, szSelfNameRealClass );
strcat( szName, ">" );
strcat( szName, szSelfNameObject );
strcat( szName, ":" );
strcat( szName, szSelfNameMsg );
/*strcpy( szName, szSelfNameRealClass ); */
/*strcat( szName, ":" ); */
/*strcat( szName, szSelfNameMsg ); */
if ( uiScope & HB_OO_CLSTP_PROTECTED )
{
if( ( *( pBase+1 ) )->type == HB_IT_ARRAY ) /* is the sender an object */
@@ -555,22 +555,28 @@ ULONG hb_cls_MsgToNum( PHB_DYNS pMsg )
return nRetVal;
}
BOOL hb_clsIsParent( PCLASS pClass, char * szParentName )
BOOL hb_clsIsParent( USHORT uiClass, char * szParentName )
{
USHORT uiAt, uiLimit;
USHORT uiAt, uiLimit;
uiLimit = ( USHORT ) ( pClass->uiHashKey * BUCKET );
if( strcmp( pClass->szName, szParentName ) == 0 )
return TRUE;
for( uiAt = 0; uiAt < uiLimit; uiAt++)
if( uiClass && uiClass <= s_uiClasses )
{
if( ( pClass->pMethods[ uiAt ].uiScope & HB_OO_CLSTP_CLASS ) == HB_OO_CLSTP_CLASS )
{
if( strcmp( pClass->pMethods[ uiAt ].pMessage->pSymbol->szName, szParentName ) == 0 )
return TRUE;
}
PCLASS pClass = s_pClasses + ( uiClass - 1 );
uiLimit = ( USHORT ) ( pClass->uiHashKey * BUCKET );
if( strcmp( pClass->szName, szParentName ) == 0 )
return TRUE;
for( uiAt = 0; uiAt < uiLimit; uiAt++)
{
if( ( pClass->pMethods[ uiAt ].uiScope & HB_OO_CLSTP_CLASS ) == HB_OO_CLSTP_CLASS )
{
if( strcmp( pClass->pMethods[ uiAt ].pMessage->pSymbol->szName, szParentName ) == 0 )
return TRUE;
}
}
}
return FALSE;
@@ -797,7 +803,7 @@ PHB_FUNC hb_objGetMthd( PHB_ITEM pObject, PHB_SYMB pMessage, BOOL lAllowErrFunc
{
pMethod = pClass->pMethods + uiAt;
pFunction = pMethod->pFunction;
hb_clsScope( pObject, pMethod );
/*hb_clsScope( pObject, pMethod );*/ /* debug */
s_pMethod = pMethod ;
if( hb_bProfiler )
@@ -1947,7 +1953,7 @@ HB_FUNC( __GETMESSAGE )
HB_FUNC( __CLSPARENT )
{
hb_retl( hb_clsIsParent( s_pClasses + ( hb_parni( 1 ) - 1 ), hb_parc( 2 ) ) );
hb_retl( hb_clsIsParent( hb_parni( 1 ) , hb_parc( 2 ) ) );
}
HB_FUNC( __SENDER )
@@ -2062,7 +2068,7 @@ static HARBOUR hb___msgClsParent( void )
for( i = 0; szParentName[ i ] != '\0'; i++ )
szParentName[ i ] = ( char ) toupper( szParentName[ i ] );
hb_retl( hb_clsIsParent( pClass, szParentName ) );
hb_retl( hb_clsIsParent( uiClass , szParentName ) );
if (lClass)
hb_itemFreeC( szParentName );
@@ -2224,14 +2230,36 @@ static HARBOUR hb___msgEval( 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);
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 */
/* Now save the Self object as the 1st elem. */
hb_itemArrayPut( pCopy, 1 , pObject );
hb_itemReturn( pObject );
/* Or Store original object as 1st elem */
/* hb_itemCopy( pCopy->item.asArray.value->pItems , 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 = 0 ;
hb_itemRelease(hb_itemReturn( pCopy ));
}
/*

View File

@@ -2956,6 +2956,7 @@ void hb_vmDo( USHORT uiParams )
BOOL lPopSuper = FALSE ;
PHB_BASEARRAY pSelfBase = NULL;
PHB_ITEM pRealSelf=NULL;
USHORT uiClass;
if( pSym == &( hb_symEval ) && HB_IS_BLOCK( pSelf ) )
@@ -2974,8 +2975,13 @@ void hb_vmDo( USHORT uiParams )
*/
uiClass=pSelfBase->uiClass;
pSelfBase->uiClass = pSelfBase->uiPrevCls;
pSelfBase->uiPrevCls = 0 ;
pRealSelf = hb_itemNew( NULL ) ;
hb_itemCopy(pRealSelf ,pSelf->item.asArray.value->pItems) ; // hb_arrayGetItemPtr(pSelf,1) ;
/* and take back the good pSelfBase */
pSelfBase = pRealSelf->item.asArray.value;
/* Now I should exchnage it with the current stacked value */
hb_itemSwap( pSelf, pRealSelf );
hb_itemRelease(pRealSelf) ; /* and release the fake one */
/* Push current SuperClass handle */
lPopSuper = TRUE ;
@@ -3125,6 +3131,7 @@ void hb_vmSend( USHORT uiParams )
BOOL lPopSuper = FALSE ;
PHB_BASEARRAY pSelfBase;
PHB_ITEM pRealSelf=NULL;
USHORT uiClass;
if( ! ( pSym == &( hb_symEval ) && HB_IS_BLOCK( pSelf ) ) )
@@ -3142,8 +3149,13 @@ void hb_vmSend( USHORT uiParams )
*/
uiClass = pSelfBase->uiClass;
pSelfBase->uiClass = pSelfBase->uiPrevCls;
pSelfBase->uiPrevCls = 0 ;
pRealSelf = hb_itemNew( NULL ) ;
hb_itemCopy(pRealSelf ,pSelf->item.asArray.value->pItems) ; // hb_arrayGetItemPtr(pSelf,1) ;
/* and take back the good pSelfBase */
pSelfBase = pRealSelf->item.asArray.value;
/* Now I should exchnage it with the current stacked value */
hb_itemSwap( pSelf, pRealSelf );
hb_itemRelease(pRealSelf) ; /* and release the fake one */
/* Push current SuperClass handle */
lPopSuper = TRUE ;