diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 02d0ca4939..a046fc0a1f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,12 @@ +2001-06-15 23:35 UTC+1 JFL (mafact) + * harbour/source/vm/Classe.c + * Hb_ClsScope finally working :-( + * harbour/include/hbsetup.ch + - removed not more needed #define about Hidden + (was causing a 'message not found' when heriting hidden var) + * harbour/include/hbclass.ch + + added the support of calling ::Super from a method + 2001-06-15 14:45 UTC-0400 David G. Holm * source\rtl\dir.c diff --git a/harbour/include/hbclass.ch b/harbour/include/hbclass.ch index 3c2abe0d0b..4e9170fcaa 100644 --- a/harbour/include/hbclass.ch +++ b/harbour/include/hbclass.ch @@ -167,6 +167,7 @@ DECLARE TClass ; [ ; #translate Super( ) : => ::: ] ; [ ; #translate Super() : => ::: ] ; [ ; #translate Super : => ::: ] ; + [ ; #translate ::Super : => ::: ] ; [ ; REQUEST ] [ , ] #else @@ -187,6 +188,7 @@ DECLARE TClass ; [ ; #translate Super( ) : => ::: ] ; [ ; #translate Super() : => ::: ] ; [ ; #translate Super : => ::: ] ; + [ ; #translate ::Super : => ::: ] ; [ ; REQUEST ] [ , ] #endif /* HB_SHORTNAMES */ diff --git a/harbour/include/hbsetup.ch b/harbour/include/hbsetup.ch index b4b4cc1204..6757776e40 100644 --- a/harbour/include/hbsetup.ch +++ b/harbour/include/hbsetup.ch @@ -79,8 +79,8 @@ #define HB_SHORTNAMES #endif -#define HB_CLS_MASKHIDDEN /* Disallow heritence of hidden variables */ -//#define HB_CLS_ENFORCERO /* Activate the RO checking on OO DATA */ +/*#define HB_CLS_ENFORCERO */ /* Activate the RO checking on OO DATA */ + /* when not called from a constructor */ #endif /* HB_SETUP_CH_ */ diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 3ae55994fa..c389421729 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -172,9 +172,9 @@ #include "hbvm.h" #include "hboo.ch" -#include /* DEBUG only*/ +/*#include */ /*#include */ typedef struct @@ -431,7 +431,7 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod ) while( ( iLevel-- > 0 ) && pBase != hb_stack.pItems ) pBase = hb_stack.pItems + ( *pBase )->item.asSymbol.stackbase; - szCallerNameMsg = ( *pBase )->item.asSymbol.value->szName ; + szCallerNameMsg = ( *pBase )->item.asSymbol.value->szName ; /* Is it an inline ? if so back one more ... */ if ( ( strcmp( szCallerNameMsg, "__EVAL" ) == 0 ) && pBase != hb_stack.pItems) @@ -439,15 +439,21 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod ) pBase = hb_stack.pItems + ( *pBase )->item.asSymbol.stackbase; } - /* Now get the callers ... */ - pCaller = * (pBase+1 ) ; - szCallerNameObject = hb_objGetClsName( pCaller ) ; - szCallerNameMsg = ( *pBase )->item.asSymbol.value->szName ; - if( iLevel == -1 ) { - strcpy( szName, szSelfNameObject ); + /* Now get the callers ... */ + pCaller = * (pBase+1 ) ; + szCallerNameMsg = ( *pBase )->item.asSymbol.value->szName ; + 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 ); @@ -455,33 +461,33 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod ) if( ( *( pBase+1 ) )->type == HB_IT_ARRAY ) /* is the sender an object */ { /* Trying to access a protected Msg from outside the object ... */ - if (! (pCaller == pObject) ) - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (protected)", szName, 0 ); + if ( strcmp( szCallerNameObject, szSelfNameRealClass ) != 0 ) + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (protected 1)", szName, 0 ); } else { /* If called from a function ... protected violation ! */ - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (protected)", szName, 0 ); + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (protected 0)", szName, 0 ); } if ( uiScope & HB_OO_CLSTP_HIDDEN ) if( ( *( pBase+1 ) )->type == HB_IT_ARRAY ) /* is the sender an object */ { /* Trying to access a protected Msg from outside the object ... */ - if (! (pCaller == pObject) ) - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden)", szName, 0 ); + if ( strcmp( szCallerNameObject, szSelfNameRealClass ) != 0 ) + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden 1)", szName, 0 ); else { /* Now as it is an hidden Msg, it can only be called from */ /* a method of its original class */ if (! (hb_objGetRealClsName( pCaller, szCallerNameMsg) == szSelfNameRealClass) ) - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden)", szName, 0 ); + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden 2)", szName, 0 ); } } else { /* If called from a function ... Hidden violation ! */ - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden)", szName, 0 ); + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (Hidden 0)", szName, 0 ); } if ( uiScope & HB_OO_CLSTP_READONLY ) @@ -497,13 +503,13 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod ) if( ( *( pBase+1 ) )->type == HB_IT_ARRAY ) /* is the sender an object */ { /* Trying to assign a RO Msg from outside the object ... */ - if (! (pCaller == pObject) ) + if ( strcmp( szCallerNameObject, szSelfNameRealClass ) != 0 ) hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (ReadOnly)", szName, 0 ); else { - /* can only be called from a Constructor */ #ifdef HB_CLS_ENFORCERO /* Not enabled by default */ - /* ok Now is it a CTOR ? */ + /* can only be called from a Constructor */ + /* ok Now is it a CTOR ? */ PHB_DYNS pCallerMsg = hb_dynsymGet( szCallerNameMsg ); @@ -520,7 +526,7 @@ void hb_clsScope( PHB_ITEM pObject, PMETHOD pMethod ) else { /* If called from a function ... ReadOnly violation ! */ - hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (ReadOnly)", szName, 0 ); + hb_errRT_BASE( EG_NOMETHOD, 1004, "Scope violation (ReadOnly 0)", szName, 0 ); } } } @@ -1227,11 +1233,6 @@ HB_FUNC( __CLSNEW ) for( uiBucket = 0; uiBucket < BUCKET; uiBucket++ ) { -#ifdef HB_CLS_MASKHIDDEN /* no hidden methods allowed by the inheritence. */ - if( ( pSprCls->pMethods[ ui ].uiScope & HB_OO_CLSTP_HIDDEN ) == HB_OO_CLSTP_HIDDEN ) - break; -#endif - /* Ok, this bucket is empty */ if( pNewCls->pMethods[ uiAt+uiBucket ].pMessage == 0 ) {