From 445b265edc79cb6a090304f89422ce1d09410013 Mon Sep 17 00:00:00 2001 From: Eddie Runia Date: Thu, 13 May 1999 11:45:29 +0000 Subject: [PATCH] Delete method and inline added --- harbour/tests/broken/classes.dif | 111 ++++++++++++++++++++++++------- harbour/tests/broken/dynobj.prg | 16 ++++- 2 files changed, 102 insertions(+), 25 deletions(-) diff --git a/harbour/tests/broken/classes.dif b/harbour/tests/broken/classes.dif index c8012763a3..ab44af5a28 100644 --- a/harbour/tests/broken/classes.dif +++ b/harbour/tests/broken/classes.dif @@ -1,6 +1,14 @@ --- \source\tcpp\cvstest\harbour\source\rtl\classes.c Tue May 11 20:23:38 1999 -+++ \source\tcpp\harb21-2\source\rtl\classes.c Thu May 13 10:52:36 1999 -@@ -136,12 +136,22 @@ ++++ \source\tcpp\harb21-2\source\rtl\classes.c Thu May 13 12:34:32 1999 +@@ -10,6 +10,7 @@ + void PushSymbol( PSYMBOL ); + void Message( PSYMBOL ); + void Do( WORD wParams ); ++void ArrayDel( PITEM, WORD ); + + #define MET_METHOD 0 + #define MET_DATA 1 +@@ -136,12 +137,22 @@ static HARBOUR GetData( void ) { @@ -25,7 +33,7 @@ } static HARBOUR GetClassData( void ) -@@ -503,6 +513,59 @@ +@@ -503,6 +514,114 @@ else { /* TODO: Crash code */ } @@ -40,7 +48,7 @@ +} /* number of DATAs */ + +HARBOUR CLASSMOD() /* Modify message (only for INLINE and METHOD) */ -+ /* := ClassMod(,, */ ++ /* := ClassMod( , , ) */ +{ + PITEM pString = _param( 2, IT_STRING ); + PSYMBOL pMessage = GetDynSym( pString->value.szText )->pSymbol; @@ -59,27 +67,82 @@ + wAt = ( ( ( unsigned ) pMsg ) % pClass->wHashKey ) * BUCKET; + wLimit = wAt + BUCKET; + -+ while( wAt < wLimit ) -+ { -+ if( pClass->pMethods[ wAt ].pMessage == pMsg ) -+ { /* Requested method found */ -+ pFunc = pClass->pMethods[ wAt ].pFunction; -+ if( pFunc == EvalInline ) /* INLINE method changed */ -+ { -+ ArraySet( &pClass->aInlines, pClass->pMethods[ wAt ].wData, -+ _param( 3, IT_BLOCK ) ); -+ } -+ else if( ( pFunc == SetData ) || ( pFunc == GetData ) ) -+ /* Not allowed for DATA */ -+ { -+ printf( "Cannot modify a DATA item\n"); -+ } /* TODO : Real error */ -+ else /* Modify METHOD */ -+ { -+ pClass->pMethods[ wAt ].pFunction = ( HARBOURFUNC ) _parnl( 3 ); -+ } -+ } ++ while( ( wAt < wLimit ) && ++ ( pClass->pMethods[ wAt ].pMessage && ++ ( pClass->pMethods[ wAt ].pMessage != pMsg ) ) ) + wAt++; ++ ++ if( wAt <= wLimit ) ++ { /* Requested method found */ ++ pFunc = pClass->pMethods[ wAt ].pFunction; ++ if( pFunc == EvalInline ) /* INLINE method changed */ ++ { ++ ArraySet( &pClass->aInlines, pClass->pMethods[ wAt ].wData, ++ _param( 3, IT_BLOCK ) ); ++ } ++ else if( ( pFunc == SetData ) || ( pFunc == GetData ) ) ++ { /* Not allowed for DATA */ ++ printf( "\nCannot modify a DATA item" ); ++ exit(1); ++ } /* TODO : Real error */ ++ else /* Modify METHOD */ ++ { ++ pClass->pMethods[ wAt ].pFunction = ( HARBOURFUNC ) _parnl( 3 ); ++ } ++ } ++ } ++} ++ ++HARBOUR CLASSDEL() /* Delete message (only for INLINE and METHOD) */ ++ /* := ClassDel( , ) */ ++{ ++ PITEM pString = _param( 2, IT_STRING ); ++ PSYMBOL pMessage = GetDynSym( pString->value.szText )->pSymbol; ++ PDYNSYM pMsg = ( PDYNSYM ) pMessage->pDynSym; ++ PCLASS pClass; ++ ++ WORD wClass = _parni( 1 ); ++ WORD wAt; ++ WORD wLimit; ++ ++ HARBOURFUNC pFunc; ++ ++ if( wClass && wClass <= wClasses ) ++ { ++ pClass = &pClasses[ wClass - 1 ]; ++ wAt = ( ( ( unsigned ) pMsg ) % pClass->wHashKey ) * BUCKET; ++ wLimit = wAt + BUCKET; ++ ++ while( ( wAt < wLimit ) && ++ ( pClass->pMethods[ wAt ].pMessage && ++ ( pClass->pMethods[ wAt ].pMessage != pMsg ) ) ) ++ wAt++; ++ ++ if( wAt <= wLimit ) ++ { /* Requested method found */ ++ pFunc = pClass->pMethods[ wAt ].pFunction; ++ if( pFunc == EvalInline ) /* INLINE method deleted */ ++ { ++ ArrayDel( &pClass->aInlines, pClass->pMethods[ wAt ].wData ); ++ /* Delete INLINE block */ ++ } ++ else if( ( pFunc == SetData ) || ( pFunc == GetData ) ) ++ { /* Not allowed for DATA */ ++ printf( "\nCannot delete a DATA item yet" ); ++ exit(1); /* TODO : Real error */ ++ } ++ /* Move messages */ ++ for( ; pClass->pMethods[ wAt ].pMessage && wAt < wLimit; wAt ++ ) ++ memcpy( &( pClass->pMethods[ wAt ] ), ++ &( pClass->pMethods[ wAt + 1 ] ), sizeof( METHOD ) ); ++ ++ pClass->pMethods[ wAt ].pFunction = NULL; ++ pClass->pMethods[ wAt ].pMessage = NULL; ++ pClass->pMethods[ wAt ].wData = NULL; ++ pClass->pMethods[ wAt ].wScope = NULL; ++ pClass->pMethods[ wAt ].wInitValue = NULL; ++ ++ pClass->wMethods--; /* Decrease number messages */ + } + } } diff --git a/harbour/tests/broken/dynobj.prg b/harbour/tests/broken/dynobj.prg index 5ed4a951bc..377d0ec897 100644 --- a/harbour/tests/broken/dynobj.prg +++ b/harbour/tests/broken/dynobj.prg @@ -84,7 +84,21 @@ function Main() QOut( "What is the Form area ?" ) QOut( oForm:CalcArea() ) - QOut( "Just one left : Delete" ) + QOut( "What methods are in the class :" ) + HBDebug( aoMethod( oForm ) ) + + QOut( "Delete CalcArea" ) + ClassDel( oForm:ClassH, "CalcArea" ) + + QOut( "What methods are in the class :" ) + HBDebug( aoMethod( oForm ) ) + + QOut( "Delete Smile" ) + ClassDel( oForm:ClassH, "Smile" ) + + QOut( "What methods are in the class :" ) + HBDebug( aoMethod( oForm ) ) + return nil