From bb8804e7aca1aecb11b0fa1b51ddd9f774e40373 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 29 Sep 2006 20:51:46 +0000 Subject: [PATCH] 2006-09-29 22:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/classes.c * allow to access object variables using assign messages without parameter. I do not want to add symmetric behavior for access messages though it's technically possible but such things should be controlled by programmer because access messages can have less restricted scoping then assign ones (READONLY) so I'll add new rule for it in hbclass.ch * harbour/source/vm/hvm.c * fixed warning message when object variable reference is generated using macro compiler without '_' as prefix. --- harbour/ChangeLog | 12 +++++ harbour/source/vm/classes.c | 103 +++++++++++++++++++----------------- harbour/source/vm/hvm.c | 2 +- 3 files changed, 66 insertions(+), 51 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6c30dc652f..fb4f0a8596 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + [ ; #translate Super( ): => ::: ] ; + [ ; #translate Super( ): => ::: ] ; + [ ; #translate Super(): => ::: ] ; + [ ; #translate Super: => ::: ] ; + [ ; #translate ::Super : => ::: ] + These rules introduce very serious bug - they are breaking supercasting + in code which makes sth like: + ::super:super:super:msg + or in any other code which sends SUPER message to some other class + objects. I will have to remove them. At least the last three ones. + There were some other things I wanted to write about but it's too late + and I'm to tired - sorry. If you will have any question please ask. if you will notice some problems with current rules please inform me. 2006-09-29 22:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index c0bc637085..71c83f7fb5 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -3458,26 +3458,27 @@ static HARBOUR hb___msgSetClsData( void ) hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ]; PMETHOD pMethod = pClass->pMethods + hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod; - PHB_ITEM pReturn = hb_stackItemFromBase( 1 ); + PHB_ITEM pReturn = hb_param( 1, HB_IT_ANY ); if( !pReturn ) - return; - else if( HB_IS_BYREF( pReturn ) ) - pReturn = hb_itemUnRef( pReturn ); + hb_arrayGet( pClass->pClassDatas, pMethod->uiData, hb_stackReturnItem() ); - if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) + else { - if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) - hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); - else + if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) { - (s___msgTypeErr.value.pFunPtr)(); - return; + if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) + hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); + else + { + (s___msgTypeErr.value.pFunPtr)(); + return; + } } - } - hb_arraySet( pClass->pClassDatas, pMethod->uiData, pReturn ); - hb_itemReturnForward( pReturn ); + hb_arraySet( pClass->pClassDatas, pMethod->uiData, pReturn ); + hb_itemReturnForward( pReturn ); + } } /* @@ -3507,27 +3508,28 @@ static HARBOUR hb___msgSetShrData( void ) hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ]; PMETHOD pMethod = pClass->pMethods + hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod; - PHB_ITEM pReturn = hb_stackItemFromBase( 1 ); + PHB_ITEM pReturn = hb_param( 1, HB_IT_ANY ); if( !pReturn ) - return; - else if( HB_IS_BYREF( pReturn ) ) - pReturn = hb_itemUnRef( pReturn ); - - if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) + hb_arrayGet( s_pClasses[ pMethod->uiSprClass ].pSharedDatas, + pMethod->uiData, hb_stackReturnItem() ); + else { - if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) - hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); - else + if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) { - (s___msgTypeErr.value.pFunPtr)(); - return; + if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) + hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); + else + { + (s___msgTypeErr.value.pFunPtr)(); + return; + } } - } - hb_arraySet( s_pClasses[ pMethod->uiSprClass ].pSharedDatas, - pMethod->uiData, pReturn ); - hb_itemReturnForward( pReturn ); + hb_arraySet( s_pClasses[ pMethod->uiSprClass ].pSharedDatas, + pMethod->uiData, pReturn ); + hb_itemReturnForward( pReturn ); + } } /* @@ -3565,7 +3567,7 @@ static HARBOUR hb___msgGetData( void ) */ static HARBOUR hb___msgSetData( void ) { - PHB_ITEM pReturn = hb_stackItemFromBase( 1 ); + PHB_ITEM pReturn = hb_param( 1, HB_IT_ANY ); PHB_ITEM pObject = hb_stackSelfItem(); USHORT uiObjClass = pObject->item.asArray.value->uiClass; USHORT uiClass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass; @@ -3574,22 +3576,6 @@ static HARBOUR hb___msgSetData( void ) hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod; ULONG ulIndex = pMethod->uiData; - if( !pReturn ) - return; - else if( HB_IS_BYREF( pReturn ) ) - pReturn = hb_itemUnRef( pReturn ); - - if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) - { - if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) - hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); - else - { - (s___msgTypeErr.value.pFunPtr)(); - return; - } - } - if( uiClass != uiObjClass ) { ulIndex += hb_clsParentInstanceOffset( &s_pClasses[ uiObjClass ], @@ -3600,11 +3586,28 @@ static HARBOUR hb___msgSetData( void ) ulIndex += pMethod->uiOffset; } - /* will arise only if the class has been modified after first instance */ - if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */ - hb_arraySize( pObject, ulIndex ); /* Make large enough */ - hb_arraySet( pObject, ulIndex, pReturn ); - hb_itemReturnForward( pReturn ); + if( !pReturn ) + hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() ); + + else + { + if( pMethod->itemType && ! ( pMethod->itemType & pReturn->type ) ) + { + if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) ) + hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) ); + else + { + (s___msgTypeErr.value.pFunPtr)(); + return; + } + } + + /* will arise only if the class has been modified after first instance */ + if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */ + hb_arraySize( pObject, ulIndex ); /* Make large enough */ + hb_arraySet( pObject, ulIndex, pReturn ); + hb_itemReturnForward( pReturn ); + } } /* No comment :-) */ diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 1795630b40..aaa1e21faa 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -4263,7 +4263,7 @@ static void hb_vmPushObjectVarRef( void ) if( !hb_objGetVarRef( hb_stackSelfItem(), pSym, &sStackState ) && hb_vmRequestQuery() == 0 ) - hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1, 1, hb_stackSelfItem() ); + hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + ( pSym->szName[ 0 ] == '_' ? 1 : 0 ), 1, hb_stackSelfItem() ); hb_stackOldFrame( &sStackState );