From 7b81aa2403a0eb9cb1bf758d150ab9914c0b00ce Mon Sep 17 00:00:00 2001 From: Eddie Runia Date: Tue, 11 May 1999 18:23:40 +0000 Subject: [PATCH] parameter self add to INLINE methods. test program inline.prg --- harbour/ChangeLog | 6 ++++ harbour/source/rtl/classes.c | 3 +- harbour/tests/working/inline.prg | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 harbour/tests/working/inline.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d97c1db928..5114e0909a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +19990511-19:20 Eddie Runia + * source/rtl/classes.c + (Default) parameter self added to INLINE methods + * tests/working/inline.prg + Test of INLINE method. + 19990511-09:55 Eddie Runia * source/rtl/objfunc.prg, source/tools/stringp.prg created from tests/working/debugtst.prg diff --git a/harbour/source/rtl/classes.c b/harbour/source/rtl/classes.c index 438cf80f7d..89263545b2 100644 --- a/harbour/source/rtl/classes.c +++ b/harbour/source/rtl/classes.c @@ -170,9 +170,10 @@ static HARBOUR EvalInline( void ) PushSymbol( &symEval ); Push( &block ); + Push( stack.pBase + 1 ); /* Push self */ for( w = 1; w <= _pcount(); w++ ) Push( _param( w, IT_ANY ) ); - Do( _pcount() ); + Do( _pcount() + 1 ); /* Self is also an argument */ } static HARBOUR Virtual( void ) diff --git a/harbour/tests/working/inline.prg b/harbour/tests/working/inline.prg new file mode 100644 index 0000000000..aae4eac9ab --- /dev/null +++ b/harbour/tests/working/inline.prg @@ -0,0 +1,47 @@ +// +// Test of inline function +// +function Main() + + local oForm := TForm():New() + + QOut( oForm:ClassName() ) + oForm:cText := "Let's show a form here :-)" + + oForm:Show() + +return nil + +function TForm() + + static oClass + + if oClass == nil + oClass = TClass():New( "TFORM" ) // starts a new class definition + + oClass:AddData( "cText" ) // define this class objects datas + oClass:AddData( "nTop" ) + oClass:AddData( "nLeft" ) + oClass:AddData( "nBottom" ) + oClass:AddData( "nRight" ) + + oClass:AddMethod( "New", @New() ) // define this class objects methods + oClass:AddInline( "Show", {|self| QOut( self:cText ) } ) + + oClass:Create() // builds this class + endif + +return oClass:Instance() // builds an object of this class + +static function New() + + local Self := QSelf() + + ::nTop = 10 + ::nLeft = 10 + ::nBottom = 20 + ::nRight = 40 + +return Self + +